ref: 1f0d91ec3d2753b90b05ed8d25170d268fb52fbb
parent: a4ab438c7fa9478d4efd8128482cbddee9130ce1
author: Philip Silva <[email protected]>
date: Fri Jul 9 12:51:10 EDT 2021
gojafs - js in separate command (crash in js engine won't make whole browser crash, pluggable js backend)
--- a/README.md
+++ b/README.md
@@ -4,11 +4,11 @@
The UI is built with https://github.com/mjl-/duit
-Still experimental and a lot of features are missing, see website for screenshots: http://psilva.sdf.org/opossum.html
+Still experimental and a lot of features are missing.
Supported features:
-- rudimentary CSS/HTML5 support, large parts like float/flex layout are just stub implementations
+- rudimentary HTML5 and CSS support, large parts like float/flex layout are just stub implementations
- Server-side rendered websites
- Images (pre-loaded all at once though)
- TLS
@@ -19,19 +19,17 @@
## Plan 9
-You can download a tarball with the binary at http://psilva.sdf.org/opossum.tgz
+Setup TLS:
```
-./opossum-plan9-amd64.bin
+hget https://curl.haxx.se/ca/cacert.pem > /sys/lib/tls/ca.pem
```
-Also `/sys/lib/tls/ca.pem` needs to be present for TLS to work. ca certs can be downloaded from the curl homepage:
+### Binary
-```
-hget https://curl.haxx.se/ca/cacert.pem > /sys/lib/tls/ca.pem
-```
+A recent binary for amd64 and 386 can be downloaded from http://psilva.sdf.org/opossum.html
-To compile the source Go 1.16 is needed. Probably `$GOPROXY` should be set to `https://proxy.golang.org`
+### Compile from Source
```
cd cmd/browse
@@ -69,13 +67,12 @@
# JS support
It's more like a demo and it's not really clear right now how much sandboxing
-is really needed. A rudimentary AJAX implementation
-is there though.
+is really needed. A rudimentary AJAX implementation is there though.
Use on your own Risk!
Mostly based on goja (ECMAScript 5.1) and https://github.com/fgnass/domino
-(DOM implementation in JS). Some sort of DOM diffing
+(fork of DOM implementation from Mozilla in JS). Some sort of DOM diffing
is needed, also AJAX functions, `getComputedStyle` etc. are either missing or stubs.
Very simple jQuery based code works though, e.g. jQuery UI Tab view
https://jqueryui.com/resources/demos/tabs/default.html or the toggle buttons on
@@ -82,7 +79,19 @@
https://golang.org/pkg There is also highly experimental ES6 support with Babel.
(Needs also https://github.com/psilva261/6to5)
-Try on Plan 9 with e.g.:
+Build the js engine:
+
+```
+cd cmd/gojafs
+go build
+cp gojafs /bin/gojafs
+```
+
+On 9legacy also the folder `/mnt/opossum` needs to exist.
+
+```
+
+Then try on Plan 9 with e.g.:
```
go run . '-experimentalJsInsecure=true' -startPage https://jqueryui.com/resources/demos/tabs/default.html
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -18,6 +18,7 @@
"github.com/psilva261/opossum/browser/fs"
"github.com/psilva261/opossum/browser/history"
"github.com/psilva261/opossum/img"
+ "github.com/psilva261/opossum/js"
"github.com/psilva261/opossum/logger"
"github.com/psilva261/opossum/nodes"
"github.com/psilva261/opossum/style"
@@ -668,7 +669,7 @@
}
q := el.n.QueryRef()
- res, consumed, err := browser.Website.d.TriggerClick(q)
+ res, consumed, err := js.TriggerClick(q)
if err != nil {
log.Errorf("trigger click %v: %v", q, err)
return
@@ -677,7 +678,6 @@
if !consumed {
return
}
- log.Infof("click processed")
offset := scroller.Offset
browser.Website.layout(browser, res, ClickRelayout)
@@ -1368,6 +1368,7 @@
if *ExperimentalJsInsecure {
fs.Client = &http.Client{}
+ fs.Fetcher = browser
}
go fs.Srv9p()
--- a/browser/experimental.go
+++ b/browser/experimental.go
@@ -4,10 +4,9 @@
"fmt"
"image"
"github.com/psilva261/opossum/browser/duitx"
- "github.com/psilva261/opossum/domino"
+ "github.com/psilva261/opossum/js"
"9fans.net/go/draw"
"github.com/mjl-/duit"
- "strings"
)
type AtomBox struct {
@@ -88,25 +87,10 @@
}
}
-func processJS2(d *domino.Domino, scripts []string) (resHtm string, changed bool, err error) {
- initialized := false
- for _, script := range scripts {
- if _, err := d.Exec/*6*/(script, !initialized); err != nil {
- if strings.Contains(err.Error(), "halt at") {
- return "", false, fmt.Errorf("execution halted: %w", err)
- }
- log.Errorf("exec <script>: %v", err)
- }
- initialized = true
- }
-
- if err = d.CloseDoc(); err != nil {
- return "", false, fmt.Errorf("close doc: %w", err)
- }
-
- resHtm, changed, err = d.TrackChanges()
+func processJS2() (resHtm string, changed bool, err error) {
+ resHtm, changed, err = js.Start()
if err != nil {
- return "", false, fmt.Errorf("track changes: %w", err)
+ return "", false, fmt.Errorf("start: %w", err)
}
log.Printf("processJS: changed = %v", changed)
return
--- a/browser/experimental_test.go
+++ b/browser/experimental_test.go
@@ -3,7 +3,8 @@
import (
"golang.org/x/net/html"
//"github.com/mjl-/duit"
- "github.com/psilva261/opossum/domino"
+ "github.com/psilva261/opossum/browser/fs"
+ "github.com/psilva261/opossum/js"
"github.com/psilva261/opossum/logger"
"github.com/psilva261/opossum/nodes"
"github.com/psilva261/opossum/style"
@@ -16,11 +17,13 @@
quiet := false
logger.Quiet = &quiet
f := false
- domino.DebugDumpJS = &f
- domino.SetLogger(&logger.Logger{})
+ js.DebugDumpJS = &f
+ js.SetLogger(&logger.Logger{})
logger.Init()
SetLogger(&logger.Logger{})
style.Init(nil, &logger.Logger{})
+ fs.SetLogger(log)
+ go fs.Srv9p()
}
func TestAtom(t *testing.T) {
@@ -40,9 +43,7 @@
doc, err := html.Parse(buf)
if err != nil { t.Fatalf(err.Error()) }
nt := nodes.NewNodeTree(doc, style.Map{}, make(map[*html.Node]style.Map), nil)
- d := domino.NewDomino(h, nil, nt)
- d.Start()
- jq, err := ioutil.ReadFile("../domino/jquery-3.5.1.js")
+ jq, err := ioutil.ReadFile("../js/jquery-3.5.1.js")
if err != nil {
t.Fatalf("%v", err)
}
@@ -53,11 +54,15 @@
`$('body').hide()`,
`throw 'fail';`,
}
- h, _, err = processJS2(d, scripts)
+ fs.DOM = nt
+ fs.Update(h, nil, scripts)
+ js.NewJS(h, nil, nt)
+ js.Start()
+ h, _, err = processJS2()
if err != nil { t.Errorf(err.Error()) }
t.Logf("h = %+v", h)
if !strings.Contains(h, `<body style="display: none;">`) {
t.Fail()
}
- d.Stop()
+ js.Stop()
}
--- a/browser/fs/fs.go
+++ b/browser/fs/fs.go
@@ -27,6 +27,7 @@
html string
DOM Queryable
Client *http.Client
+ Fetcher opossum.Fetcher
)
type Queryable interface {
@@ -115,6 +116,7 @@
l = strings.TrimSpace(l)
if DOM == nil {
+ log.Infof("DOM is nil")
return
}
nodes, err := DOM.Query(l)
@@ -123,7 +125,6 @@
return
}
if err := enc.Encode(nodes); err != nil {
- log.Errorf("encode: %v", err)
return
}
}
@@ -150,6 +151,12 @@
}
url := req.URL
url.Host = req.Host
+ if h := url.Host; h == "" {
+ url.Host = Fetcher.Origin().Host
+ } else if h != Fetcher.Origin().Host {
+ log.Errorf("no cross-origin request: %v", h)
+ return
+ }
url.Scheme = "https"
proxyReq, err := http.NewRequest(req.Method, url.String(), req.Body)
if err != nil {
@@ -178,26 +185,30 @@
defer mu.Unlock()
html = htm
- for name := range cssDir.Children() {
- cssDir.DeleteChild(name)
+ if cssDir != nil {
+ for name := range cssDir.Children() {
+ cssDir.DeleteChild(name)
+ }
+ for i, s := range css {
+ fn := fmt.Sprintf("%d.css", i)
+ f := fs.NewStaticFile(
+ oFS.NewStat(fn, un, gn, 0400),
+ []byte(s),
+ )
+ cssDir.AddChild(f)
+ }
}
- for i, s := range css {
- fn := fmt.Sprintf("%d.css", i)
- f := fs.NewStaticFile(
- oFS.NewStat(fn, un, gn, 0400),
- []byte(s),
- )
- cssDir.AddChild(f)
- }
- for name := range jsDir.Children() {
- jsDir.DeleteChild(name)
- }
- for i, s := range js {
- fn := fmt.Sprintf("%d.js", i)
- f := fs.NewStaticFile(
- oFS.NewStat(fn, un, gn, 0400),
- []byte(s),
- )
- jsDir.AddChild(f)
+ if jsDir != nil {
+ for name := range jsDir.Children() {
+ jsDir.DeleteChild(name)
+ }
+ for i, s := range js {
+ fn := fmt.Sprintf("%d.js", i)
+ f := fs.NewStaticFile(
+ oFS.NewStat(fn, un, gn, 0400),
+ []byte(s),
+ )
+ jsDir.AddChild(f)
+ }
}
}
--- a/browser/website.go
+++ b/browser/website.go
@@ -9,7 +9,7 @@
"github.com/psilva261/opossum"
"github.com/psilva261/opossum/browser/duitx"
"github.com/psilva261/opossum/browser/fs"
- "github.com/psilva261/opossum/domino"
+ "github.com/psilva261/opossum/js"
"github.com/psilva261/opossum/nodes"
"github.com/psilva261/opossum/style"
"strings"
@@ -23,7 +23,6 @@
type Website struct {
duit.UI
opossum.ContentType
- d *domino.Domino
}
func (w *Website) layout(f opossum.Fetcher, htm string, layouting int) {
@@ -81,11 +80,11 @@
// 3rd pass is only needed initially to load the scripts and set the goja VM
// state. During subsequent calls from click handlers that state is kept.
- var js []string
+ var scripts []string
if *ExperimentalJsInsecure && layouting != ClickRelayout {
log.Printf("3rd pass")
nt := nodes.NewNodeTree(doc, style.Map{}, nodeMap, nil)
- jsSrcs := domino.Srcs(nt)
+ jsSrcs := js.Srcs(nt)
downloads := make(map[string]string)
for _, src := range jsSrcs {
url, err := f.LinkedUrl(src)
@@ -101,15 +100,12 @@
}
downloads[src] = string(buf)
}
- js = domino.Scripts(nt, downloads)
+ scripts = js.Scripts(nt, downloads)
+ fs.Update(htm, csss, scripts)
+ fs.DOM = nt
log.Infof("JS pipeline start")
- if w.d != nil {
- log.Infof("Stop existing JS instance")
- w.d.Stop()
- }
- w.d = domino.NewDomino(htm, browser, nt)
- w.d.Start()
- jsProcessed, changed, err := processJS2(w.d, js)
+ js.Stop()
+ jsProcessed, changed, err := processJS2()
if changed && err == nil {
htm = jsProcessed
if debugPrintHtml {
@@ -153,7 +149,7 @@
w.UI = scroller
}
- fs.Update(htm, csss, js)
+ fs.Update(htm, csss, scripts)
fs.DOM = nt
log.Flush()
--- a/cmd/browse/main.go
+++ b/cmd/browse/main.go
@@ -10,11 +10,12 @@
"github.com/psilva261/opossum"
"github.com/psilva261/opossum/browser"
"github.com/psilva261/opossum/browser/fs"
- "github.com/psilva261/opossum/domino"
"github.com/psilva261/opossum/img"
+ "github.com/psilva261/opossum/js"
"github.com/psilva261/opossum/logger"
"github.com/psilva261/opossum/style"
"github.com/psilva261/opossum/nodes"
+ "os/signal"
"runtime/pprof"
"time"
"github.com/mjl-/duit"
@@ -31,7 +32,7 @@
func init() {
browser.DebugDumpCSS = flag.Bool("debugDumpCSS", false, "write css to info.css")
- domino.DebugDumpJS = flag.Bool("debugDumpJS", false, "write js to main.js")
+ js.DebugDumpJS = flag.Bool("debugDumpJS", false, "write js to main.js")
browser.ExperimentalJsInsecure = flag.Bool("experimentalJsInsecure", false, "DO NOT ACTIVATE UNLESS INSTRUCTED OTHERWISE")
browser.EnableNoScriptTag = flag.Bool("enableNoScriptTag", false, "enable noscript tag")
logger.Quiet = flag.Bool("quiet", defaultQuietActive, "don't print info messages and non-fatal errors")
@@ -135,8 +136,8 @@
style.Init(dui, log)
browser.SetLogger(log)
fs.SetLogger(log)
- domino.SetLogger(log)
img.SetLogger(log)
+ js.SetLogger(log)
opossum.SetLogger(log)
nodes.SetLogger(log)
@@ -186,6 +187,14 @@
log = logger.Log
log.Debug = *dbg
go9p.Verbose = log.Debug
+
+ done := make(chan os.Signal, 1)
+ signal.Notify(done, os.Interrupt, os.Kill)
+
+ go func() {
+ <-done
+ js.Stop()
+ }()
if err := Main(); err != nil {
log.Fatalf("Main: %v", err)
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/CSSStyleDeclaration.js
@@ -1,0 +1,579 @@
+"use strict";
+var parserlib = require('./cssparser');
+
+module.exports = CSSStyleDeclaration;
+
+function CSSStyleDeclaration(elt) {
+ this._element = elt;
+}
+
+// Utility function for parsing style declarations
+// Pass in a string like "margin-left: 5px; border-style: solid"
+// and this function returns an object like
+// {"margin-left":"5px", "border-style":"solid"}
+function parseStyles(s) {
+ var parser = new parserlib.css.Parser();
+ var result = { property: Object.create(null), priority: Object.create(null) };
+ parser.addListener("property", function(e) {
+ if (e.invalid) return; // Skip errors
+ result.property[e.property.text] = e.value.text;
+ if (e.important) result.priority[e.property.text] = 'important';
+ });
+ s = (''+s).replace(/^;/, '');
+ parser.parseStyleAttribute(s);
+ return result;
+}
+
+var NO_CHANGE = {}; // Private marker object
+
+CSSStyleDeclaration.prototype = Object.create(Object.prototype, {
+
+ // Return the parsed form of the element's style attribute.
+ // If the element's style attribute has never been parsed
+ // or if it has changed since the last parse, then reparse it
+ // Note that the styles don't get parsed until they're actually needed
+ _parsed: { get: function() {
+ if (!this._parsedStyles || this.cssText !== this._lastParsedText) {
+ var text = this.cssText;
+ this._parsedStyles = parseStyles(text);
+ this._lastParsedText = text;
+ delete this._names;
+ }
+ return this._parsedStyles;
+ }},
+
+ // Call this method any time the parsed representation of the
+ // style changes. It converts the style properties to a string and
+ // sets cssText and the element's style attribute
+ _serialize: { value: function() {
+ var styles = this._parsed;
+ var s = "";
+
+ for(var name in styles.property) {
+ if (s) s += " ";
+ s += name + ": " + styles.property[name];
+ if (styles.priority[name]) {
+ s += " !" + styles.priority[name];
+ }
+ s += ";";
+ }
+
+ this.cssText = s; // also sets the style attribute
+ this._lastParsedText = s; // so we don't reparse
+ delete this._names;
+ }},
+
+ cssText: {
+ get: function() {
+ // XXX: this is a CSSStyleDeclaration for an element.
+ // A different impl might be necessary for a set of styles
+ // associated returned by getComputedStyle(), e.g.
+ return this._element.getAttribute("style");
+ },
+ set: function(value) {
+ // XXX: I should parse and serialize the value to
+ // normalize it and remove errors. FF and chrome do that.
+ this._element.setAttribute("style", value);
+ }
+ },
+
+ length: { get: function() {
+ if (!this._names)
+ this._names = Object.getOwnPropertyNames(this._parsed.property);
+ return this._names.length;
+ }},
+
+ item: { value: function(n) {
+ if (!this._names)
+ this._names = Object.getOwnPropertyNames(this._parsed.property);
+ return this._names[n];
+ }},
+
+ getPropertyValue: { value: function(property) {
+ property = property.toLowerCase();
+ return this._parsed.property[property] || "";
+ }},
+
+ getPropertyPriority: { value: function(property) {
+ property = property.toLowerCase();
+ return this._parsed.priority[property] || "";
+ }},
+
+ setProperty: { value: function(property, value, priority) {
+ property = property.toLowerCase();
+ if (value === null || value === undefined) {
+ value = "";
+ }
+ if (priority === null || priority === undefined) {
+ priority = "";
+ }
+
+ // String coercion
+ if (value !== NO_CHANGE) {
+ value = "" + value;
+ }
+
+ if (value === "") {
+ this.removeProperty(property);
+ return;
+ }
+
+ if (priority !== "" && priority !== NO_CHANGE &&
+ !/^important$/i.test(priority)) {
+ return;
+ }
+
+ var styles = this._parsed;
+ if (value === NO_CHANGE) {
+ if (!styles.property[property]) {
+ return; // Not a valid property name.
+ }
+ if (priority !== "") {
+ styles.priority[property] = "important";
+ } else {
+ delete styles.priority[property];
+ }
+ } else {
+ // We don't just accept the property value. Instead
+ // we parse it to ensure that it is something valid.
+ // If it contains a semicolon it is invalid
+ if (value.indexOf(";") !== -1) return;
+
+ var newprops = parseStyles(property + ":" + value);
+ if (Object.getOwnPropertyNames(newprops.property).length === 0) {
+ return; // no valid property found
+ }
+ if (Object.getOwnPropertyNames(newprops.priority).length !== 0) {
+ return; // if the value included '!important' it wasn't valid.
+ }
+
+ // XXX handle shorthand properties
+
+ for (var p in newprops.property) {
+ styles.property[p] = newprops.property[p];
+ if (priority === NO_CHANGE) {
+ continue;
+ } else if (priority !== "") {
+ styles.priority[p] = "important";
+ } else if (styles.priority[p]) {
+ delete styles.priority[p];
+ }
+ }
+ }
+
+ // Serialize and update cssText and element.style!
+ this._serialize();
+ }},
+
+ setPropertyValue: { value: function(property, value) {
+ return this.setProperty(property, value, NO_CHANGE);
+ }},
+
+ setPropertyPriority: { value: function(property, priority) {
+ return this.setProperty(property, NO_CHANGE, priority);
+ }},
+
+ removeProperty: { value: function(property) {
+ property = property.toLowerCase();
+ var styles = this._parsed;
+ if (property in styles.property) {
+ delete styles.property[property];
+ delete styles.priority[property];
+
+ // Serialize and update cssText and element.style!
+ this._serialize();
+ }
+ }},
+});
+
+var cssProperties = {
+ alignContent: "align-content",
+ alignItems: "align-items",
+ alignmentBaseline: "alignment-baseline",
+ alignSelf: "align-self",
+ animation: "animation",
+ animationDelay: "animation-delay",
+ animationDirection: "animation-direction",
+ animationDuration: "animation-duration",
+ animationFillMode: "animation-fill-mode",
+ animationIterationCount: "animation-iteration-count",
+ animationName: "animation-name",
+ animationPlayState: "animation-play-state",
+ animationTimingFunction: "animation-timing-function",
+ backfaceVisibility: "backface-visibility",
+ background: "background",
+ backgroundAttachment: "background-attachment",
+ backgroundClip: "background-clip",
+ backgroundColor: "background-color",
+ backgroundImage: "background-image",
+ backgroundOrigin: "background-origin",
+ backgroundPosition: "background-position",
+ backgroundPositionX: "background-position-x",
+ backgroundPositionY: "background-position-y",
+ backgroundRepeat: "background-repeat",
+ backgroundSize: "background-size",
+ baselineShift: "baseline-shift",
+ border: "border",
+ borderBottom: "border-bottom",
+ borderBottomColor: "border-bottom-color",
+ borderBottomLeftRadius: "border-bottom-left-radius",
+ borderBottomRightRadius: "border-bottom-right-radius",
+ borderBottomStyle: "border-bottom-style",
+ borderBottomWidth: "border-bottom-width",
+ borderCollapse: "border-collapse",
+ borderColor: "border-color",
+ borderImage: "border-image",
+ borderImageOutset: "border-image-outset",
+ borderImageRepeat: "border-image-repeat",
+ borderImageSlice: "border-image-slice",
+ borderImageSource: "border-image-source",
+ borderImageWidth: "border-image-width",
+ borderLeft: "border-left",
+ borderLeftColor: "border-left-color",
+ borderLeftStyle: "border-left-style",
+ borderLeftWidth: "border-left-width",
+ borderRadius: "border-radius",
+ borderRight: "border-right",
+ borderRightColor: "border-right-color",
+ borderRightStyle: "border-right-style",
+ borderRightWidth: "border-right-width",
+ borderSpacing: "border-spacing",
+ borderStyle: "border-style",
+ borderTop: "border-top",
+ borderTopColor: "border-top-color",
+ borderTopLeftRadius: "border-top-left-radius",
+ borderTopRightRadius: "border-top-right-radius",
+ borderTopStyle: "border-top-style",
+ borderTopWidth: "border-top-width",
+ borderWidth: "border-width",
+ bottom: "bottom",
+ boxShadow: "box-shadow",
+ boxSizing: "box-sizing",
+ breakAfter: "break-after",
+ breakBefore: "break-before",
+ breakInside: "break-inside",
+ captionSide: "caption-side",
+ clear: "clear",
+ clip: "clip",
+ clipPath: "clip-path",
+ clipRule: "clip-rule",
+ color: "color",
+ colorInterpolationFilters: "color-interpolation-filters",
+ columnCount: "column-count",
+ columnFill: "column-fill",
+ columnGap: "column-gap",
+ columnRule: "column-rule",
+ columnRuleColor: "column-rule-color",
+ columnRuleStyle: "column-rule-style",
+ columnRuleWidth: "column-rule-width",
+ columns: "columns",
+ columnSpan: "column-span",
+ columnWidth: "column-width",
+ content: "content",
+ counterIncrement: "counter-increment",
+ counterReset: "counter-reset",
+ cssFloat: "float",
+ cursor: "cursor",
+ direction: "direction",
+ display: "display",
+ dominantBaseline: "dominant-baseline",
+ emptyCells: "empty-cells",
+ enableBackground: "enable-background",
+ fill: "fill",
+ fillOpacity: "fill-opacity",
+ fillRule: "fill-rule",
+ filter: "filter",
+ flex: "flex",
+ flexBasis: "flex-basis",
+ flexDirection: "flex-direction",
+ flexFlow: "flex-flow",
+ flexGrow: "flex-grow",
+ flexShrink: "flex-shrink",
+ flexWrap: "flex-wrap",
+ floodColor: "flood-color",
+ floodOpacity: "flood-opacity",
+ font: "font",
+ fontFamily: "font-family",
+ fontFeatureSettings: "font-feature-settings",
+ fontSize: "font-size",
+ fontSizeAdjust: "font-size-adjust",
+ fontStretch: "font-stretch",
+ fontStyle: "font-style",
+ fontVariant: "font-variant",
+ fontWeight: "font-weight",
+ glyphOrientationHorizontal: "glyph-orientation-horizontal",
+ glyphOrientationVertical: "glyph-orientation-vertical",
+ grid: "grid",
+ gridArea: "grid-area",
+ gridAutoColumns: "grid-auto-columns",
+ gridAutoFlow: "grid-auto-flow",
+ gridAutoRows: "grid-auto-rows",
+ gridColumn: "grid-column",
+ gridColumnEnd: "grid-column-end",
+ gridColumnGap: "grid-column-gap",
+ gridColumnStart: "grid-column-start",
+ gridGap: "grid-gap",
+ gridRow: "grid-row",
+ gridRowEnd: "grid-row-end",
+ gridRowGap: "grid-row-gap",
+ gridRowStart: "grid-row-start",
+ gridTemplate: "grid-template",
+ gridTemplateAreas: "grid-template-areas",
+ gridTemplateColumns: "grid-template-columns",
+ gridTemplateRows: "grid-template-rows",
+ height: "height",
+ imeMode: "ime-mode",
+ justifyContent: "justify-content",
+ kerning: "kerning",
+ layoutGrid: "layout-grid",
+ layoutGridChar: "layout-grid-char",
+ layoutGridLine: "layout-grid-line",
+ layoutGridMode: "layout-grid-mode",
+ layoutGridType: "layout-grid-type",
+ left: "left",
+ letterSpacing: "letter-spacing",
+ lightingColor: "lighting-color",
+ lineBreak: "line-break",
+ lineHeight: "line-height",
+ listStyle: "list-style",
+ listStyleImage: "list-style-image",
+ listStylePosition: "list-style-position",
+ listStyleType: "list-style-type",
+ margin: "margin",
+ marginBottom: "margin-bottom",
+ marginLeft: "margin-left",
+ marginRight: "margin-right",
+ marginTop: "margin-top",
+ marker: "marker",
+ markerEnd: "marker-end",
+ markerMid: "marker-mid",
+ markerStart: "marker-start",
+ mask: "mask",
+ maxHeight: "max-height",
+ maxWidth: "max-width",
+ minHeight: "min-height",
+ minWidth: "min-width",
+ msContentZoomChaining: "-ms-content-zoom-chaining",
+ msContentZooming: "-ms-content-zooming",
+ msContentZoomLimit: "-ms-content-zoom-limit",
+ msContentZoomLimitMax: "-ms-content-zoom-limit-max",
+ msContentZoomLimitMin: "-ms-content-zoom-limit-min",
+ msContentZoomSnap: "-ms-content-zoom-snap",
+ msContentZoomSnapPoints: "-ms-content-zoom-snap-points",
+ msContentZoomSnapType: "-ms-content-zoom-snap-type",
+ msFlowFrom: "-ms-flow-from",
+ msFlowInto: "-ms-flow-into",
+ msFontFeatureSettings: "-ms-font-feature-settings",
+ msGridColumn: "-ms-grid-column",
+ msGridColumnAlign: "-ms-grid-column-align",
+ msGridColumns: "-ms-grid-columns",
+ msGridColumnSpan: "-ms-grid-column-span",
+ msGridRow: "-ms-grid-row",
+ msGridRowAlign: "-ms-grid-row-align",
+ msGridRows: "-ms-grid-rows",
+ msGridRowSpan: "-ms-grid-row-span",
+ msHighContrastAdjust: "-ms-high-contrast-adjust",
+ msHyphenateLimitChars: "-ms-hyphenate-limit-chars",
+ msHyphenateLimitLines: "-ms-hyphenate-limit-lines",
+ msHyphenateLimitZone: "-ms-hyphenate-limit-zone",
+ msHyphens: "-ms-hyphens",
+ msImeAlign: "-ms-ime-align",
+ msOverflowStyle: "-ms-overflow-style",
+ msScrollChaining: "-ms-scroll-chaining",
+ msScrollLimit: "-ms-scroll-limit",
+ msScrollLimitXMax: "-ms-scroll-limit-x-max",
+ msScrollLimitXMin: "-ms-scroll-limit-x-min",
+ msScrollLimitYMax: "-ms-scroll-limit-y-max",
+ msScrollLimitYMin: "-ms-scroll-limit-y-min",
+ msScrollRails: "-ms-scroll-rails",
+ msScrollSnapPointsX: "-ms-scroll-snap-points-x",
+ msScrollSnapPointsY: "-ms-scroll-snap-points-y",
+ msScrollSnapType: "-ms-scroll-snap-type",
+ msScrollSnapX: "-ms-scroll-snap-x",
+ msScrollSnapY: "-ms-scroll-snap-y",
+ msScrollTranslation: "-ms-scroll-translation",
+ msTextCombineHorizontal: "-ms-text-combine-horizontal",
+ msTextSizeAdjust: "-ms-text-size-adjust",
+ msTouchAction: "-ms-touch-action",
+ msTouchSelect: "-ms-touch-select",
+ msUserSelect: "-ms-user-select",
+ msWrapFlow: "-ms-wrap-flow",
+ msWrapMargin: "-ms-wrap-margin",
+ msWrapThrough: "-ms-wrap-through",
+ opacity: "opacity",
+ order: "order",
+ orphans: "orphans",
+ outline: "outline",
+ outlineColor: "outline-color",
+ outlineOffset: "outline-offset",
+ outlineStyle: "outline-style",
+ outlineWidth: "outline-width",
+ overflow: "overflow",
+ overflowX: "overflow-x",
+ overflowY: "overflow-y",
+ padding: "padding",
+ paddingBottom: "padding-bottom",
+ paddingLeft: "padding-left",
+ paddingRight: "padding-right",
+ paddingTop: "padding-top",
+ page: "page",
+ pageBreakAfter: "page-break-after",
+ pageBreakBefore: "page-break-before",
+ pageBreakInside: "page-break-inside",
+ perspective: "perspective",
+ perspectiveOrigin: "perspective-origin",
+ pointerEvents: "pointer-events",
+ position: "position",
+ quotes: "quotes",
+ right: "right",
+ rotate: "rotate",
+ rubyAlign: "ruby-align",
+ rubyOverhang: "ruby-overhang",
+ rubyPosition: "ruby-position",
+ scale: "scale",
+ size: "size",
+ stopColor: "stop-color",
+ stopOpacity: "stop-opacity",
+ stroke: "stroke",
+ strokeDasharray: "stroke-dasharray",
+ strokeDashoffset: "stroke-dashoffset",
+ strokeLinecap: "stroke-linecap",
+ strokeLinejoin: "stroke-linejoin",
+ strokeMiterlimit: "stroke-miterlimit",
+ strokeOpacity: "stroke-opacity",
+ strokeWidth: "stroke-width",
+ tableLayout: "table-layout",
+ textAlign: "text-align",
+ textAlignLast: "text-align-last",
+ textAnchor: "text-anchor",
+ textDecoration: "text-decoration",
+ textIndent: "text-indent",
+ textJustify: "text-justify",
+ textKashida: "text-kashida",
+ textKashidaSpace: "text-kashida-space",
+ textOverflow: "text-overflow",
+ textShadow: "text-shadow",
+ textTransform: "text-transform",
+ textUnderlinePosition: "text-underline-position",
+ top: "top",
+ touchAction: "touch-action",
+ transform: "transform",
+ transformOrigin: "transform-origin",
+ transformStyle: "transform-style",
+ transition: "transition",
+ transitionDelay: "transition-delay",
+ transitionDuration: "transition-duration",
+ transitionProperty: "transition-property",
+ transitionTimingFunction: "transition-timing-function",
+ translate: "translate",
+ unicodeBidi: "unicode-bidi",
+ verticalAlign: "vertical-align",
+ visibility: "visibility",
+ webkitAlignContent: "-webkit-align-content",
+ webkitAlignItems: "-webkit-align-items",
+ webkitAlignSelf: "-webkit-align-self",
+ webkitAnimation: "-webkit-animation",
+ webkitAnimationDelay: "-webkit-animation-delay",
+ webkitAnimationDirection: "-webkit-animation-direction",
+ webkitAnimationDuration: "-webkit-animation-duration",
+ webkitAnimationFillMode: "-webkit-animation-fill-mode",
+ webkitAnimationIterationCount: "-webkit-animation-iteration-count",
+ webkitAnimationName: "-webkit-animation-name",
+ webkitAnimationPlayState: "-webkit-animation-play-state",
+ webkitAnimationTimingFunction: "-webkit-animation-timing-funciton",
+ webkitAppearance: "-webkit-appearance",
+ webkitBackfaceVisibility: "-webkit-backface-visibility",
+ webkitBackgroundClip: "-webkit-background-clip",
+ webkitBackgroundOrigin: "-webkit-background-origin",
+ webkitBackgroundSize: "-webkit-background-size",
+ webkitBorderBottomLeftRadius: "-webkit-border-bottom-left-radius",
+ webkitBorderBottomRightRadius: "-webkit-border-bottom-right-radius",
+ webkitBorderImage: "-webkit-border-image",
+ webkitBorderRadius: "-webkit-border-radius",
+ webkitBorderTopLeftRadius: "-webkit-border-top-left-radius",
+ webkitBorderTopRightRadius: "-webkit-border-top-right-radius",
+ webkitBoxAlign: "-webkit-box-align",
+ webkitBoxDirection: "-webkit-box-direction",
+ webkitBoxFlex: "-webkit-box-flex",
+ webkitBoxOrdinalGroup: "-webkit-box-ordinal-group",
+ webkitBoxOrient: "-webkit-box-orient",
+ webkitBoxPack: "-webkit-box-pack",
+ webkitBoxSizing: "-webkit-box-sizing",
+ webkitColumnBreakAfter: "-webkit-column-break-after",
+ webkitColumnBreakBefore: "-webkit-column-break-before",
+ webkitColumnBreakInside: "-webkit-column-break-inside",
+ webkitColumnCount: "-webkit-column-count",
+ webkitColumnGap: "-webkit-column-gap",
+ webkitColumnRule: "-webkit-column-rule",
+ webkitColumnRuleColor: "-webkit-column-rule-color",
+ webkitColumnRuleStyle: "-webkit-column-rule-style",
+ webkitColumnRuleWidth: "-webkit-column-rule-width",
+ webkitColumns: "-webkit-columns",
+ webkitColumnSpan: "-webkit-column-span",
+ webkitColumnWidth: "-webkit-column-width",
+ webkitFilter: "-webkit-filter",
+ webkitFlex: "-webkit-flex",
+ webkitFlexBasis: "-webkit-flex-basis",
+ webkitFlexDirection: "-webkit-flex-direction",
+ webkitFlexFlow: "-webkit-flex-flow",
+ webkitFlexGrow: "-webkit-flex-grow",
+ webkitFlexShrink: "-webkit-flex-shrink",
+ webkitFlexWrap: "-webkit-flex-wrap",
+ webkitJustifyContent: "-webkit-justify-content",
+ webkitOrder: "-webkit-order",
+ webkitPerspective: "-webkit-perspective-origin",
+ webkitPerspectiveOrigin: "-webkit-perspective-origin",
+ webkitTapHighlightColor: "-webkit-tap-highlight-color",
+ webkitTextFillColor: "-webkit-text-fill-color",
+ webkitTextSizeAdjust: "-webkit-text-size-adjust",
+ webkitTextStroke: "-webkit-text-stroke",
+ webkitTextStrokeColor: "-webkit-text-stroke-color",
+ webkitTextStrokeWidth: "-webkit-text-stroke-width",
+ webkitTransform: "-webkit-transform",
+ webkitTransformOrigin: "-webkit-transform-origin",
+ webkitTransformStyle: "-webkit-transform-style",
+ webkitTransition: "-webkit-transition",
+ webkitTransitionDelay: "-webkit-transition-delay",
+ webkitTransitionDuration: "-webkit-transition-duration",
+ webkitTransitionProperty: "-webkit-transition-property",
+ webkitTransitionTimingFunction: "-webkit-transition-timing-function",
+ webkitUserModify: "-webkit-user-modify",
+ webkitUserSelect: "-webkit-user-select",
+ webkitWritingMode: "-webkit-writing-mode",
+ whiteSpace: "white-space",
+ widows: "widows",
+ width: "width",
+ wordBreak: "word-break",
+ wordSpacing: "word-spacing",
+ wordWrap: "word-wrap",
+ writingMode: "writing-mode",
+ zIndex: "z-index",
+ zoom: "zoom",
+ resize: "resize",
+ userSelect: "user-select",
+};
+
+for(var prop in cssProperties) defineStyleProperty(prop);
+
+function defineStyleProperty(jsname) {
+ var cssname = cssProperties[jsname];
+ Object.defineProperty(CSSStyleDeclaration.prototype, jsname, {
+ get: function() {
+ return this.getPropertyValue(cssname);
+ },
+ set: function(value) {
+ this.setProperty(cssname, value);
+ }
+ });
+
+ if (!CSSStyleDeclaration.prototype.hasOwnProperty(cssname)) {
+ Object.defineProperty(CSSStyleDeclaration.prototype, cssname, {
+ get: function() {
+ return this.getPropertyValue(cssname);
+ },
+ set: function(value) {
+ this.setProperty(cssname, value);
+ }
+ });
+ }
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/CharacterData.js
@@ -1,0 +1,120 @@
+/* jshint bitwise: false */
+"use strict";
+module.exports = CharacterData;
+
+var Leaf = require('./Leaf');
+var utils = require('./utils');
+var ChildNode = require('./ChildNode');
+var NonDocumentTypeChildNode = require('./NonDocumentTypeChildNode');
+
+function CharacterData() {
+ Leaf.call(this);
+}
+
+CharacterData.prototype = Object.create(Leaf.prototype, {
+ // DOMString substringData(unsigned long offset,
+ // unsigned long count);
+ // The substringData(offset, count) method must run these steps:
+ //
+ // If offset is greater than the context object's
+ // length, throw an INDEX_SIZE_ERR exception and
+ // terminate these steps.
+ //
+ // If offset+count is greater than the context
+ // object's length, return a DOMString whose value is
+ // the UTF-16 code units from the offsetth UTF-16 code
+ // unit to the end of data.
+ //
+ // Return a DOMString whose value is the UTF-16 code
+ // units from the offsetth UTF-16 code unit to the
+ // offset+countth UTF-16 code unit in data.
+ substringData: { value: function substringData(offset, count) {
+ if (arguments.length < 2) { throw new TypeError("Not enough arguments"); }
+ // Convert arguments to WebIDL "unsigned long"
+ offset = offset >>> 0;
+ count = count >>> 0;
+ if (offset > this.data.length || offset < 0 || count < 0) {
+ utils.IndexSizeError();
+ }
+ return this.data.substring(offset, offset+count);
+ }},
+
+ // void appendData(DOMString data);
+ // The appendData(data) method must append data to the context
+ // object's data.
+ appendData: { value: function appendData(data) {
+ if (arguments.length < 1) { throw new TypeError("Not enough arguments"); }
+ this.data += String(data);
+ }},
+
+ // void insertData(unsigned long offset, DOMString data);
+ // The insertData(offset, data) method must run these steps:
+ //
+ // If offset is greater than the context object's
+ // length, throw an INDEX_SIZE_ERR exception and
+ // terminate these steps.
+ //
+ // Insert data into the context object's data after
+ // offset UTF-16 code units.
+ //
+ insertData: { value: function insertData(offset, data) {
+ return this.replaceData(offset, 0, data);
+ }},
+
+
+ // void deleteData(unsigned long offset, unsigned long count);
+ // The deleteData(offset, count) method must run these steps:
+ //
+ // If offset is greater than the context object's
+ // length, throw an INDEX_SIZE_ERR exception and
+ // terminate these steps.
+ //
+ // If offset+count is greater than the context
+ // object's length var count be length-offset.
+ //
+ // Starting from offset UTF-16 code units remove count
+ // UTF-16 code units from the context object's data.
+ deleteData: { value: function deleteData(offset, count) {
+ return this.replaceData(offset, count, '');
+ }},
+
+
+ // void replaceData(unsigned long offset, unsigned long count,
+ // DOMString data);
+ //
+ // The replaceData(offset, count, data) method must act as
+ // if the deleteData() method is invoked with offset and
+ // count as arguments followed by the insertData() method
+ // with offset and data as arguments and re-throw any
+ // exceptions these methods might have thrown.
+ replaceData: { value: function replaceData(offset, count, data) {
+ var curtext = this.data, len = curtext.length;
+ // Convert arguments to correct WebIDL type
+ offset = offset >>> 0;
+ count = count >>> 0;
+ data = String(data);
+
+ if (offset > len || offset < 0) utils.IndexSizeError();
+
+ if (offset+count > len)
+ count = len - offset;
+
+ var prefix = curtext.substring(0, offset),
+ suffix = curtext.substring(offset+count);
+
+ this.data = prefix + data + suffix;
+ }},
+
+ // Utility method that Node.isEqualNode() calls to test Text and
+ // Comment nodes for equality. It is okay to put it here, since
+ // Node will have already verified that nodeType is equal
+ isEqual: { value: function isEqual(n) {
+ return this._data === n._data;
+ }},
+
+ length: { get: function() { return this.data.length; }}
+
+});
+
+Object.defineProperties(CharacterData.prototype, ChildNode);
+Object.defineProperties(CharacterData.prototype, NonDocumentTypeChildNode);
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/ChildNode.js
@@ -1,0 +1,119 @@
+"use strict";
+
+var Node = require('./Node');
+var LinkedList = require('./LinkedList');
+
+var createDocumentFragmentFromArguments = function(document, args) {
+ var docFrag = document.createDocumentFragment();
+
+ for (var i=0; i<args.length; i++) {
+ var argItem = args[i];
+ var isNode = argItem instanceof Node;
+ docFrag.appendChild(isNode ? argItem :
+ document.createTextNode(String(argItem)));
+ }
+
+ return docFrag;
+};
+
+// The ChildNode interface contains methods that are particular to `Node`
+// objects that can have a parent. It is implemented by `Element`,
+// `DocumentType`, and `CharacterData` objects.
+var ChildNode = {
+
+ // Inserts a set of Node or String objects in the children list of this
+ // ChildNode's parent, just after this ChildNode. String objects are
+ // inserted as the equivalent Text nodes.
+ after: { value: function after() {
+ var argArr = Array.prototype.slice.call(arguments);
+ var parentNode = this.parentNode, nextSibling = this.nextSibling;
+ if (parentNode === null) { return; }
+ // Find "viable next sibling"; that is, next one not in argArr
+ while (nextSibling && argArr.some(function(v) { return v===nextSibling; }))
+ nextSibling = nextSibling.nextSibling;
+ // ok, parent and sibling are saved away since this node could itself
+ // appear in argArr and we're about to move argArr to a document fragment.
+ var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
+
+ parentNode.insertBefore(docFrag, nextSibling);
+ }},
+
+ // Inserts a set of Node or String objects in the children list of this
+ // ChildNode's parent, just before this ChildNode. String objects are
+ // inserted as the equivalent Text nodes.
+ before: { value: function before() {
+ var argArr = Array.prototype.slice.call(arguments);
+ var parentNode = this.parentNode, prevSibling = this.previousSibling;
+ if (parentNode === null) { return; }
+ // Find "viable prev sibling"; that is, prev one not in argArr
+ while (prevSibling && argArr.some(function(v) { return v===prevSibling; }))
+ prevSibling = prevSibling.previousSibling;
+ // ok, parent and sibling are saved away since this node could itself
+ // appear in argArr and we're about to move argArr to a document fragment.
+ var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
+
+ var nextSibling =
+ prevSibling ? prevSibling.nextSibling : parentNode.firstChild;
+ parentNode.insertBefore(docFrag, nextSibling);
+ }},
+
+ // Remove this node from its parent
+ remove: { value: function remove() {
+ if (this.parentNode === null) return;
+
+ // Send mutation events if necessary
+ if (this.doc) {
+ this.doc._preremoveNodeIterators(this);
+ if (this.rooted) {
+ this.doc.mutateRemove(this);
+ }
+ }
+
+ // Remove this node from its parents array of children
+ // and update the structure id for all ancestors
+ this._remove();
+
+ // Forget this node's parent
+ this.parentNode = null;
+ }},
+
+ // Remove this node w/o uprooting or sending mutation events
+ // (But do update the structure id for all ancestors)
+ _remove: { value: function _remove() {
+ var parent = this.parentNode;
+ if (parent === null) return;
+ if (parent._childNodes) {
+ parent._childNodes.splice(this.index, 1);
+ } else if (parent._firstChild === this) {
+ if (this._nextSibling === this) {
+ parent._firstChild = null;
+ } else {
+ parent._firstChild = this._nextSibling;
+ }
+ }
+ LinkedList.remove(this);
+ parent.modify();
+ }},
+
+ // Replace this node with the nodes or strings provided as arguments.
+ replaceWith: { value: function replaceWith() {
+ var argArr = Array.prototype.slice.call(arguments);
+ var parentNode = this.parentNode, nextSibling = this.nextSibling;
+ if (parentNode === null) { return; }
+ // Find "viable next sibling"; that is, next one not in argArr
+ while (nextSibling && argArr.some(function(v) { return v===nextSibling; }))
+ nextSibling = nextSibling.nextSibling;
+ // ok, parent and sibling are saved away since this node could itself
+ // appear in argArr and we're about to move argArr to a document fragment.
+ var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
+ if (this.parentNode === parentNode) {
+ parentNode.replaceChild(docFrag, this);
+ } else {
+ // `this` was inserted into docFrag
+ parentNode.insertBefore(docFrag, nextSibling);
+ }
+ }},
+
+};
+
+module.exports = ChildNode;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Comment.js
@@ -1,0 +1,39 @@
+"use strict";
+module.exports = Comment;
+
+var Node = require('./Node');
+var CharacterData = require('./CharacterData');
+
+function Comment(doc, data) {
+ CharacterData.call(this);
+ this.nodeType = Node.COMMENT_NODE;
+ this.ownerDocument = doc;
+ this._data = data;
+}
+
+var nodeValue = {
+ get: function() { return this._data; },
+ set: function(v) {
+ if (v === null || v === undefined) { v = ''; } else { v = String(v); }
+ this._data = v;
+ if (this.rooted)
+ this.ownerDocument.mutateValue(this);
+ }
+};
+
+Comment.prototype = Object.create(CharacterData.prototype, {
+ nodeName: { value: '#comment' },
+ nodeValue: nodeValue,
+ textContent: nodeValue,
+ data: {
+ get: nodeValue.get,
+ set: function(v) {
+ nodeValue.set.call(this, v===null ? '' : String(v));
+ },
+ },
+
+ // Utility methods
+ clone: { value: function clone() {
+ return new Comment(this.ownerDocument, this._data);
+ }},
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/ContainerNode.js
@@ -1,0 +1,80 @@
+"use strict";
+module.exports = ContainerNode;
+
+var Node = require('./Node');
+var NodeList = require('./NodeList');
+
+// This class defines common functionality for node subtypes that
+// can have children
+
+function ContainerNode() {
+ Node.call(this);
+ this._firstChild = this._childNodes = null;
+}
+
+// Primary representation is a circular linked list of siblings
+ContainerNode.prototype = Object.create(Node.prototype, {
+
+ hasChildNodes: { value: function() {
+ if (this._childNodes) {
+ return this._childNodes.length > 0;
+ }
+ return this._firstChild !== null;
+ }},
+
+ childNodes: { get: function() {
+ this._ensureChildNodes();
+ return this._childNodes;
+ }},
+
+ firstChild: { get: function() {
+ if (this._childNodes) {
+ return this._childNodes.length === 0 ? null : this._childNodes[0];
+ }
+ return this._firstChild;
+ }},
+
+ lastChild: { get: function() {
+ var kids = this._childNodes, first;
+ if (kids) {
+ return kids.length === 0 ? null: kids[kids.length-1];
+ }
+ first = this._firstChild;
+ if (first === null) { return null; }
+ return first._previousSibling; // circular linked list
+ }},
+
+ _ensureChildNodes: { value: function() {
+ if (this._childNodes) { return; }
+ var first = this._firstChild,
+ kid = first,
+ childNodes = this._childNodes = new NodeList();
+ if (first) do {
+ childNodes.push(kid);
+ kid = kid._nextSibling;
+ } while (kid !== first); // circular linked list
+ this._firstChild = null; // free memory
+ }},
+
+ // Remove all of this node's children. This is a minor
+ // optimization that only calls modify() once.
+ removeChildren: { value: function removeChildren() {
+ var root = this.rooted ? this.ownerDocument : null,
+ next = this.firstChild,
+ kid;
+ while (next !== null) {
+ kid = next;
+ next = kid.nextSibling;
+
+ if (root) root.mutateRemove(kid);
+ kid.parentNode = null;
+ }
+ if (this._childNodes) {
+ this._childNodes.length = 0;
+ } else {
+ this._firstChild = null;
+ }
+ this.modify(); // Update last modified type once only
+ }},
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/CustomEvent.js
@@ -1,0 +1,12 @@
+"use strict";
+module.exports = CustomEvent;
+
+var Event = require('./Event');
+
+function CustomEvent(type, dictionary) {
+ // Just use the superclass constructor to initialize
+ Event.call(this, type, dictionary);
+}
+CustomEvent.prototype = Object.create(Event.prototype, {
+ constructor: { value: CustomEvent }
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/DOMException.js
@@ -1,0 +1,134 @@
+"use strict";
+module.exports = DOMException;
+
+var INDEX_SIZE_ERR = 1;
+var HIERARCHY_REQUEST_ERR = 3;
+var WRONG_DOCUMENT_ERR = 4;
+var INVALID_CHARACTER_ERR = 5;
+var NO_MODIFICATION_ALLOWED_ERR = 7;
+var NOT_FOUND_ERR = 8;
+var NOT_SUPPORTED_ERR = 9;
+var INVALID_STATE_ERR = 11;
+var SYNTAX_ERR = 12;
+var INVALID_MODIFICATION_ERR = 13;
+var NAMESPACE_ERR = 14;
+var INVALID_ACCESS_ERR = 15;
+var TYPE_MISMATCH_ERR = 17;
+var SECURITY_ERR = 18;
+var NETWORK_ERR = 19;
+var ABORT_ERR = 20;
+var URL_MISMATCH_ERR = 21;
+var QUOTA_EXCEEDED_ERR = 22;
+var TIMEOUT_ERR = 23;
+var INVALID_NODE_TYPE_ERR = 24;
+var DATA_CLONE_ERR = 25;
+
+// Code to name
+var names = [
+ null, // No error with code 0
+ 'INDEX_SIZE_ERR',
+ null, // historical
+ 'HIERARCHY_REQUEST_ERR',
+ 'WRONG_DOCUMENT_ERR',
+ 'INVALID_CHARACTER_ERR',
+ null, // historical
+ 'NO_MODIFICATION_ALLOWED_ERR',
+ 'NOT_FOUND_ERR',
+ 'NOT_SUPPORTED_ERR',
+ 'INUSE_ATTRIBUTE_ERR', // historical
+ 'INVALID_STATE_ERR',
+ 'SYNTAX_ERR',
+ 'INVALID_MODIFICATION_ERR',
+ 'NAMESPACE_ERR',
+ 'INVALID_ACCESS_ERR',
+ null, // historical
+ 'TYPE_MISMATCH_ERR',
+ 'SECURITY_ERR',
+ 'NETWORK_ERR',
+ 'ABORT_ERR',
+ 'URL_MISMATCH_ERR',
+ 'QUOTA_EXCEEDED_ERR',
+ 'TIMEOUT_ERR',
+ 'INVALID_NODE_TYPE_ERR',
+ 'DATA_CLONE_ERR',
+];
+
+// Code to message
+// These strings are from the 13 May 2011 Editor's Draft of DOM Core.
+// http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
+// Copyright © 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved.
+// Used under the terms of the W3C Document License:
+// http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
+var messages = [
+ null, // No error with code 0
+ 'INDEX_SIZE_ERR (1): the index is not in the allowed range',
+ null,
+ 'HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model',
+ 'WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required',
+ 'INVALID_CHARACTER_ERR (5): the string contains invalid characters',
+ null,
+ 'NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified',
+ 'NOT_FOUND_ERR (8): the object can not be found here',
+ 'NOT_SUPPORTED_ERR (9): this operation is not supported',
+ 'INUSE_ATTRIBUTE_ERR (10): setAttributeNode called on owned Attribute',
+ 'INVALID_STATE_ERR (11): the object is in an invalid state',
+ 'SYNTAX_ERR (12): the string did not match the expected pattern',
+ 'INVALID_MODIFICATION_ERR (13): the object can not be modified in this way',
+ 'NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML',
+ 'INVALID_ACCESS_ERR (15): the object does not support the operation or argument',
+ null,
+ 'TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type',
+ 'SECURITY_ERR (18): the operation is insecure',
+ 'NETWORK_ERR (19): a network error occurred',
+ 'ABORT_ERR (20): the user aborted an operation',
+ 'URL_MISMATCH_ERR (21): the given URL does not match another URL',
+ 'QUOTA_EXCEEDED_ERR (22): the quota has been exceeded',
+ 'TIMEOUT_ERR (23): a timeout occurred',
+ 'INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation',
+ 'DATA_CLONE_ERR (25): the object can not be cloned.'
+];
+
+// Name to code
+var constants = {
+ INDEX_SIZE_ERR: INDEX_SIZE_ERR,
+ DOMSTRING_SIZE_ERR: 2, // historical
+ HIERARCHY_REQUEST_ERR: HIERARCHY_REQUEST_ERR,
+ WRONG_DOCUMENT_ERR: WRONG_DOCUMENT_ERR,
+ INVALID_CHARACTER_ERR: INVALID_CHARACTER_ERR,
+ NO_DATA_ALLOWED_ERR: 6, // historical
+ NO_MODIFICATION_ALLOWED_ERR: NO_MODIFICATION_ALLOWED_ERR,
+ NOT_FOUND_ERR: NOT_FOUND_ERR,
+ NOT_SUPPORTED_ERR: NOT_SUPPORTED_ERR,
+ INUSE_ATTRIBUTE_ERR: 10, // historical
+ INVALID_STATE_ERR: INVALID_STATE_ERR,
+ SYNTAX_ERR: SYNTAX_ERR,
+ INVALID_MODIFICATION_ERR: INVALID_MODIFICATION_ERR,
+ NAMESPACE_ERR: NAMESPACE_ERR,
+ INVALID_ACCESS_ERR: INVALID_ACCESS_ERR,
+ VALIDATION_ERR: 16, // historical
+ TYPE_MISMATCH_ERR: TYPE_MISMATCH_ERR,
+ SECURITY_ERR: SECURITY_ERR,
+ NETWORK_ERR: NETWORK_ERR,
+ ABORT_ERR: ABORT_ERR,
+ URL_MISMATCH_ERR: URL_MISMATCH_ERR,
+ QUOTA_EXCEEDED_ERR: QUOTA_EXCEEDED_ERR,
+ TIMEOUT_ERR: TIMEOUT_ERR,
+ INVALID_NODE_TYPE_ERR: INVALID_NODE_TYPE_ERR,
+ DATA_CLONE_ERR: DATA_CLONE_ERR
+};
+
+function DOMException(code) {
+ Error.call(this);
+ Error.captureStackTrace(this, this.constructor);
+ this.code = code;
+ this.message = messages[code];
+ this.name = names[code];
+}
+DOMException.prototype.__proto__ = Error.prototype;
+
+// Initialize the constants on DOMException and DOMException.prototype
+for(var c in constants) {
+ var v = { value: constants[c] };
+ Object.defineProperty(DOMException, c, v);
+ Object.defineProperty(DOMException.prototype, c, v);
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/DOMImplementation.js
@@ -1,0 +1,94 @@
+"use strict";
+module.exports = DOMImplementation;
+
+var Document = require('./Document');
+var DocumentType = require('./DocumentType');
+var HTMLParser = require('./HTMLParser');
+var utils = require('./utils');
+var xml = require('./xmlnames');
+
+// Each document must have its own instance of the domimplementation object
+function DOMImplementation(contextObject) {
+ this.contextObject = contextObject;
+}
+
+
+// Feature/version pairs that DOMImplementation.hasFeature() returns
+// true for. It returns false for anything else.
+var supportedFeatures = {
+ 'xml': { '': true, '1.0': true, '2.0': true }, // DOM Core
+ 'core': { '': true, '2.0': true }, // DOM Core
+ 'html': { '': true, '1.0': true, '2.0': true} , // HTML
+ 'xhtml': { '': true, '1.0': true, '2.0': true} , // HTML
+};
+
+DOMImplementation.prototype = {
+ hasFeature: function hasFeature(feature, version) {
+ var f = supportedFeatures[(feature || '').toLowerCase()];
+ return (f && f[version || '']) || false;
+ },
+
+ createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) {
+ if (!xml.isValidQName(qualifiedName)) utils.InvalidCharacterError();
+
+ return new DocumentType(this.contextObject, qualifiedName, publicId, systemId);
+ },
+
+ createDocument: function createDocument(namespace, qualifiedName, doctype) {
+ //
+ // Note that the current DOMCore spec makes it impossible to
+ // create an HTML document with this function, even if the
+ // namespace and doctype are propertly set. See this thread:
+ // http://lists.w3.org/Archives/Public/www-dom/2011AprJun/0132.html
+ //
+ var d = new Document(false, null);
+ var e;
+
+ if (qualifiedName)
+ e = d.createElementNS(namespace, qualifiedName);
+ else
+ e = null;
+
+ if (doctype) {
+ d.appendChild(doctype);
+ }
+
+ if (e) d.appendChild(e);
+ if (namespace === utils.NAMESPACE.HTML) {
+ d._contentType = 'application/xhtml+xml';
+ } else if (namespace === utils.NAMESPACE.SVG) {
+ d._contentType = 'image/svg+xml';
+ } else {
+ d._contentType = 'application/xml';
+ }
+
+ return d;
+ },
+
+ createHTMLDocument: function createHTMLDocument(titleText) {
+ var d = new Document(true, null);
+ d.appendChild(new DocumentType(d, 'html'));
+ var html = d.createElement('html');
+ d.appendChild(html);
+ var head = d.createElement('head');
+ html.appendChild(head);
+ if (titleText !== undefined) {
+ var title = d.createElement('title');
+ head.appendChild(title);
+ title.appendChild(d.createTextNode(titleText));
+ }
+ html.appendChild(d.createElement('body'));
+ d.modclock = 1; // Start tracking modifications
+ return d;
+ },
+
+ mozSetOutputMutationHandler: function(doc, handler) {
+ doc.mutationHandler = handler;
+ },
+
+ mozGetInputMutationHandler: function(doc) {
+ utils.nyi();
+ },
+
+ mozHTMLParser: HTMLParser,
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/DOMTokenList.js
@@ -1,0 +1,186 @@
+"use strict";
+// DOMTokenList implementation based on https://github.com/Raynos/DOM-shim
+var utils = require('./utils');
+
+module.exports = DOMTokenList;
+
+function DOMTokenList(getter, setter) {
+ this._getString = getter;
+ this._setString = setter;
+ this._length = 0;
+ this._lastStringValue = '';
+ this._update();
+}
+
+Object.defineProperties(DOMTokenList.prototype, {
+ length: { get: function() { return this._length; } },
+ item: { value: function(index) {
+ var list = getList(this);
+ if (index < 0 || index >= list.length) {
+ return null;
+ }
+ return list[index];
+ }},
+
+ contains: { value: function(token) {
+ token = String(token); // no error checking for contains()
+ var list = getList(this);
+ return list.indexOf(token) > -1;
+ }},
+
+ add: { value: function() {
+ var list = getList(this);
+ for (var i = 0, len = arguments.length; i < len; i++) {
+ var token = handleErrors(arguments[i]);
+ if (list.indexOf(token) < 0) {
+ list.push(token);
+ }
+ }
+ // Note: as per spec, if handleErrors() throws any errors, we never
+ // make it here and none of the changes take effect.
+ // Also per spec: we run the "update steps" even if no change was
+ // made (ie, if the token already existed)
+ this._update(list);
+ }},
+
+ remove: { value: function() {
+ var list = getList(this);
+ for (var i = 0, len = arguments.length; i < len; i++) {
+ var token = handleErrors(arguments[i]);
+ var index = list.indexOf(token);
+ if (index > -1) {
+ list.splice(index, 1);
+ }
+ }
+ // Note: as per spec, if handleErrors() throws any errors, we never
+ // make it here and none of the changes take effect.
+ // Also per spec: we run the "update steps" even if no change was
+ // made (ie, if the token wasn't previously present)
+ this._update(list);
+ }},
+
+ toggle: { value: function toggle(token, force) {
+ token = handleErrors(token);
+ if (this.contains(token)) {
+ if (force === undefined || force === false) {
+ this.remove(token);
+ return false;
+ }
+ return true;
+ } else {
+ if (force === undefined || force === true) {
+ this.add(token);
+ return true;
+ }
+ return false;
+ }
+ }},
+
+ replace: { value: function replace(token, newToken) {
+ // weird corner case of spec: if `token` contains whitespace, but
+ // `newToken` is the empty string, we must throw SyntaxError not
+ // InvalidCharacterError (sigh)
+ if (String(newToken)==='') { utils.SyntaxError(); }
+ token = handleErrors(token);
+ newToken = handleErrors(newToken);
+ var list = getList(this);
+ var idx = list.indexOf(token);
+ if (idx < 0) {
+ // Note that, per spec, we do not run the update steps on this path.
+ return false;
+ }
+ var idx2 = list.indexOf(newToken);
+ if (idx2 < 0) {
+ list[idx] = newToken;
+ } else {
+ // "replace the first instance of either `token` or `newToken` with
+ // `newToken` and remove all other instances"
+ if (idx < idx2) {
+ list[idx] = newToken;
+ list.splice(idx2, 1);
+ } else {
+ // idx2 is already `newToken`
+ list.splice(idx, 1);
+ }
+ }
+ this._update(list);
+ return true;
+ }},
+
+ toString: { value: function() {
+ return this._getString();
+ }},
+
+ value: {
+ get: function() {
+ return this._getString();
+ },
+ set: function(v) {
+ this._setString(v);
+ this._update();
+ }
+ },
+
+ // Called when the setter is called from outside this interface.
+ _update: { value: function(list) {
+ if (list) {
+ fixIndex(this, list);
+ this._setString(list.join(" ").trim());
+ } else {
+ fixIndex(this, getList(this));
+ }
+ this._lastStringValue = this._getString();
+ } },
+});
+
+function fixIndex(clist, list) {
+ var oldLength = clist._length;
+ var i;
+ clist._length = list.length;
+ for (i = 0; i < list.length; i++) {
+ clist[i] = list[i];
+ }
+ // Clear/free old entries.
+ for (; i < oldLength; i++) {
+ clist[i] = undefined;
+ }
+}
+
+function handleErrors(token) {
+ token = String(token);
+ if (token === "") {
+ utils.SyntaxError();
+ }
+ if (/[ \t\r\n\f]/.test(token)) {
+ utils.InvalidCharacterError();
+ }
+ return token;
+}
+
+function toArray(clist) {
+ var length = clist._length;
+ var arr = Array(length);
+ for (var i = 0; i < length; i++) {
+ arr[i] = clist[i];
+ }
+ return arr;
+}
+
+function getList(clist) {
+ var strProp = clist._getString();
+ if (strProp === clist._lastStringValue) {
+ return toArray(clist);
+ }
+ var str = strProp.replace(/(^[ \t\r\n\f]+)|([ \t\r\n\f]+$)/g, '');
+ if (str === "") {
+ return [];
+ } else {
+ var seen = Object.create(null);
+ return str.split(/[ \t\r\n\f]+/g).filter(function(n) {
+ var key = '$' + n;
+ if (seen[key]) { return false; }
+ seen[key] = true;
+ return true;
+ });
+ }
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Document.js
@@ -1,0 +1,884 @@
+"use strict";
+module.exports = Document;
+
+var Node = require('./Node');
+var NodeList = require('./NodeList');
+var ContainerNode = require('./ContainerNode');
+var Element = require('./Element');
+var Text = require('./Text');
+var Comment = require('./Comment');
+var Event = require('./Event');
+var DocumentFragment = require('./DocumentFragment');
+var ProcessingInstruction = require('./ProcessingInstruction');
+var DOMImplementation = require('./DOMImplementation');
+var TreeWalker = require('./TreeWalker');
+var NodeIterator = require('./NodeIterator');
+var NodeFilter = require('./NodeFilter');
+var URL = require('./URL');
+var select = require('./select');
+var events = require('./events');
+var xml = require('./xmlnames');
+var html = require('./htmlelts');
+var svg = require('./svg');
+var utils = require('./utils');
+var MUTATE = require('./MutationConstants');
+var NAMESPACE = utils.NAMESPACE;
+var isApiWritable = require("./config").isApiWritable;
+
+function Document(isHTML, address) {
+ ContainerNode.call(this);
+ this.nodeType = Node.DOCUMENT_NODE;
+ this.isHTML = isHTML;
+ this._address = address || 'about:blank';
+ this.readyState = 'loading';
+ this.implementation = new DOMImplementation(this);
+
+ // DOMCore says that documents are always associated with themselves
+ this.ownerDocument = null; // ... but W3C tests expect null
+ this._contentType = isHTML ? 'text/html' : 'application/xml';
+
+ // These will be initialized by our custom versions of
+ // appendChild and insertBefore that override the inherited
+ // Node methods.
+ // XXX: override those methods!
+ this.doctype = null;
+ this.documentElement = null;
+
+ // "Associated inert template document"
+ this._templateDocCache = null;
+ // List of active NodeIterators, see NodeIterator#_preremove()
+ this._nodeIterators = null;
+
+ // Documents are always rooted, by definition
+ this._nid = 1;
+ this._nextnid = 2; // For numbering children of the document
+ this._nodes = [null, this]; // nid to node map
+
+ // This maintains the mapping from element ids to element nodes.
+ // We may need to update this mapping every time a node is rooted
+ // or uprooted, and any time an attribute is added, removed or changed
+ // on a rooted element.
+ this.byId = Object.create(null);
+
+ // This property holds a monotonically increasing value akin to
+ // a timestamp used to record the last modification time of nodes
+ // and their subtrees. See the lastModTime attribute and modify()
+ // method of the Node class. And see FilteredElementList for an example
+ // of the use of lastModTime
+ this.modclock = 0;
+}
+
+// Map from lowercase event category names (used as arguments to
+// createEvent()) to the property name in the impl object of the
+// event constructor.
+var supportedEvents = {
+ event: 'Event',
+ customevent: 'CustomEvent',
+ uievent: 'UIEvent',
+ mouseevent: 'MouseEvent'
+};
+
+// Certain arguments to document.createEvent() must be treated specially
+var replacementEvent = {
+ events: 'event',
+ htmlevents: 'event',
+ mouseevents: 'mouseevent',
+ mutationevents: 'mutationevent',
+ uievents: 'uievent'
+};
+
+var mirrorAttr = function(f, name, defaultValue) {
+ return {
+ get: function() {
+ var o = f.call(this);
+ if (o) { return o[name]; }
+ return defaultValue;
+ },
+ set: function(value) {
+ var o = f.call(this);
+ if (o) { o[name] = value; }
+ },
+ };
+};
+
+/** @spec https://dom.spec.whatwg.org/#validate-and-extract */
+function validateAndExtract(namespace, qualifiedName) {
+ var prefix, localName, pos;
+ if (namespace==='') { namespace = null; }
+ // See https://github.com/whatwg/dom/issues/671
+ // and https://github.com/whatwg/dom/issues/319
+ if (!xml.isValidQName(qualifiedName)) {
+ utils.InvalidCharacterError();
+ }
+ prefix = null;
+ localName = qualifiedName;
+
+ pos = qualifiedName.indexOf(':');
+ if (pos >= 0) {
+ prefix = qualifiedName.substring(0, pos);
+ localName = qualifiedName.substring(pos+1);
+ }
+ if (prefix !== null && namespace === null) {
+ utils.NamespaceError();
+ }
+ if (prefix === 'xml' && namespace !== NAMESPACE.XML) {
+ utils.NamespaceError();
+ }
+ if ((prefix === 'xmlns' || qualifiedName === 'xmlns') &&
+ namespace !== NAMESPACE.XMLNS) {
+ utils.NamespaceError();
+ }
+ if (namespace === NAMESPACE.XMLNS && !(prefix==='xmlns' || qualifiedName==='xmlns')) {
+ utils.NamespaceError();
+ }
+ return { namespace: namespace, prefix: prefix, localName: localName };
+}
+
+Document.prototype = Object.create(ContainerNode.prototype, {
+ // This method allows dom.js to communicate with a renderer
+ // that displays the document in some way
+ // XXX: I should probably move this to the window object
+ _setMutationHandler: { value: function(handler) {
+ this.mutationHandler = handler;
+ }},
+
+ // This method allows dom.js to receive event notifications
+ // from the renderer.
+ // XXX: I should probably move this to the window object
+ _dispatchRendererEvent: { value: function(targetNid, type, details) {
+ var target = this._nodes[targetNid];
+ if (!target) return;
+ target._dispatchEvent(new Event(type, details), true);
+ }},
+
+ nodeName: { value: '#document'},
+ nodeValue: {
+ get: function() {
+ return null;
+ },
+ set: function() {}
+ },
+
+ // XXX: DOMCore may remove documentURI, so it is NYI for now
+ documentURI: { get: function() { return this._address; }, set: utils.nyi.bind(this, 'set documentURI') },
+ compatMode: { get: function() {
+ // The _quirks property is set by the HTML parser
+ return this._quirks ? 'BackCompat' : 'CSS1Compat';
+ }},
+
+ createTextNode: { value: function(data) {
+ return new Text(this, String(data));
+ }},
+ createComment: { value: function(data) {
+ return new Comment(this, data);
+ }},
+ createDocumentFragment: { value: function() {
+ return new DocumentFragment(this);
+ }},
+ createProcessingInstruction: { value: function(target, data) {
+ if (!xml.isValidName(target) || data.indexOf('?>') !== -1)
+ utils.InvalidCharacterError();
+ return new ProcessingInstruction(this, target, data);
+ }},
+
+ createAttribute: { value: function(localName) {
+ localName = String(localName);
+ if (!xml.isValidName(localName)) utils.InvalidCharacterError();
+ if (this.isHTML) {
+ localName = utils.toASCIILowerCase(localName);
+ }
+ return new Element._Attr(null, localName, null, null, '');
+ }},
+ createAttributeNS: { value: function(namespace, qualifiedName) {
+ // Convert parameter types according to WebIDL
+ namespace =
+ (namespace === null || namespace === undefined || namespace === '') ? null :
+ String(namespace);
+ qualifiedName = String(qualifiedName);
+ var ve = validateAndExtract(namespace, qualifiedName);
+ return new Element._Attr(null, ve.localName, ve.prefix, ve.namespace, '');
+ }},
+
+ createElement: { value: function(localName) {
+ localName = String(localName);
+ if (!xml.isValidName(localName)) utils.InvalidCharacterError();
+ // Per spec, namespace should be HTML namespace if "context object is
+ // an HTML document or context object's content type is
+ // "application/xhtml+xml", and null otherwise.
+ if (this.isHTML) {
+ if (/[A-Z]/.test(localName))
+ localName = utils.toASCIILowerCase(localName);
+ return html.createElement(this, localName, null);
+ } else if (this.contentType === 'application/xhtml+xml') {
+ return html.createElement(this, localName, null);
+ } else {
+ return new Element(this, localName, null, null);
+ }
+ }, writable: isApiWritable },
+
+ createElementNS: { value: function(namespace, qualifiedName) {
+ // Convert parameter types according to WebIDL
+ namespace =
+ (namespace === null || namespace === undefined || namespace === '') ? null :
+ String(namespace);
+ qualifiedName = String(qualifiedName);
+ var ve = validateAndExtract(namespace, qualifiedName);
+ return this._createElementNS(ve.localName, ve.namespace, ve.prefix);
+ }, writable: isApiWritable },
+
+ // This is used directly by HTML parser, which allows it to create
+ // elements with localNames containing ':' and non-default namespaces
+ _createElementNS: { value: function(localName, namespace, prefix) {
+ if (namespace === NAMESPACE.HTML) {
+ return html.createElement(this, localName, prefix);
+ }
+ else if (namespace === NAMESPACE.SVG) {
+ return svg.createElement(this, localName, prefix);
+ }
+
+ return new Element(this, localName, namespace, prefix);
+ }},
+
+ createEvent: { value: function createEvent(interfaceName) {
+ interfaceName = interfaceName.toLowerCase();
+ var name = replacementEvent[interfaceName] || interfaceName;
+ var constructor = events[supportedEvents[name]];
+
+ if (constructor) {
+ var e = new constructor();
+ e._initialized = false;
+ return e;
+ }
+ else {
+ utils.NotSupportedError();
+ }
+ }},
+
+ // See: http://www.w3.org/TR/dom/#dom-document-createtreewalker
+ createTreeWalker: {value: function (root, whatToShow, filter) {
+ if (!root) { throw new TypeError("root argument is required"); }
+ if (!(root instanceof Node)) { throw new TypeError("root not a node"); }
+ whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : (+whatToShow);
+ filter = filter === undefined ? null : filter;
+
+ return new TreeWalker(root, whatToShow, filter);
+ }},
+
+ // See: http://www.w3.org/TR/dom/#dom-document-createnodeiterator
+ createNodeIterator: {value: function (root, whatToShow, filter) {
+ if (!root) { throw new TypeError("root argument is required"); }
+ if (!(root instanceof Node)) { throw new TypeError("root not a node"); }
+ whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : (+whatToShow);
+ filter = filter === undefined ? null : filter;
+
+ return new NodeIterator(root, whatToShow, filter);
+ }},
+
+ _attachNodeIterator: { value: function(ni) {
+ // XXX ideally this should be a weak reference from Document to NodeIterator
+ if (!this._nodeIterators) { this._nodeIterators = []; }
+ this._nodeIterators.push(ni);
+ }},
+
+ _detachNodeIterator: { value: function(ni) {
+ // ni should always be in list of node iterators
+ var idx = this._nodeIterators.indexOf(ni);
+ this._nodeIterators.splice(idx, 1);
+ }},
+
+ _preremoveNodeIterators: { value: function(toBeRemoved) {
+ if (this._nodeIterators) {
+ this._nodeIterators.forEach(function(ni) { ni._preremove(toBeRemoved); });
+ }
+ }},
+
+ // Maintain the documentElement and
+ // doctype properties of the document. Each of the following
+ // methods chains to the Node implementation of the method
+ // to do the actual inserting, removal or replacement.
+
+ _updateDocTypeElement: { value: function _updateDocTypeElement() {
+ this.doctype = this.documentElement = null;
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === Node.DOCUMENT_TYPE_NODE)
+ this.doctype = kid;
+ else if (kid.nodeType === Node.ELEMENT_NODE)
+ this.documentElement = kid;
+ }
+ }},
+
+ insertBefore: { value: function insertBefore(child, refChild) {
+ Node.prototype.insertBefore.call(this, child, refChild);
+ this._updateDocTypeElement();
+ return child;
+ }},
+
+ replaceChild: { value: function replaceChild(node, child) {
+ Node.prototype.replaceChild.call(this, node, child);
+ this._updateDocTypeElement();
+ return child;
+ }},
+
+ removeChild: { value: function removeChild(child) {
+ Node.prototype.removeChild.call(this, child);
+ this._updateDocTypeElement();
+ return child;
+ }},
+
+ getElementById: { value: function(id) {
+ var n = this.byId[id];
+ if (!n) return null;
+ if (n instanceof MultiId) { // there was more than one element with this id
+ return n.getFirst();
+ }
+ return n;
+ }},
+
+ _hasMultipleElementsWithId: { value: function(id) {
+ // Used internally by querySelectorAll optimization
+ return (this.byId[id] instanceof MultiId);
+ }},
+
+ // Just copy this method from the Element prototype
+ getElementsByName: { value: Element.prototype.getElementsByName },
+ getElementsByTagName: { value: Element.prototype.getElementsByTagName },
+ getElementsByTagNameNS: { value: Element.prototype.getElementsByTagNameNS },
+ getElementsByClassName: { value: Element.prototype.getElementsByClassName },
+
+ adoptNode: { value: function adoptNode(node) {
+ if (node.nodeType === Node.DOCUMENT_NODE) utils.NotSupportedError();
+ if (node.nodeType === Node.ATTRIBUTE_NODE) { return node; }
+
+ if (node.parentNode) node.parentNode.removeChild(node);
+
+ if (node.ownerDocument !== this)
+ recursivelySetOwner(node, this);
+
+ return node;
+ }},
+
+ importNode: { value: function importNode(node, deep) {
+ return this.adoptNode(node.cloneNode(deep));
+ }, writable: isApiWritable },
+
+ // The following attributes and methods are from the HTML spec
+ origin: { get: function origin() { return null; } },
+ characterSet: { get: function characterSet() { return "UTF-8"; } },
+ contentType: { get: function contentType() { return this._contentType; } },
+ URL: { get: function URL() { return this._address; } },
+ domain: { get: utils.nyi.bind(this, 'domain'), set: utils.nyi.bind(this, 'domain') },
+ referrer: { get: opossum.referrer },
+ //cookie: { get: utils.nyi.bind(this, 'cookie get'), set: utils.nyi.bind(this, 'cookie set') },
+ lastModified: { get: utils.nyi.bind(this, 'lastModified get') },
+ location: {
+ get: function() {
+ return this.defaultView ? this.defaultView.location : null; // gh #75
+ },
+ set: utils.nyi.bind(this, 'location set')
+ },
+ _titleElement: {
+ get: function() {
+ // The title element of a document is the first title element in the
+ // document in tree order, if there is one, or null otherwise.
+ return this.getElementsByTagName('title').item(0) || null;
+ }
+ },
+ title: {
+ get: function() {
+ var elt = this._titleElement;
+ // The child text content of the title element, or '' if null.
+ var value = elt ? elt.textContent : '';
+ // Strip and collapse whitespace in value
+ return value.replace(/[ \t\n\r\f]+/g, ' ').replace(/(^ )|( $)/g, '');
+ },
+ set: function(value) {
+ var elt = this._titleElement;
+ var head = this.head;
+ if (!elt && !head) { return; /* according to spec */ }
+ if (!elt) {
+ elt = this.createElement('title');
+ head.appendChild(elt);
+ }
+ elt.textContent = value;
+ }
+ },
+ dir: mirrorAttr(function() {
+ var htmlElement = this.documentElement;
+ if (htmlElement && htmlElement.tagName === 'HTML') { return htmlElement; }
+ }, 'dir', ''),
+ fgColor: mirrorAttr(function() { return this.body; }, 'text', ''),
+ linkColor: mirrorAttr(function() { return this.body; }, 'link', ''),
+ vlinkColor: mirrorAttr(function() { return this.body; }, 'vLink', ''),
+ alinkColor: mirrorAttr(function() { return this.body; }, 'aLink', ''),
+ bgColor: mirrorAttr(function() { return this.body; }, 'bgColor', ''),
+
+ // Historical aliases of Document#characterSet
+ charset: { get: function() { return this.characterSet; } },
+ inputEncoding: { get: function() { return this.characterSet; } },
+
+ scrollingElement: {
+ get: function() {
+ return this._quirks ? this.body : this.documentElement;
+ }
+ },
+
+ // Return the first <body> child of the document element.
+ // XXX For now, setting this attribute is not implemented.
+ body: {
+ get: function() {
+ return namedHTMLChild(this.documentElement, 'body');
+ },
+ set: utils.nyi.bind(this, 'body set')
+ },
+ // Return the first <head> child of the document element.
+ head: { get: function() {
+ return namedHTMLChild(this.documentElement, 'head');
+ }},
+ images: { get: utils.nyi.bind(this, 'images get') },
+ embeds: { get: utils.nyi.bind(this, 'embeds get') },
+ plugins: { get: utils.nyi.bind(this, 'plugins get') },
+ links: { get: utils.nyi.bind(this, 'links get') },
+ forms: { get: utils.nyi.bind(this, 'forms get') },
+ scripts: { get: utils.nyi.bind(this, 'scripts get') },
+ applets: { get: function() { return []; } },
+ activeElement: { get: function() { return null; } },
+ innerHTML: {
+ get: function() { return this.serialize(); },
+ set: utils.nyi
+ },
+ outerHTML: {
+ get: function() { return this.serialize(); },
+ set: utils.nyi
+ },
+
+ write: { value: function(args) {
+ if (!this.isHTML) utils.InvalidStateError();
+
+ // XXX: still have to implement the ignore part
+ if (!this._parser /* && this._ignore_destructive_writes > 0 */ )
+ return;
+
+ if (!this._parser) {
+ // XXX call document.open, etc.
+ }
+
+ var s = arguments.join('');
+
+ // If the Document object's reload override flag is set, then
+ // append the string consisting of the concatenation of all the
+ // arguments to the method to the Document's reload override
+ // buffer.
+ // XXX: don't know what this is about. Still have to do it
+
+ // If there is no pending parsing-blocking script, have the
+ // tokenizer process the characters that were inserted, one at a
+ // time, processing resulting tokens as they are emitted, and
+ // stopping when the tokenizer reaches the insertion point or when
+ // the processing of the tokenizer is aborted by the tree
+ // construction stage (this can happen if a script end tag token is
+ // emitted by the tokenizer).
+
+ // XXX: still have to do the above. Sounds as if we don't
+ // always call parse() here. If we're blocked, then we just
+ // insert the text into the stream but don't parse it reentrantly...
+
+ // Invoke the parser reentrantly
+ this._parser.parse(s);
+ }},
+
+ writeln: { value: function writeln(args) {
+ this.write(Array.prototype.join.call(arguments, '') + '\n');
+ }},
+
+ open: { value: function() {
+ this.documentElement = null;
+ }},
+
+ close: { value: function() {
+ this.readyState = 'interactive';
+ this._dispatchEvent(new Event('readystatechange'), true);
+ this._dispatchEvent(new Event('DOMContentLoaded'), true);
+ this.readyState = 'complete';
+ this._dispatchEvent(new Event('readystatechange'), true);
+ if (this.defaultView) {
+ this.defaultView._dispatchEvent(new Event('load'), true);
+ }
+ }},
+
+ // Utility methods
+ clone: { value: function clone() {
+ var d = new Document(this.isHTML, this._address);
+ d._quirks = this._quirks;
+ d._contentType = this._contentType;
+ return d;
+ }},
+
+ // We need to adopt the nodes if we do a deep clone
+ cloneNode: { value: function cloneNode(deep) {
+ var clone = Node.prototype.cloneNode.call(this, false);
+ if (deep) {
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ clone._appendChild(clone.importNode(kid, true));
+ }
+ }
+ clone._updateDocTypeElement();
+ return clone;
+ }},
+
+ isEqual: { value: function isEqual(n) {
+ // Any two documents are shallowly equal.
+ // Node.isEqualNode will also test the children
+ return true;
+ }},
+
+ // Implementation-specific function. Called when a text, comment,
+ // or pi value changes.
+ mutateValue: { value: function(node) {
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.VALUE,
+ target: node,
+ data: node.data
+ });
+ }
+ }},
+
+ // Invoked when an attribute's value changes. Attr holds the new
+ // value. oldval is the old value. Attribute mutations can also
+ // involve changes to the prefix (and therefore the qualified name)
+ mutateAttr: { value: function(attr, oldval) {
+ // Manage id->element mapping for getElementsById()
+ // XXX: this special case id handling should not go here,
+ // but in the attribute declaration for the id attribute
+ /*
+ if (attr.localName === 'id' && attr.namespaceURI === null) {
+ if (oldval) delId(oldval, attr.ownerElement);
+ addId(attr.value, attr.ownerElement);
+ }
+ */
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.ATTR,
+ target: attr.ownerElement,
+ attr: attr
+ });
+ }
+ }},
+
+ // Used by removeAttribute and removeAttributeNS for attributes.
+ mutateRemoveAttr: { value: function(attr) {
+/*
+* This is now handled in Attributes.js
+ // Manage id to element mapping
+ if (attr.localName === 'id' && attr.namespaceURI === null) {
+ this.delId(attr.value, attr.ownerElement);
+ }
+*/
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.REMOVE_ATTR,
+ target: attr.ownerElement,
+ attr: attr
+ });
+ }
+ }},
+
+ // Called by Node.removeChild, etc. to remove a rooted element from
+ // the tree. Only needs to generate a single mutation event when a
+ // node is removed, but must recursively mark all descendants as not
+ // rooted.
+ mutateRemove: { value: function(node) {
+ // Send a single mutation event
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.REMOVE,
+ target: node.parentNode,
+ node: node
+ });
+ }
+
+ // Mark this and all descendants as not rooted
+ recursivelyUproot(node);
+ }},
+
+ // Called when a new element becomes rooted. It must recursively
+ // generate mutation events for each of the children, and mark them all
+ // as rooted.
+ mutateInsert: { value: function(node) {
+ // Mark node and its descendants as rooted
+ recursivelyRoot(node);
+
+ // Send a single mutation event
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.INSERT,
+ target: node.parentNode,
+ node: node
+ });
+ }
+ }},
+
+ // Called when a rooted element is moved within the document
+ mutateMove: { value: function(node) {
+ if (this.mutationHandler) {
+ this.mutationHandler({
+ type: MUTATE.MOVE,
+ target: node
+ });
+ }
+ }},
+
+
+ // Add a mapping from id to n for n.ownerDocument
+ addId: { value: function addId(id, n) {
+ var val = this.byId[id];
+ if (!val) {
+ this.byId[id] = n;
+ }
+ else {
+ // TODO: Add a way to opt-out console warnings
+ //console.warn('Duplicate element id ' + id);
+ if (!(val instanceof MultiId)) {
+ val = new MultiId(val);
+ this.byId[id] = val;
+ }
+ val.add(n);
+ }
+ }},
+
+ // Delete the mapping from id to n for n.ownerDocument
+ delId: { value: function delId(id, n) {
+ var val = this.byId[id];
+ utils.assert(val);
+
+ if (val instanceof MultiId) {
+ val.del(n);
+ if (val.length === 1) { // convert back to a single node
+ this.byId[id] = val.downgrade();
+ }
+ }
+ else {
+ this.byId[id] = undefined;
+ }
+ }},
+
+ _resolve: { value: function(href) {
+ //XXX: Cache the URL
+ return new URL(this._documentBaseURL).resolve(href);
+ }},
+
+ _documentBaseURL: { get: function() {
+ // XXX: This is not implemented correctly yet
+ var url = this._address;
+ if (url === 'about:blank') url = '/';
+
+ var base = this.querySelector('base[href]');
+ if (base) {
+ return new URL(url).resolve(base.getAttribute('href'));
+ }
+ return url;
+
+ // The document base URL of a Document object is the
+ // absolute URL obtained by running these substeps:
+
+ // Let fallback base url be the document's address.
+
+ // If fallback base url is about:blank, and the
+ // Document's browsing context has a creator browsing
+ // context, then let fallback base url be the document
+ // base URL of the creator Document instead.
+
+ // If the Document is an iframe srcdoc document, then
+ // let fallback base url be the document base URL of
+ // the Document's browsing context's browsing context
+ // container's Document instead.
+
+ // If there is no base element that has an href
+ // attribute, then the document base URL is fallback
+ // base url; abort these steps. Otherwise, let url be
+ // the value of the href attribute of the first such
+ // element.
+
+ // Resolve url relative to fallback base url (thus,
+ // the base href attribute isn't affected by xml:base
+ // attributes).
+
+ // The document base URL is the result of the previous
+ // step if it was successful; otherwise it is fallback
+ // base url.
+ }},
+
+ _templateDoc: { get: function() {
+ if (!this._templateDocCache) {
+ // "associated inert template document"
+ var newDoc = new Document(this.isHTML, this._address);
+ this._templateDocCache = newDoc._templateDocCache = newDoc;
+ }
+ return this._templateDocCache;
+ }},
+
+ querySelector: { value: function(selector) {
+ return select(selector, this)[0];
+ }},
+
+ querySelectorAll: { value: function(selector) {
+ var nodes = select(selector, this);
+ return nodes.item ? nodes : new NodeList(nodes);
+ }}
+
+});
+
+
+var eventHandlerTypes = [
+ 'abort', 'canplay', 'canplaythrough', 'change', 'click', 'contextmenu',
+ 'cuechange', 'dblclick', 'drag', 'dragend', 'dragenter', 'dragleave',
+ 'dragover', 'dragstart', 'drop', 'durationchange', 'emptied', 'ended',
+ 'input', 'invalid', 'keydown', 'keypress', 'keyup', 'loadeddata',
+ 'loadedmetadata', 'loadstart', 'mousedown', 'mousemove', 'mouseout',
+ 'mouseover', 'mouseup', 'mousewheel', 'pause', 'play', 'playing',
+ 'progress', 'ratechange', 'readystatechange', 'reset', 'seeked',
+ 'seeking', 'select', 'show', 'stalled', 'submit', 'suspend',
+ 'timeupdate', 'volumechange', 'waiting',
+
+ 'blur', 'error', 'focus', 'load', 'scroll'
+];
+
+// Add event handler idl attribute getters and setters to Document
+eventHandlerTypes.forEach(function(type) {
+ // Define the event handler registration IDL attribute for this type
+ Object.defineProperty(Document.prototype, 'on' + type, {
+ get: function() {
+ return this._getEventHandler(type);
+ },
+ set: function(v) {
+ this._setEventHandler(type, v);
+ }
+ });
+});
+
+function namedHTMLChild(parent, name) {
+ if (parent && parent.isHTML) {
+ for (var kid = parent.firstChild; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === Node.ELEMENT_NODE &&
+ kid.localName === name &&
+ kid.namespaceURI === NAMESPACE.HTML) {
+ return kid;
+ }
+ }
+ }
+ return null;
+}
+
+function root(n) {
+ n._nid = n.ownerDocument._nextnid++;
+ n.ownerDocument._nodes[n._nid] = n;
+ // Manage id to element mapping
+ if (n.nodeType === Node.ELEMENT_NODE) {
+ var id = n.getAttribute('id');
+ if (id) n.ownerDocument.addId(id, n);
+
+ // Script elements need to know when they're inserted
+ // into the document
+ if (n._roothook) n._roothook();
+ }
+}
+
+function uproot(n) {
+ // Manage id to element mapping
+ if (n.nodeType === Node.ELEMENT_NODE) {
+ var id = n.getAttribute('id');
+ if (id) n.ownerDocument.delId(id, n);
+ }
+ n.ownerDocument._nodes[n._nid] = undefined;
+ n._nid = undefined;
+}
+
+function recursivelyRoot(node) {
+ root(node);
+ // XXX:
+ // accessing childNodes on a leaf node creates a new array the
+ // first time, so be careful to write this loop so that it
+ // doesn't do that. node is polymorphic, so maybe this is hard to
+ // optimize? Try switching on nodeType?
+/*
+ if (node.hasChildNodes()) {
+ var kids = node.childNodes;
+ for(var i = 0, n = kids.length; i < n; i++)
+ recursivelyRoot(kids[i]);
+ }
+*/
+ if (node.nodeType === Node.ELEMENT_NODE) {
+ for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
+ recursivelyRoot(kid);
+ }
+}
+
+function recursivelyUproot(node) {
+ uproot(node);
+ for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
+ recursivelyUproot(kid);
+}
+
+function recursivelySetOwner(node, owner) {
+ node.ownerDocument = owner;
+ node._lastModTime = undefined; // mod times are document-based
+ if (Object.prototype.hasOwnProperty.call(node, '_tagName')) {
+ node._tagName = undefined; // Element subclasses might need to change case
+ }
+ for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
+ recursivelySetOwner(kid, owner);
+}
+
+// A class for storing multiple nodes with the same ID
+function MultiId(node) {
+ this.nodes = Object.create(null);
+ this.nodes[node._nid] = node;
+ this.length = 1;
+ this.firstNode = undefined;
+}
+
+// Add a node to the list, with O(1) time
+MultiId.prototype.add = function(node) {
+ if (!this.nodes[node._nid]) {
+ this.nodes[node._nid] = node;
+ this.length++;
+ this.firstNode = undefined;
+ }
+};
+
+// Remove a node from the list, with O(1) time
+MultiId.prototype.del = function(node) {
+ if (this.nodes[node._nid]) {
+ delete this.nodes[node._nid];
+ this.length--;
+ this.firstNode = undefined;
+ }
+};
+
+// Get the first node from the list, in the document order
+// Takes O(N) time in the size of the list, with a cache that is invalidated
+// when the list is modified.
+MultiId.prototype.getFirst = function() {
+ /* jshint bitwise: false */
+ if (!this.firstNode) {
+ var nid;
+ for (nid in this.nodes) {
+ if (this.firstNode === undefined ||
+ this.firstNode.compareDocumentPosition(this.nodes[nid]) & Node.DOCUMENT_POSITION_PRECEDING) {
+ this.firstNode = this.nodes[nid];
+ }
+ }
+ }
+ return this.firstNode;
+};
+
+// If there is only one node left, return it. Otherwise return "this".
+MultiId.prototype.downgrade = function() {
+ if (this.length === 1) {
+ var nid;
+ for (nid in this.nodes) {
+ return this.nodes[nid];
+ }
+ }
+ return this;
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/DocumentFragment.js
@@ -1,0 +1,68 @@
+"use strict";
+module.exports = DocumentFragment;
+
+var Node = require('./Node');
+var NodeList = require('./NodeList');
+var ContainerNode = require('./ContainerNode');
+var Element = require('./Element');
+var select = require('./select');
+var utils = require('./utils');
+
+function DocumentFragment(doc) {
+ ContainerNode.call(this);
+ this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
+ this.ownerDocument = doc;
+}
+
+DocumentFragment.prototype = Object.create(ContainerNode.prototype, {
+ nodeName: { value: '#document-fragment' },
+ nodeValue: {
+ get: function() {
+ return null;
+ },
+ set: function() {}
+ },
+ // Copy the text content getter/setter from Element
+ textContent: Object.getOwnPropertyDescriptor(Element.prototype, 'textContent'),
+
+ querySelector: { value: function(selector) {
+ // implement in terms of querySelectorAll
+ var nodes = this.querySelectorAll(selector);
+ return nodes.length ? nodes[0] : null;
+ }},
+ querySelectorAll: { value: function(selector) {
+ // create a context
+ var context = Object.create(this);
+ // add some methods to the context for zest implementation, without
+ // adding them to the public DocumentFragment API
+ context.isHTML = true; // in HTML namespace (case-insensitive match)
+ context.getElementsByTagName = Element.prototype.getElementsByTagName;
+ context.nextElement =
+ Object.getOwnPropertyDescriptor(Element.prototype, 'firstElementChild').
+ get;
+ // invoke zest
+ var nodes = select(selector, context);
+ return nodes.item ? nodes : new NodeList(nodes);
+ }},
+
+ // Utility methods
+ clone: { value: function clone() {
+ return new DocumentFragment(this.ownerDocument);
+ }},
+ isEqual: { value: function isEqual(n) {
+ // Any two document fragments are shallowly equal.
+ // Node.isEqualNode() will test their children for equality
+ return true;
+ }},
+
+ // Non-standard, but useful (github issue #73)
+ innerHTML: {
+ get: function() { return this.serialize(); },
+ set: utils.nyi
+ },
+ outerHTML: {
+ get: function() { return this.serialize(); },
+ set: utils.nyi
+ },
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/DocumentType.js
@@ -1,0 +1,36 @@
+"use strict";
+module.exports = DocumentType;
+
+var Node = require('./Node');
+var Leaf = require('./Leaf');
+var ChildNode = require('./ChildNode');
+
+function DocumentType(ownerDocument, name, publicId, systemId) {
+ Leaf.call(this);
+ this.nodeType = Node.DOCUMENT_TYPE_NODE;
+ this.ownerDocument = ownerDocument || null;
+ this.name = name;
+ this.publicId = publicId || "";
+ this.systemId = systemId || "";
+}
+
+DocumentType.prototype = Object.create(Leaf.prototype, {
+ nodeName: { get: function() { return this.name; }},
+ nodeValue: {
+ get: function() { return null; },
+ set: function() {}
+ },
+
+ // Utility methods
+ clone: { value: function clone() {
+ return new DocumentType(this.ownerDocument, this.name, this.publicId, this.systemId);
+ }},
+
+ isEqual: { value: function isEqual(n) {
+ return this.name === n.name &&
+ this.publicId === n.publicId &&
+ this.systemId === n.systemId;
+ }}
+});
+
+Object.defineProperties(DocumentType.prototype, ChildNode);
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Element.js
@@ -1,0 +1,1202 @@
+"use strict";
+module.exports = Element;
+
+var xml = require('./xmlnames');
+var utils = require('./utils');
+var NAMESPACE = utils.NAMESPACE;
+var attributes = require('./attributes');
+var Node = require('./Node');
+var NodeList = require('./NodeList');
+var NodeUtils = require('./NodeUtils');
+var FilteredElementList = require('./FilteredElementList');
+var DOMException = require('./DOMException');
+var DOMTokenList = require('./DOMTokenList');
+var select = require('./select');
+var ContainerNode = require('./ContainerNode');
+var ChildNode = require('./ChildNode');
+var NonDocumentTypeChildNode = require('./NonDocumentTypeChildNode');
+var NamedNodeMap = require('./NamedNodeMap');
+
+var uppercaseCache = Object.create(null);
+
+function Element(doc, localName, namespaceURI, prefix) {
+ ContainerNode.call(this);
+ this.nodeType = Node.ELEMENT_NODE;
+ this.ownerDocument = doc;
+ this.localName = localName;
+ this.namespaceURI = namespaceURI;
+ this.prefix = prefix;
+ this._tagName = undefined;
+
+ // These properties maintain the set of attributes
+ this._attrsByQName = Object.create(null); // The qname->Attr map
+ this._attrsByLName = Object.create(null); // The ns|lname->Attr map
+ this._attrKeys = []; // attr index -> ns|lname
+}
+
+function recursiveGetText(node, a) {
+ if (node.nodeType === Node.TEXT_NODE) {
+ a.push(node._data);
+ }
+ else {
+ for(var i = 0, n = node.childNodes.length; i < n; i++)
+ recursiveGetText(node.childNodes[i], a);
+ }
+}
+
+Element.prototype = Object.create(ContainerNode.prototype, {
+ isHTML: { get: function isHTML() {
+ return this.namespaceURI === NAMESPACE.HTML && this.ownerDocument.isHTML;
+ }},
+ tagName: { get: function tagName() {
+ if (this._tagName === undefined) {
+ var tn;
+ if (this.prefix === null) {
+ tn = this.localName;
+ } else {
+ tn = this.prefix + ':' + this.localName;
+ }
+ if (this.isHTML) {
+ var up = uppercaseCache[tn];
+ if (!up) {
+ // Converting to uppercase can be slow, so cache the conversion.
+ uppercaseCache[tn] = up = utils.toASCIIUpperCase(tn);
+ }
+ tn = up;
+ }
+ this._tagName = tn;
+ }
+ return this._tagName;
+ }},
+ nodeName: { get: function() { return this.tagName; }},
+ nodeValue: {
+ get: function() {
+ return null;
+ },
+ set: function() {}
+ },
+ textContent: {
+ get: function() {
+ var strings = [];
+ recursiveGetText(this, strings);
+ return strings.join('');
+ },
+ set: function(newtext) {
+ this.removeChildren();
+ if (newtext !== null && newtext !== undefined && newtext !== '') {
+ this._appendChild(this.ownerDocument.createTextNode(newtext));
+ }
+ }
+ },
+ innerHTML: {
+ get: function() {
+ return this.serialize();
+ },
+ set: utils.nyi
+ },
+ outerHTML: {
+ get: function() {
+ // "the attribute must return the result of running the HTML fragment
+ // serialization algorithm on a fictional node whose only child is
+ // the context object"
+ //
+ // The serialization logic is intentionally implemented in a separate
+ // `NodeUtils` helper instead of the more obvious choice of a private
+ // `_serializeOne()` method on the `Node.prototype` in order to avoid
+ // the megamorphic `this._serializeOne` property access, which reduces
+ // performance unnecessarily. If you need specialized behavior for a
+ // certain subclass, you'll need to implement that in `NodeUtils`.
+ // See https://github.com/fgnass/domino/pull/142 for more information.
+ return NodeUtils.serializeOne(this, { nodeType: 0 });
+ },
+ set: function(v) {
+ var document = this.ownerDocument;
+ var parent = this.parentNode;
+ if (parent === null) { return; }
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
+ utils.NoModificationAllowedError();
+ }
+ if (parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ parent = parent.ownerDocument.createElement("body");
+ }
+ var parser = document.implementation.mozHTMLParser(
+ document._address,
+ parent
+ );
+ parser.parse(v===null?'':String(v), true);
+ this.replaceWith(parser._asDocumentFragment());
+ },
+ },
+
+ _insertAdjacent: { value: function _insertAdjacent(position, node) {
+ var first = false;
+ switch(position) {
+ case 'beforebegin':
+ first = true;
+ /* falls through */
+ case 'afterend':
+ var parent = this.parentNode;
+ if (parent === null) { return null; }
+ return parent.insertBefore(node, first ? this : this.nextSibling);
+ case 'afterbegin':
+ first = true;
+ /* falls through */
+ case 'beforeend':
+ return this.insertBefore(node, first ? this.firstChild : null);
+ default:
+ return utils.SyntaxError();
+ }
+ }},
+
+ insertAdjacentElement: { value: function insertAdjacentElement(position, element) {
+ if (element.nodeType !== Node.ELEMENT_NODE) {
+ throw new TypeError('not an element');
+ }
+ position = utils.toASCIILowerCase(String(position));
+ return this._insertAdjacent(position, element);
+ }},
+
+ insertAdjacentText: { value: function insertAdjacentText(position, data) {
+ var textNode = this.ownerDocument.createTextNode(data);
+ position = utils.toASCIILowerCase(String(position));
+ this._insertAdjacent(position, textNode);
+ // "This method returns nothing because it existed before we had a chance
+ // to design it."
+ }},
+
+ insertAdjacentHTML: { value: function insertAdjacentHTML(position, text) {
+ position = utils.toASCIILowerCase(String(position));
+ text = String(text);
+ var context;
+ switch(position) {
+ case 'beforebegin':
+ case 'afterend':
+ context = this.parentNode;
+ if (context === null || context.nodeType === Node.DOCUMENT_NODE) {
+ utils.NoModificationAllowedError();
+ }
+ break;
+ case 'afterbegin':
+ case 'beforeend':
+ context = this;
+ break;
+ default:
+ utils.SyntaxError();
+ }
+ if ( (!(context instanceof Element)) || (
+ context.ownerDocument.isHTML &&
+ context.localName === 'html' &&
+ context.namespaceURI === NAMESPACE.HTML
+ ) ) {
+ context = context.ownerDocument.createElementNS(NAMESPACE.HTML, 'body');
+ }
+ var parser = this.ownerDocument.implementation.mozHTMLParser(
+ this.ownerDocument._address, context
+ );
+ parser.parse(text, true);
+ this._insertAdjacent(position, parser._asDocumentFragment());
+ }},
+
+ children: { get: function() {
+ if (!this._children) {
+ this._children = new ChildrenCollection(this);
+ }
+ return this._children;
+ }},
+
+ attributes: { get: function() {
+ if (!this._attributes) {
+ this._attributes = new AttributesArray(this);
+ }
+ return this._attributes;
+ }},
+
+
+ firstElementChild: { get: function() {
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === Node.ELEMENT_NODE) return kid;
+ }
+ return null;
+ }},
+
+ lastElementChild: { get: function() {
+ for (var kid = this.lastChild; kid !== null; kid = kid.previousSibling) {
+ if (kid.nodeType === Node.ELEMENT_NODE) return kid;
+ }
+ return null;
+ }},
+
+ childElementCount: { get: function() {
+ return this.children.length;
+ }},
+
+
+ // Return the next element, in source order, after this one or
+ // null if there are no more. If root element is specified,
+ // then don't traverse beyond its subtree.
+ //
+ // This is not a DOM method, but is convenient for
+ // lazy traversals of the tree.
+ nextElement: { value: function(root) {
+ if (!root) root = this.ownerDocument.documentElement;
+ var next = this.firstElementChild;
+ if (!next) {
+ // don't use sibling if we're at root
+ if (this===root) return null;
+ next = this.nextElementSibling;
+ }
+ if (next) return next;
+
+ // If we can't go down or across, then we have to go up
+ // and across to the parent sibling or another ancestor's
+ // sibling. Be careful, though: if we reach the root
+ // element, or if we reach the documentElement, then
+ // the traversal ends.
+ for(var parent = this.parentElement;
+ parent && parent !== root;
+ parent = parent.parentElement) {
+
+ next = parent.nextElementSibling;
+ if (next) return next;
+ }
+
+ return null;
+ }},
+
+ // XXX:
+ // Tests are currently failing for this function.
+ // Awaiting resolution of:
+ // http://lists.w3.org/Archives/Public/www-dom/2011JulSep/0016.html
+ getElementsByTagName: { value: function getElementsByTagName(lname) {
+ var filter;
+ if (!lname) return new NodeList();
+ if (lname === '*')
+ filter = function() { return true; };
+ else if (this.isHTML)
+ filter = htmlLocalNameElementFilter(lname);
+ else
+ filter = localNameElementFilter(lname);
+
+ return new FilteredElementList(this, filter);
+ }},
+
+ getElementsByTagNameNS: { value: function getElementsByTagNameNS(ns, lname){
+ var filter;
+ if (ns === '*' && lname === '*')
+ filter = function() { return true; };
+ else if (ns === '*')
+ filter = localNameElementFilter(lname);
+ else if (lname === '*')
+ filter = namespaceElementFilter(ns);
+ else
+ filter = namespaceLocalNameElementFilter(ns, lname);
+
+ return new FilteredElementList(this, filter);
+ }},
+
+ getElementsByClassName: { value: function getElementsByClassName(names){
+ names = String(names).trim();
+ if (names === '') {
+ var result = new NodeList(); // Empty node list
+ return result;
+ }
+ names = names.split(/[ \t\r\n\f]+/); // Split on ASCII whitespace
+ return new FilteredElementList(this, classNamesElementFilter(names));
+ }},
+
+ getElementsByName: { value: function getElementsByName(name) {
+ return new FilteredElementList(this, elementNameFilter(String(name)));
+ }},
+
+ // Utility methods used by the public API methods above
+ clone: { value: function clone() {
+ var e;
+
+ // XXX:
+ // Modify this to use the constructor directly or
+ // avoid error checking in some other way. In case we try
+ // to clone an invalid node that the parser inserted.
+ //
+ if (this.namespaceURI !== NAMESPACE.HTML || this.prefix || !this.ownerDocument.isHTML) {
+ e = this.ownerDocument.createElementNS(
+ this.namespaceURI, (this.prefix !== null) ?
+ (this.prefix + ':' + this.localName) : this.localName
+ );
+ } else {
+ e = this.ownerDocument.createElement(this.localName);
+ }
+
+ for(var i = 0, n = this._attrKeys.length; i < n; i++) {
+ var lname = this._attrKeys[i];
+ var a = this._attrsByLName[lname];
+ var b = a.cloneNode();
+ b._setOwnerElement(e);
+ e._attrsByLName[lname] = b;
+ e._addQName(b);
+ }
+ e._attrKeys = this._attrKeys.concat();
+
+ return e;
+ }},
+
+ isEqual: { value: function isEqual(that) {
+ if (this.localName !== that.localName ||
+ this.namespaceURI !== that.namespaceURI ||
+ this.prefix !== that.prefix ||
+ this._numattrs !== that._numattrs)
+ return false;
+
+ // Compare the sets of attributes, ignoring order
+ // and ignoring attribute prefixes.
+ for(var i = 0, n = this._numattrs; i < n; i++) {
+ var a = this._attr(i);
+ if (!that.hasAttributeNS(a.namespaceURI, a.localName))
+ return false;
+ if (that.getAttributeNS(a.namespaceURI,a.localName) !== a.value)
+ return false;
+ }
+
+ return true;
+ }},
+
+ // This is the 'locate a namespace prefix' algorithm from the
+ // DOM specification. It is used by Node.lookupPrefix()
+ // (Be sure to compare DOM3 and DOM4 versions of spec.)
+ _lookupNamespacePrefix: { value: function _lookupNamespacePrefix(ns, originalElement) {
+ if (
+ this.namespaceURI &&
+ this.namespaceURI === ns &&
+ this.prefix !== null &&
+ originalElement.lookupNamespaceURI(this.prefix) === ns
+ ) {
+ return this.prefix;
+ }
+
+ for(var i = 0, n = this._numattrs; i < n; i++) {
+ var a = this._attr(i);
+ if (
+ a.prefix === 'xmlns' &&
+ a.value === ns &&
+ originalElement.lookupNamespaceURI(a.localName) === ns
+ ) {
+ return a.localName;
+ }
+ }
+
+ var parent = this.parentElement;
+ return parent ? parent._lookupNamespacePrefix(ns, originalElement) : null;
+ }},
+
+ // This is the 'locate a namespace' algorithm for Element nodes
+ // from the DOM Core spec. It is used by Node#lookupNamespaceURI()
+ lookupNamespaceURI: { value: function lookupNamespaceURI(prefix) {
+ if (prefix === '' || prefix === undefined) { prefix = null; }
+ if (this.namespaceURI !== null && this.prefix === prefix)
+ return this.namespaceURI;
+
+ for(var i = 0, n = this._numattrs; i < n; i++) {
+ var a = this._attr(i);
+ if (a.namespaceURI === NAMESPACE.XMLNS) {
+ if (
+ (a.prefix === 'xmlns' && a.localName === prefix) ||
+ (prefix === null && a.prefix === null && a.localName === 'xmlns')
+ ) {
+ return a.value || null;
+ }
+ }
+ }
+
+ var parent = this.parentElement;
+ return parent ? parent.lookupNamespaceURI(prefix) : null;
+ }},
+
+ //
+ // Attribute handling methods and utilities
+ //
+
+ /*
+ * Attributes in the DOM are tricky:
+ *
+ * - there are the 8 basic get/set/has/removeAttribute{NS} methods
+ *
+ * - but many HTML attributes are also 'reflected' through IDL
+ * attributes which means that they can be queried and set through
+ * regular properties of the element. There is just one attribute
+ * value, but two ways to get and set it.
+ *
+ * - Different HTML element types have different sets of reflected
+ attributes.
+ *
+ * - attributes can also be queried and set through the .attributes
+ * property of an element. This property behaves like an array of
+ * Attr objects. The value property of each Attr is writeable, so
+ * this is a third way to read and write attributes.
+ *
+ * - for efficiency, we really want to store attributes in some kind
+ * of name->attr map. But the attributes[] array is an array, not a
+ * map, which is kind of unnatural.
+ *
+ * - When using namespaces and prefixes, and mixing the NS methods
+ * with the non-NS methods, it is apparently actually possible for
+ * an attributes[] array to have more than one attribute with the
+ * same qualified name. And certain methods must operate on only
+ * the first attribute with such a name. So for these methods, an
+ * inefficient array-like data structure would be easier to
+ * implement.
+ *
+ * - The attributes[] array is live, not a snapshot, so changes to the
+ * attributes must be immediately visible through existing arrays.
+ *
+ * - When attributes are queried and set through IDL properties
+ * (instead of the get/setAttributes() method or the attributes[]
+ * array) they may be subject to type conversions, URL
+ * normalization, etc., so some extra processing is required in that
+ * case.
+ *
+ * - But access through IDL properties is probably the most common
+ * case, so we'd like that to be as fast as possible.
+ *
+ * - We can't just store attribute values in their parsed idl form,
+ * because setAttribute() has to return whatever string is passed to
+ * getAttribute even if it is not a legal, parseable value. So
+ * attribute values must be stored in unparsed string form.
+ *
+ * - We need to be able to send change notifications or mutation
+ * events of some sort to the renderer whenever an attribute value
+ * changes, regardless of the way in which it changes.
+ *
+ * - Some attributes, such as id and class affect other parts of the
+ * DOM API, like getElementById and getElementsByClassName and so
+ * for efficiency, we need to specially track changes to these
+ * special attributes.
+ *
+ * - Some attributes like class have different names (className) when
+ * reflected.
+ *
+ * - Attributes whose names begin with the string 'data-' are treated
+ specially.
+ *
+ * - Reflected attributes that have a boolean type in IDL have special
+ * behavior: setting them to false (in IDL) is the same as removing
+ * them with removeAttribute()
+ *
+ * - numeric attributes (like HTMLElement.tabIndex) can have default
+ * values that must be returned by the idl getter even if the
+ * content attribute does not exist. (The default tabIndex value
+ * actually varies based on the type of the element, so that is a
+ * tricky one).
+ *
+ * See
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#reflect
+ * for rules on how attributes are reflected.
+ *
+ */
+
+ getAttribute: { value: function getAttribute(qname) {
+ var attr = this.getAttributeNode(qname);
+ return attr ? attr.value : null;
+ }},
+
+ getAttributeNS: { value: function getAttributeNS(ns, lname) {
+ var attr = this.getAttributeNodeNS(ns, lname);
+ return attr ? attr.value : null;
+ }},
+
+ getAttributeNode: { value: function getAttributeNode(qname) {
+ qname = String(qname);
+ if (/[A-Z]/.test(qname) && this.isHTML)
+ qname = utils.toASCIILowerCase(qname);
+ var attr = this._attrsByQName[qname];
+ if (!attr) return null;
+
+ if (Array.isArray(attr)) // If there is more than one
+ attr = attr[0]; // use the first
+
+ return attr;
+ }},
+
+ getAttributeNodeNS: { value: function getAttributeNodeNS(ns, lname) {
+ ns = (ns === undefined || ns === null) ? '' : String(ns);
+ lname = String(lname);
+ var attr = this._attrsByLName[ns + '|' + lname];
+ return attr ? attr : null;
+ }},
+
+ hasAttribute: { value: function hasAttribute(qname) {
+ qname = String(qname);
+ if (/[A-Z]/.test(qname) && this.isHTML)
+ qname = utils.toASCIILowerCase(qname);
+ return this._attrsByQName[qname] !== undefined;
+ }},
+
+ hasAttributeNS: { value: function hasAttributeNS(ns, lname) {
+ ns = (ns === undefined || ns === null) ? '' : String(ns);
+ lname = String(lname);
+ var key = ns + '|' + lname;
+ return this._attrsByLName[key] !== undefined;
+ }},
+
+ hasAttributes: { value: function hasAttributes() {
+ return this._numattrs > 0;
+ }},
+
+ toggleAttribute: { value: function toggleAttribute(qname, force) {
+ qname = String(qname);
+ if (!xml.isValidName(qname)) utils.InvalidCharacterError();
+ if (/[A-Z]/.test(qname) && this.isHTML)
+ qname = utils.toASCIILowerCase(qname);
+ var a = this._attrsByQName[qname];
+ if (a === undefined) {
+ if (force === undefined || force === true) {
+ this._setAttribute(qname, '');
+ return true;
+ }
+ return false;
+ } else {
+ if (force === undefined || force === false) {
+ this.removeAttribute(qname);
+ return false;
+ }
+ return true;
+ }
+ }},
+
+ // Set the attribute without error checking. The parser uses this.
+ _setAttribute: { value: function _setAttribute(qname, value) {
+ // XXX: the spec says that this next search should be done
+ // on the local name, but I think that is an error.
+ // email pending on www-dom about it.
+ var attr = this._attrsByQName[qname];
+ var isnew;
+ if (!attr) {
+ attr = this._newattr(qname);
+ isnew = true;
+ }
+ else {
+ if (Array.isArray(attr)) attr = attr[0];
+ }
+
+ // Now set the attribute value on the new or existing Attr object.
+ // The Attr.value setter method handles mutation events, etc.
+ attr.value = value;
+ if (this._attributes) this._attributes[qname] = attr;
+ if (isnew && this._newattrhook) this._newattrhook(qname, value);
+ }},
+
+ // Check for errors, and then set the attribute
+ setAttribute: { value: function setAttribute(qname, value) {
+ qname = String(qname);
+ if (!xml.isValidName(qname)) utils.InvalidCharacterError();
+ if (/[A-Z]/.test(qname) && this.isHTML)
+ qname = utils.toASCIILowerCase(qname);
+ this._setAttribute(qname, String(value));
+ }},
+
+
+ // The version with no error checking used by the parser
+ _setAttributeNS: { value: function _setAttributeNS(ns, qname, value) {
+ var pos = qname.indexOf(':'), prefix, lname;
+ if (pos < 0) {
+ prefix = null;
+ lname = qname;
+ }
+ else {
+ prefix = qname.substring(0, pos);
+ lname = qname.substring(pos+1);
+ }
+
+ if (ns === '' || ns === undefined) ns = null;
+ var key = (ns === null ? '' : ns) + '|' + lname;
+
+ var attr = this._attrsByLName[key];
+ var isnew;
+ if (!attr) {
+ attr = new Attr(this, lname, prefix, ns);
+ isnew = true;
+ this._attrsByLName[key] = attr;
+ if (this._attributes) {
+ this._attributes[this._attrKeys.length] = attr;
+ }
+ this._attrKeys.push(key);
+
+ // We also have to make the attr searchable by qname.
+ // But we have to be careful because there may already
+ // be an attr with this qname.
+ this._addQName(attr);
+ }
+ else if (false /* changed in DOM 4 */) {
+ // Calling setAttributeNS() can change the prefix of an
+ // existing attribute in DOM 2/3.
+ if (attr.prefix !== prefix) {
+ // Unbind the old qname
+ this._removeQName(attr);
+ // Update the prefix
+ attr.prefix = prefix;
+ // Bind the new qname
+ this._addQName(attr);
+ }
+
+ }
+ attr.value = value; // Automatically sends mutation event
+ if (isnew && this._newattrhook) this._newattrhook(qname, value);
+ }},
+
+ // Do error checking then call _setAttributeNS
+ setAttributeNS: { value: function setAttributeNS(ns, qname, value) {
+ // Convert parameter types according to WebIDL
+ ns = (ns === null || ns === undefined || ns === '') ? null : String(ns);
+ qname = String(qname);
+ if (!xml.isValidQName(qname)) utils.InvalidCharacterError();
+
+ var pos = qname.indexOf(':');
+ var prefix = (pos < 0) ? null : qname.substring(0, pos);
+
+ if ((prefix !== null && ns === null) ||
+ (prefix === 'xml' && ns !== NAMESPACE.XML) ||
+ ((qname === 'xmlns' || prefix === 'xmlns') &&
+ (ns !== NAMESPACE.XMLNS)) ||
+ (ns === NAMESPACE.XMLNS &&
+ !(qname === 'xmlns' || prefix === 'xmlns')))
+ utils.NamespaceError();
+
+ this._setAttributeNS(ns, qname, String(value));
+ }},
+
+ setAttributeNode: { value: function setAttributeNode(attr) {
+ if (attr.ownerElement !== null && attr.ownerElement !== this) {
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ var result = null;
+ var oldAttrs = this._attrsByQName[attr.name];
+ if (oldAttrs) {
+ if (!Array.isArray(oldAttrs)) { oldAttrs = [ oldAttrs ]; }
+ if (oldAttrs.some(function(a) { return a===attr; })) {
+ return attr;
+ } else if (attr.ownerElement !== null) {
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ oldAttrs.forEach(function(a) { this.removeAttributeNode(a); }, this);
+ result = oldAttrs[0];
+ }
+ this.setAttributeNodeNS(attr);
+ return result;
+ }},
+
+ setAttributeNodeNS: { value: function setAttributeNodeNS(attr) {
+ if (attr.ownerElement !== null) {
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ var ns = attr.namespaceURI;
+ var key = (ns === null ? '' : ns) + '|' + attr.localName;
+ var oldAttr = this._attrsByLName[key];
+ if (oldAttr) { this.removeAttributeNode(oldAttr); }
+ attr._setOwnerElement(this);
+ this._attrsByLName[key] = attr;
+ if (this._attributes) {
+ this._attributes[this._attrKeys.length] = attr;
+ }
+ this._attrKeys.push(key);
+ this._addQName(attr);
+ if (this._newattrhook) this._newattrhook(attr.name, attr.value);
+ return oldAttr || null;
+ }},
+
+ removeAttribute: { value: function removeAttribute(qname) {
+ qname = String(qname);
+ if (/[A-Z]/.test(qname) && this.isHTML)
+ qname = utils.toASCIILowerCase(qname);
+
+ var attr = this._attrsByQName[qname];
+ if (!attr) return;
+
+ // If there is more than one match for this qname
+ // so don't delete the qname mapping, just remove the first
+ // element from it.
+ if (Array.isArray(attr)) {
+ if (attr.length > 2) {
+ attr = attr.shift(); // remove it from the array
+ }
+ else {
+ this._attrsByQName[qname] = attr[1];
+ attr = attr[0];
+ }
+ }
+ else {
+ // only a single match, so remove the qname mapping
+ this._attrsByQName[qname] = undefined;
+ }
+
+ var ns = attr.namespaceURI;
+ // Now attr is the removed attribute. Figure out its
+ // ns+lname key and remove it from the other mapping as well.
+ var key = (ns === null ? '' : ns) + '|' + attr.localName;
+ this._attrsByLName[key] = undefined;
+
+ var i = this._attrKeys.indexOf(key);
+ if (this._attributes) {
+ Array.prototype.splice.call(this._attributes, i, 1);
+ this._attributes[qname] = undefined;
+ }
+ this._attrKeys.splice(i, 1);
+
+ // Onchange handler for the attribute
+ var onchange = attr.onchange;
+ attr._setOwnerElement(null);
+ if (onchange) {
+ onchange.call(attr, this, attr.localName, attr.value, null);
+ }
+ // Mutation event
+ if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr);
+ }},
+
+ removeAttributeNS: { value: function removeAttributeNS(ns, lname) {
+ ns = (ns === undefined || ns === null) ? '' : String(ns);
+ lname = String(lname);
+ var key = ns + '|' + lname;
+ var attr = this._attrsByLName[key];
+ if (!attr) return;
+
+ this._attrsByLName[key] = undefined;
+
+ var i = this._attrKeys.indexOf(key);
+ if (this._attributes) {
+ Array.prototype.splice.call(this._attributes, i, 1);
+ }
+ this._attrKeys.splice(i, 1);
+
+ // Now find the same Attr object in the qname mapping and remove it
+ // But be careful because there may be more than one match.
+ this._removeQName(attr);
+
+ // Onchange handler for the attribute
+ var onchange = attr.onchange;
+ attr._setOwnerElement(null);
+ if (onchange) {
+ onchange.call(attr, this, attr.localName, attr.value, null);
+ }
+ // Mutation event
+ if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr);
+ }},
+
+ removeAttributeNode: { value: function removeAttributeNode(attr) {
+ var ns = attr.namespaceURI;
+ var key = (ns === null ? '' : ns) + '|' + attr.localName;
+ if (this._attrsByLName[key] !== attr) {
+ utils.NotFoundError();
+ }
+ this.removeAttributeNS(ns, attr.localName);
+ return attr;
+ }},
+
+ getAttributeNames: { value: function getAttributeNames() {
+ var elt = this;
+ return this._attrKeys.map(function(key) {
+ return elt._attrsByLName[key].name;
+ });
+ }},
+
+ // This 'raw' version of getAttribute is used by the getter functions
+ // of reflected attributes. It skips some error checking and
+ // namespace steps
+ _getattr: { value: function _getattr(qname) {
+ // Assume that qname is already lowercased, so don't do it here.
+ // Also don't check whether attr is an array: a qname with no
+ // prefix will never have two matching Attr objects (because
+ // setAttributeNS doesn't allow a non-null namespace with a
+ // null prefix.
+ var attr = this._attrsByQName[qname];
+ return attr ? attr.value : null;
+ }},
+
+ // The raw version of setAttribute for reflected idl attributes.
+ _setattr: { value: function _setattr(qname, value) {
+ var attr = this._attrsByQName[qname];
+ var isnew;
+ if (!attr) {
+ attr = this._newattr(qname);
+ isnew = true;
+ }
+ attr.value = String(value);
+ if (this._attributes) this._attributes[qname] = attr;
+ if (isnew && this._newattrhook) this._newattrhook(qname, value);
+ }},
+
+ // Create a new Attr object, insert it, and return it.
+ // Used by setAttribute() and by set()
+ _newattr: { value: function _newattr(qname) {
+ var attr = new Attr(this, qname, null, null);
+ var key = '|' + qname;
+ this._attrsByQName[qname] = attr;
+ this._attrsByLName[key] = attr;
+ if (this._attributes) {
+ this._attributes[this._attrKeys.length] = attr;
+ }
+ this._attrKeys.push(key);
+ return attr;
+ }},
+
+ // Add a qname->Attr mapping to the _attrsByQName object, taking into
+ // account that there may be more than one attr object with the
+ // same qname
+ _addQName: { value: function(attr) {
+ var qname = attr.name;
+ var existing = this._attrsByQName[qname];
+ if (!existing) {
+ this._attrsByQName[qname] = attr;
+ }
+ else if (Array.isArray(existing)) {
+ existing.push(attr);
+ }
+ else {
+ this._attrsByQName[qname] = [existing, attr];
+ }
+ if (this._attributes) this._attributes[qname] = attr;
+ }},
+
+ // Remove a qname->Attr mapping to the _attrsByQName object, taking into
+ // account that there may be more than one attr object with the
+ // same qname
+ _removeQName: { value: function(attr) {
+ var qname = attr.name;
+ var target = this._attrsByQName[qname];
+
+ if (Array.isArray(target)) {
+ var idx = target.indexOf(attr);
+ utils.assert(idx !== -1); // It must be here somewhere
+ if (target.length === 2) {
+ this._attrsByQName[qname] = target[1-idx];
+ if (this._attributes) {
+ this._attributes[qname] = this._attrsByQName[qname];
+ }
+ } else {
+ target.splice(idx, 1);
+ if (this._attributes && this._attributes[qname] === attr) {
+ this._attributes[qname] = target[0];
+ }
+ }
+ }
+ else {
+ utils.assert(target === attr); // If only one, it must match
+ this._attrsByQName[qname] = undefined;
+ if (this._attributes) {
+ this._attributes[qname] = undefined;
+ }
+ }
+ }},
+
+ // Return the number of attributes
+ _numattrs: { get: function() { return this._attrKeys.length; }},
+ // Return the nth Attr object
+ _attr: { value: function(n) {
+ return this._attrsByLName[this._attrKeys[n]];
+ }},
+
+ // Define getters and setters for an 'id' property that reflects
+ // the content attribute 'id'.
+ id: attributes.property({name: 'id'}),
+
+ // Define getters and setters for a 'className' property that reflects
+ // the content attribute 'class'.
+ className: attributes.property({name: 'class'}),
+
+ classList: { get: function() {
+ var self = this;
+ if (this._classList) {
+ return this._classList;
+ }
+ var dtlist = new DOMTokenList(
+ function() {
+ return self.className || "";
+ },
+ function(v) {
+ self.className = v;
+ }
+ );
+ this._classList = dtlist;
+ return dtlist;
+ }, set: function(v) { this.className = v; }},
+
+ matches: { value: function(selector) {
+ return select.matches(this, selector);
+ }},
+
+ closest: { value: function(selector) {
+ var el = this;
+ do {
+ if (el.matches && el.matches(selector)) { return el; }
+ el = el.parentElement || el.parentNode;
+ } while (el !== null && el.nodeType === Node.ELEMENT_NODE);
+ return null;
+ }},
+
+ querySelector: { value: function(selector) {
+ return select(selector, this)[0];
+ }},
+
+ querySelectorAll: { value: function(selector) {
+ var nodes = select(selector, this);
+ return nodes.item ? nodes : new NodeList(nodes);
+ }}
+
+});
+
+Object.defineProperties(Element.prototype, ChildNode);
+Object.defineProperties(Element.prototype, NonDocumentTypeChildNode);
+
+// Register special handling for the id attribute
+attributes.registerChangeHandler(Element, 'id',
+ function(element, lname, oldval, newval) {
+ if (element.rooted) {
+ if (oldval) {
+ element.ownerDocument.delId(oldval, element);
+ }
+ if (newval) {
+ element.ownerDocument.addId(newval, element);
+ }
+ }
+ }
+);
+attributes.registerChangeHandler(Element, 'class',
+ function(element, lname, oldval, newval) {
+ if (element._classList) { element._classList._update(); }
+ }
+);
+
+// The Attr class represents a single attribute. The values in
+// _attrsByQName and _attrsByLName are instances of this class.
+function Attr(elt, lname, prefix, namespace, value) {
+ // localName and namespace are constant for any attr object.
+ // But value may change. And so can prefix, and so, therefore can name.
+ this.localName = lname;
+ this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix);
+ this.namespaceURI = (namespace===null || namespace==='') ? null : ('' + namespace);
+ this.data = value;
+ // Set ownerElement last to ensure it is hooked up to onchange handler
+ this._setOwnerElement(elt);
+}
+
+// In DOM 3 Attr was supposed to extend Node; in DOM 4 that was abandoned.
+Attr.prototype = Object.create(Object.prototype, {
+ ownerElement: {
+ get: function() { return this._ownerElement; },
+ },
+ _setOwnerElement: { value: function _setOwnerElement(elt) {
+ this._ownerElement = elt;
+ if (this.prefix === null && this.namespaceURI === null && elt) {
+ this.onchange = elt._attributeChangeHandlers[this.localName];
+ } else {
+ this.onchange = null;
+ }
+ }},
+
+ name: { get: function() {
+ return this.prefix ? this.prefix + ':' + this.localName : this.localName;
+ }},
+
+ specified: { get: function() {
+ // Deprecated
+ return true;
+ }},
+
+ value: {
+ get: function() {
+ return this.data;
+ },
+ set: function(value) {
+ var oldval = this.data;
+ value = (value === undefined) ? '' : value + '';
+ if (value === oldval) return;
+
+ this.data = value;
+
+ // Run the onchange hook for the attribute
+ // if there is one.
+ if (this.ownerElement) {
+ if (this.onchange)
+ this.onchange(this.ownerElement,this.localName, oldval, value);
+
+ // Generate a mutation event if the element is rooted
+ if (this.ownerElement.rooted)
+ this.ownerElement.ownerDocument.mutateAttr(this, oldval);
+ }
+ },
+ },
+
+ cloneNode: { value: function cloneNode(deep) {
+ // Both this method and Document#createAttribute*() create unowned Attrs
+ return new Attr(
+ null, this.localName, this.prefix, this.namespaceURI, this.data
+ );
+ }},
+
+ // Legacy aliases (see gh#70 and https://dom.spec.whatwg.org/#interface-attr)
+ nodeType: { get: function() { return Node.ATTRIBUTE_NODE; } },
+ nodeName: { get: function() { return this.name; } },
+ nodeValue: {
+ get: function() { return this.value; },
+ set: function(v) { this.value = v; },
+ },
+ textContent: {
+ get: function() { return this.value; },
+ set: function(v) {
+ if (v === null || v === undefined) { v = ''; }
+ this.value = v;
+ },
+ },
+});
+// Sneakily export this class for use by Document.createAttribute()
+Element._Attr = Attr;
+
+// The attributes property of an Element will be an instance of this class.
+// This class is really just a dummy, though. It only defines a length
+// property and an item() method. The AttrArrayProxy that
+// defines the public API just uses the Element object itself.
+function AttributesArray(elt) {
+ NamedNodeMap.call(this, elt);
+ for (var name in elt._attrsByQName) {
+ this[name] = elt._attrsByQName[name];
+ }
+ for (var i = 0; i < elt._attrKeys.length; i++) {
+ this[i] = elt._attrsByLName[elt._attrKeys[i]];
+ }
+}
+AttributesArray.prototype = Object.create(NamedNodeMap.prototype, {
+ length: { get: function() {
+ return this.element._attrKeys.length;
+ }, set: function() { /* ignore */ } },
+ item: { value: function(n) {
+ /* jshint bitwise: false */
+ n = n >>> 0;
+ if (n >= this.length) { return null; }
+ return this.element._attrsByLName[this.element._attrKeys[n]];
+ /* jshint bitwise: true */
+ } },
+});
+
+// We can't make direct array access work (without Proxies, node >=6)
+// but we can make `Array.from(node.attributes)` and for-of loops work.
+if (global.Symbol && global.Symbol.iterator) {
+ AttributesArray.prototype[global.Symbol.iterator] = function() {
+ var i=0, n=this.length, self=this;
+ return {
+ next: function() {
+ if (i<n) return { value: self.item(i++) };
+ return { done: true };
+ }
+ };
+ };
+}
+
+
+// The children property of an Element will be an instance of this class.
+// It defines length, item() and namedItem() and will be wrapped by an
+// HTMLCollection when exposed through the DOM.
+function ChildrenCollection(e) {
+ this.element = e;
+ this.updateCache();
+}
+
+ChildrenCollection.prototype = Object.create(Object.prototype, {
+ length: { get: function() {
+ this.updateCache();
+ return this.childrenByNumber.length;
+ } },
+ item: { value: function item(n) {
+ this.updateCache();
+ return this.childrenByNumber[n] || null;
+ } },
+
+ namedItem: { value: function namedItem(name) {
+ this.updateCache();
+ return this.childrenByName[name] || null;
+ } },
+
+ // This attribute returns the entire name->element map.
+ // It is not part of the HTMLCollection API, but we need it in
+ // src/HTMLCollectionProxy
+ namedItems: { get: function() {
+ this.updateCache();
+ return this.childrenByName;
+ } },
+
+ updateCache: { value: function updateCache() {
+ var namedElts = /^(a|applet|area|embed|form|frame|frameset|iframe|img|object)$/;
+ if (this.lastModTime !== this.element.lastModTime) {
+ this.lastModTime = this.element.lastModTime;
+
+ var n = this.childrenByNumber && this.childrenByNumber.length || 0;
+ for(var i = 0; i < n; i++) {
+ this[i] = undefined;
+ }
+
+ this.childrenByNumber = [];
+ this.childrenByName = Object.create(null);
+
+ for (var c = this.element.firstChild; c !== null; c = c.nextSibling) {
+ if (c.nodeType === Node.ELEMENT_NODE) {
+
+ this[this.childrenByNumber.length] = c;
+ this.childrenByNumber.push(c);
+
+ // XXX Are there any requirements about the namespace
+ // of the id property?
+ var id = c.getAttribute('id');
+
+ // If there is an id that is not already in use...
+ if (id && !this.childrenByName[id])
+ this.childrenByName[id] = c;
+
+ // For certain HTML elements we check the name attribute
+ var name = c.getAttribute('name');
+ if (name &&
+ this.element.namespaceURI === NAMESPACE.HTML &&
+ namedElts.test(this.element.localName) &&
+ !this.childrenByName[name])
+ this.childrenByName[id] = c;
+ }
+ }
+ }
+ } },
+});
+
+// These functions return predicates for filtering elements.
+// They're used by the Document and Element classes for methods like
+// getElementsByTagName and getElementsByClassName
+
+function localNameElementFilter(lname) {
+ return function(e) { return e.localName === lname; };
+}
+
+function htmlLocalNameElementFilter(lname) {
+ var lclname = utils.toASCIILowerCase(lname);
+ if (lclname === lname)
+ return localNameElementFilter(lname);
+
+ return function(e) {
+ return e.isHTML ? e.localName === lclname : e.localName === lname;
+ };
+}
+
+function namespaceElementFilter(ns) {
+ return function(e) { return e.namespaceURI === ns; };
+}
+
+function namespaceLocalNameElementFilter(ns, lname) {
+ return function(e) {
+ return e.namespaceURI === ns && e.localName === lname;
+ };
+}
+
+function classNamesElementFilter(names) {
+ return function(e) {
+ return names.every(function(n) { return e.classList.contains(n); });
+ };
+}
+
+function elementNameFilter(name) {
+ return function(e) {
+ // All the *HTML elements* in the document with the given name attribute
+ if (e.namespaceURI !== NAMESPACE.HTML) { return false; }
+ return e.getAttribute('name') === name;
+ };
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Event.js
@@ -1,0 +1,66 @@
+"use strict";
+module.exports = Event;
+
+Event.CAPTURING_PHASE = 1;
+Event.AT_TARGET = 2;
+Event.BUBBLING_PHASE = 3;
+
+function Event(type, dictionary) {
+ // Initialize basic event properties
+ this.type = '';
+ this.target = null;
+ this.currentTarget = null;
+ this.eventPhase = Event.AT_TARGET;
+ this.bubbles = false;
+ this.cancelable = false;
+ this.isTrusted = false;
+ this.defaultPrevented = false;
+ this.timeStamp = Date.now();
+
+ // Initialize internal flags
+ // XXX: Would it be better to inherit these defaults from the prototype?
+ this._propagationStopped = false;
+ this._immediatePropagationStopped = false;
+ this._initialized = true;
+ this._dispatching = false;
+
+ // Now initialize based on the constructor arguments (if any)
+ if (type) this.type = type;
+ if (dictionary) {
+ for(var p in dictionary) {
+ this[p] = dictionary[p];
+ }
+ }
+}
+
+Event.prototype = Object.create(Object.prototype, {
+ constructor: { value: Event },
+ stopPropagation: { value: function stopPropagation() {
+ this._propagationStopped = true;
+ }},
+
+ stopImmediatePropagation: { value: function stopImmediatePropagation() {
+ this._propagationStopped = true;
+ this._immediatePropagationStopped = true;
+ }},
+
+ preventDefault: { value: function preventDefault() {
+ if (this.cancelable) this.defaultPrevented = true;
+ }},
+
+ initEvent: { value: function initEvent(type, bubbles, cancelable) {
+ this._initialized = true;
+ if (this._dispatching) return;
+
+ this._propagationStopped = false;
+ this._immediatePropagationStopped = false;
+ this.defaultPrevented = false;
+ this.isTrusted = false;
+
+ this.target = null;
+ this.type = type;
+ this.bubbles = bubbles;
+ this.cancelable = cancelable;
+ }},
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/EventTarget.js
@@ -1,0 +1,298 @@
+"use strict";
+var Event = require('./Event');
+var MouseEvent = require('./MouseEvent');
+var utils = require('./utils');
+
+module.exports = EventTarget;
+
+function EventTarget() {}
+
+EventTarget.prototype = {
+ // XXX
+ // See WebIDL §4.8 for details on object event handlers
+ // and how they should behave. We actually have to accept
+ // any object to addEventListener... Can't type check it.
+ // on registration.
+
+ // XXX:
+ // Capturing event listeners are sort of rare. I think I can optimize
+ // them so that dispatchEvent can skip the capturing phase (or much of
+ // it). Each time a capturing listener is added, increment a flag on
+ // the target node and each of its ancestors. Decrement when removed.
+ // And update the counter when nodes are added and removed from the
+ // tree as well. Then, in dispatch event, the capturing phase can
+ // abort if it sees any node with a zero count.
+ addEventListener: function addEventListener(type, listener, capture) {
+ if (!listener) return;
+ if (capture === undefined) capture = false;
+ if (!this._listeners) this._listeners = Object.create(null);
+ if (!this._listeners[type]) this._listeners[type] = [];
+ var list = this._listeners[type];
+
+ // If this listener has already been registered, just return
+ for(var i = 0, n = list.length; i < n; i++) {
+ var l = list[i];
+ if (l.listener === listener && l.capture === capture)
+ return;
+ }
+
+ // Add an object to the list of listeners
+ var obj = { listener: listener, capture: capture };
+ if (typeof listener === 'function') obj.f = listener;
+ list.push(obj);
+ },
+
+ removeEventListener: function removeEventListener(type,
+ listener,
+ capture) {
+ if (capture === undefined) capture = false;
+ if (this._listeners) {
+ var list = this._listeners[type];
+ if (list) {
+ // Find the listener in the list and remove it
+ for(var i = 0, n = list.length; i < n; i++) {
+ var l = list[i];
+ if (l.listener === listener && l.capture === capture) {
+ if (list.length === 1) {
+ this._listeners[type] = undefined;
+ }
+ else {
+ list.splice(i, 1);
+ }
+ return;
+ }
+ }
+ }
+ }
+ },
+
+ // This is the public API for dispatching untrusted public events.
+ // See _dispatchEvent for the implementation
+ dispatchEvent: function dispatchEvent(event) {
+ // Dispatch an untrusted event
+ return this._dispatchEvent(event, false);
+ },
+
+ //
+ // See DOMCore §4.4
+ // XXX: I'll probably need another version of this method for
+ // internal use, one that does not set isTrusted to false.
+ // XXX: see Document._dispatchEvent: perhaps that and this could
+ // call a common internal function with different settings of
+ // a trusted boolean argument
+ //
+ // XXX:
+ // The spec has changed in how to deal with handlers registered
+ // on idl or content attributes rather than with addEventListener.
+ // Used to say that they always ran first. That's how webkit does it
+ // Spec now says that they run in a position determined by
+ // when they were first set. FF does it that way. See:
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handlers
+ //
+ _dispatchEvent: function _dispatchEvent(event, trusted) {
+ if (typeof trusted !== 'boolean') trusted = false;
+ function invoke(target, event) {
+ var type = event.type, phase = event.eventPhase;
+ event.currentTarget = target;
+
+ // If there was an individual handler defined, invoke it first
+ // XXX: see comment above: this shouldn't always be first.
+ if (phase !== Event.CAPTURING_PHASE &&
+ target._handlers && target._handlers[type])
+ {
+ var handler = target._handlers[type];
+ var rv;
+ if (typeof handler === 'function') {
+ rv=handler.call(event.currentTarget, event);
+ }
+ else {
+ var f = handler.handleEvent;
+ if (typeof f !== 'function')
+ throw new TypeError('handleEvent property of ' +
+ 'event handler object is' +
+ 'not a function.');
+ rv=f.call(handler, event);
+ }
+
+ switch(event.type) {
+ case 'mouseover':
+ if (rv === true) // Historical baggage
+ event.preventDefault();
+ break;
+ case 'beforeunload':
+ // XXX: eventually we need a special case here
+ /* falls through */
+ default:
+ if (rv === false)
+ event.preventDefault();
+ break;
+ }
+ }
+
+ // Now invoke list list of listeners for this target and type
+ var list = target._listeners && target._listeners[type];
+ if (!list) return;
+ list = list.slice();
+ for(var i = 0, n = list.length; i < n; i++) {
+ if (event._immediatePropagationStopped) return;
+ var l = list[i];
+ if ((phase === Event.CAPTURING_PHASE && !l.capture) ||
+ (phase === Event.BUBBLING_PHASE && l.capture))
+ continue;
+ if (l.f) {
+ l.f.call(event.currentTarget, event);
+ }
+ else {
+ var fn = l.listener.handleEvent;
+ if (typeof fn !== 'function')
+ throw new TypeError('handleEvent property of event listener object is not a function.');
+ fn.call(l.listener, event);
+ }
+ }
+ }
+
+ if (!event._initialized || event._dispatching) utils.InvalidStateError();
+ event.isTrusted = trusted;
+
+ // Begin dispatching the event now
+ event._dispatching = true;
+ event.target = this;
+
+ // Build the list of targets for the capturing and bubbling phases
+ // XXX: we'll eventually have to add Window to this list.
+ var ancestors = [];
+ for(var n = this.parentNode; n; n = n.parentNode)
+ ancestors.push(n);
+
+ // Capturing phase
+ event.eventPhase = Event.CAPTURING_PHASE;
+ for(var i = ancestors.length-1; i >= 0; i--) {
+ invoke(ancestors[i], event);
+ if (event._propagationStopped) break;
+ }
+
+ // At target phase
+ if (!event._propagationStopped) {
+ event.eventPhase = Event.AT_TARGET;
+ invoke(this, event);
+ }
+
+ // Bubbling phase
+ if (event.bubbles && !event._propagationStopped) {
+ event.eventPhase = Event.BUBBLING_PHASE;
+ for(var ii = 0, nn = ancestors.length; ii < nn; ii++) {
+ invoke(ancestors[ii], event);
+ if (event._propagationStopped) break;
+ }
+ }
+
+ event._dispatching = false;
+ event.eventPhase = Event.AT_TARGET;
+ event.currentTarget = null;
+
+ // Deal with mouse events and figure out when
+ // a click has happened
+ if (trusted && !event.defaultPrevented && event instanceof MouseEvent) {
+ switch(event.type) {
+ case 'mousedown':
+ this._armed = {
+ x: event.clientX,
+ y: event.clientY,
+ t: event.timeStamp
+ };
+ break;
+ case 'mouseout':
+ case 'mouseover':
+ this._armed = null;
+ break;
+ case 'mouseup':
+ if (this._isClick(event)) this._doClick(event);
+ this._armed = null;
+ break;
+ }
+ }
+
+
+
+ return !event.defaultPrevented;
+ },
+
+ // Determine whether a click occurred
+ // XXX We don't support double clicks for now
+ _isClick: function(event) {
+ return (this._armed !== null &&
+ event.type === 'mouseup' &&
+ event.isTrusted &&
+ event.button === 0 &&
+ event.timeStamp - this._armed.t < 1000 &&
+ Math.abs(event.clientX - this._armed.x) < 10 &&
+ Math.abs(event.clientY - this._armed.Y) < 10);
+ },
+
+ // Clicks are handled like this:
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#interactive-content-0
+ //
+ // Note that this method is similar to the HTMLElement.click() method
+ // The event argument must be the trusted mouseup event
+ _doClick: function(event) {
+ if (this._click_in_progress) return;
+ this._click_in_progress = true;
+
+ // Find the nearest enclosing element that is activatable
+ // An element is activatable if it has a
+ // _post_click_activation_steps hook
+ var activated = this;
+ while(activated && !activated._post_click_activation_steps)
+ activated = activated.parentNode;
+
+ if (activated && activated._pre_click_activation_steps) {
+ activated._pre_click_activation_steps();
+ }
+
+ var click = this.ownerDocument.createEvent('MouseEvent');
+ click.initMouseEvent('click', true, true,
+ this.ownerDocument.defaultView, 1,
+ event.screenX, event.screenY,
+ event.clientX, event.clientY,
+ event.ctrlKey, event.altKey,
+ event.shiftKey, event.metaKey,
+ event.button, null);
+
+ var result = this._dispatchEvent(click, true);
+
+ if (activated) {
+ if (result) {
+ // This is where hyperlinks get followed, for example.
+ if (activated._post_click_activation_steps)
+ activated._post_click_activation_steps(click);
+ }
+ else {
+ if (activated._cancelled_activation_steps)
+ activated._cancelled_activation_steps();
+ }
+ }
+ },
+
+ //
+ // An event handler is like an event listener, but it registered
+ // by setting an IDL or content attribute like onload or onclick.
+ // There can only be one of these at a time for any event type.
+ // This is an internal method for the attribute accessors and
+ // content attribute handlers that need to register events handlers.
+ // The type argument is the same as in addEventListener().
+ // The handler argument is the same as listeners in addEventListener:
+ // it can be a function or an object. Pass null to remove any existing
+ // handler. Handlers are always invoked before any listeners of
+ // the same type. They are not invoked during the capturing phase
+ // of event dispatch.
+ //
+ _setEventHandler: function _setEventHandler(type, handler) {
+ if (!this._handlers) this._handlers = Object.create(null);
+ this._handlers[type] = handler;
+ },
+
+ _getEventHandler: function _getEventHandler(type) {
+ return (this._handlers && this._handlers[type]) || null;
+ }
+
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/FilteredElementList.js
@@ -1,0 +1,92 @@
+"use strict";
+module.exports = FilteredElementList;
+
+var Node = require('./Node');
+
+//
+// This file defines node list implementation that lazily traverses
+// the document tree (or a subtree rooted at any element) and includes
+// only those elements for which a specified filter function returns true.
+// It is used to implement the
+// {Document,Element}.getElementsBy{TagName,ClassName}{,NS} methods.
+//
+// XXX this should inherit from NodeList
+
+function FilteredElementList(root, filter) {
+ this.root = root;
+ this.filter = filter;
+ this.lastModTime = root.lastModTime;
+ this.done = false;
+ this.cache = [];
+ this.traverse();
+}
+
+FilteredElementList.prototype = Object.create(Object.prototype, {
+ length: { get: function() {
+ this.checkcache();
+ if (!this.done) this.traverse();
+ return this.cache.length;
+ } },
+
+ item: { value: function(n) {
+ this.checkcache();
+ if (!this.done && n >= this.cache.length) {
+ // This can lead to O(N^2) behavior if we stop when we get to n
+ // and the caller is iterating through the items in order; so
+ // be sure to do the full traverse here.
+ this.traverse(/*n*/);
+ }
+ return this.cache[n];
+ } },
+
+ checkcache: { value: function() {
+ if (this.lastModTime !== this.root.lastModTime) {
+ // subtree has changed, so invalidate cache
+ for (var i = this.cache.length-1; i>=0; i--) {
+ this[i] = undefined;
+ }
+ this.cache.length = 0;
+ this.done = false;
+ this.lastModTime = this.root.lastModTime;
+ }
+ } },
+
+ // If n is specified, then traverse the tree until we've found the nth
+ // item (or until we've found all items). If n is not specified,
+ // traverse until we've found all items.
+ traverse: { value: function(n) {
+ // increment n so we can compare to length, and so it is never falsy
+ if (n !== undefined) n++;
+
+ var elt;
+ while ((elt = this.next()) !== null) {
+ this[this.cache.length] = elt; //XXX Use proxy instead
+ this.cache.push(elt);
+ if (n && this.cache.length === n) return;
+ }
+
+ // no next element, so we've found everything
+ this.done = true;
+ } },
+
+ // Return the next element under root that matches filter
+ next: { value: function() {
+ var start = (this.cache.length === 0) ? this.root // Start at the root or at
+ : this.cache[this.cache.length-1]; // the last element we found
+
+ var elt;
+ if (start.nodeType === Node.DOCUMENT_NODE)
+ elt = start.documentElement;
+ else
+ elt = start.nextElement(this.root);
+
+ while(elt) {
+ if (this.filter(elt)) {
+ return elt;
+ }
+
+ elt = elt.nextElement(this.root);
+ }
+ return null;
+ } },
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/HTMLParser.js
@@ -1,0 +1,7264 @@
+"use strict";
+module.exports = HTMLParser;
+
+var Document = require('./Document');
+var DocumentType = require('./DocumentType');
+var Node = require('./Node');
+var NAMESPACE = require('./utils').NAMESPACE;
+var html = require('./htmlelts');
+var impl = html.elements;
+
+var pushAll = Function.prototype.apply.bind(Array.prototype.push);
+
+/*
+ * This file contains an implementation of the HTML parsing algorithm.
+ * The algorithm and the implementation are complex because HTML
+ * explicitly defines how the parser should behave for all possible
+ * valid and invalid inputs.
+ *
+ * Usage:
+ *
+ * The file defines a single HTMLParser() function, which dom.js exposes
+ * publicly as document.implementation.mozHTMLParser(). This is a
+ * factory function, not a constructor.
+ *
+ * When you call document.implementation.mozHTMLParser(), it returns
+ * an object that has parse() and document() methods. To parse HTML text,
+ * pass the text (in one or more chunks) to the parse() method. When
+ * you've passed all the text (on the last chunk, or afterward) pass
+ * true as the second argument to parse() to tell the parser that there
+ * is no more coming. Call document() to get the document object that
+ * the parser is parsing into. You can call this at any time, before
+ * or after calling parse().
+ *
+ * The first argument to mozHTMLParser is the absolute URL of the document.
+ *
+ * The second argument is optional and is for internal use only. Pass an
+ * element as the fragmentContext to do innerHTML parsing for the
+ * element. To do innerHTML parsing on a document, pass null. Otherwise,
+ * omit the 2nd argument. See HTMLElement.innerHTML for an example. Note
+ * that if you pass a context element, the end() method will return an
+ * unwrapped document instead of a wrapped one.
+ *
+ * Implementation details:
+ *
+ * This is a long file of almost 7000 lines. It is structured as one
+ * big function nested within another big function. The outer
+ * function defines a bunch of constant data, utility functions
+ * that use that data, and a couple of classes used by the parser.
+ * The outer function also defines and returns the
+ * inner function. This inner function is the HTMLParser factory
+ * function that implements the parser and holds all the parser state
+ * as local variables. The HTMLParser function is quite big because
+ * it defines many nested functions that use those local variables.
+ *
+ * There are three tightly coupled parser stages: a scanner, a
+ * tokenizer and a tree builder. In a (possibly misguided) attempt at
+ * efficiency, the stages are not implemented as separate classes:
+ * everything shares state and is (mostly) implemented in imperative
+ * (rather than OO) style.
+ *
+ * The stages of the parser work like this: When the client code calls
+ * the parser's parse() method, the specified string is passed to
+ * scanChars(). The scanner loops through that string and passes characters
+ * (sometimes one at a time, sometimes in chunks) to the tokenizer stage.
+ * The tokenizer groups the characters into tokens: tags, endtags, runs
+ * of text, comments, doctype declarations, and the end-of-file (EOF)
+ * token. These tokens are then passed to the tree building stage via
+ * the insertToken() function. The tree building stage builds up the
+ * document tree.
+ *
+ * The tokenizer stage is a finite state machine. Each state is
+ * implemented as a function with a name that ends in "_state". The
+ * initial state is data_state(). The current tokenizer state is stored
+ * in the variable 'tokenizer'. Most state functions expect a single
+ * integer argument which represents a single UTF-16 codepoint. Some
+ * states want more characters and set a lookahead property on
+ * themselves. The scanChars() function in the scanner checks for this
+ * lookahead property. If it doesn't exist, then scanChars() just passes
+ * the next input character to the current tokenizer state function.
+ * Otherwise, scanChars() looks ahead (a given # of characters, or for a
+ * matching string, or for a matching regexp) and passes a string of
+ * characters to the current tokenizer state function.
+ *
+ * As a shortcut, certain states of the tokenizer use regular expressions
+ * to look ahead in the scanner's input buffer for runs of text, simple
+ * tags and attributes. For well-formed input, these shortcuts skip a
+ * lot of state transitions and speed things up a bit.
+ *
+ * When a tokenizer state function has consumed a complete token, it
+ * emits that token, by calling insertToken(), or by calling a utility
+ * function that itself calls insertToken(). These tokens are passed to
+ * the tree building stage, which is also a state machine. Like the
+ * tokenizer, the tree building states are implemented as functions, and
+ * these functions have names that end with _mode (because the HTML spec
+ * refers to them as insertion modes). The current insertion mode is held
+ * by the 'parser' variable. Each insertion mode function takes up to 4
+ * arguments. The first is a token type, represented by the constants
+ * TAG, ENDTAG, TEXT, COMMENT, DOCTYPE and EOF. The second argument is
+ * the value of the token: the text or comment data, or tagname or
+ * doctype. For tags, the 3rd argument is an array of attributes. For
+ * DOCTYPES it is the optional public id. For tags, the 4th argument is
+ * true if the tag is self-closing. For doctypes, the 4th argument is the
+ * optional system id.
+ *
+ * Search for "***" to find the major sub-divisions in the code.
+ */
+
+
+/***
+ * Data prolog. Lots of constants declared here, including some
+ * very large objects. They're used throughout the code that follows
+ */
+// Token types for the tree builder.
+var EOF = -1;
+var TEXT = 1;
+var TAG = 2;
+var ENDTAG = 3;
+var COMMENT = 4;
+var DOCTYPE = 5;
+
+// A re-usable empty array
+var NOATTRS = [];
+
+// These DTD public ids put the browser in quirks mode
+var quirkyPublicIds = /^HTML$|^-\/\/W3O\/\/DTD W3 HTML Strict 3\.0\/\/EN\/\/$|^-\/W3C\/DTD HTML 4\.0 Transitional\/EN$|^\+\/\/Silmaril\/\/dtd html Pro v0r11 19970101\/\/|^-\/\/AdvaSoft Ltd\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/AS\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict\/\/|^-\/\/IETF\/\/DTD HTML 2\.0\/\/|^-\/\/IETF\/\/DTD HTML 2\.1E\/\/|^-\/\/IETF\/\/DTD HTML 3\.0\/\/|^-\/\/IETF\/\/DTD HTML 3\.2 Final\/\/|^-\/\/IETF\/\/DTD HTML 3\.2\/\/|^-\/\/IETF\/\/DTD HTML 3\/\/|^-\/\/IETF\/\/DTD HTML Level 0\/\/|^-\/\/IETF\/\/DTD HTML Level 1\/\/|^-\/\/IETF\/\/DTD HTML Level 2\/\/|^-\/\/IETF\/\/DTD HTML Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 0\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict\/\/|^-\/\/IETF\/\/DTD HTML\/\/|^-\/\/Metrius\/\/DTD Metrius Presentational\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 Tables\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 Tables\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD HTML\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD Strict HTML\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML 2\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended 1\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended Relaxed 1\.0\/\/|^-\/\/SoftQuad Software\/\/DTD HoTMetaL PRO 6\.0::19990601::extensions to HTML 4\.0\/\/|^-\/\/SoftQuad\/\/DTD HoTMetaL PRO 4\.0::19971010::extensions to HTML 4\.0\/\/|^-\/\/Spyglass\/\/DTD HTML 2\.0 Extended\/\/|^-\/\/SQ\/\/DTD HTML 2\.0 HoTMetaL \+ extensions\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava HTML\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava Strict HTML\/\/|^-\/\/W3C\/\/DTD HTML 3 1995-03-24\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Draft\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Final\/\/|^-\/\/W3C\/\/DTD HTML 3\.2\/\/|^-\/\/W3C\/\/DTD HTML 3\.2S Draft\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Transitional\/\/|^-\/\/W3C\/\/DTD HTML Experimental 19960712\/\/|^-\/\/W3C\/\/DTD HTML Experimental 970421\/\/|^-\/\/W3C\/\/DTD W3 HTML\/\/|^-\/\/W3O\/\/DTD W3 HTML 3\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML 2\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML\/\//i;
+
+var quirkySystemId = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd";
+
+var conditionallyQuirkyPublicIds = /^-\/\/W3C\/\/DTD HTML 4\.01 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.01 Transitional\/\//i;
+
+// These DTD public ids put the browser in limited quirks mode
+var limitedQuirkyPublicIds = /^-\/\/W3C\/\/DTD XHTML 1\.0 Frameset\/\/|^-\/\/W3C\/\/DTD XHTML 1\.0 Transitional\/\//i;
+
+
+// Element sets below. See the isA() function for a way to test
+// whether an element is a member of a set
+var specialSet = Object.create(null);
+specialSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "address":true, "applet":true, "area":true, "article":true,
+ "aside":true, "base":true, "basefont":true, "bgsound":true,
+ "blockquote":true, "body":true, "br":true, "button":true,
+ "caption":true, "center":true, "col":true, "colgroup":true,
+ "dd":true, "details":true, "dir":true,
+ "div":true, "dl":true, "dt":true, "embed":true,
+ "fieldset":true, "figcaption":true, "figure":true, "footer":true,
+ "form":true, "frame":true, "frameset":true, "h1":true,
+ "h2":true, "h3":true, "h4":true, "h5":true,
+ "h6":true, "head":true, "header":true, "hgroup":true,
+ "hr":true, "html":true, "iframe":true, "img":true,
+ "input":true, "li":true, "link":true,
+ "listing":true, "main":true, "marquee":true, "menu":true, "meta":true,
+ "nav":true, "noembed":true, "noframes":true, "noscript":true,
+ "object":true, "ol":true, "p":true, "param":true,
+ "plaintext":true, "pre":true, "script":true, "section":true,
+ "select":true, "source":true, "style":true, "summary":true, "table":true,
+ "tbody":true, "td":true, "template":true, "textarea":true, "tfoot":true,
+ "th":true, "thead":true, "title":true, "tr":true, "track":true,
+ // Note that "xmp" was removed from the "special" set in the latest
+ // spec, apparently by accident; see
+ // https://github.com/whatwg/html/pull/1919
+ "ul":true, "wbr":true, "xmp":true
+};
+specialSet[NAMESPACE.SVG] = {
+ __proto__: null,
+ "foreignObject": true, "desc": true, "title": true
+};
+specialSet[NAMESPACE.MATHML] = {
+ __proto__: null,
+ "mi":true, "mo":true, "mn":true, "ms":true,
+ "mtext":true, "annotation-xml":true
+};
+
+// The set of address, div, and p HTML tags
+var addressdivpSet = Object.create(null);
+addressdivpSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "address":true, "div":true, "p":true
+};
+
+var dddtSet = Object.create(null);
+dddtSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "dd":true, "dt":true
+};
+
+var tablesectionrowSet = Object.create(null);
+tablesectionrowSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "table":true, "thead":true, "tbody":true, "tfoot":true, "tr":true
+};
+
+var impliedEndTagsSet = Object.create(null);
+impliedEndTagsSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "dd": true, "dt": true, "li": true, "menuitem": true, "optgroup": true,
+ "option": true, "p": true, "rb": true, "rp": true, "rt": true, "rtc": true
+};
+
+var thoroughImpliedEndTagsSet = Object.create(null);
+thoroughImpliedEndTagsSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "caption": true, "colgroup": true, "dd": true, "dt": true, "li": true,
+ "optgroup": true, "option": true, "p": true, "rb": true, "rp": true,
+ "rt": true, "rtc": true, "tbody": true, "td": true, "tfoot": true,
+ "th": true, "thead": true, "tr": true
+};
+
+var tableContextSet = Object.create(null);
+tableContextSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "table": true, "template": true, "html": true
+};
+
+var tableBodyContextSet = Object.create(null);
+tableBodyContextSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "tbody": true, "tfoot": true, "thead": true, "template": true, "html": true
+};
+
+var tableRowContextSet = Object.create(null);
+tableRowContextSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "tr": true, "template": true, "html": true
+};
+
+// See http://www.w3.org/TR/html5/forms.html#form-associated-element
+var formassociatedSet = Object.create(null);
+formassociatedSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "button": true, "fieldset": true, "input": true, "keygen": true,
+ "object": true, "output": true, "select": true, "textarea": true,
+ "img": true
+};
+
+var inScopeSet = Object.create(null);
+inScopeSet[NAMESPACE.HTML]= {
+ __proto__: null,
+ "applet":true, "caption":true, "html":true, "table":true,
+ "td":true, "th":true, "marquee":true, "object":true,
+ "template":true
+};
+inScopeSet[NAMESPACE.MATHML] = {
+ __proto__: null,
+ "mi":true, "mo":true, "mn":true, "ms":true,
+ "mtext":true, "annotation-xml":true
+};
+inScopeSet[NAMESPACE.SVG] = {
+ __proto__: null,
+ "foreignObject":true, "desc":true, "title":true
+};
+
+var inListItemScopeSet = Object.create(inScopeSet);
+inListItemScopeSet[NAMESPACE.HTML] =
+ Object.create(inScopeSet[NAMESPACE.HTML]);
+inListItemScopeSet[NAMESPACE.HTML].ol = true;
+inListItemScopeSet[NAMESPACE.HTML].ul = true;
+
+var inButtonScopeSet = Object.create(inScopeSet);
+inButtonScopeSet[NAMESPACE.HTML] =
+ Object.create(inScopeSet[NAMESPACE.HTML]);
+inButtonScopeSet[NAMESPACE.HTML].button = true;
+
+var inTableScopeSet = Object.create(null);
+inTableScopeSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "html":true, "table":true, "template":true
+};
+
+// The set of elements for select scope is the everything *except* these
+var invertedSelectScopeSet = Object.create(null);
+invertedSelectScopeSet[NAMESPACE.HTML] = {
+ __proto__: null,
+ "optgroup":true, "option":true
+};
+
+var mathmlTextIntegrationPointSet = Object.create(null);
+mathmlTextIntegrationPointSet[NAMESPACE.MATHML] = {
+ __proto__: null,
+ mi: true,
+ mo: true,
+ mn: true,
+ ms: true,
+ mtext: true
+};
+
+var htmlIntegrationPointSet = Object.create(null);
+htmlIntegrationPointSet[NAMESPACE.SVG] = {
+ __proto__: null,
+ foreignObject: true,
+ desc: true,
+ title: true
+};
+
+var foreignAttributes = {
+ __proto__: null,
+ "xlink:actuate": NAMESPACE.XLINK, "xlink:arcrole": NAMESPACE.XLINK,
+ "xlink:href": NAMESPACE.XLINK, "xlink:role": NAMESPACE.XLINK,
+ "xlink:show": NAMESPACE.XLINK, "xlink:title": NAMESPACE.XLINK,
+ "xlink:type": NAMESPACE.XLINK, "xml:base": NAMESPACE.XML,
+ "xml:lang": NAMESPACE.XML, "xml:space": NAMESPACE.XML,
+ "xmlns": NAMESPACE.XMLNS, "xmlns:xlink": NAMESPACE.XMLNS
+};
+
+
+// Lowercase to mixed case mapping for SVG attributes and tagnames
+var svgAttrAdjustments = {
+ __proto__: null,
+ attributename: "attributeName", attributetype: "attributeType",
+ basefrequency: "baseFrequency", baseprofile: "baseProfile",
+ calcmode: "calcMode", clippathunits: "clipPathUnits",
+ diffuseconstant: "diffuseConstant",
+ edgemode: "edgeMode",
+ filterunits: "filterUnits",
+ glyphref: "glyphRef", gradienttransform: "gradientTransform",
+ gradientunits: "gradientUnits", kernelmatrix: "kernelMatrix",
+ kernelunitlength: "kernelUnitLength", keypoints: "keyPoints",
+ keysplines: "keySplines", keytimes: "keyTimes",
+ lengthadjust: "lengthAdjust", limitingconeangle: "limitingConeAngle",
+ markerheight: "markerHeight", markerunits: "markerUnits",
+ markerwidth: "markerWidth", maskcontentunits: "maskContentUnits",
+ maskunits: "maskUnits", numoctaves: "numOctaves",
+ pathlength: "pathLength", patterncontentunits: "patternContentUnits",
+ patterntransform: "patternTransform", patternunits: "patternUnits",
+ pointsatx: "pointsAtX", pointsaty: "pointsAtY",
+ pointsatz: "pointsAtZ", preservealpha: "preserveAlpha",
+ preserveaspectratio: "preserveAspectRatio",
+ primitiveunits: "primitiveUnits", refx: "refX",
+ refy: "refY", repeatcount: "repeatCount",
+ repeatdur: "repeatDur", requiredextensions: "requiredExtensions",
+ requiredfeatures: "requiredFeatures",
+ specularconstant: "specularConstant",
+ specularexponent: "specularExponent", spreadmethod: "spreadMethod",
+ startoffset: "startOffset", stddeviation: "stdDeviation",
+ stitchtiles: "stitchTiles", surfacescale: "surfaceScale",
+ systemlanguage: "systemLanguage", tablevalues: "tableValues",
+ targetx: "targetX", targety: "targetY",
+ textlength: "textLength", viewbox: "viewBox",
+ viewtarget: "viewTarget", xchannelselector: "xChannelSelector",
+ ychannelselector: "yChannelSelector", zoomandpan: "zoomAndPan"
+};
+
+var svgTagNameAdjustments = {
+ __proto__: null,
+ altglyph: "altGlyph", altglyphdef: "altGlyphDef",
+ altglyphitem: "altGlyphItem", animatecolor: "animateColor",
+ animatemotion: "animateMotion", animatetransform: "animateTransform",
+ clippath: "clipPath", feblend: "feBlend",
+ fecolormatrix: "feColorMatrix",
+ fecomponenttransfer: "feComponentTransfer", fecomposite: "feComposite",
+ feconvolvematrix: "feConvolveMatrix",
+ fediffuselighting: "feDiffuseLighting",
+ fedisplacementmap: "feDisplacementMap",
+ fedistantlight: "feDistantLight", feflood: "feFlood",
+ fefunca: "feFuncA", fefuncb: "feFuncB",
+ fefuncg: "feFuncG", fefuncr: "feFuncR",
+ fegaussianblur: "feGaussianBlur", feimage: "feImage",
+ femerge: "feMerge", femergenode: "feMergeNode",
+ femorphology: "feMorphology", feoffset: "feOffset",
+ fepointlight: "fePointLight", fespecularlighting: "feSpecularLighting",
+ fespotlight: "feSpotLight", fetile: "feTile",
+ feturbulence: "feTurbulence", foreignobject: "foreignObject",
+ glyphref: "glyphRef", lineargradient: "linearGradient",
+ radialgradient: "radialGradient", textpath: "textPath"
+};
+
+
+// Data for parsing numeric and named character references
+// These next 3 objects are direct translations of tables
+// in the HTML spec into JavaScript object format
+var numericCharRefReplacements = {
+ __proto__: null,
+ 0x00:0xFFFD, 0x80:0x20AC, 0x82:0x201A, 0x83:0x0192, 0x84:0x201E,
+ 0x85:0x2026, 0x86:0x2020, 0x87:0x2021, 0x88:0x02C6, 0x89:0x2030,
+ 0x8A:0x0160, 0x8B:0x2039, 0x8C:0x0152, 0x8E:0x017D, 0x91:0x2018,
+ 0x92:0x2019, 0x93:0x201C, 0x94:0x201D, 0x95:0x2022, 0x96:0x2013,
+ 0x97:0x2014, 0x98:0x02DC, 0x99:0x2122, 0x9A:0x0161, 0x9B:0x203A,
+ 0x9C:0x0153, 0x9E:0x017E, 0x9F:0x0178
+};
+
+/*
+ * This table is generated with test/tools/update-entities.js
+ */
+var namedCharRefs = {
+ __proto__: null,
+ "AElig":0xc6, "AElig;":0xc6,
+ "AMP":0x26, "AMP;":0x26,
+ "Aacute":0xc1, "Aacute;":0xc1,
+ "Abreve;":0x102, "Acirc":0xc2,
+ "Acirc;":0xc2, "Acy;":0x410,
+ "Afr;":[0xd835,0xdd04], "Agrave":0xc0,
+ "Agrave;":0xc0, "Alpha;":0x391,
+ "Amacr;":0x100, "And;":0x2a53,
+ "Aogon;":0x104, "Aopf;":[0xd835,0xdd38],
+ "ApplyFunction;":0x2061, "Aring":0xc5,
+ "Aring;":0xc5, "Ascr;":[0xd835,0xdc9c],
+ "Assign;":0x2254, "Atilde":0xc3,
+ "Atilde;":0xc3, "Auml":0xc4,
+ "Auml;":0xc4, "Backslash;":0x2216,
+ "Barv;":0x2ae7, "Barwed;":0x2306,
+ "Bcy;":0x411, "Because;":0x2235,
+ "Bernoullis;":0x212c, "Beta;":0x392,
+ "Bfr;":[0xd835,0xdd05], "Bopf;":[0xd835,0xdd39],
+ "Breve;":0x2d8, "Bscr;":0x212c,
+ "Bumpeq;":0x224e, "CHcy;":0x427,
+ "COPY":0xa9, "COPY;":0xa9,
+ "Cacute;":0x106, "Cap;":0x22d2,
+ "CapitalDifferentialD;":0x2145, "Cayleys;":0x212d,
+ "Ccaron;":0x10c, "Ccedil":0xc7,
+ "Ccedil;":0xc7, "Ccirc;":0x108,
+ "Cconint;":0x2230, "Cdot;":0x10a,
+ "Cedilla;":0xb8, "CenterDot;":0xb7,
+ "Cfr;":0x212d, "Chi;":0x3a7,
+ "CircleDot;":0x2299, "CircleMinus;":0x2296,
+ "CirclePlus;":0x2295, "CircleTimes;":0x2297,
+ "ClockwiseContourIntegral;":0x2232, "CloseCurlyDoubleQuote;":0x201d,
+ "CloseCurlyQuote;":0x2019, "Colon;":0x2237,
+ "Colone;":0x2a74, "Congruent;":0x2261,
+ "Conint;":0x222f, "ContourIntegral;":0x222e,
+ "Copf;":0x2102, "Coproduct;":0x2210,
+ "CounterClockwiseContourIntegral;":0x2233, "Cross;":0x2a2f,
+ "Cscr;":[0xd835,0xdc9e], "Cup;":0x22d3,
+ "CupCap;":0x224d, "DD;":0x2145,
+ "DDotrahd;":0x2911, "DJcy;":0x402,
+ "DScy;":0x405, "DZcy;":0x40f,
+ "Dagger;":0x2021, "Darr;":0x21a1,
+ "Dashv;":0x2ae4, "Dcaron;":0x10e,
+ "Dcy;":0x414, "Del;":0x2207,
+ "Delta;":0x394, "Dfr;":[0xd835,0xdd07],
+ "DiacriticalAcute;":0xb4, "DiacriticalDot;":0x2d9,
+ "DiacriticalDoubleAcute;":0x2dd, "DiacriticalGrave;":0x60,
+ "DiacriticalTilde;":0x2dc, "Diamond;":0x22c4,
+ "DifferentialD;":0x2146, "Dopf;":[0xd835,0xdd3b],
+ "Dot;":0xa8, "DotDot;":0x20dc,
+ "DotEqual;":0x2250, "DoubleContourIntegral;":0x222f,
+ "DoubleDot;":0xa8, "DoubleDownArrow;":0x21d3,
+ "DoubleLeftArrow;":0x21d0, "DoubleLeftRightArrow;":0x21d4,
+ "DoubleLeftTee;":0x2ae4, "DoubleLongLeftArrow;":0x27f8,
+ "DoubleLongLeftRightArrow;":0x27fa, "DoubleLongRightArrow;":0x27f9,
+ "DoubleRightArrow;":0x21d2, "DoubleRightTee;":0x22a8,
+ "DoubleUpArrow;":0x21d1, "DoubleUpDownArrow;":0x21d5,
+ "DoubleVerticalBar;":0x2225, "DownArrow;":0x2193,
+ "DownArrowBar;":0x2913, "DownArrowUpArrow;":0x21f5,
+ "DownBreve;":0x311, "DownLeftRightVector;":0x2950,
+ "DownLeftTeeVector;":0x295e, "DownLeftVector;":0x21bd,
+ "DownLeftVectorBar;":0x2956, "DownRightTeeVector;":0x295f,
+ "DownRightVector;":0x21c1, "DownRightVectorBar;":0x2957,
+ "DownTee;":0x22a4, "DownTeeArrow;":0x21a7,
+ "Downarrow;":0x21d3, "Dscr;":[0xd835,0xdc9f],
+ "Dstrok;":0x110, "ENG;":0x14a,
+ "ETH":0xd0, "ETH;":0xd0,
+ "Eacute":0xc9, "Eacute;":0xc9,
+ "Ecaron;":0x11a, "Ecirc":0xca,
+ "Ecirc;":0xca, "Ecy;":0x42d,
+ "Edot;":0x116, "Efr;":[0xd835,0xdd08],
+ "Egrave":0xc8, "Egrave;":0xc8,
+ "Element;":0x2208, "Emacr;":0x112,
+ "EmptySmallSquare;":0x25fb, "EmptyVerySmallSquare;":0x25ab,
+ "Eogon;":0x118, "Eopf;":[0xd835,0xdd3c],
+ "Epsilon;":0x395, "Equal;":0x2a75,
+ "EqualTilde;":0x2242, "Equilibrium;":0x21cc,
+ "Escr;":0x2130, "Esim;":0x2a73,
+ "Eta;":0x397, "Euml":0xcb,
+ "Euml;":0xcb, "Exists;":0x2203,
+ "ExponentialE;":0x2147, "Fcy;":0x424,
+ "Ffr;":[0xd835,0xdd09], "FilledSmallSquare;":0x25fc,
+ "FilledVerySmallSquare;":0x25aa, "Fopf;":[0xd835,0xdd3d],
+ "ForAll;":0x2200, "Fouriertrf;":0x2131,
+ "Fscr;":0x2131, "GJcy;":0x403,
+ "GT":0x3e, "GT;":0x3e,
+ "Gamma;":0x393, "Gammad;":0x3dc,
+ "Gbreve;":0x11e, "Gcedil;":0x122,
+ "Gcirc;":0x11c, "Gcy;":0x413,
+ "Gdot;":0x120, "Gfr;":[0xd835,0xdd0a],
+ "Gg;":0x22d9, "Gopf;":[0xd835,0xdd3e],
+ "GreaterEqual;":0x2265, "GreaterEqualLess;":0x22db,
+ "GreaterFullEqual;":0x2267, "GreaterGreater;":0x2aa2,
+ "GreaterLess;":0x2277, "GreaterSlantEqual;":0x2a7e,
+ "GreaterTilde;":0x2273, "Gscr;":[0xd835,0xdca2],
+ "Gt;":0x226b, "HARDcy;":0x42a,
+ "Hacek;":0x2c7, "Hat;":0x5e,
+ "Hcirc;":0x124, "Hfr;":0x210c,
+ "HilbertSpace;":0x210b, "Hopf;":0x210d,
+ "HorizontalLine;":0x2500, "Hscr;":0x210b,
+ "Hstrok;":0x126, "HumpDownHump;":0x224e,
+ "HumpEqual;":0x224f, "IEcy;":0x415,
+ "IJlig;":0x132, "IOcy;":0x401,
+ "Iacute":0xcd, "Iacute;":0xcd,
+ "Icirc":0xce, "Icirc;":0xce,
+ "Icy;":0x418, "Idot;":0x130,
+ "Ifr;":0x2111, "Igrave":0xcc,
+ "Igrave;":0xcc, "Im;":0x2111,
+ "Imacr;":0x12a, "ImaginaryI;":0x2148,
+ "Implies;":0x21d2, "Int;":0x222c,
+ "Integral;":0x222b, "Intersection;":0x22c2,
+ "InvisibleComma;":0x2063, "InvisibleTimes;":0x2062,
+ "Iogon;":0x12e, "Iopf;":[0xd835,0xdd40],
+ "Iota;":0x399, "Iscr;":0x2110,
+ "Itilde;":0x128, "Iukcy;":0x406,
+ "Iuml":0xcf, "Iuml;":0xcf,
+ "Jcirc;":0x134, "Jcy;":0x419,
+ "Jfr;":[0xd835,0xdd0d], "Jopf;":[0xd835,0xdd41],
+ "Jscr;":[0xd835,0xdca5], "Jsercy;":0x408,
+ "Jukcy;":0x404, "KHcy;":0x425,
+ "KJcy;":0x40c, "Kappa;":0x39a,
+ "Kcedil;":0x136, "Kcy;":0x41a,
+ "Kfr;":[0xd835,0xdd0e], "Kopf;":[0xd835,0xdd42],
+ "Kscr;":[0xd835,0xdca6], "LJcy;":0x409,
+ "LT":0x3c, "LT;":0x3c,
+ "Lacute;":0x139, "Lambda;":0x39b,
+ "Lang;":0x27ea, "Laplacetrf;":0x2112,
+ "Larr;":0x219e, "Lcaron;":0x13d,
+ "Lcedil;":0x13b, "Lcy;":0x41b,
+ "LeftAngleBracket;":0x27e8, "LeftArrow;":0x2190,
+ "LeftArrowBar;":0x21e4, "LeftArrowRightArrow;":0x21c6,
+ "LeftCeiling;":0x2308, "LeftDoubleBracket;":0x27e6,
+ "LeftDownTeeVector;":0x2961, "LeftDownVector;":0x21c3,
+ "LeftDownVectorBar;":0x2959, "LeftFloor;":0x230a,
+ "LeftRightArrow;":0x2194, "LeftRightVector;":0x294e,
+ "LeftTee;":0x22a3, "LeftTeeArrow;":0x21a4,
+ "LeftTeeVector;":0x295a, "LeftTriangle;":0x22b2,
+ "LeftTriangleBar;":0x29cf, "LeftTriangleEqual;":0x22b4,
+ "LeftUpDownVector;":0x2951, "LeftUpTeeVector;":0x2960,
+ "LeftUpVector;":0x21bf, "LeftUpVectorBar;":0x2958,
+ "LeftVector;":0x21bc, "LeftVectorBar;":0x2952,
+ "Leftarrow;":0x21d0, "Leftrightarrow;":0x21d4,
+ "LessEqualGreater;":0x22da, "LessFullEqual;":0x2266,
+ "LessGreater;":0x2276, "LessLess;":0x2aa1,
+ "LessSlantEqual;":0x2a7d, "LessTilde;":0x2272,
+ "Lfr;":[0xd835,0xdd0f], "Ll;":0x22d8,
+ "Lleftarrow;":0x21da, "Lmidot;":0x13f,
+ "LongLeftArrow;":0x27f5, "LongLeftRightArrow;":0x27f7,
+ "LongRightArrow;":0x27f6, "Longleftarrow;":0x27f8,
+ "Longleftrightarrow;":0x27fa, "Longrightarrow;":0x27f9,
+ "Lopf;":[0xd835,0xdd43], "LowerLeftArrow;":0x2199,
+ "LowerRightArrow;":0x2198, "Lscr;":0x2112,
+ "Lsh;":0x21b0, "Lstrok;":0x141,
+ "Lt;":0x226a, "Map;":0x2905,
+ "Mcy;":0x41c, "MediumSpace;":0x205f,
+ "Mellintrf;":0x2133, "Mfr;":[0xd835,0xdd10],
+ "MinusPlus;":0x2213, "Mopf;":[0xd835,0xdd44],
+ "Mscr;":0x2133, "Mu;":0x39c,
+ "NJcy;":0x40a, "Nacute;":0x143,
+ "Ncaron;":0x147, "Ncedil;":0x145,
+ "Ncy;":0x41d, "NegativeMediumSpace;":0x200b,
+ "NegativeThickSpace;":0x200b, "NegativeThinSpace;":0x200b,
+ "NegativeVeryThinSpace;":0x200b, "NestedGreaterGreater;":0x226b,
+ "NestedLessLess;":0x226a, "NewLine;":0xa,
+ "Nfr;":[0xd835,0xdd11], "NoBreak;":0x2060,
+ "NonBreakingSpace;":0xa0, "Nopf;":0x2115,
+ "Not;":0x2aec, "NotCongruent;":0x2262,
+ "NotCupCap;":0x226d, "NotDoubleVerticalBar;":0x2226,
+ "NotElement;":0x2209, "NotEqual;":0x2260,
+ "NotEqualTilde;":[0x2242,0x338], "NotExists;":0x2204,
+ "NotGreater;":0x226f, "NotGreaterEqual;":0x2271,
+ "NotGreaterFullEqual;":[0x2267,0x338], "NotGreaterGreater;":[0x226b,0x338],
+ "NotGreaterLess;":0x2279, "NotGreaterSlantEqual;":[0x2a7e,0x338],
+ "NotGreaterTilde;":0x2275, "NotHumpDownHump;":[0x224e,0x338],
+ "NotHumpEqual;":[0x224f,0x338], "NotLeftTriangle;":0x22ea,
+ "NotLeftTriangleBar;":[0x29cf,0x338], "NotLeftTriangleEqual;":0x22ec,
+ "NotLess;":0x226e, "NotLessEqual;":0x2270,
+ "NotLessGreater;":0x2278, "NotLessLess;":[0x226a,0x338],
+ "NotLessSlantEqual;":[0x2a7d,0x338], "NotLessTilde;":0x2274,
+ "NotNestedGreaterGreater;":[0x2aa2,0x338], "NotNestedLessLess;":[0x2aa1,0x338],
+ "NotPrecedes;":0x2280, "NotPrecedesEqual;":[0x2aaf,0x338],
+ "NotPrecedesSlantEqual;":0x22e0, "NotReverseElement;":0x220c,
+ "NotRightTriangle;":0x22eb, "NotRightTriangleBar;":[0x29d0,0x338],
+ "NotRightTriangleEqual;":0x22ed, "NotSquareSubset;":[0x228f,0x338],
+ "NotSquareSubsetEqual;":0x22e2, "NotSquareSuperset;":[0x2290,0x338],
+ "NotSquareSupersetEqual;":0x22e3, "NotSubset;":[0x2282,0x20d2],
+ "NotSubsetEqual;":0x2288, "NotSucceeds;":0x2281,
+ "NotSucceedsEqual;":[0x2ab0,0x338], "NotSucceedsSlantEqual;":0x22e1,
+ "NotSucceedsTilde;":[0x227f,0x338], "NotSuperset;":[0x2283,0x20d2],
+ "NotSupersetEqual;":0x2289, "NotTilde;":0x2241,
+ "NotTildeEqual;":0x2244, "NotTildeFullEqual;":0x2247,
+ "NotTildeTilde;":0x2249, "NotVerticalBar;":0x2224,
+ "Nscr;":[0xd835,0xdca9], "Ntilde":0xd1,
+ "Ntilde;":0xd1, "Nu;":0x39d,
+ "OElig;":0x152, "Oacute":0xd3,
+ "Oacute;":0xd3, "Ocirc":0xd4,
+ "Ocirc;":0xd4, "Ocy;":0x41e,
+ "Odblac;":0x150, "Ofr;":[0xd835,0xdd12],
+ "Ograve":0xd2, "Ograve;":0xd2,
+ "Omacr;":0x14c, "Omega;":0x3a9,
+ "Omicron;":0x39f, "Oopf;":[0xd835,0xdd46],
+ "OpenCurlyDoubleQuote;":0x201c, "OpenCurlyQuote;":0x2018,
+ "Or;":0x2a54, "Oscr;":[0xd835,0xdcaa],
+ "Oslash":0xd8, "Oslash;":0xd8,
+ "Otilde":0xd5, "Otilde;":0xd5,
+ "Otimes;":0x2a37, "Ouml":0xd6,
+ "Ouml;":0xd6, "OverBar;":0x203e,
+ "OverBrace;":0x23de, "OverBracket;":0x23b4,
+ "OverParenthesis;":0x23dc, "PartialD;":0x2202,
+ "Pcy;":0x41f, "Pfr;":[0xd835,0xdd13],
+ "Phi;":0x3a6, "Pi;":0x3a0,
+ "PlusMinus;":0xb1, "Poincareplane;":0x210c,
+ "Popf;":0x2119, "Pr;":0x2abb,
+ "Precedes;":0x227a, "PrecedesEqual;":0x2aaf,
+ "PrecedesSlantEqual;":0x227c, "PrecedesTilde;":0x227e,
+ "Prime;":0x2033, "Product;":0x220f,
+ "Proportion;":0x2237, "Proportional;":0x221d,
+ "Pscr;":[0xd835,0xdcab], "Psi;":0x3a8,
+ "QUOT":0x22, "QUOT;":0x22,
+ "Qfr;":[0xd835,0xdd14], "Qopf;":0x211a,
+ "Qscr;":[0xd835,0xdcac], "RBarr;":0x2910,
+ "REG":0xae, "REG;":0xae,
+ "Racute;":0x154, "Rang;":0x27eb,
+ "Rarr;":0x21a0, "Rarrtl;":0x2916,
+ "Rcaron;":0x158, "Rcedil;":0x156,
+ "Rcy;":0x420, "Re;":0x211c,
+ "ReverseElement;":0x220b, "ReverseEquilibrium;":0x21cb,
+ "ReverseUpEquilibrium;":0x296f, "Rfr;":0x211c,
+ "Rho;":0x3a1, "RightAngleBracket;":0x27e9,
+ "RightArrow;":0x2192, "RightArrowBar;":0x21e5,
+ "RightArrowLeftArrow;":0x21c4, "RightCeiling;":0x2309,
+ "RightDoubleBracket;":0x27e7, "RightDownTeeVector;":0x295d,
+ "RightDownVector;":0x21c2, "RightDownVectorBar;":0x2955,
+ "RightFloor;":0x230b, "RightTee;":0x22a2,
+ "RightTeeArrow;":0x21a6, "RightTeeVector;":0x295b,
+ "RightTriangle;":0x22b3, "RightTriangleBar;":0x29d0,
+ "RightTriangleEqual;":0x22b5, "RightUpDownVector;":0x294f,
+ "RightUpTeeVector;":0x295c, "RightUpVector;":0x21be,
+ "RightUpVectorBar;":0x2954, "RightVector;":0x21c0,
+ "RightVectorBar;":0x2953, "Rightarrow;":0x21d2,
+ "Ropf;":0x211d, "RoundImplies;":0x2970,
+ "Rrightarrow;":0x21db, "Rscr;":0x211b,
+ "Rsh;":0x21b1, "RuleDelayed;":0x29f4,
+ "SHCHcy;":0x429, "SHcy;":0x428,
+ "SOFTcy;":0x42c, "Sacute;":0x15a,
+ "Sc;":0x2abc, "Scaron;":0x160,
+ "Scedil;":0x15e, "Scirc;":0x15c,
+ "Scy;":0x421, "Sfr;":[0xd835,0xdd16],
+ "ShortDownArrow;":0x2193, "ShortLeftArrow;":0x2190,
+ "ShortRightArrow;":0x2192, "ShortUpArrow;":0x2191,
+ "Sigma;":0x3a3, "SmallCircle;":0x2218,
+ "Sopf;":[0xd835,0xdd4a], "Sqrt;":0x221a,
+ "Square;":0x25a1, "SquareIntersection;":0x2293,
+ "SquareSubset;":0x228f, "SquareSubsetEqual;":0x2291,
+ "SquareSuperset;":0x2290, "SquareSupersetEqual;":0x2292,
+ "SquareUnion;":0x2294, "Sscr;":[0xd835,0xdcae],
+ "Star;":0x22c6, "Sub;":0x22d0,
+ "Subset;":0x22d0, "SubsetEqual;":0x2286,
+ "Succeeds;":0x227b, "SucceedsEqual;":0x2ab0,
+ "SucceedsSlantEqual;":0x227d, "SucceedsTilde;":0x227f,
+ "SuchThat;":0x220b, "Sum;":0x2211,
+ "Sup;":0x22d1, "Superset;":0x2283,
+ "SupersetEqual;":0x2287, "Supset;":0x22d1,
+ "THORN":0xde, "THORN;":0xde,
+ "TRADE;":0x2122, "TSHcy;":0x40b,
+ "TScy;":0x426, "Tab;":0x9,
+ "Tau;":0x3a4, "Tcaron;":0x164,
+ "Tcedil;":0x162, "Tcy;":0x422,
+ "Tfr;":[0xd835,0xdd17], "Therefore;":0x2234,
+ "Theta;":0x398, "ThickSpace;":[0x205f,0x200a],
+ "ThinSpace;":0x2009, "Tilde;":0x223c,
+ "TildeEqual;":0x2243, "TildeFullEqual;":0x2245,
+ "TildeTilde;":0x2248, "Topf;":[0xd835,0xdd4b],
+ "TripleDot;":0x20db, "Tscr;":[0xd835,0xdcaf],
+ "Tstrok;":0x166, "Uacute":0xda,
+ "Uacute;":0xda, "Uarr;":0x219f,
+ "Uarrocir;":0x2949, "Ubrcy;":0x40e,
+ "Ubreve;":0x16c, "Ucirc":0xdb,
+ "Ucirc;":0xdb, "Ucy;":0x423,
+ "Udblac;":0x170, "Ufr;":[0xd835,0xdd18],
+ "Ugrave":0xd9, "Ugrave;":0xd9,
+ "Umacr;":0x16a, "UnderBar;":0x5f,
+ "UnderBrace;":0x23df, "UnderBracket;":0x23b5,
+ "UnderParenthesis;":0x23dd, "Union;":0x22c3,
+ "UnionPlus;":0x228e, "Uogon;":0x172,
+ "Uopf;":[0xd835,0xdd4c], "UpArrow;":0x2191,
+ "UpArrowBar;":0x2912, "UpArrowDownArrow;":0x21c5,
+ "UpDownArrow;":0x2195, "UpEquilibrium;":0x296e,
+ "UpTee;":0x22a5, "UpTeeArrow;":0x21a5,
+ "Uparrow;":0x21d1, "Updownarrow;":0x21d5,
+ "UpperLeftArrow;":0x2196, "UpperRightArrow;":0x2197,
+ "Upsi;":0x3d2, "Upsilon;":0x3a5,
+ "Uring;":0x16e, "Uscr;":[0xd835,0xdcb0],
+ "Utilde;":0x168, "Uuml":0xdc,
+ "Uuml;":0xdc, "VDash;":0x22ab,
+ "Vbar;":0x2aeb, "Vcy;":0x412,
+ "Vdash;":0x22a9, "Vdashl;":0x2ae6,
+ "Vee;":0x22c1, "Verbar;":0x2016,
+ "Vert;":0x2016, "VerticalBar;":0x2223,
+ "VerticalLine;":0x7c, "VerticalSeparator;":0x2758,
+ "VerticalTilde;":0x2240, "VeryThinSpace;":0x200a,
+ "Vfr;":[0xd835,0xdd19], "Vopf;":[0xd835,0xdd4d],
+ "Vscr;":[0xd835,0xdcb1], "Vvdash;":0x22aa,
+ "Wcirc;":0x174, "Wedge;":0x22c0,
+ "Wfr;":[0xd835,0xdd1a], "Wopf;":[0xd835,0xdd4e],
+ "Wscr;":[0xd835,0xdcb2], "Xfr;":[0xd835,0xdd1b],
+ "Xi;":0x39e, "Xopf;":[0xd835,0xdd4f],
+ "Xscr;":[0xd835,0xdcb3], "YAcy;":0x42f,
+ "YIcy;":0x407, "YUcy;":0x42e,
+ "Yacute":0xdd, "Yacute;":0xdd,
+ "Ycirc;":0x176, "Ycy;":0x42b,
+ "Yfr;":[0xd835,0xdd1c], "Yopf;":[0xd835,0xdd50],
+ "Yscr;":[0xd835,0xdcb4], "Yuml;":0x178,
+ "ZHcy;":0x416, "Zacute;":0x179,
+ "Zcaron;":0x17d, "Zcy;":0x417,
+ "Zdot;":0x17b, "ZeroWidthSpace;":0x200b,
+ "Zeta;":0x396, "Zfr;":0x2128,
+ "Zopf;":0x2124, "Zscr;":[0xd835,0xdcb5],
+ "aacute":0xe1, "aacute;":0xe1,
+ "abreve;":0x103, "ac;":0x223e,
+ "acE;":[0x223e,0x333], "acd;":0x223f,
+ "acirc":0xe2, "acirc;":0xe2,
+ "acute":0xb4, "acute;":0xb4,
+ "acy;":0x430, "aelig":0xe6,
+ "aelig;":0xe6, "af;":0x2061,
+ "afr;":[0xd835,0xdd1e], "agrave":0xe0,
+ "agrave;":0xe0, "alefsym;":0x2135,
+ "aleph;":0x2135, "alpha;":0x3b1,
+ "amacr;":0x101, "amalg;":0x2a3f,
+ "amp":0x26, "amp;":0x26,
+ "and;":0x2227, "andand;":0x2a55,
+ "andd;":0x2a5c, "andslope;":0x2a58,
+ "andv;":0x2a5a, "ang;":0x2220,
+ "ange;":0x29a4, "angle;":0x2220,
+ "angmsd;":0x2221, "angmsdaa;":0x29a8,
+ "angmsdab;":0x29a9, "angmsdac;":0x29aa,
+ "angmsdad;":0x29ab, "angmsdae;":0x29ac,
+ "angmsdaf;":0x29ad, "angmsdag;":0x29ae,
+ "angmsdah;":0x29af, "angrt;":0x221f,
+ "angrtvb;":0x22be, "angrtvbd;":0x299d,
+ "angsph;":0x2222, "angst;":0xc5,
+ "angzarr;":0x237c, "aogon;":0x105,
+ "aopf;":[0xd835,0xdd52], "ap;":0x2248,
+ "apE;":0x2a70, "apacir;":0x2a6f,
+ "ape;":0x224a, "apid;":0x224b,
+ "apos;":0x27, "approx;":0x2248,
+ "approxeq;":0x224a, "aring":0xe5,
+ "aring;":0xe5, "ascr;":[0xd835,0xdcb6],
+ "ast;":0x2a, "asymp;":0x2248,
+ "asympeq;":0x224d, "atilde":0xe3,
+ "atilde;":0xe3, "auml":0xe4,
+ "auml;":0xe4, "awconint;":0x2233,
+ "awint;":0x2a11, "bNot;":0x2aed,
+ "backcong;":0x224c, "backepsilon;":0x3f6,
+ "backprime;":0x2035, "backsim;":0x223d,
+ "backsimeq;":0x22cd, "barvee;":0x22bd,
+ "barwed;":0x2305, "barwedge;":0x2305,
+ "bbrk;":0x23b5, "bbrktbrk;":0x23b6,
+ "bcong;":0x224c, "bcy;":0x431,
+ "bdquo;":0x201e, "becaus;":0x2235,
+ "because;":0x2235, "bemptyv;":0x29b0,
+ "bepsi;":0x3f6, "bernou;":0x212c,
+ "beta;":0x3b2, "beth;":0x2136,
+ "between;":0x226c, "bfr;":[0xd835,0xdd1f],
+ "bigcap;":0x22c2, "bigcirc;":0x25ef,
+ "bigcup;":0x22c3, "bigodot;":0x2a00,
+ "bigoplus;":0x2a01, "bigotimes;":0x2a02,
+ "bigsqcup;":0x2a06, "bigstar;":0x2605,
+ "bigtriangledown;":0x25bd, "bigtriangleup;":0x25b3,
+ "biguplus;":0x2a04, "bigvee;":0x22c1,
+ "bigwedge;":0x22c0, "bkarow;":0x290d,
+ "blacklozenge;":0x29eb, "blacksquare;":0x25aa,
+ "blacktriangle;":0x25b4, "blacktriangledown;":0x25be,
+ "blacktriangleleft;":0x25c2, "blacktriangleright;":0x25b8,
+ "blank;":0x2423, "blk12;":0x2592,
+ "blk14;":0x2591, "blk34;":0x2593,
+ "block;":0x2588, "bne;":[0x3d,0x20e5],
+ "bnequiv;":[0x2261,0x20e5], "bnot;":0x2310,
+ "bopf;":[0xd835,0xdd53], "bot;":0x22a5,
+ "bottom;":0x22a5, "bowtie;":0x22c8,
+ "boxDL;":0x2557, "boxDR;":0x2554,
+ "boxDl;":0x2556, "boxDr;":0x2553,
+ "boxH;":0x2550, "boxHD;":0x2566,
+ "boxHU;":0x2569, "boxHd;":0x2564,
+ "boxHu;":0x2567, "boxUL;":0x255d,
+ "boxUR;":0x255a, "boxUl;":0x255c,
+ "boxUr;":0x2559, "boxV;":0x2551,
+ "boxVH;":0x256c, "boxVL;":0x2563,
+ "boxVR;":0x2560, "boxVh;":0x256b,
+ "boxVl;":0x2562, "boxVr;":0x255f,
+ "boxbox;":0x29c9, "boxdL;":0x2555,
+ "boxdR;":0x2552, "boxdl;":0x2510,
+ "boxdr;":0x250c, "boxh;":0x2500,
+ "boxhD;":0x2565, "boxhU;":0x2568,
+ "boxhd;":0x252c, "boxhu;":0x2534,
+ "boxminus;":0x229f, "boxplus;":0x229e,
+ "boxtimes;":0x22a0, "boxuL;":0x255b,
+ "boxuR;":0x2558, "boxul;":0x2518,
+ "boxur;":0x2514, "boxv;":0x2502,
+ "boxvH;":0x256a, "boxvL;":0x2561,
+ "boxvR;":0x255e, "boxvh;":0x253c,
+ "boxvl;":0x2524, "boxvr;":0x251c,
+ "bprime;":0x2035, "breve;":0x2d8,
+ "brvbar":0xa6, "brvbar;":0xa6,
+ "bscr;":[0xd835,0xdcb7], "bsemi;":0x204f,
+ "bsim;":0x223d, "bsime;":0x22cd,
+ "bsol;":0x5c, "bsolb;":0x29c5,
+ "bsolhsub;":0x27c8, "bull;":0x2022,
+ "bullet;":0x2022, "bump;":0x224e,
+ "bumpE;":0x2aae, "bumpe;":0x224f,
+ "bumpeq;":0x224f, "cacute;":0x107,
+ "cap;":0x2229, "capand;":0x2a44,
+ "capbrcup;":0x2a49, "capcap;":0x2a4b,
+ "capcup;":0x2a47, "capdot;":0x2a40,
+ "caps;":[0x2229,0xfe00], "caret;":0x2041,
+ "caron;":0x2c7, "ccaps;":0x2a4d,
+ "ccaron;":0x10d, "ccedil":0xe7,
+ "ccedil;":0xe7, "ccirc;":0x109,
+ "ccups;":0x2a4c, "ccupssm;":0x2a50,
+ "cdot;":0x10b, "cedil":0xb8,
+ "cedil;":0xb8, "cemptyv;":0x29b2,
+ "cent":0xa2, "cent;":0xa2,
+ "centerdot;":0xb7, "cfr;":[0xd835,0xdd20],
+ "chcy;":0x447, "check;":0x2713,
+ "checkmark;":0x2713, "chi;":0x3c7,
+ "cir;":0x25cb, "cirE;":0x29c3,
+ "circ;":0x2c6, "circeq;":0x2257,
+ "circlearrowleft;":0x21ba, "circlearrowright;":0x21bb,
+ "circledR;":0xae, "circledS;":0x24c8,
+ "circledast;":0x229b, "circledcirc;":0x229a,
+ "circleddash;":0x229d, "cire;":0x2257,
+ "cirfnint;":0x2a10, "cirmid;":0x2aef,
+ "cirscir;":0x29c2, "clubs;":0x2663,
+ "clubsuit;":0x2663, "colon;":0x3a,
+ "colone;":0x2254, "coloneq;":0x2254,
+ "comma;":0x2c, "commat;":0x40,
+ "comp;":0x2201, "compfn;":0x2218,
+ "complement;":0x2201, "complexes;":0x2102,
+ "cong;":0x2245, "congdot;":0x2a6d,
+ "conint;":0x222e, "copf;":[0xd835,0xdd54],
+ "coprod;":0x2210, "copy":0xa9,
+ "copy;":0xa9, "copysr;":0x2117,
+ "crarr;":0x21b5, "cross;":0x2717,
+ "cscr;":[0xd835,0xdcb8], "csub;":0x2acf,
+ "csube;":0x2ad1, "csup;":0x2ad0,
+ "csupe;":0x2ad2, "ctdot;":0x22ef,
+ "cudarrl;":0x2938, "cudarrr;":0x2935,
+ "cuepr;":0x22de, "cuesc;":0x22df,
+ "cularr;":0x21b6, "cularrp;":0x293d,
+ "cup;":0x222a, "cupbrcap;":0x2a48,
+ "cupcap;":0x2a46, "cupcup;":0x2a4a,
+ "cupdot;":0x228d, "cupor;":0x2a45,
+ "cups;":[0x222a,0xfe00], "curarr;":0x21b7,
+ "curarrm;":0x293c, "curlyeqprec;":0x22de,
+ "curlyeqsucc;":0x22df, "curlyvee;":0x22ce,
+ "curlywedge;":0x22cf, "curren":0xa4,
+ "curren;":0xa4, "curvearrowleft;":0x21b6,
+ "curvearrowright;":0x21b7, "cuvee;":0x22ce,
+ "cuwed;":0x22cf, "cwconint;":0x2232,
+ "cwint;":0x2231, "cylcty;":0x232d,
+ "dArr;":0x21d3, "dHar;":0x2965,
+ "dagger;":0x2020, "daleth;":0x2138,
+ "darr;":0x2193, "dash;":0x2010,
+ "dashv;":0x22a3, "dbkarow;":0x290f,
+ "dblac;":0x2dd, "dcaron;":0x10f,
+ "dcy;":0x434, "dd;":0x2146,
+ "ddagger;":0x2021, "ddarr;":0x21ca,
+ "ddotseq;":0x2a77, "deg":0xb0,
+ "deg;":0xb0, "delta;":0x3b4,
+ "demptyv;":0x29b1, "dfisht;":0x297f,
+ "dfr;":[0xd835,0xdd21], "dharl;":0x21c3,
+ "dharr;":0x21c2, "diam;":0x22c4,
+ "diamond;":0x22c4, "diamondsuit;":0x2666,
+ "diams;":0x2666, "die;":0xa8,
+ "digamma;":0x3dd, "disin;":0x22f2,
+ "div;":0xf7, "divide":0xf7,
+ "divide;":0xf7, "divideontimes;":0x22c7,
+ "divonx;":0x22c7, "djcy;":0x452,
+ "dlcorn;":0x231e, "dlcrop;":0x230d,
+ "dollar;":0x24, "dopf;":[0xd835,0xdd55],
+ "dot;":0x2d9, "doteq;":0x2250,
+ "doteqdot;":0x2251, "dotminus;":0x2238,
+ "dotplus;":0x2214, "dotsquare;":0x22a1,
+ "doublebarwedge;":0x2306, "downarrow;":0x2193,
+ "downdownarrows;":0x21ca, "downharpoonleft;":0x21c3,
+ "downharpoonright;":0x21c2, "drbkarow;":0x2910,
+ "drcorn;":0x231f, "drcrop;":0x230c,
+ "dscr;":[0xd835,0xdcb9], "dscy;":0x455,
+ "dsol;":0x29f6, "dstrok;":0x111,
+ "dtdot;":0x22f1, "dtri;":0x25bf,
+ "dtrif;":0x25be, "duarr;":0x21f5,
+ "duhar;":0x296f, "dwangle;":0x29a6,
+ "dzcy;":0x45f, "dzigrarr;":0x27ff,
+ "eDDot;":0x2a77, "eDot;":0x2251,
+ "eacute":0xe9, "eacute;":0xe9,
+ "easter;":0x2a6e, "ecaron;":0x11b,
+ "ecir;":0x2256, "ecirc":0xea,
+ "ecirc;":0xea, "ecolon;":0x2255,
+ "ecy;":0x44d, "edot;":0x117,
+ "ee;":0x2147, "efDot;":0x2252,
+ "efr;":[0xd835,0xdd22], "eg;":0x2a9a,
+ "egrave":0xe8, "egrave;":0xe8,
+ "egs;":0x2a96, "egsdot;":0x2a98,
+ "el;":0x2a99, "elinters;":0x23e7,
+ "ell;":0x2113, "els;":0x2a95,
+ "elsdot;":0x2a97, "emacr;":0x113,
+ "empty;":0x2205, "emptyset;":0x2205,
+ "emptyv;":0x2205, "emsp13;":0x2004,
+ "emsp14;":0x2005, "emsp;":0x2003,
+ "eng;":0x14b, "ensp;":0x2002,
+ "eogon;":0x119, "eopf;":[0xd835,0xdd56],
+ "epar;":0x22d5, "eparsl;":0x29e3,
+ "eplus;":0x2a71, "epsi;":0x3b5,
+ "epsilon;":0x3b5, "epsiv;":0x3f5,
+ "eqcirc;":0x2256, "eqcolon;":0x2255,
+ "eqsim;":0x2242, "eqslantgtr;":0x2a96,
+ "eqslantless;":0x2a95, "equals;":0x3d,
+ "equest;":0x225f, "equiv;":0x2261,
+ "equivDD;":0x2a78, "eqvparsl;":0x29e5,
+ "erDot;":0x2253, "erarr;":0x2971,
+ "escr;":0x212f, "esdot;":0x2250,
+ "esim;":0x2242, "eta;":0x3b7,
+ "eth":0xf0, "eth;":0xf0,
+ "euml":0xeb, "euml;":0xeb,
+ "euro;":0x20ac, "excl;":0x21,
+ "exist;":0x2203, "expectation;":0x2130,
+ "exponentiale;":0x2147, "fallingdotseq;":0x2252,
+ "fcy;":0x444, "female;":0x2640,
+ "ffilig;":0xfb03, "fflig;":0xfb00,
+ "ffllig;":0xfb04, "ffr;":[0xd835,0xdd23],
+ "filig;":0xfb01, "fjlig;":[0x66,0x6a],
+ "flat;":0x266d, "fllig;":0xfb02,
+ "fltns;":0x25b1, "fnof;":0x192,
+ "fopf;":[0xd835,0xdd57], "forall;":0x2200,
+ "fork;":0x22d4, "forkv;":0x2ad9,
+ "fpartint;":0x2a0d, "frac12":0xbd,
+ "frac12;":0xbd, "frac13;":0x2153,
+ "frac14":0xbc, "frac14;":0xbc,
+ "frac15;":0x2155, "frac16;":0x2159,
+ "frac18;":0x215b, "frac23;":0x2154,
+ "frac25;":0x2156, "frac34":0xbe,
+ "frac34;":0xbe, "frac35;":0x2157,
+ "frac38;":0x215c, "frac45;":0x2158,
+ "frac56;":0x215a, "frac58;":0x215d,
+ "frac78;":0x215e, "frasl;":0x2044,
+ "frown;":0x2322, "fscr;":[0xd835,0xdcbb],
+ "gE;":0x2267, "gEl;":0x2a8c,
+ "gacute;":0x1f5, "gamma;":0x3b3,
+ "gammad;":0x3dd, "gap;":0x2a86,
+ "gbreve;":0x11f, "gcirc;":0x11d,
+ "gcy;":0x433, "gdot;":0x121,
+ "ge;":0x2265, "gel;":0x22db,
+ "geq;":0x2265, "geqq;":0x2267,
+ "geqslant;":0x2a7e, "ges;":0x2a7e,
+ "gescc;":0x2aa9, "gesdot;":0x2a80,
+ "gesdoto;":0x2a82, "gesdotol;":0x2a84,
+ "gesl;":[0x22db,0xfe00], "gesles;":0x2a94,
+ "gfr;":[0xd835,0xdd24], "gg;":0x226b,
+ "ggg;":0x22d9, "gimel;":0x2137,
+ "gjcy;":0x453, "gl;":0x2277,
+ "glE;":0x2a92, "gla;":0x2aa5,
+ "glj;":0x2aa4, "gnE;":0x2269,
+ "gnap;":0x2a8a, "gnapprox;":0x2a8a,
+ "gne;":0x2a88, "gneq;":0x2a88,
+ "gneqq;":0x2269, "gnsim;":0x22e7,
+ "gopf;":[0xd835,0xdd58], "grave;":0x60,
+ "gscr;":0x210a, "gsim;":0x2273,
+ "gsime;":0x2a8e, "gsiml;":0x2a90,
+ "gt":0x3e, "gt;":0x3e,
+ "gtcc;":0x2aa7, "gtcir;":0x2a7a,
+ "gtdot;":0x22d7, "gtlPar;":0x2995,
+ "gtquest;":0x2a7c, "gtrapprox;":0x2a86,
+ "gtrarr;":0x2978, "gtrdot;":0x22d7,
+ "gtreqless;":0x22db, "gtreqqless;":0x2a8c,
+ "gtrless;":0x2277, "gtrsim;":0x2273,
+ "gvertneqq;":[0x2269,0xfe00], "gvnE;":[0x2269,0xfe00],
+ "hArr;":0x21d4, "hairsp;":0x200a,
+ "half;":0xbd, "hamilt;":0x210b,
+ "hardcy;":0x44a, "harr;":0x2194,
+ "harrcir;":0x2948, "harrw;":0x21ad,
+ "hbar;":0x210f, "hcirc;":0x125,
+ "hearts;":0x2665, "heartsuit;":0x2665,
+ "hellip;":0x2026, "hercon;":0x22b9,
+ "hfr;":[0xd835,0xdd25], "hksearow;":0x2925,
+ "hkswarow;":0x2926, "hoarr;":0x21ff,
+ "homtht;":0x223b, "hookleftarrow;":0x21a9,
+ "hookrightarrow;":0x21aa, "hopf;":[0xd835,0xdd59],
+ "horbar;":0x2015, "hscr;":[0xd835,0xdcbd],
+ "hslash;":0x210f, "hstrok;":0x127,
+ "hybull;":0x2043, "hyphen;":0x2010,
+ "iacute":0xed, "iacute;":0xed,
+ "ic;":0x2063, "icirc":0xee,
+ "icirc;":0xee, "icy;":0x438,
+ "iecy;":0x435, "iexcl":0xa1,
+ "iexcl;":0xa1, "iff;":0x21d4,
+ "ifr;":[0xd835,0xdd26], "igrave":0xec,
+ "igrave;":0xec, "ii;":0x2148,
+ "iiiint;":0x2a0c, "iiint;":0x222d,
+ "iinfin;":0x29dc, "iiota;":0x2129,
+ "ijlig;":0x133, "imacr;":0x12b,
+ "image;":0x2111, "imagline;":0x2110,
+ "imagpart;":0x2111, "imath;":0x131,
+ "imof;":0x22b7, "imped;":0x1b5,
+ "in;":0x2208, "incare;":0x2105,
+ "infin;":0x221e, "infintie;":0x29dd,
+ "inodot;":0x131, "int;":0x222b,
+ "intcal;":0x22ba, "integers;":0x2124,
+ "intercal;":0x22ba, "intlarhk;":0x2a17,
+ "intprod;":0x2a3c, "iocy;":0x451,
+ "iogon;":0x12f, "iopf;":[0xd835,0xdd5a],
+ "iota;":0x3b9, "iprod;":0x2a3c,
+ "iquest":0xbf, "iquest;":0xbf,
+ "iscr;":[0xd835,0xdcbe], "isin;":0x2208,
+ "isinE;":0x22f9, "isindot;":0x22f5,
+ "isins;":0x22f4, "isinsv;":0x22f3,
+ "isinv;":0x2208, "it;":0x2062,
+ "itilde;":0x129, "iukcy;":0x456,
+ "iuml":0xef, "iuml;":0xef,
+ "jcirc;":0x135, "jcy;":0x439,
+ "jfr;":[0xd835,0xdd27], "jmath;":0x237,
+ "jopf;":[0xd835,0xdd5b], "jscr;":[0xd835,0xdcbf],
+ "jsercy;":0x458, "jukcy;":0x454,
+ "kappa;":0x3ba, "kappav;":0x3f0,
+ "kcedil;":0x137, "kcy;":0x43a,
+ "kfr;":[0xd835,0xdd28], "kgreen;":0x138,
+ "khcy;":0x445, "kjcy;":0x45c,
+ "kopf;":[0xd835,0xdd5c], "kscr;":[0xd835,0xdcc0],
+ "lAarr;":0x21da, "lArr;":0x21d0,
+ "lAtail;":0x291b, "lBarr;":0x290e,
+ "lE;":0x2266, "lEg;":0x2a8b,
+ "lHar;":0x2962, "lacute;":0x13a,
+ "laemptyv;":0x29b4, "lagran;":0x2112,
+ "lambda;":0x3bb, "lang;":0x27e8,
+ "langd;":0x2991, "langle;":0x27e8,
+ "lap;":0x2a85, "laquo":0xab,
+ "laquo;":0xab, "larr;":0x2190,
+ "larrb;":0x21e4, "larrbfs;":0x291f,
+ "larrfs;":0x291d, "larrhk;":0x21a9,
+ "larrlp;":0x21ab, "larrpl;":0x2939,
+ "larrsim;":0x2973, "larrtl;":0x21a2,
+ "lat;":0x2aab, "latail;":0x2919,
+ "late;":0x2aad, "lates;":[0x2aad,0xfe00],
+ "lbarr;":0x290c, "lbbrk;":0x2772,
+ "lbrace;":0x7b, "lbrack;":0x5b,
+ "lbrke;":0x298b, "lbrksld;":0x298f,
+ "lbrkslu;":0x298d, "lcaron;":0x13e,
+ "lcedil;":0x13c, "lceil;":0x2308,
+ "lcub;":0x7b, "lcy;":0x43b,
+ "ldca;":0x2936, "ldquo;":0x201c,
+ "ldquor;":0x201e, "ldrdhar;":0x2967,
+ "ldrushar;":0x294b, "ldsh;":0x21b2,
+ "le;":0x2264, "leftarrow;":0x2190,
+ "leftarrowtail;":0x21a2, "leftharpoondown;":0x21bd,
+ "leftharpoonup;":0x21bc, "leftleftarrows;":0x21c7,
+ "leftrightarrow;":0x2194, "leftrightarrows;":0x21c6,
+ "leftrightharpoons;":0x21cb, "leftrightsquigarrow;":0x21ad,
+ "leftthreetimes;":0x22cb, "leg;":0x22da,
+ "leq;":0x2264, "leqq;":0x2266,
+ "leqslant;":0x2a7d, "les;":0x2a7d,
+ "lescc;":0x2aa8, "lesdot;":0x2a7f,
+ "lesdoto;":0x2a81, "lesdotor;":0x2a83,
+ "lesg;":[0x22da,0xfe00], "lesges;":0x2a93,
+ "lessapprox;":0x2a85, "lessdot;":0x22d6,
+ "lesseqgtr;":0x22da, "lesseqqgtr;":0x2a8b,
+ "lessgtr;":0x2276, "lesssim;":0x2272,
+ "lfisht;":0x297c, "lfloor;":0x230a,
+ "lfr;":[0xd835,0xdd29], "lg;":0x2276,
+ "lgE;":0x2a91, "lhard;":0x21bd,
+ "lharu;":0x21bc, "lharul;":0x296a,
+ "lhblk;":0x2584, "ljcy;":0x459,
+ "ll;":0x226a, "llarr;":0x21c7,
+ "llcorner;":0x231e, "llhard;":0x296b,
+ "lltri;":0x25fa, "lmidot;":0x140,
+ "lmoust;":0x23b0, "lmoustache;":0x23b0,
+ "lnE;":0x2268, "lnap;":0x2a89,
+ "lnapprox;":0x2a89, "lne;":0x2a87,
+ "lneq;":0x2a87, "lneqq;":0x2268,
+ "lnsim;":0x22e6, "loang;":0x27ec,
+ "loarr;":0x21fd, "lobrk;":0x27e6,
+ "longleftarrow;":0x27f5, "longleftrightarrow;":0x27f7,
+ "longmapsto;":0x27fc, "longrightarrow;":0x27f6,
+ "looparrowleft;":0x21ab, "looparrowright;":0x21ac,
+ "lopar;":0x2985, "lopf;":[0xd835,0xdd5d],
+ "loplus;":0x2a2d, "lotimes;":0x2a34,
+ "lowast;":0x2217, "lowbar;":0x5f,
+ "loz;":0x25ca, "lozenge;":0x25ca,
+ "lozf;":0x29eb, "lpar;":0x28,
+ "lparlt;":0x2993, "lrarr;":0x21c6,
+ "lrcorner;":0x231f, "lrhar;":0x21cb,
+ "lrhard;":0x296d, "lrm;":0x200e,
+ "lrtri;":0x22bf, "lsaquo;":0x2039,
+ "lscr;":[0xd835,0xdcc1], "lsh;":0x21b0,
+ "lsim;":0x2272, "lsime;":0x2a8d,
+ "lsimg;":0x2a8f, "lsqb;":0x5b,
+ "lsquo;":0x2018, "lsquor;":0x201a,
+ "lstrok;":0x142, "lt":0x3c,
+ "lt;":0x3c, "ltcc;":0x2aa6,
+ "ltcir;":0x2a79, "ltdot;":0x22d6,
+ "lthree;":0x22cb, "ltimes;":0x22c9,
+ "ltlarr;":0x2976, "ltquest;":0x2a7b,
+ "ltrPar;":0x2996, "ltri;":0x25c3,
+ "ltrie;":0x22b4, "ltrif;":0x25c2,
+ "lurdshar;":0x294a, "luruhar;":0x2966,
+ "lvertneqq;":[0x2268,0xfe00], "lvnE;":[0x2268,0xfe00],
+ "mDDot;":0x223a, "macr":0xaf,
+ "macr;":0xaf, "male;":0x2642,
+ "malt;":0x2720, "maltese;":0x2720,
+ "map;":0x21a6, "mapsto;":0x21a6,
+ "mapstodown;":0x21a7, "mapstoleft;":0x21a4,
+ "mapstoup;":0x21a5, "marker;":0x25ae,
+ "mcomma;":0x2a29, "mcy;":0x43c,
+ "mdash;":0x2014, "measuredangle;":0x2221,
+ "mfr;":[0xd835,0xdd2a], "mho;":0x2127,
+ "micro":0xb5, "micro;":0xb5,
+ "mid;":0x2223, "midast;":0x2a,
+ "midcir;":0x2af0, "middot":0xb7,
+ "middot;":0xb7, "minus;":0x2212,
+ "minusb;":0x229f, "minusd;":0x2238,
+ "minusdu;":0x2a2a, "mlcp;":0x2adb,
+ "mldr;":0x2026, "mnplus;":0x2213,
+ "models;":0x22a7, "mopf;":[0xd835,0xdd5e],
+ "mp;":0x2213, "mscr;":[0xd835,0xdcc2],
+ "mstpos;":0x223e, "mu;":0x3bc,
+ "multimap;":0x22b8, "mumap;":0x22b8,
+ "nGg;":[0x22d9,0x338], "nGt;":[0x226b,0x20d2],
+ "nGtv;":[0x226b,0x338], "nLeftarrow;":0x21cd,
+ "nLeftrightarrow;":0x21ce, "nLl;":[0x22d8,0x338],
+ "nLt;":[0x226a,0x20d2], "nLtv;":[0x226a,0x338],
+ "nRightarrow;":0x21cf, "nVDash;":0x22af,
+ "nVdash;":0x22ae, "nabla;":0x2207,
+ "nacute;":0x144, "nang;":[0x2220,0x20d2],
+ "nap;":0x2249, "napE;":[0x2a70,0x338],
+ "napid;":[0x224b,0x338], "napos;":0x149,
+ "napprox;":0x2249, "natur;":0x266e,
+ "natural;":0x266e, "naturals;":0x2115,
+ "nbsp":0xa0, "nbsp;":0xa0,
+ "nbump;":[0x224e,0x338], "nbumpe;":[0x224f,0x338],
+ "ncap;":0x2a43, "ncaron;":0x148,
+ "ncedil;":0x146, "ncong;":0x2247,
+ "ncongdot;":[0x2a6d,0x338], "ncup;":0x2a42,
+ "ncy;":0x43d, "ndash;":0x2013,
+ "ne;":0x2260, "neArr;":0x21d7,
+ "nearhk;":0x2924, "nearr;":0x2197,
+ "nearrow;":0x2197, "nedot;":[0x2250,0x338],
+ "nequiv;":0x2262, "nesear;":0x2928,
+ "nesim;":[0x2242,0x338], "nexist;":0x2204,
+ "nexists;":0x2204, "nfr;":[0xd835,0xdd2b],
+ "ngE;":[0x2267,0x338], "nge;":0x2271,
+ "ngeq;":0x2271, "ngeqq;":[0x2267,0x338],
+ "ngeqslant;":[0x2a7e,0x338], "nges;":[0x2a7e,0x338],
+ "ngsim;":0x2275, "ngt;":0x226f,
+ "ngtr;":0x226f, "nhArr;":0x21ce,
+ "nharr;":0x21ae, "nhpar;":0x2af2,
+ "ni;":0x220b, "nis;":0x22fc,
+ "nisd;":0x22fa, "niv;":0x220b,
+ "njcy;":0x45a, "nlArr;":0x21cd,
+ "nlE;":[0x2266,0x338], "nlarr;":0x219a,
+ "nldr;":0x2025, "nle;":0x2270,
+ "nleftarrow;":0x219a, "nleftrightarrow;":0x21ae,
+ "nleq;":0x2270, "nleqq;":[0x2266,0x338],
+ "nleqslant;":[0x2a7d,0x338], "nles;":[0x2a7d,0x338],
+ "nless;":0x226e, "nlsim;":0x2274,
+ "nlt;":0x226e, "nltri;":0x22ea,
+ "nltrie;":0x22ec, "nmid;":0x2224,
+ "nopf;":[0xd835,0xdd5f], "not":0xac,
+ "not;":0xac, "notin;":0x2209,
+ "notinE;":[0x22f9,0x338], "notindot;":[0x22f5,0x338],
+ "notinva;":0x2209, "notinvb;":0x22f7,
+ "notinvc;":0x22f6, "notni;":0x220c,
+ "notniva;":0x220c, "notnivb;":0x22fe,
+ "notnivc;":0x22fd, "npar;":0x2226,
+ "nparallel;":0x2226, "nparsl;":[0x2afd,0x20e5],
+ "npart;":[0x2202,0x338], "npolint;":0x2a14,
+ "npr;":0x2280, "nprcue;":0x22e0,
+ "npre;":[0x2aaf,0x338], "nprec;":0x2280,
+ "npreceq;":[0x2aaf,0x338], "nrArr;":0x21cf,
+ "nrarr;":0x219b, "nrarrc;":[0x2933,0x338],
+ "nrarrw;":[0x219d,0x338], "nrightarrow;":0x219b,
+ "nrtri;":0x22eb, "nrtrie;":0x22ed,
+ "nsc;":0x2281, "nsccue;":0x22e1,
+ "nsce;":[0x2ab0,0x338], "nscr;":[0xd835,0xdcc3],
+ "nshortmid;":0x2224, "nshortparallel;":0x2226,
+ "nsim;":0x2241, "nsime;":0x2244,
+ "nsimeq;":0x2244, "nsmid;":0x2224,
+ "nspar;":0x2226, "nsqsube;":0x22e2,
+ "nsqsupe;":0x22e3, "nsub;":0x2284,
+ "nsubE;":[0x2ac5,0x338], "nsube;":0x2288,
+ "nsubset;":[0x2282,0x20d2], "nsubseteq;":0x2288,
+ "nsubseteqq;":[0x2ac5,0x338], "nsucc;":0x2281,
+ "nsucceq;":[0x2ab0,0x338], "nsup;":0x2285,
+ "nsupE;":[0x2ac6,0x338], "nsupe;":0x2289,
+ "nsupset;":[0x2283,0x20d2], "nsupseteq;":0x2289,
+ "nsupseteqq;":[0x2ac6,0x338], "ntgl;":0x2279,
+ "ntilde":0xf1, "ntilde;":0xf1,
+ "ntlg;":0x2278, "ntriangleleft;":0x22ea,
+ "ntrianglelefteq;":0x22ec, "ntriangleright;":0x22eb,
+ "ntrianglerighteq;":0x22ed, "nu;":0x3bd,
+ "num;":0x23, "numero;":0x2116,
+ "numsp;":0x2007, "nvDash;":0x22ad,
+ "nvHarr;":0x2904, "nvap;":[0x224d,0x20d2],
+ "nvdash;":0x22ac, "nvge;":[0x2265,0x20d2],
+ "nvgt;":[0x3e,0x20d2], "nvinfin;":0x29de,
+ "nvlArr;":0x2902, "nvle;":[0x2264,0x20d2],
+ "nvlt;":[0x3c,0x20d2], "nvltrie;":[0x22b4,0x20d2],
+ "nvrArr;":0x2903, "nvrtrie;":[0x22b5,0x20d2],
+ "nvsim;":[0x223c,0x20d2], "nwArr;":0x21d6,
+ "nwarhk;":0x2923, "nwarr;":0x2196,
+ "nwarrow;":0x2196, "nwnear;":0x2927,
+ "oS;":0x24c8, "oacute":0xf3,
+ "oacute;":0xf3, "oast;":0x229b,
+ "ocir;":0x229a, "ocirc":0xf4,
+ "ocirc;":0xf4, "ocy;":0x43e,
+ "odash;":0x229d, "odblac;":0x151,
+ "odiv;":0x2a38, "odot;":0x2299,
+ "odsold;":0x29bc, "oelig;":0x153,
+ "ofcir;":0x29bf, "ofr;":[0xd835,0xdd2c],
+ "ogon;":0x2db, "ograve":0xf2,
+ "ograve;":0xf2, "ogt;":0x29c1,
+ "ohbar;":0x29b5, "ohm;":0x3a9,
+ "oint;":0x222e, "olarr;":0x21ba,
+ "olcir;":0x29be, "olcross;":0x29bb,
+ "oline;":0x203e, "olt;":0x29c0,
+ "omacr;":0x14d, "omega;":0x3c9,
+ "omicron;":0x3bf, "omid;":0x29b6,
+ "ominus;":0x2296, "oopf;":[0xd835,0xdd60],
+ "opar;":0x29b7, "operp;":0x29b9,
+ "oplus;":0x2295, "or;":0x2228,
+ "orarr;":0x21bb, "ord;":0x2a5d,
+ "order;":0x2134, "orderof;":0x2134,
+ "ordf":0xaa, "ordf;":0xaa,
+ "ordm":0xba, "ordm;":0xba,
+ "origof;":0x22b6, "oror;":0x2a56,
+ "orslope;":0x2a57, "orv;":0x2a5b,
+ "oscr;":0x2134, "oslash":0xf8,
+ "oslash;":0xf8, "osol;":0x2298,
+ "otilde":0xf5, "otilde;":0xf5,
+ "otimes;":0x2297, "otimesas;":0x2a36,
+ "ouml":0xf6, "ouml;":0xf6,
+ "ovbar;":0x233d, "par;":0x2225,
+ "para":0xb6, "para;":0xb6,
+ "parallel;":0x2225, "parsim;":0x2af3,
+ "parsl;":0x2afd, "part;":0x2202,
+ "pcy;":0x43f, "percnt;":0x25,
+ "period;":0x2e, "permil;":0x2030,
+ "perp;":0x22a5, "pertenk;":0x2031,
+ "pfr;":[0xd835,0xdd2d], "phi;":0x3c6,
+ "phiv;":0x3d5, "phmmat;":0x2133,
+ "phone;":0x260e, "pi;":0x3c0,
+ "pitchfork;":0x22d4, "piv;":0x3d6,
+ "planck;":0x210f, "planckh;":0x210e,
+ "plankv;":0x210f, "plus;":0x2b,
+ "plusacir;":0x2a23, "plusb;":0x229e,
+ "pluscir;":0x2a22, "plusdo;":0x2214,
+ "plusdu;":0x2a25, "pluse;":0x2a72,
+ "plusmn":0xb1, "plusmn;":0xb1,
+ "plussim;":0x2a26, "plustwo;":0x2a27,
+ "pm;":0xb1, "pointint;":0x2a15,
+ "popf;":[0xd835,0xdd61], "pound":0xa3,
+ "pound;":0xa3, "pr;":0x227a,
+ "prE;":0x2ab3, "prap;":0x2ab7,
+ "prcue;":0x227c, "pre;":0x2aaf,
+ "prec;":0x227a, "precapprox;":0x2ab7,
+ "preccurlyeq;":0x227c, "preceq;":0x2aaf,
+ "precnapprox;":0x2ab9, "precneqq;":0x2ab5,
+ "precnsim;":0x22e8, "precsim;":0x227e,
+ "prime;":0x2032, "primes;":0x2119,
+ "prnE;":0x2ab5, "prnap;":0x2ab9,
+ "prnsim;":0x22e8, "prod;":0x220f,
+ "profalar;":0x232e, "profline;":0x2312,
+ "profsurf;":0x2313, "prop;":0x221d,
+ "propto;":0x221d, "prsim;":0x227e,
+ "prurel;":0x22b0, "pscr;":[0xd835,0xdcc5],
+ "psi;":0x3c8, "puncsp;":0x2008,
+ "qfr;":[0xd835,0xdd2e], "qint;":0x2a0c,
+ "qopf;":[0xd835,0xdd62], "qprime;":0x2057,
+ "qscr;":[0xd835,0xdcc6], "quaternions;":0x210d,
+ "quatint;":0x2a16, "quest;":0x3f,
+ "questeq;":0x225f, "quot":0x22,
+ "quot;":0x22, "rAarr;":0x21db,
+ "rArr;":0x21d2, "rAtail;":0x291c,
+ "rBarr;":0x290f, "rHar;":0x2964,
+ "race;":[0x223d,0x331], "racute;":0x155,
+ "radic;":0x221a, "raemptyv;":0x29b3,
+ "rang;":0x27e9, "rangd;":0x2992,
+ "range;":0x29a5, "rangle;":0x27e9,
+ "raquo":0xbb, "raquo;":0xbb,
+ "rarr;":0x2192, "rarrap;":0x2975,
+ "rarrb;":0x21e5, "rarrbfs;":0x2920,
+ "rarrc;":0x2933, "rarrfs;":0x291e,
+ "rarrhk;":0x21aa, "rarrlp;":0x21ac,
+ "rarrpl;":0x2945, "rarrsim;":0x2974,
+ "rarrtl;":0x21a3, "rarrw;":0x219d,
+ "ratail;":0x291a, "ratio;":0x2236,
+ "rationals;":0x211a, "rbarr;":0x290d,
+ "rbbrk;":0x2773, "rbrace;":0x7d,
+ "rbrack;":0x5d, "rbrke;":0x298c,
+ "rbrksld;":0x298e, "rbrkslu;":0x2990,
+ "rcaron;":0x159, "rcedil;":0x157,
+ "rceil;":0x2309, "rcub;":0x7d,
+ "rcy;":0x440, "rdca;":0x2937,
+ "rdldhar;":0x2969, "rdquo;":0x201d,
+ "rdquor;":0x201d, "rdsh;":0x21b3,
+ "real;":0x211c, "realine;":0x211b,
+ "realpart;":0x211c, "reals;":0x211d,
+ "rect;":0x25ad, "reg":0xae,
+ "reg;":0xae, "rfisht;":0x297d,
+ "rfloor;":0x230b, "rfr;":[0xd835,0xdd2f],
+ "rhard;":0x21c1, "rharu;":0x21c0,
+ "rharul;":0x296c, "rho;":0x3c1,
+ "rhov;":0x3f1, "rightarrow;":0x2192,
+ "rightarrowtail;":0x21a3, "rightharpoondown;":0x21c1,
+ "rightharpoonup;":0x21c0, "rightleftarrows;":0x21c4,
+ "rightleftharpoons;":0x21cc, "rightrightarrows;":0x21c9,
+ "rightsquigarrow;":0x219d, "rightthreetimes;":0x22cc,
+ "ring;":0x2da, "risingdotseq;":0x2253,
+ "rlarr;":0x21c4, "rlhar;":0x21cc,
+ "rlm;":0x200f, "rmoust;":0x23b1,
+ "rmoustache;":0x23b1, "rnmid;":0x2aee,
+ "roang;":0x27ed, "roarr;":0x21fe,
+ "robrk;":0x27e7, "ropar;":0x2986,
+ "ropf;":[0xd835,0xdd63], "roplus;":0x2a2e,
+ "rotimes;":0x2a35, "rpar;":0x29,
+ "rpargt;":0x2994, "rppolint;":0x2a12,
+ "rrarr;":0x21c9, "rsaquo;":0x203a,
+ "rscr;":[0xd835,0xdcc7], "rsh;":0x21b1,
+ "rsqb;":0x5d, "rsquo;":0x2019,
+ "rsquor;":0x2019, "rthree;":0x22cc,
+ "rtimes;":0x22ca, "rtri;":0x25b9,
+ "rtrie;":0x22b5, "rtrif;":0x25b8,
+ "rtriltri;":0x29ce, "ruluhar;":0x2968,
+ "rx;":0x211e, "sacute;":0x15b,
+ "sbquo;":0x201a, "sc;":0x227b,
+ "scE;":0x2ab4, "scap;":0x2ab8,
+ "scaron;":0x161, "sccue;":0x227d,
+ "sce;":0x2ab0, "scedil;":0x15f,
+ "scirc;":0x15d, "scnE;":0x2ab6,
+ "scnap;":0x2aba, "scnsim;":0x22e9,
+ "scpolint;":0x2a13, "scsim;":0x227f,
+ "scy;":0x441, "sdot;":0x22c5,
+ "sdotb;":0x22a1, "sdote;":0x2a66,
+ "seArr;":0x21d8, "searhk;":0x2925,
+ "searr;":0x2198, "searrow;":0x2198,
+ "sect":0xa7, "sect;":0xa7,
+ "semi;":0x3b, "seswar;":0x2929,
+ "setminus;":0x2216, "setmn;":0x2216,
+ "sext;":0x2736, "sfr;":[0xd835,0xdd30],
+ "sfrown;":0x2322, "sharp;":0x266f,
+ "shchcy;":0x449, "shcy;":0x448,
+ "shortmid;":0x2223, "shortparallel;":0x2225,
+ "shy":0xad, "shy;":0xad,
+ "sigma;":0x3c3, "sigmaf;":0x3c2,
+ "sigmav;":0x3c2, "sim;":0x223c,
+ "simdot;":0x2a6a, "sime;":0x2243,
+ "simeq;":0x2243, "simg;":0x2a9e,
+ "simgE;":0x2aa0, "siml;":0x2a9d,
+ "simlE;":0x2a9f, "simne;":0x2246,
+ "simplus;":0x2a24, "simrarr;":0x2972,
+ "slarr;":0x2190, "smallsetminus;":0x2216,
+ "smashp;":0x2a33, "smeparsl;":0x29e4,
+ "smid;":0x2223, "smile;":0x2323,
+ "smt;":0x2aaa, "smte;":0x2aac,
+ "smtes;":[0x2aac,0xfe00], "softcy;":0x44c,
+ "sol;":0x2f, "solb;":0x29c4,
+ "solbar;":0x233f, "sopf;":[0xd835,0xdd64],
+ "spades;":0x2660, "spadesuit;":0x2660,
+ "spar;":0x2225, "sqcap;":0x2293,
+ "sqcaps;":[0x2293,0xfe00], "sqcup;":0x2294,
+ "sqcups;":[0x2294,0xfe00], "sqsub;":0x228f,
+ "sqsube;":0x2291, "sqsubset;":0x228f,
+ "sqsubseteq;":0x2291, "sqsup;":0x2290,
+ "sqsupe;":0x2292, "sqsupset;":0x2290,
+ "sqsupseteq;":0x2292, "squ;":0x25a1,
+ "square;":0x25a1, "squarf;":0x25aa,
+ "squf;":0x25aa, "srarr;":0x2192,
+ "sscr;":[0xd835,0xdcc8], "ssetmn;":0x2216,
+ "ssmile;":0x2323, "sstarf;":0x22c6,
+ "star;":0x2606, "starf;":0x2605,
+ "straightepsilon;":0x3f5, "straightphi;":0x3d5,
+ "strns;":0xaf, "sub;":0x2282,
+ "subE;":0x2ac5, "subdot;":0x2abd,
+ "sube;":0x2286, "subedot;":0x2ac3,
+ "submult;":0x2ac1, "subnE;":0x2acb,
+ "subne;":0x228a, "subplus;":0x2abf,
+ "subrarr;":0x2979, "subset;":0x2282,
+ "subseteq;":0x2286, "subseteqq;":0x2ac5,
+ "subsetneq;":0x228a, "subsetneqq;":0x2acb,
+ "subsim;":0x2ac7, "subsub;":0x2ad5,
+ "subsup;":0x2ad3, "succ;":0x227b,
+ "succapprox;":0x2ab8, "succcurlyeq;":0x227d,
+ "succeq;":0x2ab0, "succnapprox;":0x2aba,
+ "succneqq;":0x2ab6, "succnsim;":0x22e9,
+ "succsim;":0x227f, "sum;":0x2211,
+ "sung;":0x266a, "sup1":0xb9,
+ "sup1;":0xb9, "sup2":0xb2,
+ "sup2;":0xb2, "sup3":0xb3,
+ "sup3;":0xb3, "sup;":0x2283,
+ "supE;":0x2ac6, "supdot;":0x2abe,
+ "supdsub;":0x2ad8, "supe;":0x2287,
+ "supedot;":0x2ac4, "suphsol;":0x27c9,
+ "suphsub;":0x2ad7, "suplarr;":0x297b,
+ "supmult;":0x2ac2, "supnE;":0x2acc,
+ "supne;":0x228b, "supplus;":0x2ac0,
+ "supset;":0x2283, "supseteq;":0x2287,
+ "supseteqq;":0x2ac6, "supsetneq;":0x228b,
+ "supsetneqq;":0x2acc, "supsim;":0x2ac8,
+ "supsub;":0x2ad4, "supsup;":0x2ad6,
+ "swArr;":0x21d9, "swarhk;":0x2926,
+ "swarr;":0x2199, "swarrow;":0x2199,
+ "swnwar;":0x292a, "szlig":0xdf,
+ "szlig;":0xdf, "target;":0x2316,
+ "tau;":0x3c4, "tbrk;":0x23b4,
+ "tcaron;":0x165, "tcedil;":0x163,
+ "tcy;":0x442, "tdot;":0x20db,
+ "telrec;":0x2315, "tfr;":[0xd835,0xdd31],
+ "there4;":0x2234, "therefore;":0x2234,
+ "theta;":0x3b8, "thetasym;":0x3d1,
+ "thetav;":0x3d1, "thickapprox;":0x2248,
+ "thicksim;":0x223c, "thinsp;":0x2009,
+ "thkap;":0x2248, "thksim;":0x223c,
+ "thorn":0xfe, "thorn;":0xfe,
+ "tilde;":0x2dc, "times":0xd7,
+ "times;":0xd7, "timesb;":0x22a0,
+ "timesbar;":0x2a31, "timesd;":0x2a30,
+ "tint;":0x222d, "toea;":0x2928,
+ "top;":0x22a4, "topbot;":0x2336,
+ "topcir;":0x2af1, "topf;":[0xd835,0xdd65],
+ "topfork;":0x2ada, "tosa;":0x2929,
+ "tprime;":0x2034, "trade;":0x2122,
+ "triangle;":0x25b5, "triangledown;":0x25bf,
+ "triangleleft;":0x25c3, "trianglelefteq;":0x22b4,
+ "triangleq;":0x225c, "triangleright;":0x25b9,
+ "trianglerighteq;":0x22b5, "tridot;":0x25ec,
+ "trie;":0x225c, "triminus;":0x2a3a,
+ "triplus;":0x2a39, "trisb;":0x29cd,
+ "tritime;":0x2a3b, "trpezium;":0x23e2,
+ "tscr;":[0xd835,0xdcc9], "tscy;":0x446,
+ "tshcy;":0x45b, "tstrok;":0x167,
+ "twixt;":0x226c, "twoheadleftarrow;":0x219e,
+ "twoheadrightarrow;":0x21a0, "uArr;":0x21d1,
+ "uHar;":0x2963, "uacute":0xfa,
+ "uacute;":0xfa, "uarr;":0x2191,
+ "ubrcy;":0x45e, "ubreve;":0x16d,
+ "ucirc":0xfb, "ucirc;":0xfb,
+ "ucy;":0x443, "udarr;":0x21c5,
+ "udblac;":0x171, "udhar;":0x296e,
+ "ufisht;":0x297e, "ufr;":[0xd835,0xdd32],
+ "ugrave":0xf9, "ugrave;":0xf9,
+ "uharl;":0x21bf, "uharr;":0x21be,
+ "uhblk;":0x2580, "ulcorn;":0x231c,
+ "ulcorner;":0x231c, "ulcrop;":0x230f,
+ "ultri;":0x25f8, "umacr;":0x16b,
+ "uml":0xa8, "uml;":0xa8,
+ "uogon;":0x173, "uopf;":[0xd835,0xdd66],
+ "uparrow;":0x2191, "updownarrow;":0x2195,
+ "upharpoonleft;":0x21bf, "upharpoonright;":0x21be,
+ "uplus;":0x228e, "upsi;":0x3c5,
+ "upsih;":0x3d2, "upsilon;":0x3c5,
+ "upuparrows;":0x21c8, "urcorn;":0x231d,
+ "urcorner;":0x231d, "urcrop;":0x230e,
+ "uring;":0x16f, "urtri;":0x25f9,
+ "uscr;":[0xd835,0xdcca], "utdot;":0x22f0,
+ "utilde;":0x169, "utri;":0x25b5,
+ "utrif;":0x25b4, "uuarr;":0x21c8,
+ "uuml":0xfc, "uuml;":0xfc,
+ "uwangle;":0x29a7, "vArr;":0x21d5,
+ "vBar;":0x2ae8, "vBarv;":0x2ae9,
+ "vDash;":0x22a8, "vangrt;":0x299c,
+ "varepsilon;":0x3f5, "varkappa;":0x3f0,
+ "varnothing;":0x2205, "varphi;":0x3d5,
+ "varpi;":0x3d6, "varpropto;":0x221d,
+ "varr;":0x2195, "varrho;":0x3f1,
+ "varsigma;":0x3c2, "varsubsetneq;":[0x228a,0xfe00],
+ "varsubsetneqq;":[0x2acb,0xfe00], "varsupsetneq;":[0x228b,0xfe00],
+ "varsupsetneqq;":[0x2acc,0xfe00], "vartheta;":0x3d1,
+ "vartriangleleft;":0x22b2, "vartriangleright;":0x22b3,
+ "vcy;":0x432, "vdash;":0x22a2,
+ "vee;":0x2228, "veebar;":0x22bb,
+ "veeeq;":0x225a, "vellip;":0x22ee,
+ "verbar;":0x7c, "vert;":0x7c,
+ "vfr;":[0xd835,0xdd33], "vltri;":0x22b2,
+ "vnsub;":[0x2282,0x20d2], "vnsup;":[0x2283,0x20d2],
+ "vopf;":[0xd835,0xdd67], "vprop;":0x221d,
+ "vrtri;":0x22b3, "vscr;":[0xd835,0xdccb],
+ "vsubnE;":[0x2acb,0xfe00], "vsubne;":[0x228a,0xfe00],
+ "vsupnE;":[0x2acc,0xfe00], "vsupne;":[0x228b,0xfe00],
+ "vzigzag;":0x299a, "wcirc;":0x175,
+ "wedbar;":0x2a5f, "wedge;":0x2227,
+ "wedgeq;":0x2259, "weierp;":0x2118,
+ "wfr;":[0xd835,0xdd34], "wopf;":[0xd835,0xdd68],
+ "wp;":0x2118, "wr;":0x2240,
+ "wreath;":0x2240, "wscr;":[0xd835,0xdccc],
+ "xcap;":0x22c2, "xcirc;":0x25ef,
+ "xcup;":0x22c3, "xdtri;":0x25bd,
+ "xfr;":[0xd835,0xdd35], "xhArr;":0x27fa,
+ "xharr;":0x27f7, "xi;":0x3be,
+ "xlArr;":0x27f8, "xlarr;":0x27f5,
+ "xmap;":0x27fc, "xnis;":0x22fb,
+ "xodot;":0x2a00, "xopf;":[0xd835,0xdd69],
+ "xoplus;":0x2a01, "xotime;":0x2a02,
+ "xrArr;":0x27f9, "xrarr;":0x27f6,
+ "xscr;":[0xd835,0xdccd], "xsqcup;":0x2a06,
+ "xuplus;":0x2a04, "xutri;":0x25b3,
+ "xvee;":0x22c1, "xwedge;":0x22c0,
+ "yacute":0xfd, "yacute;":0xfd,
+ "yacy;":0x44f, "ycirc;":0x177,
+ "ycy;":0x44b, "yen":0xa5,
+ "yen;":0xa5, "yfr;":[0xd835,0xdd36],
+ "yicy;":0x457, "yopf;":[0xd835,0xdd6a],
+ "yscr;":[0xd835,0xdcce], "yucy;":0x44e,
+ "yuml":0xff, "yuml;":0xff,
+ "zacute;":0x17a, "zcaron;":0x17e,
+ "zcy;":0x437, "zdot;":0x17c,
+ "zeetrf;":0x2128, "zeta;":0x3b6,
+ "zfr;":[0xd835,0xdd37], "zhcy;":0x436,
+ "zigrarr;":0x21dd, "zopf;":[0xd835,0xdd6b],
+ "zscr;":[0xd835,0xdccf], "zwj;":0x200d,
+ "zwnj;":0x200c,
+};
+/*
+ * This regexp is generated with test/tools/update-entities.js
+ * It will always match at least one character -- but note that there
+ * are no entities whose names are a single character long.
+ */
+var NAMEDCHARREF = /(A(?:Elig;?|MP;?|acute;?|breve;|c(?:irc;?|y;)|fr;|grave;?|lpha;|macr;|nd;|o(?:gon;|pf;)|pplyFunction;|ring;?|s(?:cr;|sign;)|tilde;?|uml;?)|B(?:a(?:ckslash;|r(?:v;|wed;))|cy;|e(?:cause;|rnoullis;|ta;)|fr;|opf;|reve;|scr;|umpeq;)|C(?:Hcy;|OPY;?|a(?:cute;|p(?:;|italDifferentialD;)|yleys;)|c(?:aron;|edil;?|irc;|onint;)|dot;|e(?:dilla;|nterDot;)|fr;|hi;|ircle(?:Dot;|Minus;|Plus;|Times;)|lo(?:ckwiseContourIntegral;|seCurly(?:DoubleQuote;|Quote;))|o(?:lon(?:;|e;)|n(?:gruent;|int;|tourIntegral;)|p(?:f;|roduct;)|unterClockwiseContourIntegral;)|ross;|scr;|up(?:;|Cap;))|D(?:D(?:;|otrahd;)|Jcy;|Scy;|Zcy;|a(?:gger;|rr;|shv;)|c(?:aron;|y;)|el(?:;|ta;)|fr;|i(?:a(?:critical(?:Acute;|Do(?:t;|ubleAcute;)|Grave;|Tilde;)|mond;)|fferentialD;)|o(?:pf;|t(?:;|Dot;|Equal;)|uble(?:ContourIntegral;|Do(?:t;|wnArrow;)|L(?:eft(?:Arrow;|RightArrow;|Tee;)|ong(?:Left(?:Arrow;|RightArrow;)|RightArrow;))|Right(?:Arrow;|Tee;)|Up(?:Arrow;|DownArrow;)|VerticalBar;)|wn(?:Arrow(?:;|Bar;|UpArrow;)|Breve;|Left(?:RightVector;|TeeVector;|Vector(?:;|Bar;))|Right(?:TeeVector;|Vector(?:;|Bar;))|Tee(?:;|Arrow;)|arrow;))|s(?:cr;|trok;))|E(?:NG;|TH;?|acute;?|c(?:aron;|irc;?|y;)|dot;|fr;|grave;?|lement;|m(?:acr;|pty(?:SmallSquare;|VerySmallSquare;))|o(?:gon;|pf;)|psilon;|qu(?:al(?:;|Tilde;)|ilibrium;)|s(?:cr;|im;)|ta;|uml;?|x(?:ists;|ponentialE;))|F(?:cy;|fr;|illed(?:SmallSquare;|VerySmallSquare;)|o(?:pf;|rAll;|uriertrf;)|scr;)|G(?:Jcy;|T;?|amma(?:;|d;)|breve;|c(?:edil;|irc;|y;)|dot;|fr;|g;|opf;|reater(?:Equal(?:;|Less;)|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|scr;|t;)|H(?:ARDcy;|a(?:cek;|t;)|circ;|fr;|ilbertSpace;|o(?:pf;|rizontalLine;)|s(?:cr;|trok;)|ump(?:DownHump;|Equal;))|I(?:Ecy;|Jlig;|Ocy;|acute;?|c(?:irc;?|y;)|dot;|fr;|grave;?|m(?:;|a(?:cr;|ginaryI;)|plies;)|n(?:t(?:;|e(?:gral;|rsection;))|visible(?:Comma;|Times;))|o(?:gon;|pf;|ta;)|scr;|tilde;|u(?:kcy;|ml;?))|J(?:c(?:irc;|y;)|fr;|opf;|s(?:cr;|ercy;)|ukcy;)|K(?:Hcy;|Jcy;|appa;|c(?:edil;|y;)|fr;|opf;|scr;)|L(?:Jcy;|T;?|a(?:cute;|mbda;|ng;|placetrf;|rr;)|c(?:aron;|edil;|y;)|e(?:ft(?:A(?:ngleBracket;|rrow(?:;|Bar;|RightArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|Right(?:Arrow;|Vector;)|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;|rightarrow;)|ss(?:EqualGreater;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;))|fr;|l(?:;|eftarrow;)|midot;|o(?:ng(?:Left(?:Arrow;|RightArrow;)|RightArrow;|left(?:arrow;|rightarrow;)|rightarrow;)|pf;|wer(?:LeftArrow;|RightArrow;))|s(?:cr;|h;|trok;)|t;)|M(?:ap;|cy;|e(?:diumSpace;|llintrf;)|fr;|inusPlus;|opf;|scr;|u;)|N(?:Jcy;|acute;|c(?:aron;|edil;|y;)|e(?:gative(?:MediumSpace;|Thi(?:ckSpace;|nSpace;)|VeryThinSpace;)|sted(?:GreaterGreater;|LessLess;)|wLine;)|fr;|o(?:Break;|nBreakingSpace;|pf;|t(?:;|C(?:ongruent;|upCap;)|DoubleVerticalBar;|E(?:lement;|qual(?:;|Tilde;)|xists;)|Greater(?:;|Equal;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|Hump(?:DownHump;|Equal;)|Le(?:ftTriangle(?:;|Bar;|Equal;)|ss(?:;|Equal;|Greater;|Less;|SlantEqual;|Tilde;))|Nested(?:GreaterGreater;|LessLess;)|Precedes(?:;|Equal;|SlantEqual;)|R(?:everseElement;|ightTriangle(?:;|Bar;|Equal;))|S(?:quareSu(?:bset(?:;|Equal;)|perset(?:;|Equal;))|u(?:bset(?:;|Equal;)|cceeds(?:;|Equal;|SlantEqual;|Tilde;)|perset(?:;|Equal;)))|Tilde(?:;|Equal;|FullEqual;|Tilde;)|VerticalBar;))|scr;|tilde;?|u;)|O(?:Elig;|acute;?|c(?:irc;?|y;)|dblac;|fr;|grave;?|m(?:acr;|ega;|icron;)|opf;|penCurly(?:DoubleQuote;|Quote;)|r;|s(?:cr;|lash;?)|ti(?:lde;?|mes;)|uml;?|ver(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;))|P(?:artialD;|cy;|fr;|hi;|i;|lusMinus;|o(?:incareplane;|pf;)|r(?:;|ecedes(?:;|Equal;|SlantEqual;|Tilde;)|ime;|o(?:duct;|portion(?:;|al;)))|s(?:cr;|i;))|Q(?:UOT;?|fr;|opf;|scr;)|R(?:Barr;|EG;?|a(?:cute;|ng;|rr(?:;|tl;))|c(?:aron;|edil;|y;)|e(?:;|verse(?:E(?:lement;|quilibrium;)|UpEquilibrium;))|fr;|ho;|ight(?:A(?:ngleBracket;|rrow(?:;|Bar;|LeftArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Ba
\ No newline at end of file
+
+var NAMEDCHARREF_MAXLEN = 32;
+
+// Regular expression constants used by the tokenizer and parser
+
+// Note that \r is included in all of these regexps because it will need
+// to be converted to LF by the scanChars() function.
+var DBLQUOTEATTRVAL = /[^\r"&\u0000]+/g;
+var SINGLEQUOTEATTRVAL = /[^\r'&\u0000]+/g;
+var UNQUOTEDATTRVAL = /[^\r\t\n\f &>\u0000]+/g;
+var TAGNAME = /[^\r\t\n\f \/>A-Z\u0000]+/g;
+var ATTRNAME = /[^\r\t\n\f \/=>A-Z\u0000]+/g;
+
+var CDATATEXT = /[^\]\r\u0000\uffff]*/g;
+var DATATEXT = /[^&<\r\u0000\uffff]*/g;
+var RAWTEXT = /[^<\r\u0000\uffff]*/g;
+var PLAINTEXT = /[^\r\u0000\uffff]*/g;
+// Since we don't have the 'sticky tag', add '|.' to the end of SIMPLETAG
+// and SIMPLEATTR so that we are guaranteed to always match. This prevents
+// us from scanning past the lastIndex set. (Note that the desired matches
+// are always greater than 1 char long, so longest-match will ensure that .
+// is not matched unless the desired match fails.)
+var SIMPLETAG = /(?:(\/)?([a-z]+)>)|[\s\S]/g;
+var SIMPLEATTR = /(?:([-a-z]+)[ \t\n\f]*=[ \t\n\f]*('[^'&\r\u0000]*'|"[^"&\r\u0000]*"|[^\t\n\r\f "&'\u0000>][^&> \t\n\r\f\u0000]*[ \t\n\f]))|[\s\S]/g;
+
+var NONWS = /[^\x09\x0A\x0C\x0D\x20]/;
+var ALLNONWS = /[^\x09\x0A\x0C\x0D\x20]/g; // like above, with g flag
+var NONWSNONNUL = /[^\x00\x09\x0A\x0C\x0D\x20]/; // don't allow NUL either
+var LEADINGWS = /^[\x09\x0A\x0C\x0D\x20]+/;
+var NULCHARS = /\x00/g;
+
+/***
+ * These are utility functions that don't use any of the parser's
+ * internal state.
+ */
+function buf2str(buf) {
+ var CHUNKSIZE=16384;
+ if (buf.length < CHUNKSIZE) {
+ return String.fromCharCode.apply(String, buf);
+ }
+ // special case for large strings, to avoid busting the stack.
+ var result = '';
+ for (var i = 0; i < buf.length; i += CHUNKSIZE) {
+ result += String.fromCharCode.apply(String, buf.slice(i, i+CHUNKSIZE));
+ }
+ return result;
+}
+
+function str2buf(s) {
+ var result = [];
+ for (var i=0; i<s.length; i++) {
+ result[i] = s.charCodeAt(i);
+ }
+ return result;
+}
+
+// Determine whether the element is a member of the set.
+// The set is an object that maps namespaces to objects. The objects
+// then map local tagnames to the value true if that tag is part of the set
+function isA(elt, set) {
+ if (typeof set === 'string') {
+ // convenience case for testing a particular HTML element
+ return elt.namespaceURI === NAMESPACE.HTML &&
+ elt.localName === set;
+ }
+ var tagnames = set[elt.namespaceURI];
+ return tagnames && tagnames[elt.localName];
+}
+
+function isMathmlTextIntegrationPoint(n) {
+ return isA(n, mathmlTextIntegrationPointSet);
+}
+
+function isHTMLIntegrationPoint(n) {
+ if (isA(n, htmlIntegrationPointSet)) return true;
+ if (n.namespaceURI === NAMESPACE.MATHML &&
+ n.localName === "annotation-xml") {
+ var encoding = n.getAttribute("encoding");
+ if (encoding) encoding = encoding.toLowerCase();
+ if (encoding === "text/html" ||
+ encoding === "application/xhtml+xml")
+ return true;
+ }
+ return false;
+}
+
+function adjustSVGTagName(name) {
+ if (name in svgTagNameAdjustments)
+ return svgTagNameAdjustments[name];
+ else
+ return name;
+}
+
+function adjustSVGAttributes(attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ if (attrs[i][0] in svgAttrAdjustments) {
+ attrs[i][0] = svgAttrAdjustments[attrs[i][0]];
+ }
+ }
+}
+
+function adjustMathMLAttributes(attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ if (attrs[i][0] === "definitionurl") {
+ attrs[i][0] = "definitionURL";
+ break;
+ }
+ }
+}
+
+function adjustForeignAttributes(attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ if (attrs[i][0] in foreignAttributes) {
+ // Attributes with namespaces get a 3rd element:
+ // [Qname, value, namespace]
+ attrs[i].push(foreignAttributes[attrs[i][0]]);
+ }
+ }
+}
+
+// For each attribute in attrs, if elt doesn't have an attribute
+// by that name, add the attribute to elt
+// XXX: I'm ignoring namespaces for now
+function transferAttributes(attrs, elt) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ var name = attrs[i][0], value = attrs[i][1];
+ if (elt.hasAttribute(name)) continue;
+ elt._setAttribute(name, value);
+ }
+}
+
+/***
+ * The ElementStack class
+ */
+HTMLParser.ElementStack = function ElementStack() {
+ this.elements = [];
+ this.top = null; // stack.top is the "current node" in the spec
+};
+
+/*
+// This is for debugging only
+HTMLParser.ElementStack.prototype.toString = function(e) {
+ return "STACK: " +
+ this.elements.map(function(e) {return e.localName;}).join("-");
+}
+*/
+
+HTMLParser.ElementStack.prototype.push = function(e) {
+ this.elements.push(e);
+ this.top = e;
+};
+
+HTMLParser.ElementStack.prototype.pop = function(e) {
+ this.elements.pop();
+ this.top = this.elements[this.elements.length-1];
+};
+
+// Pop elements off the stack up to and including the first
+// element with the specified (HTML) tagname
+HTMLParser.ElementStack.prototype.popTag = function(tag) {
+ for(var i = this.elements.length-1; i > 0; i--) {
+ var e = this.elements[i];
+ if (isA(e, tag)) break;
+ }
+ this.elements.length = i;
+ this.top = this.elements[i-1];
+};
+
+// Pop elements off the stack up to and including the first
+// element that is an instance of the specified type
+HTMLParser.ElementStack.prototype.popElementType = function(type) {
+ for(var i = this.elements.length-1; i > 0; i--) {
+ if (this.elements[i] instanceof type) break;
+ }
+ this.elements.length = i;
+ this.top = this.elements[i-1];
+};
+
+// Pop elements off the stack up to and including the element e.
+// Note that this is very different from removeElement()
+// This requires that e is on the stack.
+HTMLParser.ElementStack.prototype.popElement = function(e) {
+ for(var i = this.elements.length-1; i > 0; i--) {
+ if (this.elements[i] === e) break;
+ }
+ this.elements.length = i;
+ this.top = this.elements[i-1];
+};
+
+// Remove a specific element from the stack.
+// Do nothing if the element is not on the stack
+HTMLParser.ElementStack.prototype.removeElement = function(e) {
+ if (this.top === e) this.pop();
+ else {
+ var idx = this.elements.lastIndexOf(e);
+ if (idx !== -1)
+ this.elements.splice(idx, 1);
+ }
+};
+
+HTMLParser.ElementStack.prototype.clearToContext = function(set) {
+ // Note that we don't loop to 0. Never pop the <html> elt off.
+ for(var i = this.elements.length-1; i > 0; i--) {
+ if (isA(this.elements[i], set)) break;
+ }
+ this.elements.length = i+1;
+ this.top = this.elements[i];
+};
+
+HTMLParser.ElementStack.prototype.contains = function(tag) {
+ return this.inSpecificScope(tag, Object.create(null));
+};
+
+HTMLParser.ElementStack.prototype.inSpecificScope = function(tag, set) {
+ for(var i = this.elements.length-1; i >= 0; i--) {
+ var elt = this.elements[i];
+ if (isA(elt, tag)) return true;
+ if (isA(elt, set)) return false;
+ }
+ return false;
+};
+
+// Like the above, but for a specific element, not a tagname
+HTMLParser.ElementStack.prototype.elementInSpecificScope = function(target, set) {
+ for(var i = this.elements.length-1; i >= 0; i--) {
+ var elt = this.elements[i];
+ if (elt === target) return true;
+ if (isA(elt, set)) return false;
+ }
+ return false;
+};
+
+// Like the above, but for an element interface, not a tagname
+HTMLParser.ElementStack.prototype.elementTypeInSpecificScope = function(target, set) {
+ for(var i = this.elements.length-1; i >= 0; i--) {
+ var elt = this.elements[i];
+ if (elt instanceof target) return true;
+ if (isA(elt, set)) return false;
+ }
+ return false;
+};
+
+HTMLParser.ElementStack.prototype.inScope = function(tag) {
+ return this.inSpecificScope(tag, inScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.elementInScope = function(e) {
+ return this.elementInSpecificScope(e, inScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.elementTypeInScope = function(type) {
+ return this.elementTypeInSpecificScope(type, inScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.inButtonScope = function(tag) {
+ return this.inSpecificScope(tag, inButtonScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.inListItemScope = function(tag) {
+ return this.inSpecificScope(tag, inListItemScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.inTableScope = function(tag) {
+ return this.inSpecificScope(tag, inTableScopeSet);
+};
+
+HTMLParser.ElementStack.prototype.inSelectScope = function(tag) {
+ // Can't implement this one with inSpecificScope, since it involves
+ // a set defined by inverting another set. So implement manually.
+ for(var i = this.elements.length-1; i >= 0; i--) {
+ var elt = this.elements[i];
+ if (elt.namespaceURI !== NAMESPACE.HTML) return false;
+ var localname = elt.localName;
+ if (localname === tag) return true;
+ if (localname !== "optgroup" && localname !== "option")
+ return false;
+ }
+ return false;
+};
+
+HTMLParser.ElementStack.prototype.generateImpliedEndTags = function(butnot, thorough) {
+ var endTagSet = thorough ? thoroughImpliedEndTagsSet : impliedEndTagsSet;
+ for(var i = this.elements.length-1; i >= 0; i--) {
+ var e = this.elements[i];
+ if (butnot && isA(e, butnot)) break;
+ if (!isA(this.elements[i], endTagSet)) break;
+ }
+
+ this.elements.length = i+1;
+ this.top = this.elements[i];
+};
+
+/***
+ * The ActiveFormattingElements class
+ */
+HTMLParser.ActiveFormattingElements = function AFE() {
+ this.list = []; // elements
+ this.attrs = []; // attribute tokens for cloning
+};
+
+HTMLParser.ActiveFormattingElements.prototype.MARKER = { localName: "|" };
+
+/*
+// For debugging
+HTMLParser.ActiveFormattingElements.prototype.toString = function() {
+ return "AFE: " +
+ this.list.map(function(e) { return e.localName; }).join("-");
+}
+*/
+
+HTMLParser.ActiveFormattingElements.prototype.insertMarker = function() {
+ this.list.push(this.MARKER);
+ this.attrs.push(this.MARKER);
+};
+
+HTMLParser.ActiveFormattingElements.prototype.push = function(elt, attrs) {
+ // Scan backwards: if there are already 3 copies of this element
+ // before we encounter a marker, then drop the last one
+ var count = 0;
+ for(var i = this.list.length-1; i >= 0; i--) {
+ if (this.list[i] === this.MARKER) break;
+ // equal() is defined below
+ if (equal(elt, this.list[i], this.attrs[i])) {
+ count++;
+ if (count === 3) {
+ this.list.splice(i, 1);
+ this.attrs.splice(i, 1);
+ break;
+ }
+ }
+ }
+
+
+ // Now push the element onto the list
+ this.list.push(elt);
+
+ // Copy the attributes and push those on, too
+ var attrcopy = [];
+ for(var ii = 0; ii < attrs.length; ii++) {
+ attrcopy[ii] = attrs[ii];
+ }
+
+ this.attrs.push(attrcopy);
+
+ // This function defines equality of two elements for the purposes
+ // of the AFE list. Note that it compares the new elements
+ // attributes to the saved array of attributes associated with
+ // the old element because a script could have changed the
+ // old element's set of attributes
+ function equal(newelt, oldelt, oldattrs) {
+ if (newelt.localName !== oldelt.localName) return false;
+ if (newelt._numattrs !== oldattrs.length) return false;
+ for(var i = 0, n = oldattrs.length; i < n; i++) {
+ var oldname = oldattrs[i][0];
+ var oldval = oldattrs[i][1];
+ if (!newelt.hasAttribute(oldname)) return false;
+ if (newelt.getAttribute(oldname) !== oldval) return false;
+ }
+ return true;
+ }
+};
+
+HTMLParser.ActiveFormattingElements.prototype.clearToMarker = function() {
+ for(var i = this.list.length-1; i >= 0; i--) {
+ if (this.list[i] === this.MARKER) break;
+ }
+ if (i < 0) i = 0;
+ this.list.length = i;
+ this.attrs.length = i;
+};
+
+// Find and return the last element with the specified tag between the
+// end of the list and the last marker on the list.
+// Used when parsing <a> in_body_mode()
+HTMLParser.ActiveFormattingElements.prototype.findElementByTag = function(tag) {
+ for(var i = this.list.length-1; i >= 0; i--) {
+ var elt = this.list[i];
+ if (elt === this.MARKER) break;
+ if (elt.localName === tag) return elt;
+ }
+ return null;
+};
+
+HTMLParser.ActiveFormattingElements.prototype.indexOf = function(e) {
+ return this.list.lastIndexOf(e);
+};
+
+// Find the element e in the list and remove it
+// Used when parsing <a> in_body()
+HTMLParser.ActiveFormattingElements.prototype.remove = function(e) {
+ var idx = this.list.lastIndexOf(e);
+ if (idx !== -1) {
+ this.list.splice(idx, 1);
+ this.attrs.splice(idx, 1);
+ }
+};
+
+// Find element a in the list and replace it with element b
+// XXX: Do I need to handle attributes here?
+HTMLParser.ActiveFormattingElements.prototype.replace = function(a, b, attrs) {
+ var idx = this.list.lastIndexOf(a);
+ if (idx !== -1) {
+ this.list[idx] = b;
+ this.attrs[idx] = attrs;
+ }
+};
+
+// Find a in the list and insert b after it
+// This is only used for insert a bookmark object, so the
+// attrs array doesn't really matter
+HTMLParser.ActiveFormattingElements.prototype.insertAfter = function(a,b) {
+ var idx = this.list.lastIndexOf(a);
+ if (idx !== -1) {
+ this.list.splice(idx, 0, b);
+ this.attrs.splice(idx, 0, b);
+ }
+};
+
+
+
+
+/***
+ * This is the parser factory function. It is the return value of
+ * the outer closure that it is defined within. Most of the parser
+ * implementation details are inside this function.
+ */
+function HTMLParser(address, fragmentContext, options) {
+ /***
+ * These are the parser's state variables
+ */
+ // Scanner state
+ var chars = null;
+ var numchars = 0; // Length of chars
+ var nextchar = 0; // Index of next char
+ var input_complete = false; // Becomes true when end() called.
+ var scanner_skip_newline = false; // If previous char was CR
+ var reentrant_invocations = 0;
+ var saved_scanner_state = [];
+ var leftovers = "";
+ var first_batch = true;
+ var paused = 0; // Becomes non-zero while loading scripts
+
+
+ // Tokenizer state
+ var tokenizer = data_state; // Current tokenizer state
+ var return_state;
+ var character_reference_code;
+ var tagnamebuf = "";
+ var lasttagname = ""; // holds the target end tag for text states
+ var tempbuf = [];
+ var attrnamebuf = "";
+ var attrvaluebuf = "";
+ var commentbuf = [];
+ var doctypenamebuf = [];
+ var doctypepublicbuf = [];
+ var doctypesystembuf = [];
+ var attributes = [];
+ var is_end_tag = false;
+
+ // Tree builder state
+ var parser = initial_mode; // Current insertion mode
+ var originalInsertionMode = null; // A saved insertion mode
+ var templateInsertionModes = []; // Stack of template insertion modes.
+ var stack = new HTMLParser.ElementStack(); // Stack of open elements
+ var afe = new HTMLParser.ActiveFormattingElements(); // mis-nested tags
+ var fragment = (fragmentContext!==undefined); // For innerHTML, etc.
+ var head_element_pointer = null;
+ var form_element_pointer = null;
+ var scripting_enabled = true;
+ if (fragmentContext) {
+ scripting_enabled = fragmentContext.ownerDocument._scripting_enabled;
+ }
+ if (options && options.scripting_enabled === false)
+ scripting_enabled = false;
+ var frameset_ok = true;
+ var force_quirks = false;
+ var pending_table_text;
+ var text_integration_mode; // XXX a spec bug workaround?
+
+ // A single run of characters, buffered up to be sent to
+ // the parser as a single string.
+ var textrun = [];
+ var textIncludesNUL = false;
+ var ignore_linefeed = false;
+
+ /***
+ * This is the parser object that will be the return value of this
+ * factory function, which is some 5000 lines below.
+ * Note that the variable "parser" is the current state of the
+ * parser's state machine. This variable "htmlparser" is the
+ * return value and defines the public API of the parser
+ */
+ var htmlparser = {
+ document: function() {
+ return doc;
+ },
+
+ // Convenience function for internal use. Can only be called once,
+ // as it removes the nodes from `doc` to add them to fragment.
+ _asDocumentFragment: function() {
+ var frag = doc.createDocumentFragment();
+ var root = doc.firstChild;
+ while(root.hasChildNodes()) {
+ frag.appendChild(root.firstChild);
+ }
+ return frag;
+ },
+
+ // Internal function used from HTMLScriptElement to pause the
+ // parser while a script is being loaded from the network
+ pause: function() {
+ // print("pausing parser");
+ paused++;
+ },
+
+ // Called when a script finishes loading
+ resume: function() {
+ // print("resuming parser");
+ paused--;
+ // XXX: added this to force a resumption.
+ // Is this the right thing to do?
+ this.parse("");
+ },
+
+ // Parse the HTML text s.
+ // The second argument should be true if there is no more
+ // text to be parsed, and should be false or omitted otherwise.
+ // The second argument must not be set for recursive invocations
+ // from document.write()
+ parse: function(s, end, shouldPauseFunc) {
+ var moreToDo;
+
+ // If we're paused, remember the text to parse, but
+ // don't parse it now.
+ // (Don't invoke shouldPauseFunc because we haven't handled 'end' yet.)
+ if (paused > 0) {
+ leftovers += s;
+ return true; // more to do
+ }
+
+
+ if (reentrant_invocations === 0) {
+ // A normal, top-level invocation
+ if (leftovers) {
+ s = leftovers + s;
+ leftovers = "";
+ }
+
+ // Add a special marker character to the end of
+ // the buffer. If the scanner is at the end of
+ // the buffer and input_complete is set, then this
+ // character will transform into an EOF token.
+ // Having an actual character that represents EOF
+ // in the character buffer makes lookahead regexp
+ // matching work more easily, and this is
+ // important for character references.
+ if (end) {
+ s += "\uFFFF";
+ input_complete = true; // Makes scanChars() send EOF
+ }
+
+ chars = s;
+ numchars = s.length;
+ nextchar = 0;
+
+ if (first_batch) {
+ // We skip a leading Byte Order Mark (\uFEFF)
+ // on first batch of text we're given
+ first_batch = false;
+ if (chars.charCodeAt(0) === 0xFEFF) nextchar = 1;
+ }
+
+ reentrant_invocations++;
+ moreToDo = scanChars(shouldPauseFunc);
+ leftovers = chars.substring(nextchar, numchars);
+ reentrant_invocations--;
+ }
+ else {
+ // This is the re-entrant case, which we have to
+ // handle a little differently.
+ reentrant_invocations++;
+
+ // Save current scanner state
+ saved_scanner_state.push(chars, numchars, nextchar);
+
+ // Set new scanner state
+ chars = s;
+ numchars = s.length;
+ nextchar = 0;
+
+ // Now scan as many of these new chars as we can
+ scanChars();
+ moreToDo = false;
+
+ leftovers = chars.substring(nextchar, numchars);
+
+ // restore old scanner state
+ nextchar = saved_scanner_state.pop();
+ numchars = saved_scanner_state.pop();
+ chars = saved_scanner_state.pop();
+
+ // If there were leftover chars from this invocation
+ // insert them into the pending invocation's buffer
+ // and trim already processed chars at the same time
+ if (leftovers) {
+ chars = leftovers + chars.substring(nextchar);
+ numchars = chars.length;
+ nextchar = 0;
+ leftovers = "";
+ }
+
+ // Decrement the counter
+ reentrant_invocations--;
+ }
+ return moreToDo;
+ }
+ };
+
+
+ // This is the document we'll be building up
+ var doc = new Document(true, address);
+
+ // The document needs to know about the parser, for document.write().
+ // This _parser property will be deleted when we're done parsing.
+ doc._parser = htmlparser;
+
+ // XXX I think that any document we use this parser on should support
+ // scripts. But I may need to configure that through a parser parameter
+ // Only documents with windows ("browsing contexts" to be precise)
+ // allow scripting.
+ doc._scripting_enabled = scripting_enabled;
+
+
+ /***
+ * The actual code of the HTMLParser() factory function begins here.
+ */
+
+ if (fragmentContext) { // for innerHTML parsing
+ if (fragmentContext.ownerDocument._quirks)
+ doc._quirks = true;
+ if (fragmentContext.ownerDocument._limitedQuirks)
+ doc._limitedQuirks = true;
+
+ // Set the initial tokenizer state
+ if (fragmentContext.namespaceURI === NAMESPACE.HTML) {
+ switch(fragmentContext.localName) {
+ case "title":
+ case "textarea":
+ tokenizer = rcdata_state;
+ break;
+ case "style":
+ case "xmp":
+ case "iframe":
+ case "noembed":
+ case "noframes":
+ case "script":
+ case "plaintext":
+ tokenizer = plaintext_state;
+ break;
+ case "noscript":
+ if (scripting_enabled)
+ tokenizer = plaintext_state;
+ }
+ }
+
+ var root = doc.createElement("html");
+ doc._appendChild(root);
+ stack.push(root);
+ if (fragmentContext instanceof impl.HTMLTemplateElement) {
+ templateInsertionModes.push(in_template_mode);
+ }
+ resetInsertionMode();
+
+ for(var e = fragmentContext; e !== null; e = e.parentElement) {
+ if (e instanceof impl.HTMLFormElement) {
+ form_element_pointer = e;
+ break;
+ }
+ }
+ }
+
+ /***
+ * Scanner functions
+ */
+ // Loop through the characters in chars, and pass them one at a time
+ // to the tokenizer FSM. Return when no more characters can be processed
+ // (This may leave 1 or more characters in the buffer: like a CR
+ // waiting to see if the next char is LF, or for states that require
+ // lookahead...)
+ function scanChars(shouldPauseFunc) {
+ var codepoint, s, pattern, eof;
+
+ while(nextchar < numchars) {
+
+ // If we just tokenized a </script> tag, then the paused flag
+ // may have been set to tell us to stop tokenizing while
+ // the script is loading
+ if (paused > 0 || (shouldPauseFunc && shouldPauseFunc())) {
+ return true;
+ }
+
+
+ switch(typeof tokenizer.lookahead) {
+ case 'undefined':
+ codepoint = chars.charCodeAt(nextchar++);
+ if (scanner_skip_newline) {
+ scanner_skip_newline = false;
+ if (codepoint === 0x000A) {
+ nextchar++;
+ continue;
+ }
+ }
+ switch(codepoint) {
+ case 0x000D:
+ // CR always turns into LF, but if the next character
+ // is LF, then that second LF is skipped.
+ if (nextchar < numchars) {
+ if (chars.charCodeAt(nextchar) === 0x000A)
+ nextchar++;
+ }
+ else {
+ // We don't know the next char right now, so we
+ // can't check if it is a LF. So set a flag
+ scanner_skip_newline = true;
+ }
+
+ // In either case, emit a LF
+ tokenizer(0x000A);
+
+ break;
+ case 0xFFFF:
+ if (input_complete && nextchar === numchars) {
+ tokenizer(EOF); // codepoint will be 0xFFFF here
+ break;
+ }
+ /* falls through */
+ default:
+ tokenizer(codepoint);
+ break;
+ }
+ break;
+
+ case 'number':
+ codepoint = chars.charCodeAt(nextchar);
+
+ // The only tokenizer states that require fixed lookahead
+ // only consume alphanum characters, so we don't have
+ // to worry about CR and LF in this case
+
+ // tokenizer wants n chars of lookahead
+ var n = tokenizer.lookahead;
+ var needsString = true;
+ if (n < 0) {
+ needsString = false;
+ n = -n;
+ }
+
+ if (n < numchars - nextchar) {
+ // If we can look ahead that far
+ s = needsString ? chars.substring(nextchar, nextchar+n) : null;
+ eof = false;
+ }
+ else { // if we don't have that many characters
+ if (input_complete) { // If no more are coming
+ // Just return what we have
+ s = needsString ? chars.substring(nextchar, numchars) : null;
+ eof = true;
+ if (codepoint === 0xFFFF && nextchar === numchars-1)
+ codepoint = EOF;
+ }
+ else {
+ // Return now and wait for more chars later
+ return true;
+ }
+ }
+ tokenizer(codepoint, s, eof);
+ break;
+ case 'string':
+ codepoint = chars.charCodeAt(nextchar);
+
+ // tokenizer wants characters up to a matching string
+ pattern = tokenizer.lookahead;
+ var pos = chars.indexOf(pattern, nextchar);
+ if (pos !== -1) {
+ s = chars.substring(nextchar, pos + pattern.length);
+ eof = false;
+ }
+ else { // No match
+ // If more characters coming, wait for them
+ if (!input_complete) return true;
+
+ // Otherwise, we've got to return what we've got
+ s = chars.substring(nextchar, numchars);
+ if (codepoint === 0xFFFF && nextchar === numchars-1)
+ codepoint = EOF;
+ eof = true;
+ }
+
+ // The tokenizer states that require this kind of
+ // lookahead have to be careful to handle CR characters
+ // correctly
+ tokenizer(codepoint, s, eof);
+ break;
+ }
+ }
+ return false; // no more characters to scan!
+ }
+
+
+ /***
+ * Tokenizer utility functions
+ */
+ function addAttribute(name,value) {
+ // Make sure there isn't already an attribute with this name
+ // If there is, ignore this one.
+ for(var i = 0; i < attributes.length; i++) {
+ if (attributes[i][0] === name) return;
+ }
+
+ if (value !== undefined) {
+ attributes.push([name, value]);
+ }
+ else {
+ attributes.push([name]);
+ }
+ }
+
+ // Shortcut for simple attributes
+ function handleSimpleAttribute() {
+ SIMPLEATTR.lastIndex = nextchar-1;
+ var matched = SIMPLEATTR.exec(chars);
+ if (!matched) throw new Error("should never happen");
+ var name = matched[1];
+ if (!name) return false;
+ var value = matched[2];
+ var len = value.length;
+ switch(value[0]) {
+ case '"':
+ case "'":
+ value = value.substring(1, len-1);
+ nextchar += (matched[0].length-1);
+ tokenizer = after_attribute_value_quoted_state;
+ break;
+ default:
+ tokenizer = before_attribute_name_state;
+ nextchar += (matched[0].length-1);
+ value = value.substring(0, len-1);
+ break;
+ }
+
+ // Make sure there isn't already an attribute with this name
+ // If there is, ignore this one.
+ for(var i = 0; i < attributes.length; i++) {
+ if (attributes[i][0] === name) return true;
+ }
+
+ attributes.push([name, value]);
+ return true;
+ }
+
+ function beginTagName() {
+ is_end_tag = false;
+ tagnamebuf = "";
+ attributes.length = 0;
+ }
+ function beginEndTagName() {
+ is_end_tag = true;
+ tagnamebuf = "";
+ attributes.length = 0;
+ }
+
+ function beginTempBuf() { tempbuf.length = 0; }
+ function beginAttrName() { attrnamebuf = ""; }
+ function beginAttrValue() { attrvaluebuf = ""; }
+ function beginComment() { commentbuf.length = 0; }
+ function beginDoctype() {
+ doctypenamebuf.length = 0;
+ doctypepublicbuf = null;
+ doctypesystembuf = null;
+ }
+ function beginDoctypePublicId() { doctypepublicbuf = []; }
+ function beginDoctypeSystemId() { doctypesystembuf = []; }
+ function forcequirks() { force_quirks = true; }
+ function cdataAllowed() {
+ return stack.top &&
+ stack.top.namespaceURI !== "http://www.w3.org/1999/xhtml";
+ }
+
+ // Return true if the codepoints in the specified buffer match the
+ // characters of lasttagname
+ function appropriateEndTag(buf) {
+ return lasttagname === buf;
+ }
+
+ function flushText() {
+ if (textrun.length > 0) {
+ var s = buf2str(textrun);
+ textrun.length = 0;
+
+ if (ignore_linefeed) {
+ ignore_linefeed = false;
+ if (s[0] === "\n") s = s.substring(1);
+ if (s.length === 0) return;
+ }
+
+ insertToken(TEXT, s);
+ textIncludesNUL = false;
+ }
+ ignore_linefeed = false;
+ }
+
+ // Consume chars matched by the pattern and return them as a string. Starts
+ // matching at the current position, so users should drop the current char
+ // otherwise.
+ function getMatchingChars(pattern) {
+ pattern.lastIndex = nextchar - 1;
+ var match = pattern.exec(chars);
+ if (match && match.index === nextchar - 1) {
+ match = match[0];
+ nextchar += match.length - 1;
+ /* Careful! Make sure we haven't matched the EOF character! */
+ if (input_complete && nextchar === numchars) {
+ // Oops, backup one.
+ match = match.slice(0, -1);
+ nextchar--;
+ }
+ return match;
+ } else {
+ throw new Error("should never happen");
+ }
+ }
+
+ // emit a string of chars that match a regexp
+ // Returns false if no chars matched.
+ function emitCharsWhile(pattern) {
+ pattern.lastIndex = nextchar-1;
+ var match = pattern.exec(chars)[0];
+ if (!match) return false;
+ emitCharString(match);
+ nextchar += match.length - 1;
+ return true;
+ }
+
+ // This is used by CDATA sections
+ function emitCharString(s) {
+ if (textrun.length > 0) flushText();
+
+ if (ignore_linefeed) {
+ ignore_linefeed = false;
+ if (s[0] === "\n") s = s.substring(1);
+ if (s.length === 0) return;
+ }
+
+ insertToken(TEXT, s);
+ }
+
+ function emitTag() {
+ if (is_end_tag) insertToken(ENDTAG, tagnamebuf);
+ else {
+ // Remember the last open tag we emitted
+ var tagname = tagnamebuf;
+ tagnamebuf = "";
+ lasttagname = tagname;
+ insertToken(TAG, tagname, attributes);
+ }
+ }
+
+
+ // A shortcut: look ahead and if this is a open or close tag
+ // in lowercase with no spaces and no attributes, just emit it now.
+ function emitSimpleTag() {
+ if (nextchar === numchars) { return false; /* not even 1 char left */ }
+ SIMPLETAG.lastIndex = nextchar;
+ var matched = SIMPLETAG.exec(chars);
+ if (!matched) throw new Error("should never happen");
+ var tagname = matched[2];
+ if (!tagname) return false;
+ var endtag = matched[1];
+ if (endtag) {
+ nextchar += (tagname.length+2);
+ insertToken(ENDTAG, tagname);
+ }
+ else {
+ nextchar += (tagname.length+1);
+ lasttagname = tagname;
+ insertToken(TAG, tagname, NOATTRS);
+ }
+ return true;
+ }
+
+ function emitSelfClosingTag() {
+ if (is_end_tag) insertToken(ENDTAG, tagnamebuf, null, true);
+ else {
+ insertToken(TAG, tagnamebuf, attributes, true);
+ }
+ }
+
+ function emitDoctype() {
+ insertToken(DOCTYPE,
+ buf2str(doctypenamebuf),
+ doctypepublicbuf ? buf2str(doctypepublicbuf) : undefined,
+ doctypesystembuf ? buf2str(doctypesystembuf) : undefined);
+ }
+
+ function emitEOF() {
+ flushText();
+ parser(EOF); // EOF never goes to insertForeignContent()
+ doc.modclock = 1; // Start tracking modifications
+ }
+
+ // Insert a token, either using the current parser insertion mode
+ // (for HTML stuff) or using the insertForeignToken() method.
+ var insertToken = htmlparser.insertToken = function insertToken(t, value, arg3, arg4) {
+ flushText();
+ var current = stack.top;
+
+ if (!current || current.namespaceURI === NAMESPACE.HTML) {
+ // This is the common case
+ parser(t, value, arg3, arg4);
+ }
+ else {
+ // Otherwise we may need to insert this token as foreign content
+ if (t !== TAG && t !== TEXT) {
+ insertForeignToken(t, value, arg3, arg4);
+ }
+ else {
+ // But in some cases we treat it as regular content
+ if ((isMathmlTextIntegrationPoint(current) &&
+ (t === TEXT ||
+ (t === TAG &&
+ value !== "mglyph" && value !== "malignmark"))) ||
+ (t === TAG &&
+ value === "svg" &&
+ current.namespaceURI === NAMESPACE.MATHML &&
+ current.localName === "annotation-xml") ||
+ isHTMLIntegrationPoint(current)) {
+
+ // XXX: the text_integration_mode stuff is an
+ // attempted bug workaround of mine
+ text_integration_mode = true;
+ parser(t, value, arg3, arg4);
+ text_integration_mode = false;
+ }
+ // Otherwise it is foreign content
+ else {
+ insertForeignToken(t, value, arg3, arg4);
+ }
+ }
+ }
+ };
+
+
+ /***
+ * Tree building utility functions
+ */
+ function insertComment(data) {
+ var parent = stack.top;
+ if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
+ fosterParent(function(doc) { return doc.createComment(data); });
+ } else {
+ // "If the adjusted insertion location is inside a template element,
+ // let it instead be inside the template element's template contents"
+ if (parent instanceof impl.HTMLTemplateElement) {
+ parent = parent.content;
+ }
+ parent._appendChild(parent.ownerDocument.createComment(data));
+ }
+ }
+
+ function insertText(s) {
+ var parent = stack.top;
+ if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
+ fosterParent(function(doc) { return doc.createTextNode(s); });
+ } else {
+ // "If the adjusted insertion location is inside a template element,
+ // let it instead be inside the template element's template contents"
+ if (parent instanceof impl.HTMLTemplateElement) {
+ parent = parent.content;
+ }
+ // "If there is a Text node immediately before the adjusted insertion
+ // location, then append data to that Text node's data."
+ var lastChild = parent.lastChild;
+ if (lastChild && lastChild.nodeType === Node.TEXT_NODE) {
+ lastChild.appendData(s);
+ } else {
+ parent._appendChild(parent.ownerDocument.createTextNode(s));
+ }
+ }
+ }
+
+ function createHTMLElt(doc, name, attrs) {
+ // Create the element this way, rather than with
+ // doc.createElement because createElement() does error
+ // checking on the element name that we need to avoid here.
+ var elt = html.createElement(doc, name, null);
+
+ if (attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ // Use the _ version to avoid testing the validity
+ // of the attribute name
+ elt._setAttribute(attrs[i][0], attrs[i][1]);
+ }
+ }
+ // XXX
+ // If the element is a resettable form element,
+ // run its reset algorithm now
+ // XXX
+ // handle case where form-element-pointer is not null
+ return elt;
+ }
+
+ // The in_table insertion mode turns on this flag, and that makes
+ // insertHTMLElement use the foster parenting algorithm for elements
+ // tags inside a table
+ var foster_parent_mode = false;
+
+ function insertHTMLElement(name, attrs) {
+ var elt = insertElement(function(doc) {
+ return createHTMLElt(doc, name, attrs);
+ });
+
+ // XXX
+ // If this is a form element, set its form attribute property here
+ if (isA(elt, formassociatedSet)) {
+ elt._form = form_element_pointer;
+ }
+
+ return elt;
+ }
+
+ // Insert the element into the open element or foster parent it
+ function insertElement(eltFunc) {
+ var elt;
+ if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) {
+ elt = fosterParent(eltFunc);
+ }
+ else if (stack.top instanceof impl.HTMLTemplateElement) {
+ // "If the adjusted insertion location is inside a template element,
+ // let it instead be inside the template element's template contents"
+ elt = eltFunc(stack.top.content.ownerDocument);
+ stack.top.content._appendChild(elt);
+ } else {
+ elt = eltFunc(stack.top.ownerDocument);
+ stack.top._appendChild(elt);
+ }
+
+ stack.push(elt);
+ return elt;
+ }
+
+ function insertForeignElement(name, attrs, ns) {
+ return insertElement(function(doc) {
+ // We need to prevent createElementNS from trying to parse `name` as a
+ // `qname`, so use an internal Document#_createElementNS() interface.
+ var elt = doc._createElementNS(name, ns, null);
+ if (attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ var attr = attrs[i];
+ if (attr.length === 2)
+ elt._setAttribute(attr[0], attr[1]);
+ else {
+ elt._setAttributeNS(attr[2], attr[0], attr[1]);
+ }
+ }
+ }
+ return elt;
+ });
+ }
+
+ function lastElementOfType(type) {
+ for(var i = stack.elements.length-1; i >= 0; i--) {
+ if (stack.elements[i] instanceof type) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ function fosterParent(eltFunc) {
+ var parent, before, lastTable = -1, lastTemplate = -1, elt;
+
+ lastTable = lastElementOfType(impl.HTMLTableElement);
+ lastTemplate = lastElementOfType(impl.HTMLTemplateElement);
+
+ if (lastTemplate >= 0 && (lastTable < 0 || lastTemplate > lastTable)) {
+ parent = stack.elements[lastTemplate];
+ } else if (lastTable >= 0) {
+ parent = stack.elements[lastTable].parentNode;
+ if (parent) {
+ before = stack.elements[lastTable];
+ } else {
+ parent = stack.elements[lastTable - 1];
+ }
+ }
+ if (!parent) parent = stack.elements[0]; // the `html` element.
+
+ // "If the adjusted insertion location is inside a template element,
+ // let it instead be inside the template element's template contents"
+ if (parent instanceof impl.HTMLTemplateElement) {
+ parent = parent.content;
+ }
+ // Create element in the appropriate document.
+ elt = eltFunc(parent.ownerDocument);
+
+ if (elt.nodeType === Node.TEXT_NODE) {
+ var prev;
+ if (before) prev = before.previousSibling;
+ else prev = parent.lastChild;
+ if (prev && prev.nodeType === Node.TEXT_NODE) {
+ prev.appendData(elt.data);
+ return elt;
+ }
+ }
+ if (before)
+ parent.insertBefore(elt, before);
+ else
+ parent._appendChild(elt);
+ return elt;
+ }
+
+
+ function resetInsertionMode() {
+ var last = false;
+ for(var i = stack.elements.length-1; i >= 0; i--) {
+ var node = stack.elements[i];
+ if (i === 0) {
+ last = true;
+ if (fragment) {
+ node = fragmentContext;
+ }
+ }
+ if (node.namespaceURI === NAMESPACE.HTML) {
+ var tag = node.localName;
+ switch(tag) {
+ case "select":
+ for(var j = i; j > 0; ) {
+ var ancestor = stack.elements[--j];
+ if (ancestor instanceof impl.HTMLTemplateElement) {
+ break;
+ } else if (ancestor instanceof impl.HTMLTableElement) {
+ parser = in_select_in_table_mode;
+ return;
+ }
+ }
+ parser = in_select_mode;
+ return;
+ case "tr":
+ parser = in_row_mode;
+ return;
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ parser = in_table_body_mode;
+ return;
+ case "caption":
+ parser = in_caption_mode;
+ return;
+ case "colgroup":
+ parser = in_column_group_mode;
+ return;
+ case "table":
+ parser = in_table_mode;
+ return;
+ case "template":
+ parser = templateInsertionModes[templateInsertionModes.length-1];
+ return;
+ case "body":
+ parser = in_body_mode;
+ return;
+ case "frameset":
+ parser = in_frameset_mode;
+ return;
+ case "html":
+ if (head_element_pointer === null) {
+ parser = before_head_mode;
+ } else {
+ parser = after_head_mode;
+ }
+ return;
+ default:
+ if (!last) {
+ if (tag === "head") {
+ parser = in_head_mode;
+ return;
+ }
+ if (tag === "td" || tag === "th") {
+ parser = in_cell_mode;
+ return;
+ }
+ }
+ }
+ }
+ if (last) {
+ parser = in_body_mode;
+ return;
+ }
+ }
+ }
+
+
+ function parseRawText(name, attrs) {
+ insertHTMLElement(name, attrs);
+ tokenizer = rawtext_state;
+ originalInsertionMode = parser;
+ parser = text_mode;
+ }
+
+ function parseRCDATA(name, attrs) {
+ insertHTMLElement(name, attrs);
+ tokenizer = rcdata_state;
+ originalInsertionMode = parser;
+ parser = text_mode;
+ }
+
+ // Make a copy of element i on the list of active formatting
+ // elements, using its original attributes, not current
+ // attributes (which may have been modified by a script)
+ function afeclone(doc, i) {
+ return {
+ elt: createHTMLElt(doc, afe.list[i].localName, afe.attrs[i]),
+ attrs: afe.attrs[i],
+ };
+ }
+
+
+ function afereconstruct() {
+ if (afe.list.length === 0) return;
+ var entry = afe.list[afe.list.length-1];
+ // If the last is a marker , do nothing
+ if (entry === afe.MARKER) return;
+ // Or if it is an open element, do nothing
+ if (stack.elements.lastIndexOf(entry) !== -1) return;
+
+ // Loop backward through the list until we find a marker or an
+ // open element, and then move forward one from there.
+ for(var i = afe.list.length-2; i >= 0; i--) {
+ entry = afe.list[i];
+ if (entry === afe.MARKER) break;
+ if (stack.elements.lastIndexOf(entry) !== -1) break;
+ }
+
+ // Now loop forward, starting from the element after the current
+ // one, recreating formatting elements and pushing them back onto
+ // the list of open elements
+ for(i = i+1; i < afe.list.length; i++) {
+ var newelt = insertElement(function(doc) { return afeclone(doc, i).elt; });
+ afe.list[i] = newelt;
+ }
+ }
+
+ // Used by the adoptionAgency() function
+ var BOOKMARK = {localName:"BM"};
+
+ function adoptionAgency(tag) {
+ // If the current node is an HTML element whose tag name is subject,
+ // and the current node is not in the list of active formatting
+ // elements, then pop the current node off the stack of open
+ // elements and abort these steps.
+ if (isA(stack.top, tag) && afe.indexOf(stack.top) === -1) {
+ stack.pop();
+ return true; // no more handling required
+ }
+
+ // Let outer loop counter be zero.
+ var outer = 0;
+
+ // Outer loop: If outer loop counter is greater than or
+ // equal to eight, then abort these steps.
+ while(outer < 8) {
+ // Increment outer loop counter by one.
+ outer++;
+
+ // Let the formatting element be the last element in the list
+ // of active formatting elements that: is between the end of
+ // the list and the last scope marker in the list, if any, or
+ // the start of the list otherwise, and has the same tag name
+ // as the token.
+ var fmtelt = afe.findElementByTag(tag);
+
+ // If there is no such node, then abort these steps and instead
+ // act as described in the "any other end tag" entry below.
+ if (!fmtelt) {
+ return false; // false means handle by the default case
+ }
+
+ // Otherwise, if there is such a node, but that node is not in
+ // the stack of open elements, then this is a parse error;
+ // remove the element from the list, and abort these steps.
+ var index = stack.elements.lastIndexOf(fmtelt);
+ if (index === -1) {
+ afe.remove(fmtelt);
+ return true; // true means no more handling required
+ }
+
+ // Otherwise, if there is such a node, and that node is also in
+ // the stack of open elements, but the element is not in scope,
+ // then this is a parse error; ignore the token, and abort
+ // these steps.
+ if (!stack.elementInScope(fmtelt)) {
+ return true;
+ }
+
+ // Let the furthest block be the topmost node in the stack of
+ // open elements that is lower in the stack than the formatting
+ // element, and is an element in the special category. There
+ // might not be one.
+ var furthestblock = null, furthestblockindex;
+ for(var i = index+1; i < stack.elements.length; i++) {
+ if (isA(stack.elements[i], specialSet)) {
+ furthestblock = stack.elements[i];
+ furthestblockindex = i;
+ break;
+ }
+ }
+
+ // If there is no furthest block, then the UA must skip the
+ // subsequent steps and instead just pop all the nodes from the
+ // bottom of the stack of open elements, from the current node
+ // up to and including the formatting element, and remove the
+ // formatting element from the list of active formatting
+ // elements.
+ if (!furthestblock) {
+ stack.popElement(fmtelt);
+ afe.remove(fmtelt);
+ return true;
+ }
+ else {
+ // Let the common ancestor be the element immediately above
+ // the formatting element in the stack of open elements.
+ var ancestor = stack.elements[index-1];
+
+ // Let a bookmark note the position of the formatting
+ // element in the list of active formatting elements
+ // relative to the elements on either side of it in the
+ // list.
+ afe.insertAfter(fmtelt, BOOKMARK);
+
+ // Let node and last node be the furthest block.
+ var node = furthestblock;
+ var lastnode = furthestblock;
+ var nodeindex = furthestblockindex;
+ var nodeafeindex;
+
+ // Let inner loop counter be zero.
+ var inner = 0;
+
+ while (true) {
+
+ // Increment inner loop counter by one.
+ inner++;
+
+ // Let node be the element immediately above node in
+ // the stack of open elements, or if node is no longer
+ // in the stack of open elements (e.g. because it got
+ // removed by this algorithm), the element that was
+ // immediately above node in the stack of open elements
+ // before node was removed.
+ node = stack.elements[--nodeindex];
+
+ // If node is the formatting element, then go
+ // to the next step in the overall algorithm.
+ if (node === fmtelt) break;
+
+ // If the inner loop counter is greater than three and node
+ // is in the list of active formatting elements, then remove
+ // node from the list of active formatting elements.
+ nodeafeindex = afe.indexOf(node);
+ if (inner > 3 && nodeafeindex !== -1) {
+ afe.remove(node);
+ nodeafeindex = -1;
+ }
+
+ // If node is not in the list of active formatting
+ // elements, then remove node from the stack of open
+ // elements and then go back to the step labeled inner
+ // loop.
+ if (nodeafeindex === -1) {
+ stack.removeElement(node);
+ continue;
+ }
+
+ // Create an element for the token for which the
+ // element node was created with common ancestor as
+ // the intended parent, replace the entry for node
+ // in the list of active formatting elements with an
+ // entry for the new element, replace the entry for
+ // node in the stack of open elements with an entry for
+ // the new element, and let node be the new element.
+ var newelt = afeclone(ancestor.ownerDocument, nodeafeindex);
+ afe.replace(node, newelt.elt, newelt.attrs);
+ stack.elements[nodeindex] = newelt.elt;
+ node = newelt.elt;
+
+ // If last node is the furthest block, then move the
+ // aforementioned bookmark to be immediately after the
+ // new node in the list of active formatting elements.
+ if (lastnode === furthestblock) {
+ afe.remove(BOOKMARK);
+ afe.insertAfter(newelt.elt, BOOKMARK);
+ }
+
+ // Insert last node into node, first removing it from
+ // its previous parent node if any.
+ node._appendChild(lastnode);
+
+ // Let last node be node.
+ lastnode = node;
+ }
+
+ // If the common ancestor node is a table, tbody, tfoot,
+ // thead, or tr element, then, foster parent whatever last
+ // node ended up being in the previous step, first removing
+ // it from its previous parent node if any.
+ if (foster_parent_mode && isA(ancestor, tablesectionrowSet)) {
+ fosterParent(function() { return lastnode; });
+ }
+ // Otherwise, append whatever last node ended up being in
+ // the previous step to the common ancestor node, first
+ // removing it from its previous parent node if any.
+ else if (ancestor instanceof impl.HTMLTemplateElement) {
+ ancestor.content._appendChild(lastnode);
+ } else {
+ ancestor._appendChild(lastnode);
+ }
+
+ // Create an element for the token for which the
+ // formatting element was created, with furthest block
+ // as the intended parent.
+ var newelt2 = afeclone(furthestblock.ownerDocument, afe.indexOf(fmtelt));
+
+ // Take all of the child nodes of the furthest block and
+ // append them to the element created in the last step.
+ while(furthestblock.hasChildNodes()) {
+ newelt2.elt._appendChild(furthestblock.firstChild);
+ }
+
+ // Append that new element to the furthest block.
+ furthestblock._appendChild(newelt2.elt);
+
+ // Remove the formatting element from the list of active
+ // formatting elements, and insert the new element into the
+ // list of active formatting elements at the position of
+ // the aforementioned bookmark.
+ afe.remove(fmtelt);
+ afe.replace(BOOKMARK, newelt2.elt, newelt2.attrs);
+
+ // Remove the formatting element from the stack of open
+ // elements, and insert the new element into the stack of
+ // open elements immediately below the position of the
+ // furthest block in that stack.
+ stack.removeElement(fmtelt);
+ var pos = stack.elements.lastIndexOf(furthestblock);
+ stack.elements.splice(pos+1, 0, newelt2.elt);
+ }
+ }
+
+ return true;
+ }
+
+ // We do this when we get /script in in_text_mode
+ function handleScriptEnd() {
+ // XXX:
+ // This is just a stub implementation right now and doesn't run scripts.
+ // Getting this method right involves the event loop, URL resolution
+ // script fetching etc. For now I just want to be able to parse
+ // documents and test the parser.
+
+ //var script = stack.top;
+ stack.pop();
+ parser = originalInsertionMode;
+ //script._prepare();
+ return;
+
+ // XXX: here is what this method is supposed to do
+
+ // Provide a stable state.
+
+ // Let script be the current node (which will be a script
+ // element).
+
+ // Pop the current node off the stack of open elements.
+
+ // Switch the insertion mode to the original insertion mode.
+
+ // Let the old insertion point have the same value as the current
+ // insertion point. Let the insertion point be just before the
+ // next input character.
+
+ // Increment the parser's script nesting level by one.
+
+ // Prepare the script. This might cause some script to execute,
+ // which might cause new characters to be inserted into the
+ // tokenizer, and might cause the tokenizer to output more tokens,
+ // resulting in a reentrant invocation of the parser.
+
+ // Decrement the parser's script nesting level by one. If the
+ // parser's script nesting level is zero, then set the parser
+ // pause flag to false.
+
+ // Let the insertion point have the value of the old insertion
+ // point. (In other words, restore the insertion point to its
+ // previous value. This value might be the "undefined" value.)
+
+ // At this stage, if there is a pending parsing-blocking script,
+ // then:
+
+ // If the script nesting level is not zero:
+
+ // Set the parser pause flag to true, and abort the processing
+ // of any nested invocations of the tokenizer, yielding
+ // control back to the caller. (Tokenization will resume when
+ // the caller returns to the "outer" tree construction stage.)
+
+ // The tree construction stage of this particular parser is
+ // being called reentrantly, say from a call to
+ // document.write().
+
+ // Otherwise:
+
+ // Run these steps:
+
+ // Let the script be the pending parsing-blocking
+ // script. There is no longer a pending
+ // parsing-blocking script.
+
+ // Block the tokenizer for this instance of the HTML
+ // parser, such that the event loop will not run tasks
+ // that invoke the tokenizer.
+
+ // If the parser's Document has a style sheet that is
+ // blocking scripts or the script's "ready to be
+ // parser-executed" flag is not set: spin the event
+ // loop until the parser's Document has no style sheet
+ // that is blocking scripts and the script's "ready to
+ // be parser-executed" flag is set.
+
+ // Unblock the tokenizer for this instance of the HTML
+ // parser, such that tasks that invoke the tokenizer
+ // can again be run.
+
+ // Let the insertion point be just before the next
+ // input character.
+
+ // Increment the parser's script nesting level by one
+ // (it should be zero before this step, so this sets
+ // it to one).
+
+ // Execute the script.
+
+ // Decrement the parser's script nesting level by
+ // one. If the parser's script nesting level is zero
+ // (which it always should be at this point), then set
+ // the parser pause flag to false.
+
+ // Let the insertion point be undefined again.
+
+ // If there is once again a pending parsing-blocking
+ // script, then repeat these steps from step 1.
+
+
+ }
+
+ function stopParsing() {
+ // XXX This is just a temporary implementation to get the parser working.
+ // A full implementation involves scripts and events and the event loop.
+
+ // Remove the link from document to parser.
+ // This is instead of "set the insertion point to undefined".
+ // It means that document.write() can't write into the doc anymore.
+ delete doc._parser;
+
+ stack.elements.length = 0; // pop everything off
+
+ // If there is a window object associated with the document
+ // then trigger an load event on it
+ if (doc.defaultView) {
+ doc.defaultView.dispatchEvent(new impl.Event("load",{}));
+ }
+
+ }
+
+ /****
+ * Tokenizer states
+ */
+
+ /**
+ * This file was partially mechanically generated from
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
+ *
+ * After mechanical conversion, it was further converted from
+ * prose to JS by hand, but the intent is that it is a very
+ * faithful rendering of the HTML tokenization spec in
+ * JavaScript.
+ *
+ * It is not a goal of this tokenizer to detect or report
+ * parse errors.
+ *
+ * XXX The tokenizer is supposed to work with straight UTF32
+ * codepoints. But I don't think it has any dependencies on
+ * any character outside of the BMP so I think it is safe to
+ * pass it UTF16 characters. I don't think it will ever change
+ * state in the middle of a surrogate pair.
+ */
+
+ /*
+ * Each state is represented by a function. For most states, the
+ * scanner simply passes the next character (as an integer
+ * codepoint) to the current state function and automatically
+ * consumes the character. If the state function can't process
+ * the character it can call pushback() to push it back to the
+ * scanner.
+ *
+ * Some states require lookahead, though. If a state function has
+ * a lookahead property, then it is invoked differently. In this
+ * case, the scanner invokes the function with 3 arguments: 1) the
+ * next codepoint 2) a string of lookahead text 3) a boolean that
+ * is true if the lookahead goes all the way to the EOF. (XXX
+ * actually maybe this third is not necessary... the lookahead
+ * could just include \uFFFF?)
+ *
+ * If the lookahead property of a state function is an integer, it
+ * specifies the number of characters required. If it is a string,
+ * then the scanner will scan for that string and return all
+ * characters up to and including that sequence, or up to EOF. If
+ * the lookahead property is a regexp, then the scanner will match
+ * the regexp at the current point and return the matching string.
+ *
+ * States that require lookahead are responsible for explicitly
+ * consuming the characters they process. They do this by
+ * incrementing nextchar by the number of processed characters.
+ */
+ function reconsume(c, new_state) {
+ tokenizer = new_state;
+ nextchar--; // pushback
+ }
+
+ function data_state(c) {
+ switch(c) {
+ case 0x0026: // AMPERSAND
+ return_state = data_state;
+ tokenizer = character_reference_state;
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ if (emitSimpleTag()) // Shortcut for <p>, <dl>, </div> etc.
+ break;
+ tokenizer = tag_open_state;
+ break;
+ case 0x0000: // NULL
+ // Usually null characters emitted by the tokenizer will be
+ // ignored by the tree builder, but sometimes they'll be
+ // converted to \uFFFD. I don't want to have the search every
+ // string emitted to replace NULs, so I'll set a flag
+ // if I've emitted a NUL.
+ textrun.push(c);
+ textIncludesNUL = true;
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ // Instead of just pushing a single character and then
+ // coming back to the very same place, lookahead and
+ // emit everything we can at once.
+ /*jshint -W030 */
+ emitCharsWhile(DATATEXT) || textrun.push(c);
+ break;
+ }
+ }
+
+ function rcdata_state(c) {
+ // Save the open tag so we can find a matching close tag
+ switch(c) {
+ case 0x0026: // AMPERSAND
+ return_state = rcdata_state;
+ tokenizer = character_reference_state;
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = rcdata_less_than_sign_state;
+ break;
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ textIncludesNUL = true;
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function rawtext_state(c) {
+ switch(c) {
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = rawtext_less_than_sign_state;
+ break;
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ /*jshint -W030 */
+ emitCharsWhile(RAWTEXT) || textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_state(c) {
+ switch(c) {
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_less_than_sign_state;
+ break;
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ /*jshint -W030 */
+ emitCharsWhile(RAWTEXT) || textrun.push(c);
+ break;
+ }
+ }
+
+ function plaintext_state(c) {
+ switch(c) {
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ /*jshint -W030 */
+ emitCharsWhile(PLAINTEXT) || textrun.push(c);
+ break;
+ }
+ }
+
+ function tag_open_state(c) {
+ switch(c) {
+ case 0x0021: // EXCLAMATION MARK
+ tokenizer = markup_declaration_open_state;
+ break;
+ case 0x002F: // SOLIDUS
+ tokenizer = end_tag_open_state;
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginTagName();
+ reconsume(c, tag_name_state);
+ break;
+ case 0x003F: // QUESTION MARK
+ reconsume(c, bogus_comment_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, data_state);
+ break;
+ }
+ }
+
+ function end_tag_open_state(c) {
+ switch(c) {
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginEndTagName();
+ reconsume(c, tag_name_state);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ break;
+ case -1: // EOF
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ emitEOF();
+ break;
+ default:
+ reconsume(c, bogus_comment_state);
+ break;
+ }
+ }
+
+ function tag_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = before_attribute_name_state;
+ break;
+ case 0x002F: // SOLIDUS
+ tokenizer = self_closing_start_tag_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitTag();
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ tagnamebuf += String.fromCharCode(c + 0x0020);
+ break;
+ case 0x0000: // NULL
+ tagnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ tagnamebuf += getMatchingChars(TAGNAME);
+ break;
+ }
+ }
+
+ function rcdata_less_than_sign_state(c) {
+ /* identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g */
+ if (c === 0x002F) { // SOLIDUS
+ beginTempBuf();
+ tokenizer = rcdata_end_tag_open_state;
+ }
+ else {
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, rcdata_state);
+ }
+ }
+
+ function rcdata_end_tag_open_state(c) {
+ /* identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g */
+ switch(c) {
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginEndTagName();
+ reconsume(c, rcdata_end_tag_name_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ reconsume(c, rcdata_state);
+ break;
+ }
+ }
+
+ function rcdata_end_tag_name_state(c) {
+ /* identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g */
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = before_attribute_name_state;
+ return;
+ }
+ break;
+ case 0x002F: // SOLIDUS
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = self_closing_start_tag_state;
+ return;
+ }
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = data_state;
+ emitTag();
+ return;
+ }
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+
+ tagnamebuf += String.fromCharCode(c + 0x0020);
+ tempbuf.push(c);
+ return;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+
+ tagnamebuf += String.fromCharCode(c);
+ tempbuf.push(c);
+ return;
+ default:
+ break;
+ }
+
+ // If we don't return in one of the cases above, then this was not
+ // an appropriately matching close tag, so back out by emitting all
+ // the characters as text
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ pushAll(textrun, tempbuf);
+ reconsume(c, rcdata_state);
+ }
+
+ function rawtext_less_than_sign_state(c) {
+ /* identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g
+ */
+ if (c === 0x002F) { // SOLIDUS
+ beginTempBuf();
+ tokenizer = rawtext_end_tag_open_state;
+ }
+ else {
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, rawtext_state);
+ }
+ }
+
+ function rawtext_end_tag_open_state(c) {
+ /* identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g */
+ switch(c) {
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginEndTagName();
+ reconsume(c, rawtext_end_tag_name_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ reconsume(c, rawtext_state);
+ break;
+ }
+ }
+
+ function rawtext_end_tag_name_state(c) {
+ /* identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g */
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = before_attribute_name_state;
+ return;
+ }
+ break;
+ case 0x002F: // SOLIDUS
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = self_closing_start_tag_state;
+ return;
+ }
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = data_state;
+ emitTag();
+ return;
+ }
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ tagnamebuf += String.fromCharCode(c + 0x0020);
+ tempbuf.push(c);
+ return;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ tagnamebuf += String.fromCharCode(c);
+ tempbuf.push(c);
+ return;
+ default:
+ break;
+ }
+
+ // If we don't return in one of the cases above, then this was not
+ // an appropriately matching close tag, so back out by emitting all
+ // the characters as text
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ pushAll(textrun,tempbuf);
+ reconsume(c, rawtext_state);
+ }
+
+ function script_data_less_than_sign_state(c) {
+ switch(c) {
+ case 0x002F: // SOLIDUS
+ beginTempBuf();
+ tokenizer = script_data_end_tag_open_state;
+ break;
+ case 0x0021: // EXCLAMATION MARK
+ tokenizer = script_data_escape_start_state;
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x0021); // EXCLAMATION MARK
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, script_data_state);
+ break;
+ }
+ }
+
+ function script_data_end_tag_open_state(c) {
+ /* identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g */
+ switch(c) {
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginEndTagName();
+ reconsume(c, script_data_end_tag_name_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ reconsume(c, script_data_state);
+ break;
+ }
+ }
+
+ function script_data_end_tag_name_state(c) {
+ /* identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g */
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = before_attribute_name_state;
+ return;
+ }
+ break;
+ case 0x002F: // SOLIDUS
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = self_closing_start_tag_state;
+ return;
+ }
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = data_state;
+ emitTag();
+ return;
+ }
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+
+ tagnamebuf += String.fromCharCode(c + 0x0020);
+ tempbuf.push(c);
+ return;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+
+ tagnamebuf += String.fromCharCode(c);
+ tempbuf.push(c);
+ return;
+ default:
+ break;
+ }
+
+ // If we don't return in one of the cases above, then this was not
+ // an appropriately matching close tag, so back out by emitting all
+ // the characters as text
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ pushAll(textrun,tempbuf);
+ reconsume(c, script_data_state);
+ }
+
+ function script_data_escape_start_state(c) {
+ if (c === 0x002D) { // HYPHEN-MINUS
+ tokenizer = script_data_escape_start_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ }
+ else {
+ reconsume(c, script_data_state);
+ }
+ }
+
+ function script_data_escape_start_dash_state(c) {
+ if (c === 0x002D) { // HYPHEN-MINUS
+ tokenizer = script_data_escaped_dash_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ }
+ else {
+ reconsume(c, script_data_state);
+ }
+ }
+
+ function script_data_escaped_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = script_data_escaped_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_escaped_less_than_sign_state;
+ break;
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_escaped_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = script_data_escaped_dash_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_escaped_less_than_sign_state;
+ break;
+ case 0x0000: // NULL
+ tokenizer = script_data_escaped_state;
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ tokenizer = script_data_escaped_state;
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_escaped_dash_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_escaped_less_than_sign_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = script_data_state;
+ textrun.push(0x003E); // GREATER-THAN SIGN
+ break;
+ case 0x0000: // NULL
+ tokenizer = script_data_escaped_state;
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ tokenizer = script_data_escaped_state;
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_escaped_less_than_sign_state(c) {
+ switch(c) {
+ case 0x002F: // SOLIDUS
+ beginTempBuf();
+ tokenizer = script_data_escaped_end_tag_open_state;
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginTempBuf();
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, script_data_double_escape_start_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ reconsume(c, script_data_escaped_state);
+ break;
+ }
+ }
+
+ function script_data_escaped_end_tag_open_state(c) {
+ switch(c) {
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ beginEndTagName();
+ reconsume(c, script_data_escaped_end_tag_name_state);
+ break;
+ default:
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ reconsume(c, script_data_escaped_state);
+ break;
+ }
+ }
+
+ function script_data_escaped_end_tag_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = before_attribute_name_state;
+ return;
+ }
+ break;
+ case 0x002F: // SOLIDUS
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = self_closing_start_tag_state;
+ return;
+ }
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ if (appropriateEndTag(tagnamebuf)) {
+ tokenizer = data_state;
+ emitTag();
+ return;
+ }
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ tagnamebuf += String.fromCharCode(c + 0x0020);
+ tempbuf.push(c);
+ return;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ tagnamebuf += String.fromCharCode(c);
+ tempbuf.push(c);
+ return;
+ default:
+ break;
+ }
+
+ // We get here in the default case, and if the closing tagname
+ // is not an appropriate tagname.
+ textrun.push(0x003C); // LESS-THAN SIGN
+ textrun.push(0x002F); // SOLIDUS
+ pushAll(textrun,tempbuf);
+ reconsume(c, script_data_escaped_state);
+ }
+
+ function script_data_double_escape_start_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ case 0x002F: // SOLIDUS
+ case 0x003E: // GREATER-THAN SIGN
+ if (buf2str(tempbuf) === "script") {
+ tokenizer = script_data_double_escaped_state;
+ }
+ else {
+ tokenizer = script_data_escaped_state;
+ }
+ textrun.push(c);
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ tempbuf.push(c + 0x0020);
+ textrun.push(c);
+ break;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ tempbuf.push(c);
+ textrun.push(c);
+ break;
+ default:
+ reconsume(c, script_data_escaped_state);
+ break;
+ }
+ }
+
+ function script_data_double_escaped_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = script_data_double_escaped_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_double_escaped_less_than_sign_state;
+ textrun.push(0x003C); // LESS-THAN SIGN
+ break;
+ case 0x0000: // NULL
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_double_escaped_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = script_data_double_escaped_dash_dash_state;
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_double_escaped_less_than_sign_state;
+ textrun.push(0x003C); // LESS-THAN SIGN
+ break;
+ case 0x0000: // NULL
+ tokenizer = script_data_double_escaped_state;
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ tokenizer = script_data_double_escaped_state;
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_double_escaped_dash_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ textrun.push(0x002D); // HYPHEN-MINUS
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ tokenizer = script_data_double_escaped_less_than_sign_state;
+ textrun.push(0x003C); // LESS-THAN SIGN
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = script_data_state;
+ textrun.push(0x003E); // GREATER-THAN SIGN
+ break;
+ case 0x0000: // NULL
+ tokenizer = script_data_double_escaped_state;
+ textrun.push(0xFFFD); // REPLACEMENT CHARACTER
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ tokenizer = script_data_double_escaped_state;
+ textrun.push(c);
+ break;
+ }
+ }
+
+ function script_data_double_escaped_less_than_sign_state(c) {
+ if (c === 0x002F) { // SOLIDUS
+ beginTempBuf();
+ tokenizer = script_data_double_escape_end_state;
+ textrun.push(0x002F); // SOLIDUS
+ }
+ else {
+ reconsume(c, script_data_double_escaped_state);
+ }
+ }
+
+ function script_data_double_escape_end_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ case 0x002F: // SOLIDUS
+ case 0x003E: // GREATER-THAN SIGN
+ if (buf2str(tempbuf) === "script") {
+ tokenizer = script_data_escaped_state;
+ }
+ else {
+ tokenizer = script_data_double_escaped_state;
+ }
+ textrun.push(c);
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ tempbuf.push(c + 0x0020);
+ textrun.push(c);
+ break;
+ case 0x0061: // [a-z]
+ case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
+ case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
+ case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
+ case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
+ case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
+ tempbuf.push(c);
+ textrun.push(c);
+ break;
+ default:
+ reconsume(c, script_data_double_escaped_state);
+ break;
+ }
+ }
+
+ function before_attribute_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ // For SOLIDUS, GREATER-THAN SIGN, and EOF, spec says "reconsume in
+ // the after attribute name state", but in our implementation that
+ // state always has an active attribute in attrnamebuf. Just clone
+ // the rules here, without the addAttribute business.
+ case 0x002F: // SOLIDUS
+ tokenizer = self_closing_start_tag_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitTag();
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ case 0x003D: // EQUALS SIGN
+ beginAttrName();
+ attrnamebuf += String.fromCharCode(c);
+ tokenizer = attribute_name_state;
+ break;
+ default:
+ if (handleSimpleAttribute()) break;
+ beginAttrName();
+ reconsume(c, attribute_name_state);
+ break;
+ }
+ }
+
+ // beginAttrName() must have been called before this point
+ // There is an active attribute in attrnamebuf (but not attrvaluebuf)
+ function attribute_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ case 0x002F: // SOLIDUS
+ case 0x003E: // GREATER-THAN SIGN
+ case -1: // EOF
+ reconsume(c, after_attribute_name_state);
+ break;
+ case 0x003D: // EQUALS SIGN
+ tokenizer = before_attribute_value_state;
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ attrnamebuf += String.fromCharCode(c + 0x0020);
+ break;
+ case 0x0000: // NULL
+ attrnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case 0x0022: // QUOTATION MARK
+ case 0x0027: // APOSTROPHE
+ case 0x003C: // LESS-THAN SIGN
+ /* falls through */
+ default:
+ attrnamebuf += getMatchingChars(ATTRNAME);
+ break;
+ }
+ }
+
+ // There is an active attribute in attrnamebuf, but not yet in attrvaluebuf.
+ function after_attribute_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ case 0x002F: // SOLIDUS
+ // Keep in sync with before_attribute_name_state.
+ addAttribute(attrnamebuf);
+ tokenizer = self_closing_start_tag_state;
+ break;
+ case 0x003D: // EQUALS SIGN
+ tokenizer = before_attribute_value_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ // Keep in sync with before_attribute_name_state.
+ tokenizer = data_state;
+ addAttribute(attrnamebuf);
+ emitTag();
+ break;
+ case -1: // EOF
+ // Keep in sync with before_attribute_name_state.
+ addAttribute(attrnamebuf);
+ emitEOF();
+ break;
+ default:
+ addAttribute(attrnamebuf);
+ beginAttrName();
+ reconsume(c, attribute_name_state);
+ break;
+ }
+ }
+
+ function before_attribute_value_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginAttrValue();
+ tokenizer = attribute_value_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginAttrValue();
+ tokenizer = attribute_value_single_quoted_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ /* falls through */
+ default:
+ beginAttrValue();
+ reconsume(c, attribute_value_unquoted_state);
+ break;
+ }
+ }
+
+ function attribute_value_double_quoted_state(c) {
+ switch(c) {
+ case 0x0022: // QUOTATION MARK
+ addAttribute(attrnamebuf, attrvaluebuf);
+ tokenizer = after_attribute_value_quoted_state;
+ break;
+ case 0x0026: // AMPERSAND
+ return_state = attribute_value_double_quoted_state;
+ tokenizer = character_reference_state;
+ break;
+ case 0x0000: // NULL
+ attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ case 0x000A: // LF
+ // this could be a converted \r, so don't use getMatchingChars
+ attrvaluebuf += String.fromCharCode(c);
+ break;
+ default:
+ attrvaluebuf += getMatchingChars(DBLQUOTEATTRVAL);
+ break;
+ }
+ }
+
+ function attribute_value_single_quoted_state(c) {
+ switch(c) {
+ case 0x0027: // APOSTROPHE
+ addAttribute(attrnamebuf, attrvaluebuf);
+ tokenizer = after_attribute_value_quoted_state;
+ break;
+ case 0x0026: // AMPERSAND
+ return_state = attribute_value_single_quoted_state;
+ tokenizer = character_reference_state;
+ break;
+ case 0x0000: // NULL
+ attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ case 0x000A: // LF
+ // this could be a converted \r, so don't use getMatchingChars
+ attrvaluebuf += String.fromCharCode(c);
+ break;
+ default:
+ attrvaluebuf += getMatchingChars(SINGLEQUOTEATTRVAL);
+ break;
+ }
+ }
+
+ function attribute_value_unquoted_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ addAttribute(attrnamebuf, attrvaluebuf);
+ tokenizer = before_attribute_name_state;
+ break;
+ case 0x0026: // AMPERSAND
+ return_state = attribute_value_unquoted_state;
+ tokenizer = character_reference_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ addAttribute(attrnamebuf, attrvaluebuf);
+ tokenizer = data_state;
+ emitTag();
+ break;
+ case 0x0000: // NULL
+ attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ nextchar--; // pushback
+ tokenizer = data_state;
+ break;
+ case 0x0022: // QUOTATION MARK
+ case 0x0027: // APOSTROPHE
+ case 0x003C: // LESS-THAN SIGN
+ case 0x003D: // EQUALS SIGN
+ case 0x0060: // GRAVE ACCENT
+ /* falls through */
+ default:
+ attrvaluebuf += getMatchingChars(UNQUOTEDATTRVAL);
+ break;
+ }
+ }
+
+ function after_attribute_value_quoted_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = before_attribute_name_state;
+ break;
+ case 0x002F: // SOLIDUS
+ tokenizer = self_closing_start_tag_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitTag();
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ reconsume(c, before_attribute_name_state);
+ break;
+ }
+ }
+
+ function self_closing_start_tag_state(c) {
+ switch(c) {
+ case 0x003E: // GREATER-THAN SIGN
+ // Set the <i>self-closing flag</i> of the current tag token.
+ tokenizer = data_state;
+ emitSelfClosingTag(true);
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ default:
+ reconsume(c, before_attribute_name_state);
+ break;
+ }
+ }
+
+ function bogus_comment_state(c, lookahead, eof) {
+ var len = lookahead.length;
+
+ if (eof) {
+ nextchar += len-1; // don't consume the eof
+ }
+ else {
+ nextchar += len;
+ }
+
+ var comment = lookahead.substring(0, len-1);
+
+ comment = comment.replace(/\u0000/g,"\uFFFD");
+ comment = comment.replace(/\u000D\u000A/g,"\u000A");
+ comment = comment.replace(/\u000D/g,"\u000A");
+
+ insertToken(COMMENT, comment);
+ tokenizer = data_state;
+ }
+ bogus_comment_state.lookahead = ">";
+
+ function markup_declaration_open_state(c, lookahead, eof) {
+ if (lookahead[0] === "-" && lookahead[1] === "-") {
+ nextchar += 2;
+ beginComment();
+ tokenizer = comment_start_state;
+ return;
+ }
+
+ if (lookahead.toUpperCase() === "DOCTYPE") {
+ nextchar += 7;
+ tokenizer = doctype_state;
+ }
+ else if (lookahead === "[CDATA[" && cdataAllowed()) {
+ nextchar += 7;
+ tokenizer = cdata_section_state;
+ }
+ else {
+ tokenizer = bogus_comment_state;
+ }
+ }
+ markup_declaration_open_state.lookahead = 7;
+
+ function comment_start_state(c) {
+ beginComment();
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_start_dash_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ insertToken(COMMENT, buf2str(commentbuf));
+ break; /* see comment in comment end state */
+ default:
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_start_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_end_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ insertToken(COMMENT, buf2str(commentbuf));
+ break;
+ case -1: // EOF
+ insertToken(COMMENT, buf2str(commentbuf));
+ emitEOF();
+ break; /* see comment in comment end state */
+ default:
+ commentbuf.push(0x002D /* HYPHEN-MINUS */);
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_state(c) {
+ switch(c) {
+ case 0x003C: // LESS-THAN SIGN
+ commentbuf.push(c);
+ tokenizer = comment_less_than_sign_state;
+ break;
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_end_dash_state;
+ break;
+ case 0x0000: // NULL
+ commentbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ insertToken(COMMENT, buf2str(commentbuf));
+ emitEOF();
+ break; /* see comment in comment end state */
+ default:
+ commentbuf.push(c);
+ break;
+ }
+ }
+
+ function comment_less_than_sign_state(c) {
+ switch(c) {
+ case 0x0021: // EXCLAMATION MARK
+ commentbuf.push(c);
+ tokenizer = comment_less_than_sign_bang_state;
+ break;
+ case 0x003C: // LESS-THAN SIGN
+ commentbuf.push(c);
+ break;
+ default:
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_less_than_sign_bang_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_less_than_sign_bang_dash_state;
+ break;
+ default:
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_less_than_sign_bang_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_less_than_sign_bang_dash_dash_state;
+ break;
+ default:
+ reconsume(c, comment_end_dash_state);
+ break;
+ }
+ }
+
+ function comment_less_than_sign_bang_dash_dash_state(c) {
+ switch(c) {
+ case 0x003E: // GREATER-THAN SIGN
+ case -1: // EOF
+ reconsume(c, comment_end_state);
+ break;
+ default:
+ // parse error
+ reconsume(c, comment_end_state);
+ break;
+ }
+ }
+
+ function comment_end_dash_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ tokenizer = comment_end_state;
+ break;
+ case -1: // EOF
+ insertToken(COMMENT, buf2str(commentbuf));
+ emitEOF();
+ break; /* see comment in comment end state */
+ default:
+ commentbuf.push(0x002D /* HYPHEN-MINUS */);
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_end_state(c) {
+ switch(c) {
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ insertToken(COMMENT, buf2str(commentbuf));
+ break;
+ case 0x0021: // EXCLAMATION MARK
+ tokenizer = comment_end_bang_state;
+ break;
+ case 0x002D: // HYPHEN-MINUS
+ commentbuf.push(0x002D);
+ break;
+ case -1: // EOF
+ insertToken(COMMENT, buf2str(commentbuf));
+ emitEOF();
+ break; /* For security reasons: otherwise, hostile user could put a script in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't read, and then the commented script tag would be treated as live code */
+ default:
+ commentbuf.push(0x002D);
+ commentbuf.push(0x002D);
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function comment_end_bang_state(c) {
+ switch(c) {
+ case 0x002D: // HYPHEN-MINUS
+ commentbuf.push(0x002D);
+ commentbuf.push(0x002D);
+ commentbuf.push(0x0021);
+ tokenizer = comment_end_dash_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ insertToken(COMMENT, buf2str(commentbuf));
+ break;
+ case -1: // EOF
+ insertToken(COMMENT, buf2str(commentbuf));
+ emitEOF();
+ break; /* see comment in comment end state */
+ default:
+ commentbuf.push(0x002D);
+ commentbuf.push(0x002D);
+ commentbuf.push(0x0021);
+ reconsume(c, comment_state);
+ break;
+ }
+ }
+
+ function doctype_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = before_doctype_name_state;
+ break;
+ case -1: // EOF
+ beginDoctype();
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ reconsume(c, before_doctype_name_state);
+ break;
+ }
+ }
+
+ function before_doctype_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ beginDoctype();
+ doctypenamebuf.push(c + 0x0020);
+ tokenizer = doctype_name_state;
+ break;
+ case 0x0000: // NULL
+ beginDoctype();
+ doctypenamebuf.push(0xFFFD);
+ tokenizer = doctype_name_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ beginDoctype();
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ beginDoctype();
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ beginDoctype();
+ doctypenamebuf.push(c);
+ tokenizer = doctype_name_state;
+ break;
+ }
+ }
+
+ function doctype_name_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = after_doctype_name_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case 0x0041: // [A-Z]
+ case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
+ case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
+ case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
+ case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
+ case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
+ doctypenamebuf.push(c + 0x0020);
+ break;
+ case 0x0000: // NULL
+ doctypenamebuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ doctypenamebuf.push(c);
+ break;
+ }
+ }
+
+ function after_doctype_name_state(c, lookahead, eof) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ nextchar += 1;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ nextchar += 1;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ lookahead = lookahead.toUpperCase();
+ if (lookahead === "PUBLIC") {
+ nextchar += 6;
+ tokenizer = after_doctype_public_keyword_state;
+ }
+ else if (lookahead === "SYSTEM") {
+ nextchar += 6;
+ tokenizer = after_doctype_system_keyword_state;
+ }
+ else {
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ }
+ break;
+ }
+ }
+ after_doctype_name_state.lookahead = 6;
+
+ function after_doctype_public_keyword_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = before_doctype_public_identifier_state;
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypePublicId();
+ tokenizer = doctype_public_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypePublicId();
+ tokenizer = doctype_public_identifier_single_quoted_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function before_doctype_public_identifier_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypePublicId();
+ tokenizer = doctype_public_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypePublicId();
+ tokenizer = doctype_public_identifier_single_quoted_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function doctype_public_identifier_double_quoted_state(c) {
+ switch(c) {
+ case 0x0022: // QUOTATION MARK
+ tokenizer = after_doctype_public_identifier_state;
+ break;
+ case 0x0000: // NULL
+ doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ doctypepublicbuf.push(c);
+ break;
+ }
+ }
+
+ function doctype_public_identifier_single_quoted_state(c) {
+ switch(c) {
+ case 0x0027: // APOSTROPHE
+ tokenizer = after_doctype_public_identifier_state;
+ break;
+ case 0x0000: // NULL
+ doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ doctypepublicbuf.push(c);
+ break;
+ }
+ }
+
+ function after_doctype_public_identifier_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = between_doctype_public_and_system_identifiers_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_single_quoted_state;
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function between_doctype_public_and_system_identifiers_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE Ignore the character.
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_single_quoted_state;
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function after_doctype_system_keyword_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ tokenizer = before_doctype_system_identifier_state;
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_single_quoted_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function before_doctype_system_identifier_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE Ignore the character.
+ break;
+ case 0x0022: // QUOTATION MARK
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_double_quoted_state;
+ break;
+ case 0x0027: // APOSTROPHE
+ beginDoctypeSystemId();
+ tokenizer = doctype_system_identifier_single_quoted_state;
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ forcequirks();
+ tokenizer = bogus_doctype_state;
+ break;
+ }
+ }
+
+ function doctype_system_identifier_double_quoted_state(c) {
+ switch(c) {
+ case 0x0022: // QUOTATION MARK
+ tokenizer = after_doctype_system_identifier_state;
+ break;
+ case 0x0000: // NULL
+ doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ doctypesystembuf.push(c);
+ break;
+ }
+ }
+
+ function doctype_system_identifier_single_quoted_state(c) {
+ switch(c) {
+ case 0x0027: // APOSTROPHE
+ tokenizer = after_doctype_system_identifier_state;
+ break;
+ case 0x0000: // NULL
+ doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ forcequirks();
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ doctypesystembuf.push(c);
+ break;
+ }
+ }
+
+ function after_doctype_system_identifier_state(c) {
+ switch(c) {
+ case 0x0009: // CHARACTER TABULATION (tab)
+ case 0x000A: // LINE FEED (LF)
+ case 0x000C: // FORM FEED (FF)
+ case 0x0020: // SPACE
+ /* Ignore the character. */
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ forcequirks();
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ tokenizer = bogus_doctype_state;
+ /* This does *not* set the DOCTYPE token's force-quirks flag. */
+ break;
+ }
+ }
+
+ function bogus_doctype_state(c) {
+ switch(c) {
+ case 0x003E: // GREATER-THAN SIGN
+ tokenizer = data_state;
+ emitDoctype();
+ break;
+ case -1: // EOF
+ emitDoctype();
+ emitEOF();
+ break;
+ default:
+ /* Ignore the character. */
+ break;
+ }
+ }
+
+ function cdata_section_state(c) {
+ switch(c) {
+ case 0x005D: // RIGHT SQUARE BRACKET
+ tokenizer = cdata_section_bracket_state;
+ break;
+ case -1: // EOF
+ emitEOF();
+ break;
+ case 0x0000: // NULL
+ textIncludesNUL = true;
+ /* fall through */
+ default:
+ // Instead of just pushing a single character and then
+ // coming back to the very same place, lookahead and
+ // emit everything we can at once.
+ /*jshint -W030 */
+ emitCharsWhile(CDATATEXT) || textrun.push(c);
+ break;
+ }
+ }
+
+ function cdata_section_bracket_state(c) {
+ switch(c) {
+ case 0x005D: // RIGHT SQUARE BRACKET
+ tokenizer = cdata_section_end_state;
+ break;
+ default:
+ textrun.push(0x005D);
+ reconsume(c, cdata_section_state);
+ break;
+ }
+ }
+
+ function cdata_section_end_state(c) {
+ switch(c) {
+ case 0x005D: // RIGHT SQUARE BRACKET
+ textrun.push(0x005D);
+ break;
+ case 0x003E: // GREATER-THAN SIGN
+ flushText();
+ tokenizer = data_state;
+ break;
+ default:
+ textrun.push(0x005D);
+ textrun.push(0x005D);
+ reconsume(c, cdata_section_state);
+ break;
+ }
+ }
+
+ function character_reference_state(c) {
+ beginTempBuf();
+ tempbuf.push(0x0026);
+ switch(c) {
+ case 0x0009: // TAB
+ case 0x000A: // LINE FEED
+ case 0x000C: // FORM FEED
+ case 0x0020: // SPACE
+ case 0x003C: // LESS-THAN SIGN
+ case 0x0026: // AMPERSAND
+ case -1: // EOF
+ reconsume(c, character_reference_end_state);
+ break;
+ case 0x0023: // NUMBER SIGN
+ tempbuf.push(c);
+ tokenizer = numeric_character_reference_state;
+ break;
+ default:
+ reconsume(c, named_character_reference_state);
+ break;
+ }
+ }
+
+ function named_character_reference_state(c) {
+ NAMEDCHARREF.lastIndex = nextchar; // w/ lookahead no char has been consumed
+ var matched = NAMEDCHARREF.exec(chars);
+ if (!matched) throw new Error("should never happen");
+ var name = matched[1];
+ if (!name) {
+ // If no match can be made, switch to the character reference end state
+ tokenizer = character_reference_end_state;
+ return;
+ }
+
+ // Consume the matched characters and append them to temporary buffer
+ nextchar += name.length;
+ pushAll(tempbuf, str2buf(name));
+
+ switch(return_state) {
+ case attribute_value_double_quoted_state:
+ case attribute_value_single_quoted_state:
+ case attribute_value_unquoted_state:
+ // If the character reference was consumed as part of an attribute...
+ if (name[name.length-1] !== ';') { // ...and the last char is not ;
+ if (/[=A-Za-z0-9]/.test(chars[nextchar])) {
+ tokenizer = character_reference_end_state;
+ return;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ beginTempBuf();
+ var rv = namedCharRefs[name];
+ if (typeof rv === 'number') {
+ tempbuf.push(rv);
+ } else {
+ pushAll(tempbuf, rv);
+ }
+ tokenizer = character_reference_end_state;
+ }
+ // We might need to pause tokenization until we have enough characters
+ // in the buffer for longest possible character reference.
+ named_character_reference_state.lookahead = -NAMEDCHARREF_MAXLEN;
+
+ function numeric_character_reference_state(c) {
+ character_reference_code = 0;
+ switch(c) {
+ case 0x0078: // x
+ case 0x0058: // X
+ tempbuf.push(c);
+ tokenizer = hexadecimal_character_reference_start_state;
+ break;
+ default:
+ reconsume(c, decimal_character_reference_start_state);
+ break;
+ }
+ }
+
+ function hexadecimal_character_reference_start_state(c) {
+ switch(c) {
+ case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
+ case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
+ case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
+ case 0x0046: // [A-F]
+ case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
+ case 0x0066: // [a-f]
+ reconsume(c, hexadecimal_character_reference_state);
+ break;
+ default:
+ reconsume(c, character_reference_end_state);
+ break;
+ }
+ }
+
+ function decimal_character_reference_start_state(c) {
+ switch(c) {
+ case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
+ case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
+ reconsume(c, decimal_character_reference_state);
+ break;
+ default:
+ reconsume(c, character_reference_end_state);
+ break;
+ }
+ }
+
+ function hexadecimal_character_reference_state(c) {
+ switch(c) {
+ case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
+ case 0x0046: // [A-F]
+ character_reference_code *= 16;
+ character_reference_code += (c - 0x0037);
+ break;
+ case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
+ case 0x0066: // [a-f]
+ character_reference_code *= 16;
+ character_reference_code += (c - 0x0057);
+ break;
+ case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
+ case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
+ character_reference_code *= 16;
+ character_reference_code += (c - 0x0030);
+ break;
+ case 0x003B: // SEMICOLON
+ tokenizer = numeric_character_reference_end_state;
+ break;
+ default:
+ reconsume(c, numeric_character_reference_end_state);
+ break;
+ }
+ }
+
+ function decimal_character_reference_state(c) {
+ switch(c) {
+ case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
+ case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
+ character_reference_code *= 10;
+ character_reference_code += (c - 0x0030);
+ break;
+ case 0x003B: // SEMICOLON
+ tokenizer = numeric_character_reference_end_state;
+ break;
+ default:
+ reconsume(c, numeric_character_reference_end_state);
+ break;
+ }
+ }
+
+ function numeric_character_reference_end_state(c) {
+ if (character_reference_code in numericCharRefReplacements) {
+ character_reference_code = numericCharRefReplacements[character_reference_code];
+ } else if (character_reference_code > 0x10FFFF || (character_reference_code >= 0xD800 && character_reference_code < 0xE000)) {
+ character_reference_code = 0xFFFD;
+ }
+
+ beginTempBuf();
+ if (character_reference_code <= 0xFFFF) {
+ tempbuf.push(character_reference_code);
+ } else {
+ character_reference_code = character_reference_code - 0x10000;
+ /* jshint bitwise: false */
+ tempbuf.push(0xD800 + (character_reference_code >> 10));
+ tempbuf.push(0xDC00 + (character_reference_code & 0x03FF));
+ }
+ reconsume(c, character_reference_end_state);
+ }
+
+ function character_reference_end_state(c) {
+ switch(return_state) {
+ case attribute_value_double_quoted_state:
+ case attribute_value_single_quoted_state:
+ case attribute_value_unquoted_state:
+ // append each character to the current attribute's value
+ attrvaluebuf += buf2str(tempbuf);
+ break;
+ default:
+ pushAll(textrun, tempbuf);
+ break;
+ }
+ reconsume(c, return_state);
+ }
+
+ /***
+ * The tree builder insertion modes
+ */
+
+ // 11.2.5.4.1 The "initial" insertion mode
+ function initial_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ value = value.replace(LEADINGWS, ""); // Ignore spaces
+ if (value.length === 0) return; // Are we done?
+ break; // Handle anything non-space text below
+ case 4: // COMMENT
+ doc._appendChild(doc.createComment(value));
+ return;
+ case 5: // DOCTYPE
+ var name = value;
+ var publicid = arg3;
+ var systemid = arg4;
+ // Use the constructor directly instead of
+ // implementation.createDocumentType because the create
+ // function throws errors on invalid characters, and
+ // we don't want the parser to throw them.
+ doc.appendChild(new DocumentType(doc, name, publicid, systemid));
+
+ // Note that there is no public API for setting quirks mode We can
+ // do this here because we have access to implementation details
+ if (force_quirks ||
+ name.toLowerCase() !== "html" ||
+ quirkyPublicIds.test(publicid) ||
+ (systemid && systemid.toLowerCase() === quirkySystemId) ||
+ (systemid === undefined &&
+ conditionallyQuirkyPublicIds.test(publicid)))
+ doc._quirks = true;
+ else if (limitedQuirkyPublicIds.test(publicid) ||
+ (systemid !== undefined &&
+ conditionallyQuirkyPublicIds.test(publicid)))
+ doc._limitedQuirks = true;
+ parser = before_html_mode;
+ return;
+ }
+
+ // tags or non-whitespace text
+ doc._quirks = true;
+ parser = before_html_mode;
+ parser(t,value,arg3,arg4);
+ }
+
+ // 11.2.5.4.2 The "before html" insertion mode
+ function before_html_mode(t,value,arg3,arg4) {
+ var elt;
+ switch(t) {
+ case 1: // TEXT
+ value = value.replace(LEADINGWS, ""); // Ignore spaces
+ if (value.length === 0) return; // Are we done?
+ break; // Handle anything non-space text below
+ case 5: // DOCTYPE
+ /* ignore the token */
+ return;
+ case 4: // COMMENT
+ doc._appendChild(doc.createComment(value));
+ return;
+ case 2: // TAG
+ if (value === "html") {
+ elt = createHTMLElt(doc, value, arg3);
+ stack.push(elt);
+ doc.appendChild(elt);
+ // XXX: handle application cache here
+ parser = before_head_mode;
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "html":
+ case "head":
+ case "body":
+ case "br":
+ break; // fall through on these
+ default:
+ return; // ignore most end tags
+ }
+ }
+
+ // Anything that didn't get handled above is handled like this:
+ elt = createHTMLElt(doc, "html", null);
+ stack.push(elt);
+ doc.appendChild(elt);
+ // XXX: handle application cache here
+ parser = before_head_mode;
+ parser(t,value,arg3,arg4);
+ }
+
+ // 11.2.5.4.3 The "before head" insertion mode
+ function before_head_mode(t,value,arg3,arg4) {
+ switch(t) {
+ case 1: // TEXT
+ value = value.replace(LEADINGWS, ""); // Ignore spaces
+ if (value.length === 0) return; // Are we done?
+ break; // Handle anything non-space text below
+ case 5: // DOCTYPE
+ /* ignore the token */
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t,value,arg3,arg4);
+ return;
+ case "head":
+ var elt = insertHTMLElement(value, arg3);
+ head_element_pointer = elt;
+ parser = in_head_mode;
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "html":
+ case "head":
+ case "body":
+ case "br":
+ break;
+ default:
+ return; // ignore most end tags
+ }
+ }
+
+ // If not handled explicitly above
+ before_head_mode(TAG, "head", null); // create a head tag
+ parser(t, value, arg3, arg4); // then try again with this token
+ }
+
+ function in_head_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ var ws = value.match(LEADINGWS);
+ if (ws) {
+ insertText(ws[0]);
+ value = value.substring(ws[0].length);
+ }
+ if (value.length === 0) return;
+ break; // Handle non-whitespace below
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "meta":
+ // XXX:
+ // May need to change the encoding based on this tag
+ /* falls through */
+ case "base":
+ case "basefont":
+ case "bgsound":
+ case "link":
+ insertHTMLElement(value, arg3);
+ stack.pop();
+ return;
+ case "title":
+ parseRCDATA(value, arg3);
+ return;
+ case "noscript":
+ if (!scripting_enabled) {
+ insertHTMLElement(value, arg3);
+ parser = in_head_noscript_mode;
+ return;
+ }
+ // Otherwise, if scripting is enabled...
+ /* falls through */
+ case "noframes":
+ case "style":
+ parseRawText(value,arg3);
+ return;
+ case "script":
+ insertElement(function(doc) {
+ var elt = createHTMLElt(doc, value, arg3);
+ elt._parser_inserted = true;
+ elt._force_async = false;
+ if (fragment) elt._already_started = true;
+ flushText();
+ return elt;
+ });
+ tokenizer = script_data_state;
+ originalInsertionMode = parser;
+ parser = text_mode;
+ return;
+ case "template":
+ insertHTMLElement(value, arg3);
+ afe.insertMarker();
+ frameset_ok = false;
+ parser = in_template_mode;
+ templateInsertionModes.push(parser);
+ return;
+ case "head":
+ return; // ignore it
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "head":
+ stack.pop();
+ parser = after_head_mode;
+ return;
+ case "body":
+ case "html":
+ case "br":
+ break; // handle these at the bottom of the function
+ case "template":
+ if (!stack.contains("template")) {
+ return;
+ }
+ stack.generateImpliedEndTags(null, "thorough");
+ stack.popTag("template");
+ afe.clearToMarker();
+ templateInsertionModes.pop();
+ resetInsertionMode();
+ return;
+ default:
+ // ignore any other end tag
+ return;
+ }
+ break;
+ }
+
+ // If not handled above
+ in_head_mode(ENDTAG, "head", null); // synthetic </head>
+ parser(t, value, arg3, arg4); // Then redo this one
+ }
+
+ // 13.2.5.4.5 The "in head noscript" insertion mode
+ function in_head_noscript_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 5: // DOCTYPE
+ return;
+ case 4: // COMMENT
+ in_head_mode(t, value);
+ return;
+ case 1: // TEXT
+ var ws = value.match(LEADINGWS);
+ if (ws) {
+ in_head_mode(t, ws[0]);
+ value = value.substring(ws[0].length);
+ }
+ if (value.length === 0) return; // no more text
+ break; // Handle non-whitespace below
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "basefont":
+ case "bgsound":
+ case "link":
+ case "meta":
+ case "noframes":
+ case "style":
+ in_head_mode(t, value, arg3);
+ return;
+ case "head":
+ case "noscript":
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "noscript":
+ stack.pop();
+ parser = in_head_mode;
+ return;
+ case "br":
+ break; // goes to the outer default
+ default:
+ return; // ignore other end tags
+ }
+ break;
+ }
+
+ // If not handled above
+ in_head_noscript_mode(ENDTAG, "noscript", null);
+ parser(t, value, arg3, arg4);
+ }
+
+ function after_head_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ var ws = value.match(LEADINGWS);
+ if (ws) {
+ insertText(ws[0]);
+ value = value.substring(ws[0].length);
+ }
+ if (value.length === 0) return;
+ break; // Handle non-whitespace below
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "body":
+ insertHTMLElement(value, arg3);
+ frameset_ok = false;
+ parser = in_body_mode;
+ return;
+ case "frameset":
+ insertHTMLElement(value, arg3);
+ parser = in_frameset_mode;
+ return;
+ case "base":
+ case "basefont":
+ case "bgsound":
+ case "link":
+ case "meta":
+ case "noframes":
+ case "script":
+ case "style":
+ case "template":
+ case "title":
+ stack.push(head_element_pointer);
+ in_head_mode(TAG, value, arg3);
+ stack.removeElement(head_element_pointer);
+ return;
+ case "head":
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "template":
+ return in_head_mode(t, value, arg3, arg4);
+ case "body":
+ case "html":
+ case "br":
+ break;
+ default:
+ return; // ignore any other end tag
+ }
+ break;
+ }
+
+ after_head_mode(TAG, "body", null);
+ frameset_ok = true;
+ parser(t, value, arg3, arg4);
+ }
+
+ // 13.2.5.4.7 The "in body" insertion mode
+ function in_body_mode(t,value,arg3,arg4) {
+ var body, i, node, elt;
+ switch(t) {
+ case 1: // TEXT
+ if (textIncludesNUL) {
+ value = value.replace(NULCHARS, "");
+ if (value.length === 0) return;
+ }
+ // If any non-space characters
+ if (frameset_ok && NONWS.test(value))
+ frameset_ok = false;
+ afereconstruct();
+ insertText(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case -1: // EOF
+ if (templateInsertionModes.length) {
+ return in_template_mode(t);
+ }
+ stopParsing();
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ if (stack.contains("template")) {
+ return;
+ }
+ transferAttributes(arg3, stack.elements[0]);
+ return;
+ case "base":
+ case "basefont":
+ case "bgsound":
+ case "link":
+ case "meta":
+ case "noframes":
+ case "script":
+ case "style":
+ case "template":
+ case "title":
+ in_head_mode(TAG, value, arg3);
+ return;
+ case "body":
+ body = stack.elements[1];
+ if (!body || !(body instanceof impl.HTMLBodyElement) ||
+ stack.contains("template"))
+ return;
+ frameset_ok = false;
+ transferAttributes(arg3, body);
+ return;
+ case "frameset":
+ if (!frameset_ok) return;
+ body = stack.elements[1];
+ if (!body || !(body instanceof impl.HTMLBodyElement))
+ return;
+ if (body.parentNode) body.parentNode.removeChild(body);
+ while(!(stack.top instanceof impl.HTMLHtmlElement))
+ stack.pop();
+ insertHTMLElement(value, arg3);
+ parser = in_frameset_mode;
+ return;
+
+ case "address":
+ case "article":
+ case "aside":
+ case "blockquote":
+ case "center":
+ case "details":
+ case "dialog":
+ case "dir":
+ case "div":
+ case "dl":
+ case "fieldset":
+ case "figcaption":
+ case "figure":
+ case "footer":
+ case "header":
+ case "hgroup":
+ case "main":
+ case "nav":
+ case "ol":
+ case "p":
+ case "section":
+ case "summary":
+ case "ul":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "menu":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ if (isA(stack.top, 'menuitem')) {
+ stack.pop();
+ }
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ if (stack.top instanceof impl.HTMLHeadingElement)
+ stack.pop();
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "pre":
+ case "listing":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ insertHTMLElement(value, arg3);
+ ignore_linefeed = true;
+ frameset_ok = false;
+ return;
+
+ case "form":
+ if (form_element_pointer && !stack.contains("template")) return;
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ elt = insertHTMLElement(value, arg3);
+ if (!stack.contains("template"))
+ form_element_pointer = elt;
+ return;
+
+ case "li":
+ frameset_ok = false;
+ for(i = stack.elements.length-1; i >= 0; i--) {
+ node = stack.elements[i];
+ if (node instanceof impl.HTMLLIElement) {
+ in_body_mode(ENDTAG, "li");
+ break;
+ }
+ if (isA(node, specialSet) && !isA(node, addressdivpSet))
+ break;
+ }
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "dd":
+ case "dt":
+ frameset_ok = false;
+ for(i = stack.elements.length-1; i >= 0; i--) {
+ node = stack.elements[i];
+ if (isA(node, dddtSet)) {
+ in_body_mode(ENDTAG, node.localName);
+ break;
+ }
+ if (isA(node, specialSet) && !isA(node, addressdivpSet))
+ break;
+ }
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "plaintext":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ insertHTMLElement(value, arg3);
+ tokenizer = plaintext_state;
+ return;
+
+ case "button":
+ if (stack.inScope("button")) {
+ in_body_mode(ENDTAG, "button");
+ parser(t, value, arg3, arg4);
+ }
+ else {
+ afereconstruct();
+ insertHTMLElement(value, arg3);
+ frameset_ok = false;
+ }
+ return;
+
+ case "a":
+ var activeElement = afe.findElementByTag("a");
+ if (activeElement) {
+ in_body_mode(ENDTAG, value);
+ afe.remove(activeElement);
+ stack.removeElement(activeElement);
+ }
+ /* falls through */
+ case "b":
+ case "big":
+ case "code":
+ case "em":
+ case "font":
+ case "i":
+ case "s":
+ case "small":
+ case "strike":
+ case "strong":
+ case "tt":
+ case "u":
+ afereconstruct();
+ afe.push(insertHTMLElement(value,arg3), arg3);
+ return;
+
+ case "nobr":
+ afereconstruct();
+
+ if (stack.inScope(value)) {
+ in_body_mode(ENDTAG, value);
+ afereconstruct();
+ }
+ afe.push(insertHTMLElement(value,arg3), arg3);
+ return;
+
+ case "applet":
+ case "marquee":
+ case "object":
+ afereconstruct();
+ insertHTMLElement(value,arg3);
+ afe.insertMarker();
+ frameset_ok = false;
+ return;
+
+ case "table":
+ if (!doc._quirks && stack.inButtonScope("p")) {
+ in_body_mode(ENDTAG, "p");
+ }
+ insertHTMLElement(value,arg3);
+ frameset_ok = false;
+ parser = in_table_mode;
+ return;
+
+ case "area":
+ case "br":
+ case "embed":
+ case "img":
+ case "keygen":
+ case "wbr":
+ afereconstruct();
+ insertHTMLElement(value,arg3);
+ stack.pop();
+ frameset_ok = false;
+ return;
+
+ case "input":
+ afereconstruct();
+ elt = insertHTMLElement(value,arg3);
+ stack.pop();
+ var type = elt.getAttribute("type");
+ if (!type || type.toLowerCase() !== "hidden")
+ frameset_ok = false;
+ return;
+
+ case "param":
+ case "source":
+ case "track":
+ insertHTMLElement(value,arg3);
+ stack.pop();
+ return;
+
+ case "hr":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ if (isA(stack.top, 'menuitem')) {
+ stack.pop();
+ }
+ insertHTMLElement(value,arg3);
+ stack.pop();
+ frameset_ok = false;
+ return;
+
+ case "image":
+ in_body_mode(TAG, "img", arg3, arg4);
+ return;
+
+ case "textarea":
+ insertHTMLElement(value,arg3);
+ ignore_linefeed = true;
+ frameset_ok = false;
+ tokenizer = rcdata_state;
+ originalInsertionMode = parser;
+ parser = text_mode;
+ return;
+
+ case "xmp":
+ if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
+ afereconstruct();
+ frameset_ok = false;
+ parseRawText(value, arg3);
+ return;
+
+ case "iframe":
+ frameset_ok = false;
+ parseRawText(value, arg3);
+ return;
+
+ case "noembed":
+ parseRawText(value,arg3);
+ return;
+
+ case "noscript":
+ if (scripting_enabled) {
+ parseRawText(value,arg3);
+ return;
+ }
+ break; // XXX Otherwise treat it as any other open tag?
+
+ case "select":
+ afereconstruct();
+ insertHTMLElement(value,arg3);
+ frameset_ok = false;
+ if (parser === in_table_mode ||
+ parser === in_caption_mode ||
+ parser === in_table_body_mode ||
+ parser === in_row_mode ||
+ parser === in_cell_mode)
+ parser = in_select_in_table_mode;
+ else
+ parser = in_select_mode;
+ return;
+
+ case "optgroup":
+ case "option":
+ if (stack.top instanceof impl.HTMLOptionElement) {
+ in_body_mode(ENDTAG, "option");
+ }
+ afereconstruct();
+ insertHTMLElement(value,arg3);
+ return;
+
+ case "menuitem":
+ if (isA(stack.top, 'menuitem')) {
+ stack.pop();
+ }
+ afereconstruct();
+ insertHTMLElement(value, arg3);
+ return;
+
+ case "rb":
+ case "rtc":
+ if (stack.inScope("ruby")) {
+ stack.generateImpliedEndTags();
+ }
+ insertHTMLElement(value,arg3);
+ return;
+
+ case "rp":
+ case "rt":
+ if (stack.inScope("ruby")) {
+ stack.generateImpliedEndTags("rtc");
+ }
+ insertHTMLElement(value,arg3);
+ return;
+
+ case "math":
+ afereconstruct();
+ adjustMathMLAttributes(arg3);
+ adjustForeignAttributes(arg3);
+ insertForeignElement(value, arg3, NAMESPACE.MATHML);
+ if (arg4) // self-closing flag
+ stack.pop();
+ return;
+
+ case "svg":
+ afereconstruct();
+ adjustSVGAttributes(arg3);
+ adjustForeignAttributes(arg3);
+ insertForeignElement(value, arg3, NAMESPACE.SVG);
+ if (arg4) // self-closing flag
+ stack.pop();
+ return;
+
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "frame":
+ case "head":
+ case "tbody":
+ case "td":
+ case "tfoot":
+ case "th":
+ case "thead":
+ case "tr":
+ // Ignore table tags if we're not in_table mode
+ return;
+ }
+
+ // Handle any other start tag here
+ // (and also noscript tags when scripting is disabled)
+ afereconstruct();
+ insertHTMLElement(value,arg3);
+ return;
+
+ case 3: // ENDTAG
+ switch(value) {
+ case "template":
+ in_head_mode(ENDTAG, value, arg3);
+ return;
+ case "body":
+ if (!stack.inScope("body")) return;
+ parser = after_body_mode;
+ return;
+ case "html":
+ if (!stack.inScope("body")) return;
+ parser = after_body_mode;
+ parser(t, value, arg3);
+ return;
+
+ case "address":
+ case "article":
+ case "aside":
+ case "blockquote":
+ case "button":
+ case "center":
+ case "details":
+ case "dialog":
+ case "dir":
+ case "div":
+ case "dl":
+ case "fieldset":
+ case "figcaption":
+ case "figure":
+ case "footer":
+ case "header":
+ case "hgroup":
+ case "listing":
+ case "main":
+ case "menu":
+ case "nav":
+ case "ol":
+ case "pre":
+ case "section":
+ case "summary":
+ case "ul":
+ // Ignore if there is not a matching open tag
+ if (!stack.inScope(value)) return;
+ stack.generateImpliedEndTags();
+ stack.popTag(value);
+ return;
+
+ case "form":
+ if (!stack.contains("template")) {
+ var openform = form_element_pointer;
+ form_element_pointer = null;
+ if (!openform || !stack.elementInScope(openform)) return;
+ stack.generateImpliedEndTags();
+ stack.removeElement(openform);
+ } else {
+ if (!stack.inScope("form")) return;
+ stack.generateImpliedEndTags();
+ stack.popTag("form");
+ }
+ return;
+
+ case "p":
+ if (!stack.inButtonScope(value)) {
+ in_body_mode(TAG, value, null);
+ parser(t, value, arg3, arg4);
+ }
+ else {
+ stack.generateImpliedEndTags(value);
+ stack.popTag(value);
+ }
+ return;
+
+ case "li":
+ if (!stack.inListItemScope(value)) return;
+ stack.generateImpliedEndTags(value);
+ stack.popTag(value);
+ return;
+
+ case "dd":
+ case "dt":
+ if (!stack.inScope(value)) return;
+ stack.generateImpliedEndTags(value);
+ stack.popTag(value);
+ return;
+
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ if (!stack.elementTypeInScope(impl.HTMLHeadingElement)) return;
+ stack.generateImpliedEndTags();
+ stack.popElementType(impl.HTMLHeadingElement);
+ return;
+
+ case "sarcasm":
+ // Take a deep breath, and then:
+ break;
+
+ case "a":
+ case "b":
+ case "big":
+ case "code":
+ case "em":
+ case "font":
+ case "i":
+ case "nobr":
+ case "s":
+ case "small":
+ case "strike":
+ case "strong":
+ case "tt":
+ case "u":
+ var result = adoptionAgency(value);
+ if (result) return; // If we did something we're done
+ break; // Go to the "any other end tag" case
+
+ case "applet":
+ case "marquee":
+ case "object":
+ if (!stack.inScope(value)) return;
+ stack.generateImpliedEndTags();
+ stack.popTag(value);
+ afe.clearToMarker();
+ return;
+
+ case "br":
+ in_body_mode(TAG, value, null); // Turn </br> into <br>
+ return;
+ }
+
+ // Any other end tag goes here
+ for(i = stack.elements.length-1; i >= 0; i--) {
+ node = stack.elements[i];
+ if (isA(node, value)) {
+ stack.generateImpliedEndTags(value);
+ stack.popElement(node);
+ break;
+ }
+ else if (isA(node, specialSet)) {
+ return;
+ }
+ }
+
+ return;
+ }
+ }
+
+ function text_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ insertText(value);
+ return;
+ case -1: // EOF
+ if (stack.top instanceof impl.HTMLScriptElement)
+ stack.top._already_started = true;
+ stack.pop();
+ parser = originalInsertionMode;
+ parser(t);
+ return;
+ case 3: // ENDTAG
+ if (value === "script") {
+ handleScriptEnd();
+ }
+ else {
+ stack.pop();
+ parser = originalInsertionMode;
+ }
+ return;
+ default:
+ // We should never get any other token types
+ return;
+ }
+ }
+
+ function in_table_mode(t, value, arg3, arg4) {
+ function getTypeAttr(attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ if (attrs[i][0] === "type")
+ return attrs[i][1].toLowerCase();
+ }
+ return null;
+ }
+
+ switch(t) {
+ case 1: // TEXT
+ // XXX the text_integration_mode stuff is
+ // just a hack I made up
+ if (text_integration_mode) {
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ }
+ else if (isA(stack.top, tablesectionrowSet)) {
+ pending_table_text = [];
+ originalInsertionMode = parser;
+ parser = in_table_text_mode;
+ parser(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "caption":
+ stack.clearToContext(tableContextSet);
+ afe.insertMarker();
+ insertHTMLElement(value,arg3);
+ parser = in_caption_mode;
+ return;
+ case "colgroup":
+ stack.clearToContext(tableContextSet);
+ insertHTMLElement(value,arg3);
+ parser = in_column_group_mode;
+ return;
+ case "col":
+ in_table_mode(TAG, "colgroup", null);
+ parser(t, value, arg3, arg4);
+ return;
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ stack.clearToContext(tableContextSet);
+ insertHTMLElement(value,arg3);
+ parser = in_table_body_mode;
+ return;
+ case "td":
+ case "th":
+ case "tr":
+ in_table_mode(TAG, "tbody", null);
+ parser(t, value, arg3, arg4);
+ return;
+
+ case "table":
+ if (!stack.inTableScope(value)) {
+ return; // Ignore the token
+ }
+ in_table_mode(ENDTAG, value);
+ parser(t, value, arg3, arg4);
+ return;
+
+ case "style":
+ case "script":
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+
+ case "input":
+ var type = getTypeAttr(arg3);
+ if (type !== "hidden") break; // to the anything else case
+ insertHTMLElement(value,arg3);
+ stack.pop();
+ return;
+
+ case "form":
+ if (form_element_pointer || stack.contains("template")) return;
+ form_element_pointer = insertHTMLElement(value, arg3);
+ stack.popElement(form_element_pointer);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "table":
+ if (!stack.inTableScope(value)) return;
+ stack.popTag(value);
+ resetInsertionMode();
+ return;
+ case "body":
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "html":
+ case "tbody":
+ case "td":
+ case "tfoot":
+ case "th":
+ case "thead":
+ case "tr":
+ return;
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+
+ break;
+ case -1: // EOF
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ }
+
+ // This is the anything else case
+ foster_parent_mode = true;
+ in_body_mode(t, value, arg3, arg4);
+ foster_parent_mode = false;
+ }
+
+ function in_table_text_mode(t, value, arg3, arg4) {
+ if (t === TEXT) {
+ if (textIncludesNUL) {
+ value = value.replace(NULCHARS, "");
+ if (value.length === 0) return;
+ }
+ pending_table_text.push(value);
+ }
+ else {
+ var s = pending_table_text.join("");
+ pending_table_text.length = 0;
+ if (NONWS.test(s)) { // If any non-whitespace characters
+ // This must be the same code as the "anything else"
+ // case of the in_table mode above.
+ foster_parent_mode = true;
+ in_body_mode(TEXT, s);
+ foster_parent_mode = false;
+ }
+ else {
+ insertText(s);
+ }
+ parser = originalInsertionMode;
+ parser(t, value, arg3, arg4);
+ }
+ }
+
+
+ function in_caption_mode(t, value, arg3, arg4) {
+ function end_caption() {
+ if (!stack.inTableScope("caption")) return false;
+ stack.generateImpliedEndTags();
+ stack.popTag("caption");
+ afe.clearToMarker();
+ parser = in_table_mode;
+ return true;
+ }
+
+ switch(t) {
+ case 2: // TAG
+ switch(value) {
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "tbody":
+ case "td":
+ case "tfoot":
+ case "th":
+ case "thead":
+ case "tr":
+ if (end_caption()) parser(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "caption":
+ end_caption();
+ return;
+ case "table":
+ if (end_caption()) parser(t, value, arg3, arg4);
+ return;
+ case "body":
+ case "col":
+ case "colgroup":
+ case "html":
+ case "tbody":
+ case "td":
+ case "tfoot":
+ case "th":
+ case "thead":
+ case "tr":
+ return;
+ }
+ break;
+ }
+
+ // The Anything Else case
+ in_body_mode(t, value, arg3, arg4);
+ }
+
+ function in_column_group_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ var ws = value.match(LEADINGWS);
+ if (ws) {
+ insertText(ws[0]);
+ value = value.substring(ws[0].length);
+ }
+ if (value.length === 0) return;
+ break; // Handle non-whitespace below
+
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "col":
+ insertHTMLElement(value, arg3);
+ stack.pop();
+ return;
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "colgroup":
+ if (!isA(stack.top, 'colgroup')) {
+ return; // Ignore the token.
+ }
+ stack.pop();
+ parser = in_table_mode;
+ return;
+ case "col":
+ return;
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case -1: // EOF
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ }
+
+ // Anything else
+ if (!isA(stack.top, 'colgroup')) {
+ return; // Ignore the token.
+ }
+ in_column_group_mode(ENDTAG, "colgroup");
+ parser(t, value, arg3, arg4);
+ }
+
+ function in_table_body_mode(t, value, arg3, arg4) {
+ function endsect() {
+ if (!stack.inTableScope("tbody") &&
+ !stack.inTableScope("thead") &&
+ !stack.inTableScope("tfoot"))
+ return;
+ stack.clearToContext(tableBodyContextSet);
+ in_table_body_mode(ENDTAG, stack.top.localName, null);
+ parser(t, value, arg3, arg4);
+ }
+
+ switch(t) {
+ case 2: // TAG
+ switch(value) {
+ case "tr":
+ stack.clearToContext(tableBodyContextSet);
+ insertHTMLElement(value, arg3);
+ parser = in_row_mode;
+ return;
+ case "th":
+ case "td":
+ in_table_body_mode(TAG, "tr", null);
+ parser(t, value, arg3, arg4);
+ return;
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ endsect();
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "table":
+ endsect();
+ return;
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ if (stack.inTableScope(value)) {
+ stack.clearToContext(tableBodyContextSet);
+ stack.pop();
+ parser = in_table_mode;
+ }
+ return;
+ case "body":
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "html":
+ case "td":
+ case "th":
+ case "tr":
+ return;
+ }
+ break;
+ }
+
+ // Anything else:
+ in_table_mode(t, value, arg3, arg4);
+ }
+
+ function in_row_mode(t, value, arg3, arg4) {
+ function endrow() {
+ if (!stack.inTableScope("tr")) return false;
+ stack.clearToContext(tableRowContextSet);
+ stack.pop();
+ parser = in_table_body_mode;
+ return true;
+ }
+
+ switch(t) {
+ case 2: // TAG
+ switch(value) {
+ case "th":
+ case "td":
+ stack.clearToContext(tableRowContextSet);
+ insertHTMLElement(value, arg3);
+ parser = in_cell_mode;
+ afe.insertMarker();
+ return;
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ case "tr":
+ if (endrow()) parser(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "tr":
+ endrow();
+ return;
+ case "table":
+ if (endrow()) parser(t, value, arg3, arg4);
+ return;
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ if (stack.inTableScope(value)) {
+ if (endrow()) parser(t, value, arg3, arg4);
+ }
+ return;
+ case "body":
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "html":
+ case "td":
+ case "th":
+ return;
+ }
+ break;
+ }
+
+ // anything else
+ in_table_mode(t, value, arg3, arg4);
+ }
+
+ function in_cell_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 2: // TAG
+ switch(value) {
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "tbody":
+ case "td":
+ case "tfoot":
+ case "th":
+ case "thead":
+ case "tr":
+ if (stack.inTableScope("td")) {
+ in_cell_mode(ENDTAG, "td");
+ parser(t, value, arg3, arg4);
+ }
+ else if (stack.inTableScope("th")) {
+ in_cell_mode(ENDTAG, "th");
+ parser(t, value, arg3, arg4);
+ }
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "td":
+ case "th":
+ if (!stack.inTableScope(value)) return;
+ stack.generateImpliedEndTags();
+ stack.popTag(value);
+ afe.clearToMarker();
+ parser = in_row_mode;
+ return;
+
+ case "body":
+ case "caption":
+ case "col":
+ case "colgroup":
+ case "html":
+ return;
+
+ case "table":
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ case "tr":
+ if (!stack.inTableScope(value)) return;
+ in_cell_mode(ENDTAG, stack.inTableScope("td") ? "td" : "th");
+ parser(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ }
+
+ // anything else
+ in_body_mode(t, value, arg3, arg4);
+ }
+
+ function in_select_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ if (textIncludesNUL) {
+ value = value.replace(NULCHARS, "");
+ if (value.length === 0) return;
+ }
+ insertText(value);
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case -1: // EOF
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "option":
+ if (stack.top instanceof impl.HTMLOptionElement)
+ in_select_mode(ENDTAG, value);
+ insertHTMLElement(value, arg3);
+ return;
+ case "optgroup":
+ if (stack.top instanceof impl.HTMLOptionElement)
+ in_select_mode(ENDTAG, "option");
+ if (stack.top instanceof impl.HTMLOptGroupElement)
+ in_select_mode(ENDTAG, value);
+ insertHTMLElement(value, arg3);
+ return;
+ case "select":
+ in_select_mode(ENDTAG, value); // treat it as a close tag
+ return;
+
+ case "input":
+ case "keygen":
+ case "textarea":
+ if (!stack.inSelectScope("select")) return;
+ in_select_mode(ENDTAG, "select");
+ parser(t, value, arg3, arg4);
+ return;
+
+ case "script":
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ switch(value) {
+ case "optgroup":
+ if (stack.top instanceof impl.HTMLOptionElement &&
+ stack.elements[stack.elements.length-2] instanceof
+ impl.HTMLOptGroupElement) {
+ in_select_mode(ENDTAG, "option");
+ }
+ if (stack.top instanceof impl.HTMLOptGroupElement)
+ stack.pop();
+
+ return;
+
+ case "option":
+ if (stack.top instanceof impl.HTMLOptionElement)
+ stack.pop();
+ return;
+
+ case "select":
+ if (!stack.inSelectScope(value)) return;
+ stack.popTag(value);
+ resetInsertionMode();
+ return;
+
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+
+ break;
+ }
+
+ // anything else: just ignore the token
+ }
+
+ function in_select_in_table_mode(t, value, arg3, arg4) {
+ switch(value) {
+ case "caption":
+ case "table":
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ case "tr":
+ case "td":
+ case "th":
+ switch(t) {
+ case 2: // TAG
+ in_select_in_table_mode(ENDTAG, "select");
+ parser(t, value, arg3, arg4);
+ return;
+ case 3: // ENDTAG
+ if (stack.inTableScope(value)) {
+ in_select_in_table_mode(ENDTAG, "select");
+ parser(t, value, arg3, arg4);
+ }
+ return;
+ }
+ }
+
+ // anything else
+ in_select_mode(t, value, arg3, arg4);
+ }
+
+ function in_template_mode(t, value, arg3, arg4) {
+ function switchModeAndReprocess(mode) {
+ parser = mode;
+ templateInsertionModes[templateInsertionModes.length-1] = parser;
+ parser(t, value, arg3, arg4);
+ }
+ switch(t) {
+ case 1: // TEXT
+ case 4: // COMMENT
+ case 5: // DOCTYPE
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case -1: // EOF
+ if (!stack.contains("template")) {
+ stopParsing();
+ } else {
+ stack.popTag("template");
+ afe.clearToMarker();
+ templateInsertionModes.pop();
+ resetInsertionMode();
+ parser(t, value, arg3, arg4);
+ }
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "base":
+ case "basefont":
+ case "bgsound":
+ case "link":
+ case "meta":
+ case "noframes":
+ case "script":
+ case "style":
+ case "template":
+ case "title":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ case "caption":
+ case "colgroup":
+ case "tbody":
+ case "tfoot":
+ case "thead":
+ switchModeAndReprocess(in_table_mode);
+ return;
+ case "col":
+ switchModeAndReprocess(in_column_group_mode);
+ return;
+ case "tr":
+ switchModeAndReprocess(in_table_body_mode);
+ return;
+ case "td":
+ case "th":
+ switchModeAndReprocess(in_row_mode);
+ return;
+ }
+ switchModeAndReprocess(in_body_mode);
+ return;
+ case 3: // ENDTAG
+ switch(value) {
+ case "template":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ default:
+ return;
+ }
+ }
+ }
+
+ function after_body_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ // If any non-space chars, handle below
+ if (NONWS.test(value)) break;
+ in_body_mode(t, value);
+ return;
+ case 4: // COMMENT
+ // Append it to the <html> element
+ stack.elements[0]._appendChild(doc.createComment(value));
+ return;
+ case 5: // DOCTYPE
+ return;
+ case -1: // EOF
+ stopParsing();
+ return;
+ case 2: // TAG
+ if (value === "html") {
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ }
+ break; // for any other tags
+ case 3: // ENDTAG
+ if (value === "html") {
+ if (fragment) return;
+ parser = after_after_body_mode;
+ return;
+ }
+ break; // for any other tags
+ }
+
+ // anything else
+ parser = in_body_mode;
+ parser(t, value, arg3, arg4);
+ }
+
+ function in_frameset_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ // Ignore any non-space characters
+ value = value.replace(ALLNONWS, "");
+ if (value.length > 0) insertText(value);
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case -1: // EOF
+ stopParsing();
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "frameset":
+ insertHTMLElement(value, arg3);
+ return;
+ case "frame":
+ insertHTMLElement(value, arg3);
+ stack.pop();
+ return;
+ case "noframes":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ if (value === "frameset") {
+ if (fragment && stack.top instanceof impl.HTMLHtmlElement)
+ return;
+ stack.pop();
+ if (!fragment &&
+ !(stack.top instanceof impl.HTMLFrameSetElement))
+ parser = after_frameset_mode;
+ return;
+ }
+ break;
+ }
+
+ // ignore anything else
+ }
+
+ function after_frameset_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ // Ignore any non-space characters
+ value = value.replace(ALLNONWS, "");
+ if (value.length > 0) insertText(value);
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ return;
+ case -1: // EOF
+ stopParsing();
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "noframes":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ case 3: // ENDTAG
+ if (value === "html") {
+ parser = after_after_frameset_mode;
+ return;
+ }
+ break;
+ }
+
+ // ignore anything else
+ }
+
+ function after_after_body_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ // If any non-space chars, handle below
+ if (NONWS.test(value)) break;
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case 4: // COMMENT
+ doc._appendChild(doc.createComment(value));
+ return;
+ case 5: // DOCTYPE
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case -1: // EOF
+ stopParsing();
+ return;
+ case 2: // TAG
+ if (value === "html") {
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ }
+
+ // anything else
+ parser = in_body_mode;
+ parser(t, value, arg3, arg4);
+ }
+
+ function after_after_frameset_mode(t, value, arg3, arg4) {
+ switch(t) {
+ case 1: // TEXT
+ // Ignore any non-space characters
+ value = value.replace(ALLNONWS, "");
+ if (value.length > 0)
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case 4: // COMMENT
+ doc._appendChild(doc.createComment(value));
+ return;
+ case 5: // DOCTYPE
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case -1: // EOF
+ stopParsing();
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "html":
+ in_body_mode(t, value, arg3, arg4);
+ return;
+ case "noframes":
+ in_head_mode(t, value, arg3, arg4);
+ return;
+ }
+ break;
+ }
+
+ // ignore anything else
+ }
+
+
+ // 13.2.5.5 The rules for parsing tokens in foreign content
+ //
+ // This is like one of the insertion modes above, but is
+ // invoked somewhat differently when the current token is not HTML.
+ // See the insertToken() function.
+ function insertForeignToken(t, value, arg3, arg4) {
+ // A <font> tag is an HTML font tag if it has a color, font, or size
+ // attribute. Otherwise we assume it is foreign content
+ function isHTMLFont(attrs) {
+ for(var i = 0, n = attrs.length; i < n; i++) {
+ switch(attrs[i][0]) {
+ case "color":
+ case "face":
+ case "size":
+ return true;
+ }
+ }
+ return false;
+ }
+
+ var current;
+
+ switch(t) {
+ case 1: // TEXT
+ // If any non-space, non-nul characters
+ if (frameset_ok && NONWSNONNUL.test(value))
+ frameset_ok = false;
+ if (textIncludesNUL) {
+ value = value.replace(NULCHARS, "\uFFFD");
+ }
+ insertText(value);
+ return;
+ case 4: // COMMENT
+ insertComment(value);
+ return;
+ case 5: // DOCTYPE
+ // ignore it
+ return;
+ case 2: // TAG
+ switch(value) {
+ case "font":
+ if (!isHTMLFont(arg3)) break;
+ /* falls through */
+ case "b":
+ case "big":
+ case "blockquote":
+ case "body":
+ case "br":
+ case "center":
+ case "code":
+ case "dd":
+ case "div":
+ case "dl":
+ case "dt":
+ case "em":
+ case "embed":
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ case "head":
+ case "hr":
+ case "i":
+ case "img":
+ case "li":
+ case "listing":
+ case "menu":
+ case "meta":
+ case "nobr":
+ case "ol":
+ case "p":
+ case "pre":
+ case "ruby":
+ case "s":
+ case "small":
+ case "span":
+ case "strong":
+ case "strike":
+ case "sub":
+ case "sup":
+ case "table":
+ case "tt":
+ case "u":
+ case "ul":
+ case "var":
+ if (fragment) {
+ break;
+ }
+ do {
+ stack.pop();
+ current = stack.top;
+ } while(current.namespaceURI !== NAMESPACE.HTML &&
+ !isMathmlTextIntegrationPoint(current) &&
+ !isHTMLIntegrationPoint(current));
+
+ insertToken(t, value, arg3, arg4); // reprocess
+ return;
+ }
+
+ // Any other start tag case goes here
+ current = (stack.elements.length===1 && fragment) ? fragmentContext :
+ stack.top;
+ if (current.namespaceURI === NAMESPACE.MATHML) {
+ adjustMathMLAttributes(arg3);
+ }
+ else if (current.namespaceURI === NAMESPACE.SVG) {
+ value = adjustSVGTagName(value);
+ adjustSVGAttributes(arg3);
+ }
+ adjustForeignAttributes(arg3);
+
+ insertForeignElement(value, arg3, current.namespaceURI);
+ if (arg4) { // the self-closing flag
+ if (value === 'script' && current.namespaceURI === NAMESPACE.SVG) {
+ // XXX deal with SVG scripts here
+ }
+ stack.pop();
+ }
+ return;
+
+ case 3: // ENDTAG
+ current = stack.top;
+ if (value === "script" &&
+ current.namespaceURI === NAMESPACE.SVG &&
+ current.localName === "script") {
+
+ stack.pop();
+
+ // XXX
+ // Deal with SVG scripts here
+ }
+ else {
+ // The any other end tag case
+ var i = stack.elements.length-1;
+ var node = stack.elements[i];
+ for(;;) {
+ if (node.localName.toLowerCase() === value) {
+ stack.popElement(node);
+ break;
+ }
+ node = stack.elements[--i];
+ // If non-html, keep looping
+ if (node.namespaceURI !== NAMESPACE.HTML)
+ continue;
+ // Otherwise process the end tag as html
+ parser(t, value, arg3, arg4);
+ break;
+ }
+ }
+ return;
+ }
+ }
+
+ /***
+ * Finally, this is the end of the HTMLParser() factory function.
+ * It returns the htmlparser object with the append() and end() methods.
+ */
+
+ // Sneak another method into the htmlparser object to allow us to run
+ // tokenizer tests. This can be commented out in production code.
+ // This is a hook for testing the tokenizer. It has to be here
+ // because the tokenizer details are all hidden away within the closure.
+ // It should return an array of tokens generated while parsing the
+ // input string.
+ htmlparser.testTokenizer = function(input, initialState, lastStartTag, charbychar) {
+ var tokens = [];
+
+ switch(initialState) {
+ case "PCDATA state":
+ tokenizer = data_state;
+ break;
+ case "RCDATA state":
+ tokenizer = rcdata_state;
+ break;
+ case "RAWTEXT state":
+ tokenizer = rawtext_state;
+ break;
+ case "PLAINTEXT state":
+ tokenizer = plaintext_state;
+ break;
+ }
+
+ if (lastStartTag) {
+ lasttagname = lastStartTag;
+ }
+
+ insertToken = function(t, value, arg3, arg4) {
+ flushText();
+ switch(t) {
+ case 1: // TEXT
+ if (tokens.length > 0 &&
+ tokens[tokens.length-1][0] === "Character") {
+ tokens[tokens.length-1][1] += value;
+ }
+ else tokens.push(["Character", value]);
+ break;
+ case 4: // COMMENT
+ tokens.push(["Comment", value]);
+ break;
+ case 5: // DOCTYPE
+ tokens.push(["DOCTYPE", value,
+ arg3 === undefined ? null : arg3,
+ arg4 === undefined ? null : arg4,
+ !force_quirks]);
+ break;
+ case 2: // TAG
+ var attrs = Object.create(null);
+ for(var i = 0; i < arg3.length; i++) {
+ // XXX: does attribute order matter?
+ var a = arg3[i];
+ if (a.length === 1) {
+ attrs[a[0]] = "";
+ }
+ else {
+ attrs[a[0]] = a[1];
+ }
+ }
+ var token = ["StartTag", value, attrs];
+ if (arg4) token.push(true);
+ tokens.push(token);
+ break;
+ case 3: // ENDTAG
+ tokens.push(["EndTag", value]);
+ break;
+ case -1: // EOF
+ break;
+ }
+ };
+
+ if (!charbychar) {
+ this.parse(input, true);
+ }
+ else {
+ for(var i = 0; i < input.length; i++) {
+ this.parse(input[i]);
+ }
+ this.parse("", true);
+ }
+ return tokens;
+ };
+
+ // Return the parser object from the HTMLParser() factory function
+ return htmlparser;
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/LICENSE
@@ -1,0 +1,25 @@
+Copyright (c) 2011 The Mozilla Foundation.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Leaf.js
@@ -1,0 +1,37 @@
+"use strict";
+module.exports = Leaf;
+
+var Node = require('./Node');
+var NodeList = require('./NodeList');
+var utils = require('./utils');
+var HierarchyRequestError = utils.HierarchyRequestError;
+var NotFoundError = utils.NotFoundError;
+
+// This class defines common functionality for node subtypes that
+// can never have children
+function Leaf() {
+ Node.call(this);
+}
+
+Leaf.prototype = Object.create(Node.prototype, {
+ hasChildNodes: { value: function() { return false; }},
+ firstChild: { value: null },
+ lastChild: { value: null },
+ insertBefore: { value: function(node, child) {
+ if (!node.nodeType) throw new TypeError('not a node');
+ HierarchyRequestError();
+ }},
+ replaceChild: { value: function(node, child) {
+ if (!node.nodeType) throw new TypeError('not a node');
+ HierarchyRequestError();
+ }},
+ removeChild: { value: function(node) {
+ if (!node.nodeType) throw new TypeError('not a node');
+ NotFoundError();
+ }},
+ removeChildren: { value: function() { /* no op */ }},
+ childNodes: { get: function() {
+ if (!this._childNodes) this._childNodes = new NodeList();
+ return this._childNodes;
+ }}
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/LinkedList.js
@@ -1,0 +1,44 @@
+"use strict";
+var utils = require('./utils');
+
+var LinkedList = module.exports = {
+ // basic validity tests on a circular linked list a
+ valid: function(a) {
+ utils.assert(a, "list falsy");
+ utils.assert(a._previousSibling, "previous falsy");
+ utils.assert(a._nextSibling, "next falsy");
+ // xxx check that list is actually circular
+ return true;
+ },
+ // insert a before b
+ insertBefore: function(a, b) {
+ utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
+ var a_first = a, a_last = a._previousSibling;
+ var b_first = b, b_last = b._previousSibling;
+ a_first._previousSibling = b_last;
+ a_last._nextSibling = b_first;
+ b_last._nextSibling = a_first;
+ b_first._previousSibling = a_last;
+ utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
+ },
+ // replace a single node a with a list b (which could be null)
+ replace: function(a, b) {
+ utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
+ if (b!==null) {
+ LinkedList.insertBefore(b, a);
+ }
+ LinkedList.remove(a);
+ utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
+ },
+ // remove single node a from its list
+ remove: function(a) {
+ utils.assert(LinkedList.valid(a));
+ var prev = a._previousSibling;
+ if (prev === a) { return; }
+ var next = a._nextSibling;
+ prev._nextSibling = next;
+ next._previousSibling = prev;
+ a._previousSibling = a._nextSibling = a;
+ utils.assert(LinkedList.valid(a));
+ }
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Location.js
@@ -1,0 +1,56 @@
+"use strict";
+var URL = require('./URL');
+var URLUtils = require('./URLUtils');
+
+module.exports = Location;
+
+function Location(window, href) {
+ this._window = window;
+ this._href = href;
+}
+
+Location.prototype = Object.create(URLUtils.prototype, {
+ constructor: { value: Location },
+
+ // Special behavior when href is set
+ href: {
+ get: function() { return this._href; },
+ set: function(v) { this.assign(v); }
+ },
+
+ assign: { value: function(url) {
+ // Resolve the new url against the current one
+ // XXX:
+ // This is not actually correct. It should be resolved against
+ // the URL of the document of the script. For now, though, I only
+ // support a single window and there is only one base url.
+ // So this is good enough for now.
+ var current = new URL(this._href);
+ var newurl = current.resolve(url);
+
+ // Save the new url
+ this._href = newurl;
+
+ // Start loading the new document!
+ // XXX
+ // This is just something hacked together.
+ // The real algorithm is: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#navigate
+ }},
+
+ replace: { value: function(url) {
+ // XXX
+ // Since we aren't tracking history yet, replace is the same as assign
+ this.assign(url);
+ }},
+
+ reload: { value: function() {
+ // XXX:
+ // Actually, the spec is a lot more complicated than this
+ this.assign(this.href);
+ }},
+
+ toString: { value: function() {
+ return this.href;
+ }}
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/MouseEvent.js
@@ -1,0 +1,52 @@
+"use strict";
+var UIEvent = require('./UIEvent');
+
+module.exports = MouseEvent;
+
+function MouseEvent() {
+ // Just use the superclass constructor to initialize
+ UIEvent.call(this);
+
+ this.screenX = this.screenY = this.clientX = this.clientY = 0;
+ this.ctrlKey = this.altKey = this.shiftKey = this.metaKey = false;
+ this.button = 0;
+ this.buttons = 1;
+ this.relatedTarget = null;
+}
+MouseEvent.prototype = Object.create(UIEvent.prototype, {
+ constructor: { value: MouseEvent },
+ initMouseEvent: { value: function(type, bubbles, cancelable,
+ view, detail,
+ screenX, screenY, clientX, clientY,
+ ctrlKey, altKey, shiftKey, metaKey,
+ button, relatedTarget) {
+
+ this.initEvent(type, bubbles, cancelable, view, detail);
+ this.screenX = screenX;
+ this.screenY = screenY;
+ this.clientX = clientX;
+ this.clientY = clientY;
+ this.ctrlKey = ctrlKey;
+ this.altKey = altKey;
+ this.shiftKey = shiftKey;
+ this.metaKey = metaKey;
+ this.button = button;
+ switch(button) {
+ case 0: this.buttons = 1; break;
+ case 1: this.buttons = 4; break;
+ case 2: this.buttons = 2; break;
+ default: this.buttons = 0; break;
+ }
+ this.relatedTarget = relatedTarget;
+ }},
+
+ getModifierState: { value: function(key) {
+ switch(key) {
+ case "Alt": return this.altKey;
+ case "Control": return this.ctrlKey;
+ case "Shift": return this.shiftKey;
+ case "Meta": return this.metaKey;
+ default: return false;
+ }
+ }}
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/MutationConstants.js
@@ -1,0 +1,9 @@
+"use strict";
+module.exports = {
+ VALUE: 1, // The value of a Text, Comment or PI node changed
+ ATTR: 2, // A new attribute was added or an attribute value and/or prefix changed
+ REMOVE_ATTR: 3, // An attribute was removed
+ REMOVE: 4, // A node was removed
+ MOVE: 5, // A node was moved
+ INSERT: 6 // A node (or a subtree of nodes) was inserted
+};
\ No newline at end of file
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NamedNodeMap.js
@@ -1,0 +1,41 @@
+"use strict";
+module.exports = NamedNodeMap;
+
+var utils = require('./utils');
+
+/* This is a hacky implementation of NamedNodeMap, intended primarily to
+ * satisfy clients (like dompurify and the web-platform-tests) which check
+ * to ensure that Node#attributes instanceof NamedNodeMap. */
+
+function NamedNodeMap(element) {
+ this.element = element;
+}
+Object.defineProperties(NamedNodeMap.prototype, {
+ length: { get: utils.shouldOverride },
+ item: { value: utils.shouldOverride },
+
+ getNamedItem: { value: function getNamedItem(qualifiedName) {
+ return this.element.getAttributeNode(qualifiedName);
+ } },
+ getNamedItemNS: { value: function getNamedItemNS(namespace, localName) {
+ return this.element.getAttributeNodeNS(namespace, localName);
+ } },
+ setNamedItem: { value: utils.nyi },
+ setNamedItemNS: { value: utils.nyi },
+ removeNamedItem: { value: function removeNamedItem(qualifiedName) {
+ var attr = this.element.getAttributeNode(qualifiedName);
+ if (attr) {
+ this.element.removeAttribute(qualifiedName);
+ return attr;
+ }
+ utils.NotFoundError();
+ } },
+ removeNamedItemNS: { value: function removeNamedItemNS(ns, lname) {
+ var attr = this.element.getAttributeNodeNS(ns, lname);
+ if (attr) {
+ this.element.removeAttributeNS(ns, lname);
+ return attr;
+ }
+ utils.NotFoundError();
+ } },
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NavigatorID.js
@@ -1,0 +1,17 @@
+"use strict";
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#navigatorid
+var NavigatorID = Object.create(null, {
+ appCodeName: { value: "Mozilla" },
+ appName: { value: "Netscape" },
+ appVersion: { value: "4.0" },
+ platform: { value: "" },
+ product: { value: "Gecko" },
+ productSub: { value: "20100101" },
+ userAgent: { value: "" },
+ vendor: { value: "" },
+ vendorSub: { value: "" },
+ taintEnabled: { value: function() { return false; } }
+});
+
+module.exports = NavigatorID;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Node.js
@@ -1,0 +1,738 @@
+"use strict";
+module.exports = Node;
+
+var EventTarget = require('./EventTarget');
+var LinkedList = require('./LinkedList');
+var NodeUtils = require('./NodeUtils');
+var utils = require('./utils');
+
+// All nodes have a nodeType and an ownerDocument.
+// Once inserted, they also have a parentNode.
+// This is an abstract class; all nodes in a document are instances
+// of a subtype, so all the properties are defined by more specific
+// constructors.
+function Node() {
+ EventTarget.call(this);
+ this.parentNode = null;
+ this._nextSibling = this._previousSibling = this;
+ this._index = undefined;
+}
+
+var ELEMENT_NODE = Node.ELEMENT_NODE = 1;
+var ATTRIBUTE_NODE = Node.ATTRIBUTE_NODE = 2;
+var TEXT_NODE = Node.TEXT_NODE = 3;
+var CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE = 4;
+var ENTITY_REFERENCE_NODE = Node.ENTITY_REFERENCE_NODE = 5;
+var ENTITY_NODE = Node.ENTITY_NODE = 6;
+var PROCESSING_INSTRUCTION_NODE = Node.PROCESSING_INSTRUCTION_NODE = 7;
+var COMMENT_NODE = Node.COMMENT_NODE = 8;
+var DOCUMENT_NODE = Node.DOCUMENT_NODE = 9;
+var DOCUMENT_TYPE_NODE = Node.DOCUMENT_TYPE_NODE = 10;
+var DOCUMENT_FRAGMENT_NODE = Node.DOCUMENT_FRAGMENT_NODE = 11;
+var NOTATION_NODE = Node.NOTATION_NODE = 12;
+
+var DOCUMENT_POSITION_DISCONNECTED = Node.DOCUMENT_POSITION_DISCONNECTED = 0x01;
+var DOCUMENT_POSITION_PRECEDING = Node.DOCUMENT_POSITION_PRECEDING = 0x02;
+var DOCUMENT_POSITION_FOLLOWING = Node.DOCUMENT_POSITION_FOLLOWING = 0x04;
+var DOCUMENT_POSITION_CONTAINS = Node.DOCUMENT_POSITION_CONTAINS = 0x08;
+var DOCUMENT_POSITION_CONTAINED_BY = Node.DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
+
+Node.prototype = Object.create(EventTarget.prototype, {
+
+ // Node that are not inserted into the tree inherit a null parent
+
+ // XXX: the baseURI attribute is defined by dom core, but
+ // a correct implementation of it requires HTML features, so
+ // we'll come back to this later.
+ baseURI: { get: utils.nyi },
+
+ parentElement: { get: function() {
+ return (this.parentNode && this.parentNode.nodeType===ELEMENT_NODE) ? this.parentNode : null;
+ }},
+
+ hasChildNodes: { value: utils.shouldOverride },
+
+ firstChild: { get: utils.shouldOverride },
+
+ lastChild: { get: utils.shouldOverride },
+
+ previousSibling: { get: function() {
+ var parent = this.parentNode;
+ if (!parent) return null;
+ if (this === parent.firstChild) return null;
+ return this._previousSibling;
+ }},
+
+ nextSibling: { get: function() {
+ var parent = this.parentNode, next = this._nextSibling;
+ if (!parent) return null;
+ if (next === parent.firstChild) return null;
+ return next;
+ }},
+
+ textContent: {
+ // Should override for DocumentFragment/Element/Attr/Text/PI/Comment
+ get: function() { return null; },
+ set: function(v) { /* do nothing */ },
+ },
+
+ _countChildrenOfType: { value: function(type) {
+ var sum = 0;
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === type) sum++;
+ }
+ return sum;
+ }},
+
+ _ensureInsertValid: { value: function _ensureInsertValid(node, child, isPreinsert) {
+ var parent = this, i, kid;
+ if (!node.nodeType) throw new TypeError('not a node');
+ // 1. If parent is not a Document, DocumentFragment, or Element
+ // node, throw a HierarchyRequestError.
+ switch (parent.nodeType) {
+ case DOCUMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ case ELEMENT_NODE:
+ break;
+ default: utils.HierarchyRequestError();
+ }
+ // 2. If node is a host-including inclusive ancestor of parent,
+ // throw a HierarchyRequestError.
+ if (node.isAncestor(parent)) utils.HierarchyRequestError();
+ // 3. If child is not null and its parent is not parent, then
+ // throw a NotFoundError. (replaceChild omits the 'child is not null'
+ // and throws a TypeError here if child is null.)
+ if (child !== null || !isPreinsert) {
+ if (child.parentNode !== parent) utils.NotFoundError();
+ }
+ // 4. If node is not a DocumentFragment, DocumentType, Element,
+ // Text, ProcessingInstruction, or Comment node, throw a
+ // HierarchyRequestError.
+ switch (node.nodeType) {
+ case DOCUMENT_FRAGMENT_NODE:
+ case DOCUMENT_TYPE_NODE:
+ case ELEMENT_NODE:
+ case TEXT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ case COMMENT_NODE:
+ break;
+ default: utils.HierarchyRequestError();
+ }
+ // 5. If either node is a Text node and parent is a document, or
+ // node is a doctype and parent is not a document, throw a
+ // HierarchyRequestError.
+ // 6. If parent is a document, and any of the statements below, switched
+ // on node, are true, throw a HierarchyRequestError.
+ if (parent.nodeType === DOCUMENT_NODE) {
+ switch (node.nodeType) {
+ case TEXT_NODE:
+ utils.HierarchyRequestError();
+ break;
+ case DOCUMENT_FRAGMENT_NODE:
+ // 6a1. If node has more than one element child or has a Text
+ // node child.
+ if (node._countChildrenOfType(TEXT_NODE) > 0)
+ utils.HierarchyRequestError();
+ switch (node._countChildrenOfType(ELEMENT_NODE)) {
+ case 0:
+ break;
+ case 1:
+ // 6a2. Otherwise, if node has one element child and either
+ // parent has an element child, child is a doctype, or child
+ // is not null and a doctype is following child. [preinsert]
+ // 6a2. Otherwise, if node has one element child and either
+ // parent has an element child that is not child or a
+ // doctype is following child. [replaceWith]
+ if (child !== null /* always true here for replaceWith */) {
+ if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE)
+ utils.HierarchyRequestError();
+ for (kid = child.nextSibling; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === DOCUMENT_TYPE_NODE)
+ utils.HierarchyRequestError();
+ }
+ }
+ i = parent._countChildrenOfType(ELEMENT_NODE);
+ if (isPreinsert) {
+ // "parent has an element child"
+ if (i > 0)
+ utils.HierarchyRequestError();
+ } else {
+ // "parent has an element child that is not child"
+ if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE))
+ utils.HierarchyRequestError();
+ }
+ break;
+ default: // 6a1, continued. (more than one Element child)
+ utils.HierarchyRequestError();
+ }
+ break;
+ case ELEMENT_NODE:
+ // 6b. parent has an element child, child is a doctype, or
+ // child is not null and a doctype is following child. [preinsert]
+ // 6b. parent has an element child that is not child or a
+ // doctype is following child. [replaceWith]
+ if (child !== null /* always true here for replaceWith */) {
+ if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE)
+ utils.HierarchyRequestError();
+ for (kid = child.nextSibling; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === DOCUMENT_TYPE_NODE)
+ utils.HierarchyRequestError();
+ }
+ }
+ i = parent._countChildrenOfType(ELEMENT_NODE);
+ if (isPreinsert) {
+ // "parent has an element child"
+ if (i > 0)
+ utils.HierarchyRequestError();
+ } else {
+ // "parent has an element child that is not child"
+ if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE))
+ utils.HierarchyRequestError();
+ }
+ break;
+ case DOCUMENT_TYPE_NODE:
+ // 6c. parent has a doctype child, child is non-null and an
+ // element is preceding child, or child is null and parent has
+ // an element child. [preinsert]
+ // 6c. parent has a doctype child that is not child, or an
+ // element is preceding child. [replaceWith]
+ if (child === null) {
+ if (parent._countChildrenOfType(ELEMENT_NODE))
+ utils.HierarchyRequestError();
+ } else {
+ // child is always non-null for [replaceWith] case
+ for (kid = parent.firstChild; kid !== null; kid = kid.nextSibling) {
+ if (kid === child) break;
+ if (kid.nodeType === ELEMENT_NODE)
+ utils.HierarchyRequestError();
+ }
+ }
+ i = parent._countChildrenOfType(DOCUMENT_TYPE_NODE);
+ if (isPreinsert) {
+ // "parent has an doctype child"
+ if (i > 0)
+ utils.HierarchyRequestError();
+ } else {
+ // "parent has an doctype child that is not child"
+ if (i > 1 || (i === 1 && child.nodeType !== DOCUMENT_TYPE_NODE))
+ utils.HierarchyRequestError();
+ }
+ break;
+ }
+ } else {
+ // 5, continued: (parent is not a document)
+ if (node.nodeType === DOCUMENT_TYPE_NODE) utils.HierarchyRequestError();
+ }
+ }},
+
+ insertBefore: { value: function insertBefore(node, child) {
+ var parent = this;
+ // 1. Ensure pre-insertion validity
+ parent._ensureInsertValid(node, child, true);
+ // 2. Let reference child be child.
+ var refChild = child;
+ // 3. If reference child is node, set it to node's next sibling
+ if (refChild === node) { refChild = node.nextSibling; }
+ // 4. Adopt node into parent's node document.
+ parent.doc.adoptNode(node);
+ // 5. Insert node into parent before reference child.
+ node._insertOrReplace(parent, refChild, false);
+ // 6. Return node
+ return node;
+ }},
+
+
+ appendChild: { value: function(child) {
+ // This invokes _appendChild after doing validity checks.
+ return this.insertBefore(child, null);
+ }},
+
+ _appendChild: { value: function(child) {
+ child._insertOrReplace(this, null, false);
+ }},
+
+ removeChild: { value: function removeChild(child) {
+ var parent = this;
+ if (!child.nodeType) throw new TypeError('not a node');
+ if (child.parentNode !== parent) utils.NotFoundError();
+ child.remove();
+ return child;
+ }},
+
+ // To replace a `child` with `node` within a `parent` (this)
+ replaceChild: { value: function replaceChild(node, child) {
+ var parent = this;
+ // Ensure validity (slight differences from pre-insertion check)
+ parent._ensureInsertValid(node, child, false);
+ // Adopt node into parent's node document.
+ if (node.doc !== parent.doc) {
+ // XXX adoptNode has side-effect of removing node from its parent
+ // and generating a mutation event, thus causing the _insertOrReplace
+ // to generate two deletes and an insert instead of a 'move'
+ // event. It looks like the new MutationObserver stuff avoids
+ // this problem, but for now let's only adopt (ie, remove `node`
+ // from its parent) here if we need to.
+ parent.doc.adoptNode(node);
+ }
+ // Do the replace.
+ node._insertOrReplace(parent, child, true);
+ return child;
+ }},
+
+ // See: http://ejohn.org/blog/comparing-document-position/
+ contains: { value: function contains(node) {
+ if (node === null) { return false; }
+ if (this === node) { return true; /* inclusive descendant */ }
+ /* jshint bitwise: false */
+ return (this.compareDocumentPosition(node) &
+ DOCUMENT_POSITION_CONTAINED_BY) !== 0;
+ }},
+
+ compareDocumentPosition: { value: function compareDocumentPosition(that){
+ // Basic algorithm for finding the relative position of two nodes.
+ // Make a list the ancestors of each node, starting with the
+ // document element and proceeding down to the nodes themselves.
+ // Then, loop through the lists, looking for the first element
+ // that differs. The order of those two elements give the
+ // order of their descendant nodes. Or, if one list is a prefix
+ // of the other one, then that node contains the other.
+
+ if (this === that) return 0;
+
+ // If they're not owned by the same document or if one is rooted
+ // and one is not, then they're disconnected.
+ if (this.doc !== that.doc ||
+ this.rooted !== that.rooted)
+ return (DOCUMENT_POSITION_DISCONNECTED +
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
+
+ // Get arrays of ancestors for this and that
+ var these = [], those = [];
+ for(var n = this; n !== null; n = n.parentNode) these.push(n);
+ for(n = that; n !== null; n = n.parentNode) those.push(n);
+ these.reverse(); // So we start with the outermost
+ those.reverse();
+
+ if (these[0] !== those[0]) // No common ancestor
+ return (DOCUMENT_POSITION_DISCONNECTED +
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
+
+ n = Math.min(these.length, those.length);
+ for(var i = 1; i < n; i++) {
+ if (these[i] !== those[i]) {
+ // We found two different ancestors, so compare
+ // their positions
+ if (these[i].index < those[i].index)
+ return DOCUMENT_POSITION_FOLLOWING;
+ else
+ return DOCUMENT_POSITION_PRECEDING;
+ }
+ }
+
+ // If we get to here, then one of the nodes (the one with the
+ // shorter list of ancestors) contains the other one.
+ if (these.length < those.length)
+ return (DOCUMENT_POSITION_FOLLOWING +
+ DOCUMENT_POSITION_CONTAINED_BY);
+ else
+ return (DOCUMENT_POSITION_PRECEDING +
+ DOCUMENT_POSITION_CONTAINS);
+ }},
+
+ isSameNode: {value : function isSameNode(node) {
+ return this === node;
+ }},
+
+
+ // This method implements the generic parts of node equality testing
+ // and defers to the (non-recursive) type-specific isEqual() method
+ // defined by subclasses
+ isEqualNode: { value: function isEqualNode(node) {
+ if (!node) return false;
+ if (node.nodeType !== this.nodeType) return false;
+
+ // Check type-specific properties for equality
+ if (!this.isEqual(node)) return false;
+
+ // Now check children for number and equality
+ for (var c1 = this.firstChild, c2 = node.firstChild;
+ c1 && c2;
+ c1 = c1.nextSibling, c2 = c2.nextSibling) {
+ if (!c1.isEqualNode(c2)) return false;
+ }
+ return c1 === null && c2 === null;
+ }},
+
+ // This method delegates shallow cloning to a clone() method
+ // that each concrete subclass must implement
+ cloneNode: { value: function(deep) {
+ // Clone this node
+ var clone = this.clone();
+
+ // Handle the recursive case if necessary
+ if (deep) {
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ clone._appendChild(kid.cloneNode(true));
+ }
+ }
+
+ return clone;
+ }},
+
+ lookupPrefix: { value: function lookupPrefix(ns) {
+ var e;
+ if (ns === '' || ns === null || ns === undefined) return null;
+ switch(this.nodeType) {
+ case ELEMENT_NODE:
+ return this._lookupNamespacePrefix(ns, this);
+ case DOCUMENT_NODE:
+ e = this.documentElement;
+ return e ? e.lookupPrefix(ns) : null;
+ case ENTITY_NODE:
+ case NOTATION_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ case DOCUMENT_TYPE_NODE:
+ return null;
+ case ATTRIBUTE_NODE:
+ e = this.ownerElement;
+ return e ? e.lookupPrefix(ns) : null;
+ default:
+ e = this.parentElement;
+ return e ? e.lookupPrefix(ns) : null;
+ }
+ }},
+
+
+ lookupNamespaceURI: {value: function lookupNamespaceURI(prefix) {
+ if (prefix === '' || prefix === undefined) { prefix = null; }
+ var e;
+ switch(this.nodeType) {
+ case ELEMENT_NODE:
+ return utils.shouldOverride();
+ case DOCUMENT_NODE:
+ e = this.documentElement;
+ return e ? e.lookupNamespaceURI(prefix) : null;
+ case ENTITY_NODE:
+ case NOTATION_NODE:
+ case DOCUMENT_TYPE_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ return null;
+ case ATTRIBUTE_NODE:
+ e = this.ownerElement;
+ return e ? e.lookupNamespaceURI(prefix) : null;
+ default:
+ e = this.parentElement;
+ return e ? e.lookupNamespaceURI(prefix) : null;
+ }
+ }},
+
+ isDefaultNamespace: { value: function isDefaultNamespace(ns) {
+ if (ns === '' || ns === undefined) { ns = null; }
+ var defaultNamespace = this.lookupNamespaceURI(null);
+ return (defaultNamespace === ns);
+ }},
+
+ // Utility methods for nodes. Not part of the DOM
+
+ // Return the index of this node in its parent.
+ // Throw if no parent, or if this node is not a child of its parent
+ index: { get: function() {
+ var parent = this.parentNode;
+ if (this === parent.firstChild) return 0; // fast case
+ var kids = parent.childNodes;
+ if (this._index === undefined || kids[this._index] !== this) {
+ // Ensure that we don't have an O(N^2) blowup if none of the
+ // kids have defined indices yet and we're traversing via
+ // nextSibling or previousSibling
+ for (var i=0; i<kids.length; i++) {
+ kids[i]._index = i;
+ }
+ utils.assert(kids[this._index] === this);
+ }
+ return this._index;
+ }},
+
+ // Return true if this node is equal to or is an ancestor of that node
+ // Note that nodes are considered to be ancestors of themselves
+ isAncestor: { value: function(that) {
+ // If they belong to different documents, then they're unrelated.
+ if (this.doc !== that.doc) return false;
+ // If one is rooted and one isn't then they're not related
+ if (this.rooted !== that.rooted) return false;
+
+ // Otherwise check by traversing the parentNode chain
+ for(var e = that; e; e = e.parentNode) {
+ if (e === this) return true;
+ }
+ return false;
+ }},
+
+ // DOMINO Changed the behavior to conform with the specs. See:
+ // https://groups.google.com/d/topic/mozilla.dev.platform/77sIYcpdDmc/discussion
+ ensureSameDoc: { value: function(that) {
+ if (that.ownerDocument === null) {
+ that.ownerDocument = this.doc;
+ }
+ else if(that.ownerDocument !== this.doc) {
+ utils.WrongDocumentError();
+ }
+ }},
+
+ removeChildren: { value: utils.shouldOverride },
+
+ // Insert this node as a child of parent before the specified child,
+ // or insert as the last child of parent if specified child is null,
+ // or replace the specified child with this node, firing mutation events as
+ // necessary
+ _insertOrReplace: { value: function _insertOrReplace(parent, before, isReplace) {
+ var child = this, before_index, i;
+
+ if (child.nodeType === DOCUMENT_FRAGMENT_NODE && child.rooted) {
+ utils.HierarchyRequestError();
+ }
+
+ /* Ensure index of `before` is cached before we (possibly) remove it. */
+ if (parent._childNodes) {
+ before_index = (before === null) ? parent._childNodes.length :
+ before.index; /* ensure _index is cached */
+
+ // If we are already a child of the specified parent, then
+ // the index may have to be adjusted.
+ if (child.parentNode === parent) {
+ var child_index = child.index;
+ // If the child is before the spot it is to be inserted at,
+ // then when it is removed, the index of that spot will be
+ // reduced.
+ if (child_index < before_index) {
+ before_index--;
+ }
+ }
+ }
+
+ // Delete the old child
+ if (isReplace) {
+ if (before.rooted) before.doc.mutateRemove(before);
+ before.parentNode = null;
+ }
+
+ var n = before;
+ if (n === null) { n = parent.firstChild; }
+
+ // If both the child and the parent are rooted, then we want to
+ // transplant the child without uprooting and rerooting it.
+ var bothRooted = child.rooted && parent.rooted;
+ if (child.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var spliceArgs = [0, isReplace ? 1 : 0], next;
+ for (var kid = child.firstChild; kid !== null; kid = next) {
+ next = kid.nextSibling;
+ spliceArgs.push(kid);
+ kid.parentNode = parent;
+ }
+ var len = spliceArgs.length;
+ // Add all nodes to the new parent, overwriting the old child
+ if (isReplace) {
+ LinkedList.replace(n, len > 2 ? spliceArgs[2] : null);
+ } else if (len > 2 && n !== null) {
+ LinkedList.insertBefore(spliceArgs[2], n);
+ }
+ if (parent._childNodes) {
+ spliceArgs[0] = (before === null) ?
+ parent._childNodes.length : before._index;
+ parent._childNodes.splice.apply(parent._childNodes, spliceArgs);
+ for (i=2; i<len; i++) {
+ spliceArgs[i]._index = spliceArgs[0] + (i - 2);
+ }
+ } else if (parent._firstChild === before) {
+ if (len > 2) {
+ parent._firstChild = spliceArgs[2];
+ } else if (isReplace) {
+ parent._firstChild = null;
+ }
+ }
+ // Remove all nodes from the document fragment
+ if (child._childNodes) {
+ child._childNodes.length = 0;
+ } else {
+ child._firstChild = null;
+ }
+ // Call the mutation handlers
+ // Use spliceArgs since the original array has been destroyed. The
+ // liveness guarantee requires us to clone the array so that
+ // references to the childNodes of the DocumentFragment will be empty
+ // when the insertion handlers are called.
+ if (parent.rooted) {
+ parent.modify();
+ for (i = 2; i < len; i++) {
+ parent.doc.mutateInsert(spliceArgs[i]);
+ }
+ }
+ } else {
+ if (before === child) { return; }
+ if (bothRooted) {
+ // Remove the child from its current position in the tree
+ // without calling remove(), since we don't want to uproot it.
+ child._remove();
+ } else if (child.parentNode) {
+ child.remove();
+ }
+
+ // Insert it as a child of its new parent
+ child.parentNode = parent;
+ if (isReplace) {
+ LinkedList.replace(n, child);
+ if (parent._childNodes) {
+ child._index = before_index;
+ parent._childNodes[before_index] = child;
+ } else if (parent._firstChild === before) {
+ parent._firstChild = child;
+ }
+ } else {
+ if (n !== null) {
+ LinkedList.insertBefore(child, n);
+ }
+ if (parent._childNodes) {
+ child._index = before_index;
+ parent._childNodes.splice(before_index, 0, child);
+ } else if (parent._firstChild === before) {
+ parent._firstChild = child;
+ }
+ }
+ if (bothRooted) {
+ parent.modify();
+ // Generate a move mutation event
+ parent.doc.mutateMove(child);
+ } else if (parent.rooted) {
+ parent.modify();
+ parent.doc.mutateInsert(child);
+ }
+ }
+ }},
+
+
+ // Return the lastModTime value for this node. (For use as a
+ // cache invalidation mechanism. If the node does not already
+ // have one, initialize it from the owner document's modclock
+ // property. (Note that modclock does not return the actual
+ // time; it is simply a counter incremented on each document
+ // modification)
+ lastModTime: { get: function() {
+ if (!this._lastModTime) {
+ this._lastModTime = this.doc.modclock;
+ }
+ return this._lastModTime;
+ }},
+
+ // Increment the owner document's modclock and use the new
+ // value to update the lastModTime value for this node and
+ // all of its ancestors. Nodes that have never had their
+ // lastModTime value queried do not need to have a
+ // lastModTime property set on them since there is no
+ // previously queried value to ever compare the new value
+ // against, so only update nodes that already have a
+ // _lastModTime property.
+ modify: { value: function() {
+ if (this.doc.modclock) { // Skip while doc.modclock == 0
+ var time = ++this.doc.modclock;
+ for(var n = this; n; n = n.parentElement) {
+ if (n._lastModTime) {
+ n._lastModTime = time;
+ }
+ }
+ }
+ }},
+
+ // This attribute is not part of the DOM but is quite helpful.
+ // It returns the document with which a node is associated. Usually
+ // this is the ownerDocument. But ownerDocument is null for the
+ // document object itself, so this is a handy way to get the document
+ // regardless of the node type
+ doc: { get: function() {
+ return this.ownerDocument || this;
+ }},
+
+
+ // If the node has a nid (node id), then it is rooted in a document
+ rooted: { get: function() {
+ return !!this._nid;
+ }},
+
+ normalize: { value: function() {
+ var next;
+ for (var child=this.firstChild; child !== null; child=next) {
+ next = child.nextSibling;
+
+ if (child.normalize) {
+ child.normalize();
+ }
+
+ if (child.nodeType !== Node.TEXT_NODE) {
+ continue;
+ }
+
+ if (child.nodeValue === "") {
+ this.removeChild(child);
+ continue;
+ }
+
+ var prevChild = child.previousSibling;
+ if (prevChild === null) {
+ continue;
+ } else if (prevChild.nodeType === Node.TEXT_NODE) {
+ // merge this with previous and remove the child
+ prevChild.appendData(child.nodeValue);
+ this.removeChild(child);
+ }
+ }
+ }},
+
+ // Convert the children of a node to an HTML string.
+ // This is used by the innerHTML getter
+ // The serialization spec is at:
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments
+ //
+ // The serialization logic is intentionally implemented in a separate
+ // `NodeUtils` helper instead of the more obvious choice of a private
+ // `_serializeOne()` method on the `Node.prototype` in order to avoid
+ // the megamorphic `this._serializeOne` property access, which reduces
+ // performance unnecessarily. If you need specialized behavior for a
+ // certain subclass, you'll need to implement that in `NodeUtils`.
+ // See https://github.com/fgnass/domino/pull/142 for more information.
+ serialize: { value: function() {
+ var s = '';
+ for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
+ s += NodeUtils.serializeOne(kid, this);
+ }
+ return s;
+ }},
+
+ // Non-standard, but often useful for debugging.
+ outerHTML: {
+ get: function() {
+ return NodeUtils.serializeOne(this, { nodeType: 0 });
+ },
+ set: utils.nyi,
+ },
+
+ // mirror node type properties in the prototype, so they are present
+ // in instances of Node (and subclasses)
+ ELEMENT_NODE: { value: ELEMENT_NODE },
+ ATTRIBUTE_NODE: { value: ATTRIBUTE_NODE },
+ TEXT_NODE: { value: TEXT_NODE },
+ CDATA_SECTION_NODE: { value: CDATA_SECTION_NODE },
+ ENTITY_REFERENCE_NODE: { value: ENTITY_REFERENCE_NODE },
+ ENTITY_NODE: { value: ENTITY_NODE },
+ PROCESSING_INSTRUCTION_NODE: { value: PROCESSING_INSTRUCTION_NODE },
+ COMMENT_NODE: { value: COMMENT_NODE },
+ DOCUMENT_NODE: { value: DOCUMENT_NODE },
+ DOCUMENT_TYPE_NODE: { value: DOCUMENT_TYPE_NODE },
+ DOCUMENT_FRAGMENT_NODE: { value: DOCUMENT_FRAGMENT_NODE },
+ NOTATION_NODE: { value: NOTATION_NODE },
+
+ DOCUMENT_POSITION_DISCONNECTED: { value: DOCUMENT_POSITION_DISCONNECTED },
+ DOCUMENT_POSITION_PRECEDING: { value: DOCUMENT_POSITION_PRECEDING },
+ DOCUMENT_POSITION_FOLLOWING: { value: DOCUMENT_POSITION_FOLLOWING },
+ DOCUMENT_POSITION_CONTAINS: { value: DOCUMENT_POSITION_CONTAINS },
+ DOCUMENT_POSITION_CONTAINED_BY: { value: DOCUMENT_POSITION_CONTAINED_BY },
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: { value: DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC },
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeFilter.js
@@ -1,0 +1,24 @@
+"use strict";
+var NodeFilter = {
+ // Constants for acceptNode()
+ FILTER_ACCEPT: 1,
+ FILTER_REJECT: 2,
+ FILTER_SKIP: 3,
+
+ // Constants for whatToShow
+ SHOW_ALL: 0xFFFFFFFF,
+ SHOW_ELEMENT: 0x1,
+ SHOW_ATTRIBUTE: 0x2, // historical
+ SHOW_TEXT: 0x4,
+ SHOW_CDATA_SECTION: 0x8, // historical
+ SHOW_ENTITY_REFERENCE: 0x10, // historical
+ SHOW_ENTITY: 0x20, // historical
+ SHOW_PROCESSING_INSTRUCTION: 0x40,
+ SHOW_COMMENT: 0x80,
+ SHOW_DOCUMENT: 0x100,
+ SHOW_DOCUMENT_TYPE: 0x200,
+ SHOW_DOCUMENT_FRAGMENT: 0x400,
+ SHOW_NOTATION: 0x800 // historical
+};
+
+module.exports = (NodeFilter.constructor = NodeFilter.prototype = NodeFilter);
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeIterator.js
@@ -1,0 +1,217 @@
+"use strict";
+module.exports = NodeIterator;
+
+var NodeFilter = require('./NodeFilter');
+var NodeTraversal = require('./NodeTraversal');
+var utils = require('./utils');
+
+/* Private methods and helpers */
+
+/**
+ * @based on WebKit's NodeIterator::moveToNext and NodeIterator::moveToPrevious
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeIterator.cpp?rev=186279#L51
+ */
+function move(node, stayWithin, directionIsNext) {
+ if (directionIsNext) {
+ return NodeTraversal.next(node, stayWithin);
+ } else {
+ if (node === stayWithin) {
+ return null;
+ }
+ return NodeTraversal.previous(node, null);
+ }
+}
+
+function isInclusiveAncestor(node, possibleChild) {
+ for ( ; possibleChild; possibleChild = possibleChild.parentNode) {
+ if (node === possibleChild) { return true; }
+ }
+ return false;
+}
+
+/**
+ * @spec http://www.w3.org/TR/dom/#concept-nodeiterator-traverse
+ * @method
+ * @access private
+ * @param {NodeIterator} ni
+ * @param {string} direction One of 'next' or 'previous'.
+ * @return {Node|null}
+ */
+function traverse(ni, directionIsNext) {
+ var node, beforeNode;
+ node = ni._referenceNode;
+ beforeNode = ni._pointerBeforeReferenceNode;
+ while (true) {
+ if (beforeNode === directionIsNext) {
+ beforeNode = !beforeNode;
+ } else {
+ node = move(node, ni._root, directionIsNext);
+ if (node === null) {
+ return null;
+ }
+ }
+ var result = ni._internalFilter(node);
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ break;
+ }
+ }
+ ni._referenceNode = node;
+ ni._pointerBeforeReferenceNode = beforeNode;
+ return node;
+}
+
+/* Public API */
+
+/**
+ * Implemented version: http://www.w3.org/TR/2015/WD-dom-20150618/#nodeiterator
+ * Latest version: http://www.w3.org/TR/dom/#nodeiterator
+ *
+ * @constructor
+ * @param {Node} root
+ * @param {number} whatToShow [optional]
+ * @param {Function|NodeFilter} filter [optional]
+ * @throws Error
+ */
+function NodeIterator(root, whatToShow, filter) {
+ if (!root || !root.nodeType) {
+ utils.NotSupportedError();
+ }
+
+ // Read-only properties
+ this._root = root;
+ this._referenceNode = root;
+ this._pointerBeforeReferenceNode = true;
+ this._whatToShow = Number(whatToShow) || 0;
+ this._filter = filter || null;
+ this._active = false;
+ // Record active node iterators in the document, in order to perform
+ // "node iterator pre-removal steps".
+ root.doc._attachNodeIterator(this);
+}
+
+Object.defineProperties(NodeIterator.prototype, {
+ root: { get: function root() {
+ return this._root;
+ } },
+ referenceNode: { get: function referenceNode() {
+ return this._referenceNode;
+ } },
+ pointerBeforeReferenceNode: { get: function pointerBeforeReferenceNode() {
+ return this._pointerBeforeReferenceNode;
+ } },
+ whatToShow: { get: function whatToShow() {
+ return this._whatToShow;
+ } },
+ filter: { get: function filter() {
+ return this._filter;
+ } },
+
+ /**
+ * @method
+ * @param {Node} node
+ * @return {Number} Constant NodeFilter.FILTER_ACCEPT,
+ * NodeFilter.FILTER_REJECT or NodeFilter.FILTER_SKIP.
+ */
+ _internalFilter: { value: function _internalFilter(node) {
+ /* jshint bitwise: false */
+ var result, filter;
+ if (this._active) {
+ utils.InvalidStateError();
+ }
+
+ // Maps nodeType to whatToShow
+ if (!(((1 << (node.nodeType - 1)) & this._whatToShow))) {
+ return NodeFilter.FILTER_SKIP;
+ }
+
+ filter = this._filter;
+ if (filter === null) {
+ result = NodeFilter.FILTER_ACCEPT;
+ } else {
+ this._active = true;
+ try {
+ if (typeof filter === 'function') {
+ result = filter(node);
+ } else {
+ result = filter.acceptNode(node);
+ }
+ } finally {
+ this._active = false;
+ }
+ }
+
+ // Note that coercing to a number means that
+ // `true` becomes `1` (which is NodeFilter.FILTER_ACCEPT)
+ // `false` becomes `0` (neither accept, reject, or skip)
+ return (+result);
+ } },
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#nodeiterator-pre-removing-steps
+ * @method
+ * @return void
+ */
+ _preremove: { value: function _preremove(toBeRemovedNode) {
+ if (isInclusiveAncestor(toBeRemovedNode, this._root)) { return; }
+ if (!isInclusiveAncestor(toBeRemovedNode, this._referenceNode)) { return; }
+ if (this._pointerBeforeReferenceNode) {
+ var next = toBeRemovedNode;
+ while (next.lastChild) {
+ next = next.lastChild;
+ }
+ next = NodeTraversal.next(next, this.root);
+ if (next) {
+ this._referenceNode = next;
+ return;
+ }
+ this._pointerBeforeReferenceNode = false;
+ // fall through
+ }
+ if (toBeRemovedNode.previousSibling === null) {
+ this._referenceNode = toBeRemovedNode.parentNode;
+ } else {
+ this._referenceNode = toBeRemovedNode.previousSibling;
+ var lastChild;
+ for (lastChild = this._referenceNode.lastChild;
+ lastChild;
+ lastChild = this._referenceNode.lastChild) {
+ this._referenceNode = lastChild;
+ }
+ }
+ } },
+
+ /**
+ * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-nextnode
+ * @method
+ * @return {Node|null}
+ */
+ nextNode: { value: function nextNode() {
+ return traverse(this, true);
+ } },
+
+ /**
+ * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-previousnode
+ * @method
+ * @return {Node|null}
+ */
+ previousNode: { value: function previousNode() {
+ return traverse(this, false);
+ } },
+
+ /**
+ * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-detach
+ * @method
+ * @return void
+ */
+ detach: { value: function detach() {
+ /* "The detach() method must do nothing.
+ * Its functionality (disabling a NodeIterator object) was removed,
+ * but the method itself is preserved for compatibility.
+ */
+ } },
+
+ /** For compatibility with web-platform-tests. */
+ toString: { value: function toString() {
+ return "[object NodeIterator]";
+ } },
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeList.es5.js
@@ -1,0 +1,15 @@
+"use strict";
+
+// No support for subclassing array, return an actual Array object.
+function item(i) {
+ /* jshint validthis: true */
+ return this[i] || null;
+}
+
+function NodeList(a) {
+ if (!a) a = [];
+ a.item = item;
+ return a;
+}
+
+module.exports = NodeList;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeList.es6.js
@@ -1,0 +1,12 @@
+/* jshint esversion: 6 */
+"use strict";
+
+module.exports = class NodeList extends Array {
+ constructor(a) {
+ super((a && a.length) || 0);
+ if (a) {
+ for (var idx in a) { this[idx] = a[idx]; }
+ }
+ }
+ item(i) { return this[i] || null; }
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeList.js
@@ -1,0 +1,13 @@
+"use strict";
+
+var NodeList;
+
+try {
+ // Attempt to use ES6-style Array subclass if possible.
+ NodeList = require('./NodeList.es6.js');
+} catch (e) {
+ // No support for subclassing array, return an actual Array object.
+ NodeList = require('./NodeList.es5.js');
+}
+
+module.exports = NodeList;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeTraversal.js
@@ -1,0 +1,87 @@
+"use strict";
+/* exported NodeTraversal */
+var NodeTraversal = module.exports = {
+ nextSkippingChildren: nextSkippingChildren,
+ nextAncestorSibling: nextAncestorSibling,
+ next: next,
+ previous: previous,
+ deepLastChild: deepLastChild
+};
+
+/**
+ * @based on WebKit's NodeTraversal::nextSkippingChildren
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L109
+ */
+function nextSkippingChildren(node, stayWithin) {
+ if (node === stayWithin) {
+ return null;
+ }
+ if (node.nextSibling !== null) {
+ return node.nextSibling;
+ }
+ return nextAncestorSibling(node, stayWithin);
+}
+
+/**
+ * @based on WebKit's NodeTraversal::nextAncestorSibling
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L93
+ */
+function nextAncestorSibling(node, stayWithin) {
+ for (node = node.parentNode; node !== null; node = node.parentNode) {
+ if (node === stayWithin) {
+ return null;
+ }
+ if (node.nextSibling !== null) {
+ return node.nextSibling;
+ }
+ }
+ return null;
+}
+
+/**
+ * @based on WebKit's NodeTraversal::next
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L99
+ */
+function next(node, stayWithin) {
+ var n;
+ n = node.firstChild;
+ if (n !== null) {
+ return n;
+ }
+ if (node === stayWithin) {
+ return null;
+ }
+ n = node.nextSibling;
+ if (n !== null) {
+ return n;
+ }
+ return nextAncestorSibling(node, stayWithin);
+}
+
+/**
+ * @based on WebKit's NodeTraversal::deepLastChild
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L116
+ */
+function deepLastChild(node) {
+ while (node.lastChild) {
+ node = node.lastChild;
+ }
+ return node;
+}
+
+/**
+ * @based on WebKit's NodeTraversal::previous
+ * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L121
+ */
+function previous(node, stayWithin) {
+ var p;
+ p = node.previousSibling;
+ if (p !== null) {
+ return deepLastChild(p);
+ }
+ p = node.parentNode;
+ if (p === stayWithin) {
+ return null;
+ }
+ return p;
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NodeUtils.js
@@ -1,0 +1,168 @@
+"use strict";
+module.exports = {
+ // NOTE: The `serializeOne()` function used to live on the `Node.prototype`
+ // as a private method `Node#_serializeOne(child)`, however that requires
+ // a megamorphic property access `this._serializeOne` just to get to the
+ // method, and this is being done on lots of different `Node` subclasses,
+ // which puts a lot of pressure on V8's megamorphic stub cache. So by
+ // moving the helper off of the `Node.prototype` and into a separate
+ // function in this helper module, we get a monomorphic property access
+ // `NodeUtils.serializeOne` to get to the function and reduce pressure
+ // on the megamorphic stub cache.
+ // See https://github.com/fgnass/domino/pull/142 for more information.
+ serializeOne: serializeOne
+};
+
+var utils = require('./utils');
+var NAMESPACE = utils.NAMESPACE;
+
+var hasRawContent = {
+ STYLE: true,
+ SCRIPT: true,
+ XMP: true,
+ IFRAME: true,
+ NOEMBED: true,
+ NOFRAMES: true,
+ PLAINTEXT: true
+};
+
+var emptyElements = {
+ area: true,
+ base: true,
+ basefont: true,
+ bgsound: true,
+ br: true,
+ col: true,
+ embed: true,
+ frame: true,
+ hr: true,
+ img: true,
+ input: true,
+ keygen: true,
+ link: true,
+ meta: true,
+ param: true,
+ source: true,
+ track: true,
+ wbr: true
+};
+
+var extraNewLine = {
+ /* Removed in https://github.com/whatwg/html/issues/944
+ pre: true,
+ textarea: true,
+ listing: true
+ */
+};
+
+function escape(s) {
+ return s.replace(/[&<>\u00A0]/g, function(c) {
+ switch(c) {
+ case '&': return '&';
+ case '<': return '<';
+ case '>': return '>';
+ case '\u00A0': return ' ';
+ }
+ });
+}
+
+function escapeAttr(s) {
+ var toEscape = /[&"\u00A0]/g;
+ if (!toEscape.test(s)) {
+ // nothing to do, fast path
+ return s;
+ } else {
+ return s.replace(toEscape, function(c) {
+ switch(c) {
+ case '&': return '&';
+ case '"': return '"';
+ case '\u00A0': return ' ';
+ }
+ });
+ }
+}
+
+function attrname(a) {
+ var ns = a.namespaceURI;
+ if (!ns)
+ return a.localName;
+ if (ns === NAMESPACE.XML)
+ return 'xml:' + a.localName;
+ if (ns === NAMESPACE.XLINK)
+ return 'xlink:' + a.localName;
+
+ if (ns === NAMESPACE.XMLNS) {
+ if (a.localName === 'xmlns') return 'xmlns';
+ else return 'xmlns:' + a.localName;
+ }
+ return a.name;
+}
+
+function serializeOne(kid, parent) {
+ var s = '';
+ switch(kid.nodeType) {
+ case 1: //ELEMENT_NODE
+ var ns = kid.namespaceURI;
+ var html = ns === NAMESPACE.HTML;
+ var tagname = (html || ns === NAMESPACE.SVG || ns === NAMESPACE.MATHML) ? kid.localName : kid.tagName;
+
+ s += '<' + tagname;
+
+ for(var j = 0, k = kid._numattrs; j < k; j++) {
+ var a = kid._attr(j);
+ s += ' ' + attrname(a);
+ if (a.value !== undefined) s += '="' + escapeAttr(a.value) + '"';
+ }
+ s += '>';
+
+ if (!(html && emptyElements[tagname])) {
+ var ss = kid.serialize();
+ if (html && extraNewLine[tagname] && ss.charAt(0)==='\n') s += '\n';
+ // Serialize children and add end tag for all others
+ s += ss;
+ s += '</' + tagname + '>';
+ }
+ break;
+ case 3: //TEXT_NODE
+ case 4: //CDATA_SECTION_NODE
+ var parenttag;
+ if (parent.nodeType === 1 /*ELEMENT_NODE*/ &&
+ parent.namespaceURI === NAMESPACE.HTML)
+ parenttag = parent.tagName;
+ else
+ parenttag = '';
+
+ if (hasRawContent[parenttag] ||
+ (parenttag==='NOSCRIPT' && parent.ownerDocument._scripting_enabled)) {
+ s += kid.data;
+ } else {
+ s += escape(kid.data);
+ }
+ break;
+ case 8: //COMMENT_NODE
+ s += '<!--' + kid.data + '-->';
+ break;
+ case 7: //PROCESSING_INSTRUCTION_NODE
+ s += '<?' + kid.target + ' ' + kid.data + '?>';
+ break;
+ case 10: //DOCUMENT_TYPE_NODE
+ s += '<!DOCTYPE ' + kid.name;
+
+ if (false) {
+ // Latest HTML serialization spec omits the public/system ID
+ if (kid.publicID) {
+ s += ' PUBLIC "' + kid.publicId + '"';
+ }
+
+ if (kid.systemId) {
+ s += ' "' + kid.systemId + '"';
+ }
+ }
+
+ s += '>';
+ break;
+ default:
+ utils.InvalidStateError();
+ }
+ return s;
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/NonDocumentTypeChildNode.js
@@ -1,0 +1,26 @@
+"use strict";
+var Node = require('./Node');
+
+var NonDocumentTypeChildNode = {
+
+ nextElementSibling: { get: function() {
+ if (this.parentNode) {
+ for (var kid = this.nextSibling; kid !== null; kid = kid.nextSibling) {
+ if (kid.nodeType === Node.ELEMENT_NODE) return kid;
+ }
+ }
+ return null;
+ }},
+
+ previousElementSibling: { get: function() {
+ if (this.parentNode) {
+ for (var kid = this.previousSibling; kid !== null; kid = kid.previousSibling) {
+ if (kid.nodeType === Node.ELEMENT_NODE) return kid;
+ }
+ }
+ return null;
+ }}
+
+};
+
+module.exports = NonDocumentTypeChildNode;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/ProcessingInstruction.js
@@ -1,0 +1,43 @@
+"use strict";
+module.exports = ProcessingInstruction;
+
+var Node = require('./Node');
+var CharacterData = require('./CharacterData');
+
+function ProcessingInstruction(doc, target, data) {
+ CharacterData.call(this);
+ this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
+ this.ownerDocument = doc;
+ this.target = target;
+ this._data = data;
+}
+
+var nodeValue = {
+ get: function() { return this._data; },
+ set: function(v) {
+ if (v === null || v === undefined) { v = ''; } else { v = String(v); }
+ this._data = v;
+ if (this.rooted) this.ownerDocument.mutateValue(this);
+ }
+};
+
+ProcessingInstruction.prototype = Object.create(CharacterData.prototype, {
+ nodeName: { get: function() { return this.target; }},
+ nodeValue: nodeValue,
+ textContent: nodeValue,
+ data: {
+ get: nodeValue.get,
+ set: function(v) {
+ nodeValue.set.call(this, v===null ? '' : String(v));
+ },
+ },
+
+ // Utility methods
+ clone: { value: function clone() {
+ return new ProcessingInstruction(this.ownerDocument, this.target, this._data);
+ }},
+ isEqual: { value: function isEqual(n) {
+ return this.target === n.target && this._data === n._data;
+ }}
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Text.js
@@ -1,0 +1,74 @@
+"use strict";
+module.exports = Text;
+
+var utils = require('./utils');
+var Node = require('./Node');
+var CharacterData = require('./CharacterData');
+
+function Text(doc, data) {
+ CharacterData.call(this);
+ this.nodeType = Node.TEXT_NODE;
+ this.ownerDocument = doc;
+ this._data = data;
+ this._index = undefined;
+}
+
+var nodeValue = {
+ get: function() { return this._data; },
+ set: function(v) {
+ if (v === null || v === undefined) { v = ''; } else { v = String(v); }
+ if (v === this._data) return;
+ this._data = v;
+ if (this.rooted)
+ this.ownerDocument.mutateValue(this);
+ if (this.parentNode &&
+ this.parentNode._textchangehook)
+ this.parentNode._textchangehook(this);
+ }
+};
+
+Text.prototype = Object.create(CharacterData.prototype, {
+ nodeName: { value: "#text" },
+ // These three attributes are all the same.
+ // The data attribute has a [TreatNullAs=EmptyString] but we'll
+ // implement that at the interface level
+ nodeValue: nodeValue,
+ textContent: nodeValue,
+ data: {
+ get: nodeValue.get,
+ set: function(v) {
+ nodeValue.set.call(this, v===null ? '' : String(v));
+ },
+ },
+
+ splitText: { value: function splitText(offset) {
+ if (offset > this._data.length || offset < 0) utils.IndexSizeError();
+
+ var newdata = this._data.substring(offset),
+ newnode = this.ownerDocument.createTextNode(newdata);
+ this.data = this.data.substring(0, offset);
+
+ var parent = this.parentNode;
+ if (parent !== null)
+ parent.insertBefore(newnode, this.nextSibling);
+
+ return newnode;
+ }},
+
+ wholeText: { get: function wholeText() {
+ var result = this.textContent;
+ for (var next = this.nextSibling; next; next = next.nextSibling) {
+ if (next.nodeType !== Node.TEXT_NODE) { break; }
+ result += next.textContent;
+ }
+ return result;
+ }},
+ // Obsolete, removed from spec.
+ replaceWholeText: { value: utils.nyi },
+
+ // Utility methods
+ clone: { value: function clone() {
+ return new Text(this.ownerDocument, this._data);
+ }},
+
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/TreeWalker.js
@@ -1,0 +1,336 @@
+"use strict";
+module.exports = TreeWalker;
+
+var Node = require('./Node');
+var NodeFilter = require('./NodeFilter');
+var NodeTraversal = require('./NodeTraversal');
+var utils = require('./utils');
+
+var mapChild = {
+ first: 'firstChild',
+ last: 'lastChild',
+ next: 'firstChild',
+ previous: 'lastChild'
+};
+
+var mapSibling = {
+ first: 'nextSibling',
+ last: 'previousSibling',
+ next: 'nextSibling',
+ previous: 'previousSibling'
+};
+
+/* Private methods and helpers */
+
+/**
+ * @spec https://dom.spec.whatwg.org/#concept-traverse-children
+ * @method
+ * @access private
+ * @param {TreeWalker} tw
+ * @param {string} type One of 'first' or 'last'.
+ * @return {Node|null}
+ */
+function traverseChildren(tw, type) {
+ var child, node, parent, result, sibling;
+ node = tw._currentNode[mapChild[type]];
+ while (node !== null) {
+ result = tw._internalFilter(node);
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ tw._currentNode = node;
+ return node;
+ }
+ if (result === NodeFilter.FILTER_SKIP) {
+ child = node[mapChild[type]];
+ if (child !== null) {
+ node = child;
+ continue;
+ }
+ }
+ while (node !== null) {
+ sibling = node[mapSibling[type]];
+ if (sibling !== null) {
+ node = sibling;
+ break;
+ }
+ parent = node.parentNode;
+ if (parent === null || parent === tw.root || parent === tw._currentNode) {
+ return null;
+ } else {
+ node = parent;
+ }
+ }
+ }
+ return null;
+}
+
+/**
+ * @spec https://dom.spec.whatwg.org/#concept-traverse-siblings
+ * @method
+ * @access private
+ * @param {TreeWalker} tw
+ * @param {TreeWalker} type One of 'next' or 'previous'.
+ * @return {Node|nul}
+ */
+function traverseSiblings(tw, type) {
+ var node, result, sibling;
+ node = tw._currentNode;
+ if (node === tw.root) {
+ return null;
+ }
+ while (true) {
+ sibling = node[mapSibling[type]];
+ while (sibling !== null) {
+ node = sibling;
+ result = tw._internalFilter(node);
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ tw._currentNode = node;
+ return node;
+ }
+ sibling = node[mapChild[type]];
+ if (result === NodeFilter.FILTER_REJECT || sibling === null) {
+ sibling = node[mapSibling[type]];
+ }
+ }
+ node = node.parentNode;
+ if (node === null || node === tw.root) {
+ return null;
+ }
+ if (tw._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
+ return null;
+ }
+ }
+}
+
+
+/* Public API */
+
+/**
+ * Latest version: https://dom.spec.whatwg.org/#treewalker
+ *
+ * @constructor
+ * @param {Node} root
+ * @param {number} whatToShow [optional]
+ * @param {Function|NodeFilter} filter [optional]
+ * @throws Error
+ */
+function TreeWalker(root, whatToShow, filter) {
+ if (!root || !root.nodeType) {
+ utils.NotSupportedError();
+ }
+
+ // Read-only properties
+ this._root = root;
+ this._whatToShow = Number(whatToShow) || 0;
+ this._filter = filter || null;
+ this._active = false;
+ // Read-write property
+ this._currentNode = root;
+}
+
+Object.defineProperties(TreeWalker.prototype, {
+ root: { get: function() { return this._root; } },
+ whatToShow: { get: function() { return this._whatToShow; } },
+ filter: { get: function() { return this._filter; } },
+
+ currentNode: {
+ get: function currentNode() {
+ return this._currentNode;
+ },
+ set: function setCurrentNode(v) {
+ if (!(v instanceof Node)) {
+ throw new TypeError("Not a Node"); // `null` is also not a node
+ }
+ this._currentNode = v;
+ },
+ },
+
+ /**
+ * @method
+ * @param {Node} node
+ * @return {Number} Constant NodeFilter.FILTER_ACCEPT,
+ * NodeFilter.FILTER_REJECT or NodeFilter.FILTER_SKIP.
+ */
+ _internalFilter: { value: function _internalFilter(node) {
+ /* jshint bitwise: false */
+ var result, filter;
+ if (this._active) {
+ utils.InvalidStateError();
+ }
+
+ // Maps nodeType to whatToShow
+ if (!(((1 << (node.nodeType - 1)) & this._whatToShow))) {
+ return NodeFilter.FILTER_SKIP;
+ }
+
+ filter = this._filter;
+ if (filter === null) {
+ result = NodeFilter.FILTER_ACCEPT;
+ } else {
+ this._active = true;
+ try {
+ if (typeof filter === 'function') {
+ result = filter(node);
+ } else {
+ result = filter.acceptNode(node);
+ }
+ } finally {
+ this._active = false;
+ }
+ }
+
+ // Note that coercing to a number means that
+ // `true` becomes `1` (which is NodeFilter.FILTER_ACCEPT)
+ // `false` becomes `0` (neither accept, reject, or skip)
+ return (+result);
+ }},
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#dom-treewalker-parentnode
+ * @based on WebKit's TreeWalker::parentNode
+ * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L50
+ * @method
+ * @return {Node|null}
+ */
+ parentNode: { value: function parentNode() {
+ var node = this._currentNode;
+ while (node !== this.root) {
+ node = node.parentNode;
+ if (node === null) {
+ return null;
+ }
+ if (this._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
+ this._currentNode = node;
+ return node;
+ }
+ }
+ return null;
+ }},
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#dom-treewalker-firstchild
+ * @method
+ * @return {Node|null}
+ */
+ firstChild: { value: function firstChild() {
+ return traverseChildren(this, 'first');
+ }},
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#dom-treewalker-lastchild
+ * @method
+ * @return {Node|null}
+ */
+ lastChild: { value: function lastChild() {
+ return traverseChildren(this, 'last');
+ }},
+
+ /**
+ * @spec http://www.w3.org/TR/dom/#dom-treewalker-previoussibling
+ * @method
+ * @return {Node|null}
+ */
+ previousSibling: { value: function previousSibling() {
+ return traverseSiblings(this, 'previous');
+ }},
+
+ /**
+ * @spec http://www.w3.org/TR/dom/#dom-treewalker-nextsibling
+ * @method
+ * @return {Node|null}
+ */
+ nextSibling: { value: function nextSibling() {
+ return traverseSiblings(this, 'next');
+ }},
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#dom-treewalker-previousnode
+ * @based on WebKit's TreeWalker::previousNode
+ * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L181
+ * @method
+ * @return {Node|null}
+ */
+ previousNode: { value: function previousNode() {
+ var node, result, previousSibling, lastChild;
+ node = this._currentNode;
+ while (node !== this._root) {
+ for (previousSibling = node.previousSibling;
+ previousSibling;
+ previousSibling = node.previousSibling) {
+ node = previousSibling;
+ result = this._internalFilter(node);
+ if (result === NodeFilter.FILTER_REJECT) {
+ continue;
+ }
+ for (lastChild = node.lastChild;
+ lastChild;
+ lastChild = node.lastChild) {
+ node = lastChild;
+ result = this._internalFilter(node);
+ if (result === NodeFilter.FILTER_REJECT) {
+ break;
+ }
+ }
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ this._currentNode = node;
+ return node;
+ }
+ }
+ if (node === this.root || node.parentNode === null) {
+ return null;
+ }
+ node = node.parentNode;
+ if (this._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
+ this._currentNode = node;
+ return node;
+ }
+ }
+ return null;
+ }},
+
+ /**
+ * @spec https://dom.spec.whatwg.org/#dom-treewalker-nextnode
+ * @based on WebKit's TreeWalker::nextNode
+ * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L228
+ * @method
+ * @return {Node|null}
+ */
+ nextNode: { value: function nextNode() {
+ var node, result, firstChild, nextSibling;
+ node = this._currentNode;
+ result = NodeFilter.FILTER_ACCEPT;
+
+ CHILDREN:
+ while (true) {
+ for (firstChild = node.firstChild;
+ firstChild;
+ firstChild = node.firstChild) {
+ node = firstChild;
+ result = this._internalFilter(node);
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ this._currentNode = node;
+ return node;
+ } else if (result === NodeFilter.FILTER_REJECT) {
+ break;
+ }
+ }
+ for (nextSibling = NodeTraversal.nextSkippingChildren(node, this.root);
+ nextSibling;
+ nextSibling = NodeTraversal.nextSkippingChildren(node, this.root)) {
+ node = nextSibling;
+ result = this._internalFilter(node);
+ if (result === NodeFilter.FILTER_ACCEPT) {
+ this._currentNode = node;
+ return node;
+ } else if (result === NodeFilter.FILTER_SKIP) {
+ continue CHILDREN;
+ }
+ }
+ return null;
+ }
+ }},
+
+ /** For compatibility with web-platform-tests. */
+ toString: { value: function toString() {
+ return "[object TreeWalker]";
+ }},
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/UIEvent.js
@@ -1,0 +1,19 @@
+"use strict";
+var Event = require('./Event');
+
+module.exports = UIEvent;
+
+function UIEvent() {
+ // Just use the superclass constructor to initialize
+ Event.call(this);
+ this.view = null; // FF uses the current window
+ this.detail = 0;
+}
+UIEvent.prototype = Object.create(Event.prototype, {
+ constructor: { value: UIEvent },
+ initUIEvent: { value: function(type, bubbles, cancelable, view, detail) {
+ this.initEvent(type, bubbles, cancelable);
+ this.view = view;
+ this.detail = detail;
+ }}
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/URL.js
@@ -1,0 +1,194 @@
+"use strict";
+module.exports = URL;
+
+function URL(url) {
+ if (!url) return Object.create(URL.prototype);
+ // Can't use String.trim() since it defines whitespace differently than HTML
+ this.url = url.replace(/^[ \t\n\r\f]+|[ \t\n\r\f]+$/g, "");
+
+ // See http://tools.ietf.org/html/rfc3986#appendix-B
+ // and https://url.spec.whatwg.org/#parsing
+ var match = URL.pattern.exec(this.url);
+ if (match) {
+ if (match[2]) this.scheme = match[2];
+ if (match[4]) {
+ // parse username/password
+ var userinfo = match[4].match(URL.userinfoPattern);
+ if (userinfo) {
+ this.username = userinfo[1];
+ this.password = userinfo[3];
+ match[4] = match[4].substring(userinfo[0].length);
+ }
+ if (match[4].match(URL.portPattern)) {
+ var pos = match[4].lastIndexOf(':');
+ this.host = match[4].substring(0, pos);
+ this.port = match[4].substring(pos+1);
+ }
+ else {
+ this.host = match[4];
+ }
+ }
+ if (match[5]) this.path = match[5];
+ if (match[6]) this.query = match[7];
+ if (match[8]) this.fragment = match[9];
+ }
+}
+
+URL.pattern = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/;
+URL.userinfoPattern = /^([^@:]*)(:([^@]*))?@/;
+URL.portPattern = /:\d+$/;
+URL.authorityPattern = /^[^:\/?#]+:\/\//;
+URL.hierarchyPattern = /^[^:\/?#]+:\//;
+
+// Return a percentEncoded version of s.
+// S should be a single-character string
+// XXX: needs to do utf-8 encoding?
+URL.percentEncode = function percentEncode(s) {
+ var c = s.charCodeAt(0);
+ if (c < 256) return "%" + c.toString(16);
+ else throw Error("can't percent-encode codepoints > 255 yet");
+};
+
+URL.prototype = {
+ constructor: URL,
+
+ // XXX: not sure if this is the precise definition of absolute
+ isAbsolute: function() { return !!this.scheme; },
+ isAuthorityBased: function() {
+ return URL.authorityPattern.test(this.url);
+ },
+ isHierarchical: function() {
+ return URL.hierarchyPattern.test(this.url);
+ },
+
+ toString: function() {
+ var s = "";
+ if (this.scheme !== undefined) s += this.scheme + ":";
+ if (this.isAbsolute()) {
+ s += '//';
+ if (this.username || this.password) {
+ s += this.username || '';
+ if (this.password) {
+ s += ':' + this.password;
+ }
+ s += '@';
+ }
+ if (this.host) {
+ s += this.host;
+ }
+ }
+ if (this.port !== undefined) s += ":" + this.port;
+ if (this.path !== undefined) s += this.path;
+ if (this.query !== undefined) s += "?" + this.query;
+ if (this.fragment !== undefined) s += "#" + this.fragment;
+ return s;
+ },
+
+ // See: http://tools.ietf.org/html/rfc3986#section-5.2
+ // and https://url.spec.whatwg.org/#constructors
+ resolve: function(relative) {
+ var base = this; // The base url we're resolving against
+ var r = new URL(relative); // The relative reference url to resolve
+ var t = new URL(); // The absolute target url we will return
+
+ if (r.scheme !== undefined) {
+ t.scheme = r.scheme;
+ t.username = r.username;
+ t.password = r.password;
+ t.host = r.host;
+ t.port = r.port;
+ t.path = remove_dot_segments(r.path);
+ t.query = r.query;
+ }
+ else {
+ t.scheme = base.scheme;
+ if (r.host !== undefined) {
+ t.username = r.username;
+ t.password = r.password;
+ t.host = r.host;
+ t.port = r.port;
+ t.path = remove_dot_segments(r.path);
+ t.query = r.query;
+ }
+ else {
+ t.username = base.username;
+ t.password = base.password;
+ t.host = base.host;
+ t.port = base.port;
+ if (!r.path) { // undefined or empty
+ t.path = base.path;
+ if (r.query !== undefined)
+ t.query = r.query;
+ else
+ t.query = base.query;
+ }
+ else {
+ if (r.path.charAt(0) === "/") {
+ t.path = remove_dot_segments(r.path);
+ }
+ else {
+ t.path = merge(base.path, r.path);
+ t.path = remove_dot_segments(t.path);
+ }
+ t.query = r.query;
+ }
+ }
+ }
+ t.fragment = r.fragment;
+
+ return t.toString();
+
+
+ function merge(basepath, refpath) {
+ if (base.host !== undefined && !base.path)
+ return "/" + refpath;
+
+ var lastslash = basepath.lastIndexOf("/");
+ if (lastslash === -1)
+ return refpath;
+ else
+ return basepath.substring(0, lastslash+1) + refpath;
+ }
+
+ function remove_dot_segments(path) {
+ if (!path) return path; // For "" or undefined
+
+ var output = "";
+ while(path.length > 0) {
+ if (path === "." || path === "..") {
+ path = "";
+ break;
+ }
+
+ var twochars = path.substring(0,2);
+ var threechars = path.substring(0,3);
+ var fourchars = path.substring(0,4);
+ if (threechars === "../") {
+ path = path.substring(3);
+ }
+ else if (twochars === "./") {
+ path = path.substring(2);
+ }
+ else if (threechars === "/./") {
+ path = "/" + path.substring(3);
+ }
+ else if (twochars === "/." && path.length === 2) {
+ path = "/";
+ }
+ else if (fourchars === "/../" ||
+ (threechars === "/.." && path.length === 3)) {
+ path = "/" + path.substring(4);
+
+ output = output.replace(/\/?[^\/]*$/, "");
+ }
+ else {
+ var segment = path.match(/(\/?([^\/]*))/)[0];
+ output += segment;
+ path = path.substring(segment.length);
+ }
+ }
+
+ return output;
+ }
+ },
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/URLUtils.js
@@ -1,0 +1,270 @@
+"use strict";
+var URL = require('./URL');
+
+module.exports = URLUtils;
+
+// Allow the `x == null` pattern. This is eslint's "null: 'ignore'" option,
+// but jshint doesn't support this.
+/* jshint eqeqeq: false */
+
+// This is an abstract superclass for Location, HTMLAnchorElement and
+// other types that have the standard complement of "URL decomposition
+// IDL attributes". This is now standardized as URLUtils, see:
+// https://url.spec.whatwg.org/#urlutils
+// Subclasses must define a getter/setter on href.
+// The getter and setter methods parse and rebuild the URL on each
+// invocation; there is no attempt to cache the value and be more efficient
+function URLUtils() {}
+URLUtils.prototype = Object.create(Object.prototype, {
+
+ _url: { get: function() {
+ // XXX: this should do the "Reinitialize url" steps, and "null" should
+ // be a valid return value.
+ return new URL(this.href);
+ } },
+
+ protocol: {
+ get: function() {
+ var url = this._url;
+ if (url && url.scheme) return url.scheme + ":";
+ else return ":";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute()) {
+ v = v.replace(/:+$/, "");
+ v = v.replace(/[^-+\.a-zA-Z0-9]/g, URL.percentEncode);
+ if (v.length > 0) {
+ url.scheme = v;
+ output = url.toString();
+ }
+ }
+ this.href = output;
+ },
+ },
+
+ host: {
+ get: function() {
+ var url = this._url;
+ if (url.isAbsolute() && url.isAuthorityBased())
+ return url.host + (url.port ? (":" + url.port) : "");
+ else
+ return "";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute() && url.isAuthorityBased()) {
+ v = v.replace(/[^-+\._~!$&'()*,;:=a-zA-Z0-9]/g, URL.percentEncode);
+ if (v.length > 0) {
+ url.host = v;
+ delete url.port;
+ output = url.toString();
+ }
+ }
+ this.href = output;
+ },
+ },
+
+ hostname: {
+ get: function() {
+ var url = this._url;
+ if (url.isAbsolute() && url.isAuthorityBased())
+ return url.host;
+ else
+ return "";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute() && url.isAuthorityBased()) {
+ v = v.replace(/^\/+/, "");
+ v = v.replace(/[^-+\._~!$&'()*,;:=a-zA-Z0-9]/g, URL.percentEncode);
+ if (v.length > 0) {
+ url.host = v;
+ output = url.toString();
+ }
+ }
+ this.href = output;
+ },
+ },
+
+ port: {
+ get: function() {
+ var url = this._url;
+ if (url.isAbsolute() && url.isAuthorityBased() && url.port!==undefined)
+ return url.port;
+ else
+ return "";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute() && url.isAuthorityBased()) {
+ v = '' + v;
+ v = v.replace(/[^0-9].*$/, "");
+ v = v.replace(/^0+/, "");
+ if (v.length === 0) v = "0";
+ if (parseInt(v, 10) <= 65535) {
+ url.port = v;
+ output = url.toString();
+ }
+ }
+ this.href = output;
+ },
+ },
+
+ pathname: {
+ get: function() {
+ var url = this._url;
+ if (url.isAbsolute() && url.isHierarchical())
+ return url.path;
+ else
+ return "";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute() && url.isHierarchical()) {
+ if (v.charAt(0) !== "/")
+ v = "/" + v;
+ v = v.replace(/[^-+\._~!$&'()*,;:=@\/a-zA-Z0-9]/g, URL.percentEncode);
+ url.path = v;
+ output = url.toString();
+ }
+ this.href = output;
+ },
+ },
+
+ search: {
+ get: function() {
+ var url = this._url;
+ if (url.isAbsolute() && url.isHierarchical() && url.query!==undefined)
+ return "?" + url.query;
+ else
+ return "";
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute() && url.isHierarchical()) {
+ if (v.charAt(0) === "?") v = v.substring(1);
+ v = v.replace(/[^-+\._~!$&'()*,;:=@\/?a-zA-Z0-9]/g, URL.percentEncode);
+ url.query = v;
+ output = url.toString();
+ }
+ this.href = output;
+ },
+ },
+
+ hash: {
+ get: function() {
+ var url = this._url;
+ if (url == null || url.fragment == null || url.fragment === '') {
+ return "";
+ } else {
+ return "#" + url.fragment;
+ }
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+
+ if (v.charAt(0) === "#") v = v.substring(1);
+ v = v.replace(/[^-+\._~!$&'()*,;:=@\/?a-zA-Z0-9]/g, URL.percentEncode);
+ url.fragment = v;
+ output = url.toString();
+
+ this.href = output;
+ },
+ },
+
+ username: {
+ get: function() {
+ var url = this._url;
+ return url.username || '';
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute()) {
+ v = v.replace(/[\x00-\x1F\x7F-\uFFFF "#<>?`\/@\\:]/g, URL.percentEncode);
+ url.username = v;
+ output = url.toString();
+ }
+ this.href = output;
+ },
+ },
+
+ password: {
+ get: function() {
+ var url = this._url;
+ return url.password || '';
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ if (url.isAbsolute()) {
+ if (v==='') {
+ url.password = null;
+ } else {
+ v = v.replace(/[\x00-\x1F\x7F-\uFFFF "#<>?`\/@\\]/g, URL.percentEncode);
+ url.password = v;
+ }
+ output = url.toString();
+ }
+ this.href = output;
+ },
+ },
+
+ origin: { get: function() {
+ var url = this._url;
+ if (url == null) { return ''; }
+ var originForPort = function(defaultPort) {
+ var origin = [url.scheme, url.host, +url.port || defaultPort];
+ // XXX should be "unicode serialization"
+ return origin[0] + '://' + origin[1] +
+ (origin[2] === defaultPort ? '' : (':' + origin[2]));
+ };
+ switch (url.scheme) {
+ case 'ftp':
+ return originForPort(21);
+ case 'gopher':
+ return originForPort(70);
+ case 'http':
+ case 'ws':
+ return originForPort(80);
+ case 'https':
+ case 'wss':
+ return originForPort(443);
+ default:
+ // this is what chrome does
+ return url.scheme + '://';
+ }
+ } },
+
+ /*
+ searchParams: {
+ get: function() {
+ var url = this._url;
+ // XXX
+ },
+ set: function(v) {
+ var output = this.href;
+ var url = new URL(output);
+ // XXX
+ this.href = output;
+ },
+ },
+ */
+});
+
+URLUtils._inherit = function(proto) {
+ // copy getters/setters from URLUtils to o.
+ Object.getOwnPropertyNames(URLUtils.prototype).forEach(function(p) {
+ if (p==='constructor' || p==='href') { return; }
+ var desc = Object.getOwnPropertyDescriptor(URLUtils.prototype, p);
+ Object.defineProperty(proto, p, desc);
+ });
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/Window.js
@@ -1,0 +1,62 @@
+"use strict";
+var DOMImplementation = require('./DOMImplementation');
+var EventTarget = require('./EventTarget');
+var Location = require('./Location');
+var sloppy = require('./sloppy');
+var utils = require('./utils');
+
+module.exports = Window;
+
+function Window(document) {
+ this.document = document || new DOMImplementation(null).createHTMLDocument("");
+ this.document._scripting_enabled = true;
+ this.document.defaultView = this;
+ this.location = new Location(this, this.document._address || 'about:blank');
+}
+
+Window.prototype = Object.create(EventTarget.prototype, {
+ _run: { value: sloppy.Window_run },
+ console: { value: console },
+ history: { value: {
+ back: utils.nyi,
+ forward: utils.nyi,
+ go: utils.nyi
+ }},
+ navigator: { value: require("./NavigatorID") },
+
+ // Self-referential properties
+ window: { get: function() { return this; }},
+ self: { get: function() { return this; }},
+ frames: { get: function() { return this; }},
+
+ // Self-referential properties for a top-level window
+ parent: { get: function() { return this; }},
+ top: { get: function() { return this; }},
+
+ // We don't support any other windows for now
+ length: { value: 0 }, // no frames
+ frameElement: { value: null }, // not part of a frame
+ opener: { value: null }, // not opened by another window
+
+ // The onload event handler.
+ // XXX: need to support a bunch of other event types, too,
+ // and have them interoperate with document.body.
+
+ onload: {
+ get: function() {
+ return this._getEventHandler("load");
+ },
+ set: function(v) {
+ this._setEventHandler("load", v);
+ }
+ },
+
+ // XXX This is a completely broken implementation
+ getComputedStyle: { value: function getComputedStyle(elt) {
+ return elt.style;
+ }}
+
+});
+
+utils.expose(require('./WindowTimers'), Window);
+utils.expose(require('./impl'), Window);
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/WindowTimers.js
@@ -1,0 +1,11 @@
+"use strict";
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#windowtimers
+var WindowTimers = {
+ setTimeout: setTimeout,
+ clearTimeout: clearTimeout,
+ setInterval: setInterval,
+ clearInterval: clearInterval
+};
+
+module.exports = WindowTimers;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/attributes.js
@@ -1,0 +1,152 @@
+"use strict";
+var utils = require('./utils');
+
+exports.property = function(attr) {
+ if (Array.isArray(attr.type)) {
+ var valid = Object.create(null);
+ attr.type.forEach(function(val) {
+ valid[val.value || val] = val.alias || val;
+ });
+ var missingValueDefault = attr.missing;
+ if (missingValueDefault===undefined) { missingValueDefault = null; }
+ var invalidValueDefault = attr.invalid;
+ if (invalidValueDefault===undefined) { invalidValueDefault = missingValueDefault; }
+ return {
+ get: function() {
+ var v = this._getattr(attr.name);
+ if (v === null) return missingValueDefault;
+
+ v = valid[v.toLowerCase()];
+ if (v !== undefined) return v;
+ if (invalidValueDefault !== null) return invalidValueDefault;
+ return v;
+ },
+ set: function(v) {
+ this._setattr(attr.name, v);
+ }
+ };
+ }
+ else if (attr.type === Boolean) {
+ return {
+ get: function() {
+ return this.hasAttribute(attr.name);
+ },
+ set: function(v) {
+ if (v) {
+ this._setattr(attr.name, '');
+ }
+ else {
+ this.removeAttribute(attr.name);
+ }
+ }
+ };
+ }
+ else if (attr.type === Number ||
+ attr.type === "long" ||
+ attr.type === "unsigned long" ||
+ attr.type === "limited unsigned long with fallback") {
+ return numberPropDesc(attr);
+ }
+ else if (!attr.type || attr.type === String) {
+ return {
+ get: function() { return this._getattr(attr.name) || ''; },
+ set: function(v) {
+ if (attr.treatNullAsEmptyString && v === null) { v = ''; }
+ this._setattr(attr.name, v);
+ }
+ };
+ }
+ else if (typeof attr.type === 'function') {
+ return attr.type(attr.name, attr);
+ }
+ throw new Error('Invalid attribute definition');
+};
+
+// See http://www.whatwg.org/specs/web-apps/current-work/#reflect
+//
+// defval is the default value. If it is a function, then that function
+// will be invoked as a method of the element to obtain the default.
+// If no default is specified for a given attribute, then the default
+// depends on the type of the attribute, but since this function handles
+// 4 integer cases, you must specify the default value in each call
+//
+// min and max define a valid range for getting the attribute.
+//
+// setmin defines a minimum value when setting. If the value is less
+// than that, then throw INDEX_SIZE_ERR.
+//
+// Conveniently, JavaScript's parseInt function appears to be
+// compatible with HTML's 'rules for parsing integers'
+function numberPropDesc(a) {
+ var def;
+ if(typeof a.default === 'function') {
+ def = a.default;
+ }
+ else if(typeof a.default === 'number') {
+ def = function() { return a.default; };
+ }
+ else {
+ def = function() { utils.assert(false, typeof a.default); };
+ }
+ var unsigned_long = (a.type === 'unsigned long');
+ var signed_long = (a.type === 'long');
+ var unsigned_fallback = (a.type === 'limited unsigned long with fallback');
+ var min = a.min, max = a.max, setmin = a.setmin;
+ if (min === undefined) {
+ if (unsigned_long) min = 0;
+ if (signed_long) min = -0x80000000;
+ if (unsigned_fallback) min = 1;
+ }
+ if (max === undefined) {
+ if (unsigned_long || signed_long || unsigned_fallback) max = 0x7FFFFFFF;
+ }
+
+ return {
+ get: function() {
+ var v = this._getattr(a.name);
+ var n = a.float ? parseFloat(v) : parseInt(v, 10);
+ if (v === null || !isFinite(n) || (min !== undefined && n < min) || (max !== undefined && n > max)) {
+ return def.call(this);
+ }
+ if (unsigned_long || signed_long || unsigned_fallback) {
+ if (!/^[ \t\n\f\r]*[-+]?[0-9]/.test(v)) { return def.call(this); }
+ n = n|0; // jshint ignore:line
+ }
+ return n;
+ },
+ set: function(v) {
+ if (!a.float) { v = Math.floor(v); }
+ if (setmin !== undefined && v < setmin) {
+ utils.IndexSizeError(a.name + ' set to ' + v);
+ }
+ if (unsigned_long) {
+ v = (v < 0 || v > 0x7FFFFFFF) ? def.call(this) :
+ (v|0); // jshint ignore:line
+ } else if (unsigned_fallback) {
+ v = (v < 1 || v > 0x7FFFFFFF) ? def.call(this) :
+ (v|0); // jshint ignore:line
+ } else if (signed_long) {
+ v = (v < -0x80000000 || v > 0x7FFFFFFF) ? def.call(this) :
+ (v|0); // jshint ignore:line
+ }
+ this._setattr(a.name, String(v));
+ }
+ };
+}
+
+// This is a utility function for setting up change handler functions
+// for attributes like 'id' that require special handling when they change.
+exports.registerChangeHandler = function(c, name, handler) {
+ var p = c.prototype;
+
+ // If p does not already have its own _attributeChangeHandlers
+ // then create one for it, inheriting from the inherited
+ // _attributeChangeHandlers. At the top (for the Element class) the
+ // _attributeChangeHandlers object will be created with a null prototype.
+ if (!Object.prototype.hasOwnProperty.call(p, '_attributeChangeHandlers')) {
+ p._attributeChangeHandlers =
+ Object.create(p._attributeChangeHandlers || null);
+ }
+
+ p._attributeChangeHandlers[name] = handler;
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/config.js
@@ -1,0 +1,7 @@
+/*
+ * This file defines Domino behaviour that can be externally configured.
+ * To change these settings, set the relevant global property *before*
+ * you call `require("domino")`.
+ */
+
+exports.isApiWritable = !global.__domino_frozen__;
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/cssparser.js
@@ -1,0 +1,6654 @@
+/* jshint node:true, latedef:false */
+"use strict"; // jshint ignore:line
+/*!
+Parser-Lib
+Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+/* Version v0.2.5+domino1, Build time: 30-January-2016 05:13:03 */
+var parserlib = Object.create(null);
+(function(){
+
+/**
+ * A generic base to inherit from for any object
+ * that needs event handling.
+ * @class EventTarget
+ * @constructor
+ */
+function EventTarget(){
+
+ /**
+ * The array of listeners for various events.
+ * @type Object
+ * @property _listeners
+ * @private
+ */
+ this._listeners = Object.create(null);
+}
+
+EventTarget.prototype = {
+
+ //restore constructor
+ constructor: EventTarget,
+
+ /**
+ * Adds a listener for a given event type.
+ * @param {String} type The type of event to add a listener for.
+ * @param {Function} listener The function to call when the event occurs.
+ * @return {void}
+ * @method addListener
+ */
+ addListener: function(type, listener){
+ if (!this._listeners[type]){
+ this._listeners[type] = [];
+ }
+
+ this._listeners[type].push(listener);
+ },
+
+ /**
+ * Fires an event based on the passed-in object.
+ * @param {Object|String} event An object with at least a 'type' attribute
+ * or a string indicating the event name.
+ * @return {void}
+ * @method fire
+ */
+ fire: function(event){
+ if (typeof event === "string"){
+ event = { type: event };
+ }
+ if (typeof event.target !== "undefined"){
+ event.target = this;
+ }
+
+ if (typeof event.type === "undefined"){
+ throw new Error("Event object missing 'type' property.");
+ }
+
+ if (this._listeners[event.type]){
+
+ //create a copy of the array and use that so listeners can't chane
+ var listeners = this._listeners[event.type].concat();
+ for (var i=0, len=listeners.length; i < len; i++){
+ listeners[i].call(this, event);
+ }
+ }
+ },
+
+ /**
+ * Removes a listener for a given event type.
+ * @param {String} type The type of event to remove a listener from.
+ * @param {Function} listener The function to remove from the event.
+ * @return {void}
+ * @method removeListener
+ */
+ removeListener: function(type, listener){
+ if (this._listeners[type]){
+ var listeners = this._listeners[type];
+ for (var i=0, len=listeners.length; i < len; i++){
+ if (listeners[i] === listener){
+ listeners.splice(i, 1);
+ break;
+ }
+ }
+
+
+ }
+ }
+};
+/**
+ * Convenient way to read through strings.
+ * @namespace parserlib.util
+ * @class StringReader
+ * @constructor
+ * @param {String} text The text to read.
+ */
+function StringReader(text){
+
+ /**
+ * The input text with line endings normalized.
+ * @property _input
+ * @type String
+ * @private
+ */
+ this._input = text.replace(/(\r|\n){1,2}/g, "\n");
+
+
+ /**
+ * The row for the character to be read next.
+ * @property _line
+ * @type int
+ * @private
+ */
+ this._line = 1;
+
+
+ /**
+ * The column for the character to be read next.
+ * @property _col
+ * @type int
+ * @private
+ */
+ this._col = 1;
+
+ /**
+ * The index of the character in the input to be read next.
+ * @property _cursor
+ * @type int
+ * @private
+ */
+ this._cursor = 0;
+}
+
+StringReader.prototype = {
+
+ //restore constructor
+ constructor: StringReader,
+
+ //-------------------------------------------------------------------------
+ // Position info
+ //-------------------------------------------------------------------------
+
+ /**
+ * Returns the column of the character to be read next.
+ * @return {int} The column of the character to be read next.
+ * @method getCol
+ */
+ getCol: function(){
+ return this._col;
+ },
+
+ /**
+ * Returns the row of the character to be read next.
+ * @return {int} The row of the character to be read next.
+ * @method getLine
+ */
+ getLine: function(){
+ return this._line ;
+ },
+
+ /**
+ * Determines if you're at the end of the input.
+ * @return {Boolean} True if there's no more input, false otherwise.
+ * @method eof
+ */
+ eof: function(){
+ return (this._cursor === this._input.length);
+ },
+
+ //-------------------------------------------------------------------------
+ // Basic reading
+ //-------------------------------------------------------------------------
+
+ /**
+ * Reads the next character without advancing the cursor.
+ * @param {int} count How many characters to look ahead (default is 1).
+ * @return {String} The next character or null if there is no next character.
+ * @method peek
+ */
+ peek: function(count){
+ var c = null;
+ count = (typeof count === "undefined" ? 1 : count);
+
+ //if we're not at the end of the input...
+ if (this._cursor < this._input.length){
+
+ //get character and increment cursor and column
+ c = this._input.charAt(this._cursor + count - 1);
+ }
+
+ return c;
+ },
+
+ /**
+ * Reads the next character from the input and adjusts the row and column
+ * accordingly.
+ * @return {String} The next character or null if there is no next character.
+ * @method read
+ */
+ read: function(){
+ var c = null;
+
+ //if we're not at the end of the input...
+ if (this._cursor < this._input.length){
+
+ //if the last character was a newline, increment row count
+ //and reset column count
+ if (this._input.charAt(this._cursor) === "\n"){
+ this._line++;
+ this._col=1;
+ } else {
+ this._col++;
+ }
+
+ //get character and increment cursor and column
+ c = this._input.charAt(this._cursor++);
+ }
+
+ return c;
+ },
+
+ //-------------------------------------------------------------------------
+ // Misc
+ //-------------------------------------------------------------------------
+
+ /**
+ * Saves the current location so it can be returned to later.
+ * @method mark
+ * @return {void}
+ */
+ mark: function(){
+ this._bookmark = {
+ cursor: this._cursor,
+ line: this._line,
+ col: this._col
+ };
+ },
+
+ reset: function(){
+ if (this._bookmark){
+ this._cursor = this._bookmark.cursor;
+ this._line = this._bookmark.line;
+ this._col = this._bookmark.col;
+ delete this._bookmark;
+ }
+ },
+
+ //-------------------------------------------------------------------------
+ // Advanced reading
+ //-------------------------------------------------------------------------
+
+ /**
+ * Reads up to and including the given string. Throws an error if that
+ * string is not found.
+ * @param {String} pattern The string to read.
+ * @return {String} The string when it is found.
+ * @throws Error when the string pattern is not found.
+ * @method readTo
+ */
+ readTo: function(pattern){
+
+ var buffer = "",
+ c;
+
+ /*
+ * First, buffer must be the same length as the pattern.
+ * Then, buffer must end with the pattern or else reach the
+ * end of the input.
+ */
+ while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length){
+ c = this.read();
+ if (c){
+ buffer += c;
+ } else {
+ throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
+ }
+ }
+
+ return buffer;
+
+ },
+
+ /**
+ * Reads characters while each character causes the given
+ * filter function to return true. The function is passed
+ * in each character and either returns true to continue
+ * reading or false to stop.
+ * @param {Function} filter The function to read on each character.
+ * @return {String} The string made up of all characters that passed the
+ * filter check.
+ * @method readWhile
+ */
+ readWhile: function(filter){
+
+ var buffer = "",
+ c = this.read();
+
+ while(c !== null && filter(c)){
+ buffer += c;
+ c = this.read();
+ }
+
+ return buffer;
+
+ },
+
+ /**
+ * Reads characters that match either text or a regular expression and
+ * returns those characters. If a match is found, the row and column
+ * are adjusted; if no match is found, the reader's state is unchanged.
+ * reading or false to stop.
+ * @param {String|RegExp} matchter If a string, then the literal string
+ * value is searched for. If a regular expression, then any string
+ * matching the pattern is search for.
+ * @return {String} The string made up of all characters that matched or
+ * null if there was no match.
+ * @method readMatch
+ */
+ readMatch: function(matcher){
+
+ var source = this._input.substring(this._cursor),
+ value = null;
+
+ //if it's a string, just do a straight match
+ if (typeof matcher === "string"){
+ if (source.indexOf(matcher) === 0){
+ value = this.readCount(matcher.length);
+ }
+ } else if (matcher instanceof RegExp){
+ if (matcher.test(source)){
+ value = this.readCount(RegExp.lastMatch.length);
+ }
+ }
+
+ return value;
+ },
+
+
+ /**
+ * Reads a given number of characters. If the end of the input is reached,
+ * it reads only the remaining characters and does not throw an error.
+ * @param {int} count The number of characters to read.
+ * @return {String} The string made up the read characters.
+ * @method readCount
+ */
+ readCount: function(count){
+ var buffer = "";
+
+ while(count--){
+ buffer += this.read();
+ }
+
+ return buffer;
+ }
+
+};
+/**
+ * Type to use when a syntax error occurs.
+ * @class SyntaxError
+ * @namespace parserlib.util
+ * @constructor
+ * @param {String} message The error message.
+ * @param {int} line The line at which the error occurred.
+ * @param {int} col The column at which the error occurred.
+ */
+function SyntaxError(message, line, col){
+ Error.call(this);
+ this.name = this.constructor.name;
+
+ /**
+ * The column at which the error occurred.
+ * @type int
+ * @property col
+ */
+ this.col = col;
+
+ /**
+ * The line at which the error occurred.
+ * @type int
+ * @property line
+ */
+ this.line = line;
+
+ /**
+ * The text representation of the unit.
+ * @type String
+ * @property text
+ */
+ this.message = message;
+
+}
+
+//inherit from Error
+SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
+SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
+/**
+ * Base type to represent a single syntactic unit.
+ * @class SyntaxUnit
+ * @namespace parserlib.util
+ * @constructor
+ * @param {String} text The text of the unit.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function SyntaxUnit(text, line, col, type){
+
+
+ /**
+ * The column of text on which the unit resides.
+ * @type int
+ * @property col
+ */
+ this.col = col;
+
+ /**
+ * The line of text on which the unit resides.
+ * @type int
+ * @property line
+ */
+ this.line = line;
+
+ /**
+ * The text representation of the unit.
+ * @type String
+ * @property text
+ */
+ this.text = text;
+
+ /**
+ * The type of syntax unit.
+ * @type int
+ * @property type
+ */
+ this.type = type;
+}
+
+/**
+ * Create a new syntax unit based solely on the given token.
+ * Convenience method for creating a new syntax unit when
+ * it represents a single token instead of multiple.
+ * @param {Object} token The token object to represent.
+ * @return {parserlib.util.SyntaxUnit} The object representing the token.
+ * @static
+ * @method fromToken
+ */
+SyntaxUnit.fromToken = function(token){
+ return new SyntaxUnit(token.value, token.startLine, token.startCol);
+};
+
+SyntaxUnit.prototype = {
+
+ //restore constructor
+ constructor: SyntaxUnit,
+
+ /**
+ * Returns the text representation of the unit.
+ * @return {String} The text representation of the unit.
+ * @method valueOf
+ */
+ valueOf: function(){
+ return this.toString();
+ },
+
+ /**
+ * Returns the text representation of the unit.
+ * @return {String} The text representation of the unit.
+ * @method toString
+ */
+ toString: function(){
+ return this.text;
+ }
+
+};
+
+/**
+ * Generic TokenStream providing base functionality.
+ * @class TokenStreamBase
+ * @namespace parserlib.util
+ * @constructor
+ * @param {String|StringReader} input The text to tokenize or a reader from
+ * which to read the input.
+ */
+function TokenStreamBase(input, tokenData){
+
+ /**
+ * The string reader for easy access to the text.
+ * @type StringReader
+ * @property _reader
+ * @private
+ */
+ this._reader = input ? new StringReader(input.toString()) : null;
+
+ /**
+ * Token object for the last consumed token.
+ * @type Token
+ * @property _token
+ * @private
+ */
+ this._token = null;
+
+ /**
+ * The array of token information.
+ * @type Array
+ * @property _tokenData
+ * @private
+ */
+ this._tokenData = tokenData;
+
+ /**
+ * Lookahead token buffer.
+ * @type Array
+ * @property _lt
+ * @private
+ */
+ this._lt = [];
+
+ /**
+ * Lookahead token buffer index.
+ * @type int
+ * @property _ltIndex
+ * @private
+ */
+ this._ltIndex = 0;
+
+ this._ltIndexCache = [];
+}
+
+/**
+ * Accepts an array of token information and outputs
+ * an array of token data containing key-value mappings
+ * and matching functions that the TokenStream needs.
+ * @param {Array} tokens An array of token descriptors.
+ * @return {Array} An array of processed token data.
+ * @method createTokenData
+ * @static
+ */
+TokenStreamBase.createTokenData = function(tokens){
+
+ var nameMap = [],
+ typeMap = Object.create(null),
+ tokenData = tokens.concat([]),
+ i = 0,
+ len = tokenData.length+1;
+
+ tokenData.UNKNOWN = -1;
+ tokenData.unshift({name:"EOF"});
+
+ for (; i < len; i++){
+ nameMap.push(tokenData[i].name);
+ tokenData[tokenData[i].name] = i;
+ if (tokenData[i].text){
+ typeMap[tokenData[i].text] = i;
+ }
+ }
+
+ tokenData.name = function(tt){
+ return nameMap[tt];
+ };
+
+ tokenData.type = function(c){
+ return typeMap[c];
+ };
+
+ return tokenData;
+};
+
+TokenStreamBase.prototype = {
+
+ //restore constructor
+ constructor: TokenStreamBase,
+
+ //-------------------------------------------------------------------------
+ // Matching methods
+ //-------------------------------------------------------------------------
+
+ /**
+ * Determines if the next token matches the given token type.
+ * If so, that token is consumed; if not, the token is placed
+ * back onto the token stream. You can pass in any number of
+ * token types and this will return true if any of the token
+ * types is found.
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
+ * token types that the next token might be. If an array is passed,
+ * it's assumed that the token can be any of these.
+ * @param {variant} channel (Optional) The channel to read from. If not
+ * provided, reads from the default (unnamed) channel.
+ * @return {Boolean} True if the token type matches, false if not.
+ * @method match
+ */
+ match: function(tokenTypes, channel){
+
+ //always convert to an array, makes things easier
+ if (!(tokenTypes instanceof Array)){
+ tokenTypes = [tokenTypes];
+ }
+
+ var tt = this.get(channel),
+ i = 0,
+ len = tokenTypes.length;
+
+ while(i < len){
+ if (tt === tokenTypes[i++]){
+ return true;
+ }
+ }
+
+ //no match found, put the token back
+ this.unget();
+ return false;
+ },
+
+ /**
+ * Determines if the next token matches the given token type.
+ * If so, that token is consumed; if not, an error is thrown.
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
+ * token types that the next token should be. If an array is passed,
+ * it's assumed that the token must be one of these.
+ * @param {variant} channel (Optional) The channel to read from. If not
+ * provided, reads from the default (unnamed) channel.
+ * @return {void}
+ * @method mustMatch
+ */
+ mustMatch: function(tokenTypes, channel){
+
+ var token;
+
+ //always convert to an array, makes things easier
+ if (!(tokenTypes instanceof Array)){
+ tokenTypes = [tokenTypes];
+ }
+
+ if (!this.match.apply(this, arguments)){
+ token = this.LT(1);
+ throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
+ " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
+ }
+ },
+
+ //-------------------------------------------------------------------------
+ // Consuming methods
+ //-------------------------------------------------------------------------
+
+ /**
+ * Keeps reading from the token stream until either one of the specified
+ * token types is found or until the end of the input is reached.
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
+ * token types that the next token should be. If an array is passed,
+ * it's assumed that the token must be one of these.
+ * @param {variant} channel (Optional) The channel to read from. If not
+ * provided, reads from the default (unnamed) channel.
+ * @return {void}
+ * @method advance
+ */
+ advance: function(tokenTypes, channel){
+
+ while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){
+ this.get();
+ }
+
+ return this.LA(0);
+ },
+
+ /**
+ * Consumes the next token from the token stream.
+ * @return {int} The token type of the token that was just consumed.
+ * @method get
+ */
+ get: function(channel){
+
+ var tokenInfo = this._tokenData,
+ i =0,
+ token,
+ info;
+
+ //check the lookahead buffer first
+ if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){
+
+ i++;
+ this._token = this._lt[this._ltIndex++];
+ info = tokenInfo[this._token.type];
+
+ //obey channels logic
+ while((info.channel !== undefined && channel !== info.channel) &&
+ this._ltIndex < this._lt.length){
+ this._token = this._lt[this._ltIndex++];
+ info = tokenInfo[this._token.type];
+ i++;
+ }
+
+ //here be dragons
+ if ((info.channel === undefined || channel === info.channel) &&
+ this._ltIndex <= this._lt.length){
+ this._ltIndexCache.push(i);
+ return this._token.type;
+ }
+ }
+
+ //call token retriever method
+ token = this._getToken();
+
+ //if it should be hidden, don't save a token
+ if (token.type > -1 && !tokenInfo[token.type].hide){
+
+ //apply token channel
+ token.channel = tokenInfo[token.type].channel;
+
+ //save for later
+ this._token = token;
+ this._lt.push(token);
+
+ //save space that will be moved (must be done before array is truncated)
+ this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
+
+ //keep the buffer under 5 items
+ if (this._lt.length > 5){
+ this._lt.shift();
+ }
+
+ //also keep the shift buffer under 5 items
+ if (this._ltIndexCache.length > 5){
+ this._ltIndexCache.shift();
+ }
+
+ //update lookahead index
+ this._ltIndex = this._lt.length;
+ }
+
+ /*
+ * Skip to the next token if:
+ * 1. The token type is marked as hidden.
+ * 2. The token type has a channel specified and it isn't the current channel.
+ */
+ info = tokenInfo[token.type];
+ if (info &&
+ (info.hide ||
+ (info.channel !== undefined && channel !== info.channel))){
+ return this.get(channel);
+ } else {
+ //return just the type
+ return token.type;
+ }
+ },
+
+ /**
+ * Looks ahead a certain number of tokens and returns the token type at
+ * that position. This will throw an error if you lookahead past the
+ * end of input, past the size of the lookahead buffer, or back past
+ * the first token in the lookahead buffer.
+ * @param {int} The index of the token type to retrieve. 0 for the
+ * current token, 1 for the next, -1 for the previous, etc.
+ * @return {int} The token type of the token in the given position.
+ * @method LA
+ */
+ LA: function(index){
+ var total = index,
+ tt;
+ if (index > 0){
+ //TODO: Store 5 somewhere
+ if (index > 5){
+ throw new Error("Too much lookahead.");
+ }
+
+ //get all those tokens
+ while(total){
+ tt = this.get();
+ total--;
+ }
+
+ //unget all those tokens
+ while(total < index){
+ this.unget();
+ total++;
+ }
+ } else if (index < 0){
+
+ if(this._lt[this._ltIndex+index]){
+ tt = this._lt[this._ltIndex+index].type;
+ } else {
+ throw new Error("Too much lookbehind.");
+ }
+
+ } else {
+ tt = this._token.type;
+ }
+
+ return tt;
+
+ },
+
+ /**
+ * Looks ahead a certain number of tokens and returns the token at
+ * that position. This will throw an error if you lookahead past the
+ * end of input, past the size of the lookahead buffer, or back past
+ * the first token in the lookahead buffer.
+ * @param {int} The index of the token type to retrieve. 0 for the
+ * current token, 1 for the next, -1 for the previous, etc.
+ * @return {Object} The token of the token in the given position.
+ * @method LA
+ */
+ LT: function(index){
+
+ //lookahead first to prime the token buffer
+ this.LA(index);
+
+ //now find the token, subtract one because _ltIndex is already at the next index
+ return this._lt[this._ltIndex+index-1];
+ },
+
+ /**
+ * Returns the token type for the next token in the stream without
+ * consuming it.
+ * @return {int} The token type of the next token in the stream.
+ * @method peek
+ */
+ peek: function(){
+ return this.LA(1);
+ },
+
+ /**
+ * Returns the actual token object for the last consumed token.
+ * @return {Token} The token object for the last consumed token.
+ * @method token
+ */
+ token: function(){
+ return this._token;
+ },
+
+ /**
+ * Returns the name of the token for the given token type.
+ * @param {int} tokenType The type of token to get the name of.
+ * @return {String} The name of the token or "UNKNOWN_TOKEN" for any
+ * invalid token type.
+ * @method tokenName
+ */
+ tokenName: function(tokenType){
+ if (tokenType < 0 || tokenType > this._tokenData.length){
+ return "UNKNOWN_TOKEN";
+ } else {
+ return this._tokenData[tokenType].name;
+ }
+ },
+
+ /**
+ * Returns the token type value for the given token name.
+ * @param {String} tokenName The name of the token whose value should be returned.
+ * @return {int} The token type value for the given token name or -1
+ * for an unknown token.
+ * @method tokenName
+ */
+ tokenType: function(tokenName){
+ return this._tokenData[tokenName] || -1;
+ },
+
+ /**
+ * Returns the last consumed token to the token stream.
+ * @method unget
+ */
+ unget: function(){
+ //if (this._ltIndex > -1){
+ if (this._ltIndexCache.length){
+ this._ltIndex -= this._ltIndexCache.pop();//--;
+ this._token = this._lt[this._ltIndex - 1];
+ } else {
+ throw new Error("Too much lookahead.");
+ }
+ }
+
+};
+
+
+parserlib.util = {
+__proto__ : null,
+StringReader: StringReader,
+SyntaxError : SyntaxError,
+SyntaxUnit : SyntaxUnit,
+EventTarget : EventTarget,
+TokenStreamBase : TokenStreamBase
+};
+})();
+/*
+Parser-Lib
+Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+/* Version v0.2.5+domino1, Build time: 30-January-2016 05:13:03 */
+(function(){
+var EventTarget = parserlib.util.EventTarget,
+TokenStreamBase = parserlib.util.TokenStreamBase,
+StringReader = parserlib.util.StringReader, // jshint ignore:line
+SyntaxError = parserlib.util.SyntaxError,
+SyntaxUnit = parserlib.util.SyntaxUnit;
+
+var Colors = {
+ __proto__ :null,
+ aliceblue :"#f0f8ff",
+ antiquewhite :"#faebd7",
+ aqua :"#00ffff",
+ aquamarine :"#7fffd4",
+ azure :"#f0ffff",
+ beige :"#f5f5dc",
+ bisque :"#ffe4c4",
+ black :"#000000",
+ blanchedalmond :"#ffebcd",
+ blue :"#0000ff",
+ blueviolet :"#8a2be2",
+ brown :"#a52a2a",
+ burlywood :"#deb887",
+ cadetblue :"#5f9ea0",
+ chartreuse :"#7fff00",
+ chocolate :"#d2691e",
+ coral :"#ff7f50",
+ cornflowerblue :"#6495ed",
+ cornsilk :"#fff8dc",
+ crimson :"#dc143c",
+ cyan :"#00ffff",
+ darkblue :"#00008b",
+ darkcyan :"#008b8b",
+ darkgoldenrod :"#b8860b",
+ darkgray :"#a9a9a9",
+ darkgrey :"#a9a9a9",
+ darkgreen :"#006400",
+ darkkhaki :"#bdb76b",
+ darkmagenta :"#8b008b",
+ darkolivegreen :"#556b2f",
+ darkorange :"#ff8c00",
+ darkorchid :"#9932cc",
+ darkred :"#8b0000",
+ darksalmon :"#e9967a",
+ darkseagreen :"#8fbc8f",
+ darkslateblue :"#483d8b",
+ darkslategray :"#2f4f4f",
+ darkslategrey :"#2f4f4f",
+ darkturquoise :"#00ced1",
+ darkviolet :"#9400d3",
+ deeppink :"#ff1493",
+ deepskyblue :"#00bfff",
+ dimgray :"#696969",
+ dimgrey :"#696969",
+ dodgerblue :"#1e90ff",
+ firebrick :"#b22222",
+ floralwhite :"#fffaf0",
+ forestgreen :"#228b22",
+ fuchsia :"#ff00ff",
+ gainsboro :"#dcdcdc",
+ ghostwhite :"#f8f8ff",
+ gold :"#ffd700",
+ goldenrod :"#daa520",
+ gray :"#808080",
+ grey :"#808080",
+ green :"#008000",
+ greenyellow :"#adff2f",
+ honeydew :"#f0fff0",
+ hotpink :"#ff69b4",
+ indianred :"#cd5c5c",
+ indigo :"#4b0082",
+ ivory :"#fffff0",
+ khaki :"#f0e68c",
+ lavender :"#e6e6fa",
+ lavenderblush :"#fff0f5",
+ lawngreen :"#7cfc00",
+ lemonchiffon :"#fffacd",
+ lightblue :"#add8e6",
+ lightcoral :"#f08080",
+ lightcyan :"#e0ffff",
+ lightgoldenrodyellow :"#fafad2",
+ lightgray :"#d3d3d3",
+ lightgrey :"#d3d3d3",
+ lightgreen :"#90ee90",
+ lightpink :"#ffb6c1",
+ lightsalmon :"#ffa07a",
+ lightseagreen :"#20b2aa",
+ lightskyblue :"#87cefa",
+ lightslategray :"#778899",
+ lightslategrey :"#778899",
+ lightsteelblue :"#b0c4de",
+ lightyellow :"#ffffe0",
+ lime :"#00ff00",
+ limegreen :"#32cd32",
+ linen :"#faf0e6",
+ magenta :"#ff00ff",
+ maroon :"#800000",
+ mediumaquamarine:"#66cdaa",
+ mediumblue :"#0000cd",
+ mediumorchid :"#ba55d3",
+ mediumpurple :"#9370d8",
+ mediumseagreen :"#3cb371",
+ mediumslateblue :"#7b68ee",
+ mediumspringgreen :"#00fa9a",
+ mediumturquoise :"#48d1cc",
+ mediumvioletred :"#c71585",
+ midnightblue :"#191970",
+ mintcream :"#f5fffa",
+ mistyrose :"#ffe4e1",
+ moccasin :"#ffe4b5",
+ navajowhite :"#ffdead",
+ navy :"#000080",
+ oldlace :"#fdf5e6",
+ olive :"#808000",
+ olivedrab :"#6b8e23",
+ orange :"#ffa500",
+ orangered :"#ff4500",
+ orchid :"#da70d6",
+ palegoldenrod :"#eee8aa",
+ palegreen :"#98fb98",
+ paleturquoise :"#afeeee",
+ palevioletred :"#d87093",
+ papayawhip :"#ffefd5",
+ peachpuff :"#ffdab9",
+ peru :"#cd853f",
+ pink :"#ffc0cb",
+ plum :"#dda0dd",
+ powderblue :"#b0e0e6",
+ purple :"#800080",
+ red :"#ff0000",
+ rosybrown :"#bc8f8f",
+ royalblue :"#4169e1",
+ saddlebrown :"#8b4513",
+ salmon :"#fa8072",
+ sandybrown :"#f4a460",
+ seagreen :"#2e8b57",
+ seashell :"#fff5ee",
+ sienna :"#a0522d",
+ silver :"#c0c0c0",
+ skyblue :"#87ceeb",
+ slateblue :"#6a5acd",
+ slategray :"#708090",
+ slategrey :"#708090",
+ snow :"#fffafa",
+ springgreen :"#00ff7f",
+ steelblue :"#4682b4",
+ tan :"#d2b48c",
+ teal :"#008080",
+ thistle :"#d8bfd8",
+ tomato :"#ff6347",
+ turquoise :"#40e0d0",
+ violet :"#ee82ee",
+ wheat :"#f5deb3",
+ white :"#ffffff",
+ whitesmoke :"#f5f5f5",
+ yellow :"#ffff00",
+ yellowgreen :"#9acd32",
+ //'currentColor' color keyword http://www.w3.org/TR/css3-color/#currentcolor
+ currentColor :"The value of the 'color' property.",
+ //CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system
+ activeBorder :"Active window border.",
+ activecaption :"Active window caption.",
+ appworkspace :"Background color of multiple document interface.",
+ background :"Desktop background.",
+ buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
+ buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
+ buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
+ buttontext :"Text on push buttons.",
+ captiontext :"Text in caption, size box, and scrollbar arrow box.",
+ graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
+ greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
+ highlight :"Item(s) selected in a control.",
+ highlighttext :"Text of item(s) selected in a control.",
+ inactiveborder :"Inactive window border.",
+ inactivecaption :"Inactive window caption.",
+ inactivecaptiontext :"Color of text in an inactive caption.",
+ infobackground :"Background color for tooltip controls.",
+ infotext :"Text color for tooltip controls.",
+ menu :"Menu background.",
+ menutext :"Text in menus.",
+ scrollbar :"Scroll bar gray area.",
+ threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
+ threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
+ threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
+ threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
+ threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
+ window :"Window background.",
+ windowframe :"Window frame.",
+ windowtext :"Text in windows."
+};
+/**
+ * Represents a selector combinator (whitespace, +, >).
+ * @namespace parserlib.css
+ * @class Combinator
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {String} text The text representation of the unit.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function Combinator(text, line, col){
+
+ SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
+
+ /**
+ * The type of modifier.
+ * @type String
+ * @property type
+ */
+ this.type = "unknown";
+
+ //pretty simple
+ if (/^\s+$/.test(text)){
+ this.type = "descendant";
+ } else if (text === ">"){
+ this.type = "child";
+ } else if (text === "+"){
+ this.type = "adjacent-sibling";
+ } else if (text === "~"){
+ this.type = "sibling";
+ }
+
+}
+
+Combinator.prototype = new SyntaxUnit();
+Combinator.prototype.constructor = Combinator;
+
+/**
+ * Represents a media feature, such as max-width:500.
+ * @namespace parserlib.css
+ * @class MediaFeature
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {SyntaxUnit} name The name of the feature.
+ * @param {SyntaxUnit} value The value of the feature or null if none.
+ */
+function MediaFeature(name, value){
+
+ SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
+
+ /**
+ * The name of the media feature
+ * @type String
+ * @property name
+ */
+ this.name = name;
+
+ /**
+ * The value for the feature or null if there is none.
+ * @type SyntaxUnit
+ * @property value
+ */
+ this.value = value;
+}
+
+MediaFeature.prototype = new SyntaxUnit();
+MediaFeature.prototype.constructor = MediaFeature;
+
+/**
+ * Represents an individual media query.
+ * @namespace parserlib.css
+ * @class MediaQuery
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {String} modifier The modifier "not" or "only" (or null).
+ * @param {String} mediaType The type of media (i.e., "print").
+ * @param {Array} parts Array of selectors parts making up this selector.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function MediaQuery(modifier, mediaType, features, line, col){
+
+ SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
+
+ /**
+ * The media modifier ("not" or "only")
+ * @type String
+ * @property modifier
+ */
+ this.modifier = modifier;
+
+ /**
+ * The mediaType (i.e., "print")
+ * @type String
+ * @property mediaType
+ */
+ this.mediaType = mediaType;
+
+ /**
+ * The parts that make up the selector.
+ * @type Array
+ * @property features
+ */
+ this.features = features;
+
+}
+
+MediaQuery.prototype = new SyntaxUnit();
+MediaQuery.prototype.constructor = MediaQuery;
+
+
+/**
+ * A CSS3 parser.
+ * @namespace parserlib.css
+ * @class Parser
+ * @constructor
+ * @param {Object} options (Optional) Various options for the parser:
+ * starHack (true|false) to allow IE6 star hack as valid,
+ * underscoreHack (true|false) to interpret leading underscores
+ * as IE6-7 targeting for known properties, ieFilters (true|false)
+ * to indicate that IE < 8 filters should be accepted and not throw
+ * syntax errors.
+ */
+function Parser(options){
+
+ //inherit event functionality
+ EventTarget.call(this);
+
+
+ this.options = options || {};
+
+ this._tokenStream = null;
+}
+
+//Static constants
+Parser.DEFAULT_TYPE = 0;
+Parser.COMBINATOR_TYPE = 1;
+Parser.MEDIA_FEATURE_TYPE = 2;
+Parser.MEDIA_QUERY_TYPE = 3;
+Parser.PROPERTY_NAME_TYPE = 4;
+Parser.PROPERTY_VALUE_TYPE = 5;
+Parser.PROPERTY_VALUE_PART_TYPE = 6;
+Parser.SELECTOR_TYPE = 7;
+Parser.SELECTOR_PART_TYPE = 8;
+Parser.SELECTOR_SUB_PART_TYPE = 9;
+
+Parser.prototype = function(){
+
+ var proto = new EventTarget(), //new prototype
+ prop,
+ additions = {
+ __proto__: null,
+
+ //restore constructor
+ constructor: Parser,
+
+ //instance constants - yuck
+ DEFAULT_TYPE : 0,
+ COMBINATOR_TYPE : 1,
+ MEDIA_FEATURE_TYPE : 2,
+ MEDIA_QUERY_TYPE : 3,
+ PROPERTY_NAME_TYPE : 4,
+ PROPERTY_VALUE_TYPE : 5,
+ PROPERTY_VALUE_PART_TYPE : 6,
+ SELECTOR_TYPE : 7,
+ SELECTOR_PART_TYPE : 8,
+ SELECTOR_SUB_PART_TYPE : 9,
+
+ //-----------------------------------------------------------------
+ // Grammar
+ //-----------------------------------------------------------------
+
+ _stylesheet: function(){
+
+ /*
+ * stylesheet
+ * : [ CHARSET_SYM S* STRING S* ';' ]?
+ * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
+ * [ namespace [S|CDO|CDC]* ]*
+ * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ count,
+ token,
+ tt;
+
+ this.fire("startstylesheet");
+
+ //try to read character set
+ this._charset();
+
+ this._skipCruft();
+
+ //try to read imports - may be more than one
+ while (tokenStream.peek() === Tokens.IMPORT_SYM){
+ this._import();
+ this._skipCruft();
+ }
+
+ //try to read namespaces - may be more than one
+ while (tokenStream.peek() === Tokens.NAMESPACE_SYM){
+ this._namespace();
+ this._skipCruft();
+ }
+
+ //get the next token
+ tt = tokenStream.peek();
+
+ //try to read the rest
+ while(tt > Tokens.EOF){
+
+ try {
+
+ switch(tt){
+ case Tokens.MEDIA_SYM:
+ this._media();
+ this._skipCruft();
+ break;
+ case Tokens.PAGE_SYM:
+ this._page();
+ this._skipCruft();
+ break;
+ case Tokens.FONT_FACE_SYM:
+ this._font_face();
+ this._skipCruft();
+ break;
+ case Tokens.KEYFRAMES_SYM:
+ this._keyframes();
+ this._skipCruft();
+ break;
+ case Tokens.VIEWPORT_SYM:
+ this._viewport();
+ this._skipCruft();
+ break;
+ case Tokens.DOCUMENT_SYM:
+ this._document();
+ this._skipCruft();
+ break;
+ case Tokens.UNKNOWN_SYM: //unknown @ rule
+ tokenStream.get();
+ if (!this.options.strict){
+
+ //fire error event
+ this.fire({
+ type: "error",
+ error: null,
+ message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
+ line: tokenStream.LT(0).startLine,
+ col: tokenStream.LT(0).startCol
+ });
+
+ //skip braces
+ count=0;
+ while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE){
+ count++; //keep track of nesting depth
+ }
+
+ while(count){
+ tokenStream.advance([Tokens.RBRACE]);
+ count--;
+ }
+
+ } else {
+ //not a syntax error, rethrow it
+ throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
+ }
+ break;
+ case Tokens.S:
+ this._readWhitespace();
+ break;
+ default:
+ if(!this._ruleset()){
+
+ //error handling for known issues
+ switch(tt){
+ case Tokens.CHARSET_SYM:
+ token = tokenStream.LT(1);
+ this._charset(false);
+ throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
+ case Tokens.IMPORT_SYM:
+ token = tokenStream.LT(1);
+ this._import(false);
+ throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
+ case Tokens.NAMESPACE_SYM:
+ token = tokenStream.LT(1);
+ this._namespace(false);
+ throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
+ default:
+ tokenStream.get(); //get the last token
+ this._unexpectedToken(tokenStream.token());
+ }
+
+ }
+ }
+ } catch(ex) {
+ if (ex instanceof SyntaxError && !this.options.strict){
+ this.fire({
+ type: "error",
+ error: ex,
+ message: ex.message,
+ line: ex.line,
+ col: ex.col
+ });
+ } else {
+ throw ex;
+ }
+ }
+
+ tt = tokenStream.peek();
+ }
+
+ if (tt !== Tokens.EOF){
+ this._unexpectedToken(tokenStream.token());
+ }
+
+ this.fire("endstylesheet");
+ },
+
+ _charset: function(emit){
+ var tokenStream = this._tokenStream,
+ charset,
+ token,
+ line,
+ col;
+
+ if (tokenStream.match(Tokens.CHARSET_SYM)){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this._readWhitespace();
+ tokenStream.mustMatch(Tokens.STRING);
+
+ token = tokenStream.token();
+ charset = token.value;
+
+ this._readWhitespace();
+ tokenStream.mustMatch(Tokens.SEMICOLON);
+
+ if (emit !== false){
+ this.fire({
+ type: "charset",
+ charset:charset,
+ line: line,
+ col: col
+ });
+ }
+ }
+ },
+
+ _import: function(emit){
+ /*
+ * import
+ * : IMPORT_SYM S*
+ * [STRING|URI] S* media_query_list? ';' S*
+ */
+
+ var tokenStream = this._tokenStream,
+ uri,
+ importToken,
+ mediaList = [];
+
+ //read import symbol
+ tokenStream.mustMatch(Tokens.IMPORT_SYM);
+ importToken = tokenStream.token();
+ this._readWhitespace();
+
+ tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
+
+ //grab the URI value
+ uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
+
+ this._readWhitespace();
+
+ mediaList = this._media_query_list();
+
+ //must end with a semicolon
+ tokenStream.mustMatch(Tokens.SEMICOLON);
+ this._readWhitespace();
+
+ if (emit !== false){
+ this.fire({
+ type: "import",
+ uri: uri,
+ media: mediaList,
+ line: importToken.startLine,
+ col: importToken.startCol
+ });
+ }
+
+ },
+
+ _namespace: function(emit){
+ /*
+ * namespace
+ * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S*
+ */
+
+ var tokenStream = this._tokenStream,
+ line,
+ col,
+ prefix,
+ uri;
+
+ //read import symbol
+ tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ this._readWhitespace();
+
+ //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT
+ if (tokenStream.match(Tokens.IDENT)){
+ prefix = tokenStream.token().value;
+ this._readWhitespace();
+ }
+
+ tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
+ /*if (!tokenStream.match(Tokens.STRING)){
+ tokenStream.mustMatch(Tokens.URI);
+ }*/
+
+ //grab the URI value
+ uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
+
+ this._readWhitespace();
+
+ //must end with a semicolon
+ tokenStream.mustMatch(Tokens.SEMICOLON);
+ this._readWhitespace();
+
+ if (emit !== false){
+ this.fire({
+ type: "namespace",
+ prefix: prefix,
+ uri: uri,
+ line: line,
+ col: col
+ });
+ }
+
+ },
+
+ _media: function(){
+ /*
+ * media
+ * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ line,
+ col,
+ mediaList;// = [];
+
+ //look for @media
+ tokenStream.mustMatch(Tokens.MEDIA_SYM);
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this._readWhitespace();
+
+ mediaList = this._media_query_list();
+
+ tokenStream.mustMatch(Tokens.LBRACE);
+ this._readWhitespace();
+
+ this.fire({
+ type: "startmedia",
+ media: mediaList,
+ line: line,
+ col: col
+ });
+
+ while(true) {
+ if (tokenStream.peek() === Tokens.PAGE_SYM){
+ this._page();
+ } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
+ this._font_face();
+ } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
+ this._viewport();
+ } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM){
+ this._document();
+ } else if (!this._ruleset()){
+ break;
+ }
+ }
+
+ tokenStream.mustMatch(Tokens.RBRACE);
+ this._readWhitespace();
+
+ this.fire({
+ type: "endmedia",
+ media: mediaList,
+ line: line,
+ col: col
+ });
+ },
+
+
+ //CSS3 Media Queries
+ _media_query_list: function(){
+ /*
+ * media_query_list
+ * : S* [media_query [ ',' S* media_query ]* ]?
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ mediaList = [];
+
+
+ this._readWhitespace();
+
+ if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN){
+ mediaList.push(this._media_query());
+ }
+
+ while(tokenStream.match(Tokens.COMMA)){
+ this._readWhitespace();
+ mediaList.push(this._media_query());
+ }
+
+ return mediaList;
+ },
+
+ /*
+ * Note: "expression" in the grammar maps to the _media_expression
+ * method.
+
+ */
+ _media_query: function(){
+ /*
+ * media_query
+ * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
+ * | expression [ AND S* expression ]*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ type = null,
+ ident = null,
+ token = null,
+ expressions = [];
+
+ if (tokenStream.match(Tokens.IDENT)){
+ ident = tokenStream.token().value.toLowerCase();
+
+ //since there's no custom tokens for these, need to manually check
+ if (ident !== "only" && ident !== "not"){
+ tokenStream.unget();
+ ident = null;
+ } else {
+ token = tokenStream.token();
+ }
+ }
+
+ this._readWhitespace();
+
+ if (tokenStream.peek() === Tokens.IDENT){
+ type = this._media_type();
+ if (token === null){
+ token = tokenStream.token();
+ }
+ } else if (tokenStream.peek() === Tokens.LPAREN){
+ if (token === null){
+ token = tokenStream.LT(1);
+ }
+ expressions.push(this._media_expression());
+ }
+
+ if (type === null && expressions.length === 0){
+ return null;
+ } else {
+ this._readWhitespace();
+ while (tokenStream.match(Tokens.IDENT)){
+ if (tokenStream.token().value.toLowerCase() !== "and"){
+ this._unexpectedToken(tokenStream.token());
+ }
+
+ this._readWhitespace();
+ expressions.push(this._media_expression());
+ }
+ }
+
+ return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
+ },
+
+ //CSS3 Media Queries
+ _media_type: function(){
+ /*
+ * media_type
+ * : IDENT
+ * ;
+ */
+ return this._media_feature();
+ },
+
+ /**
+ * Note: in CSS3 Media Queries, this is called "expression".
+ * Renamed here to avoid conflict with CSS3 Selectors
+ * definition of "expression". Also note that "expr" in the
+ * grammar now maps to "expression" from CSS3 selectors.
+ * @method _media_expression
+ * @private
+ */
+ _media_expression: function(){
+ /*
+ * expression
+ * : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ feature = null,
+ token,
+ expression = null;
+
+ tokenStream.mustMatch(Tokens.LPAREN);
+
+ feature = this._media_feature();
+ this._readWhitespace();
+
+ if (tokenStream.match(Tokens.COLON)){
+ this._readWhitespace();
+ token = tokenStream.LT(1);
+ expression = this._expression();
+ }
+
+ tokenStream.mustMatch(Tokens.RPAREN);
+ this._readWhitespace();
+
+ return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null));
+ },
+
+ //CSS3 Media Queries
+ _media_feature: function(){
+ /*
+ * media_feature
+ * : IDENT
+ * ;
+ */
+ var tokenStream = this._tokenStream;
+
+ this._readWhitespace();
+
+ tokenStream.mustMatch(Tokens.IDENT);
+
+ return SyntaxUnit.fromToken(tokenStream.token());
+ },
+
+ //CSS3 Paged Media
+ _page: function(){
+ /*
+ * page:
+ * PAGE_SYM S* IDENT? pseudo_page? S*
+ * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ line,
+ col,
+ identifier = null,
+ pseudoPage = null;
+
+ //look for @page
+ tokenStream.mustMatch(Tokens.PAGE_SYM);
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this._readWhitespace();
+
+ if (tokenStream.match(Tokens.IDENT)){
+ identifier = tokenStream.token().value;
+
+ //The value 'auto' may not be used as a page name and MUST be treated as a syntax error.
+ if (identifier.toLowerCase() === "auto"){
+ this._unexpectedToken(tokenStream.token());
+ }
+ }
+
+ //see if there's a colon upcoming
+ if (tokenStream.peek() === Tokens.COLON){
+ pseudoPage = this._pseudo_page();
+ }
+
+ this._readWhitespace();
+
+ this.fire({
+ type: "startpage",
+ id: identifier,
+ pseudo: pseudoPage,
+ line: line,
+ col: col
+ });
+
+ this._readDeclarations(true, true);
+
+ this.fire({
+ type: "endpage",
+ id: identifier,
+ pseudo: pseudoPage,
+ line: line,
+ col: col
+ });
+
+ },
+
+ //CSS3 Paged Media
+ _margin: function(){
+ /*
+ * margin :
+ * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ line,
+ col,
+ marginSym = this._margin_sym();
+
+ if (marginSym){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this.fire({
+ type: "startpagemargin",
+ margin: marginSym,
+ line: line,
+ col: col
+ });
+
+ this._readDeclarations(true);
+
+ this.fire({
+ type: "endpagemargin",
+ margin: marginSym,
+ line: line,
+ col: col
+ });
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ //CSS3 Paged Media
+ _margin_sym: function(){
+
+ /*
+ * margin_sym :
+ * TOPLEFTCORNER_SYM |
+ * TOPLEFT_SYM |
+ * TOPCENTER_SYM |
+ * TOPRIGHT_SYM |
+ * TOPRIGHTCORNER_SYM |
+ * BOTTOMLEFTCORNER_SYM |
+ * BOTTOMLEFT_SYM |
+ * BOTTOMCENTER_SYM |
+ * BOTTOMRIGHT_SYM |
+ * BOTTOMRIGHTCORNER_SYM |
+ * LEFTTOP_SYM |
+ * LEFTMIDDLE_SYM |
+ * LEFTBOTTOM_SYM |
+ * RIGHTTOP_SYM |
+ * RIGHTMIDDLE_SYM |
+ * RIGHTBOTTOM_SYM
+ * ;
+ */
+
+ var tokenStream = this._tokenStream;
+
+ if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
+ Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
+ Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
+ Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
+ Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
+ Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
+ Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM]))
+ {
+ return SyntaxUnit.fromToken(tokenStream.token());
+ } else {
+ return null;
+ }
+
+ },
+
+ _pseudo_page: function(){
+ /*
+ * pseudo_page
+ * : ':' IDENT
+ * ;
+ */
+
+ var tokenStream = this._tokenStream;
+
+ tokenStream.mustMatch(Tokens.COLON);
+ tokenStream.mustMatch(Tokens.IDENT);
+
+ //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed
+
+ return tokenStream.token().value;
+ },
+
+ _font_face: function(){
+ /*
+ * font_face
+ * : FONT_FACE_SYM S*
+ * '{' S* declaration [ ';' S* declaration ]* '}' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ line,
+ col;
+
+ //look for @page
+ tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this._readWhitespace();
+
+ this.fire({
+ type: "startfontface",
+ line: line,
+ col: col
+ });
+
+ this._readDeclarations(true);
+
+ this.fire({
+ type: "endfontface",
+ line: line,
+ col: col
+ });
+ },
+
+ _viewport: function(){
+ /*
+ * viewport
+ * : VIEWPORT_SYM S*
+ * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ line,
+ col;
+
+ tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+
+ this._readWhitespace();
+
+ this.fire({
+ type: "startviewport",
+ line: line,
+ col: col
+ });
+
+ this._readDeclarations(true);
+
+ this.fire({
+ type: "endviewport",
+ line: line,
+ col: col
+ });
+
+ },
+
+ _document: function(){
+ /*
+ * document
+ * : DOCUMENT_SYM S*
+ * _document_function [ ',' S* _document_function ]* S*
+ * '{' S* ruleset* '}'
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token,
+ functions = [],
+ prefix = "";
+
+ tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
+ token = tokenStream.token();
+ if (/^@\-([^\-]+)\-/.test(token.value)) {
+ prefix = RegExp.$1;
+ }
+
+ this._readWhitespace();
+ functions.push(this._document_function());
+
+ while(tokenStream.match(Tokens.COMMA)) {
+ this._readWhitespace();
+ functions.push(this._document_function());
+ }
+
+ tokenStream.mustMatch(Tokens.LBRACE);
+ this._readWhitespace();
+
+ this.fire({
+ type: "startdocument",
+ functions: functions,
+ prefix: prefix,
+ line: token.startLine,
+ col: token.startCol
+ });
+
+ while(true) {
+ if (tokenStream.peek() === Tokens.PAGE_SYM){
+ this._page();
+ } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
+ this._font_face();
+ } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
+ this._viewport();
+ } else if (tokenStream.peek() === Tokens.MEDIA_SYM){
+ this._media();
+ } else if (!this._ruleset()){
+ break;
+ }
+ }
+
+ tokenStream.mustMatch(Tokens.RBRACE);
+ this._readWhitespace();
+
+ this.fire({
+ type: "enddocument",
+ functions: functions,
+ prefix: prefix,
+ line: token.startLine,
+ col: token.startCol
+ });
+ },
+
+ _document_function: function(){
+ /*
+ * document_function
+ * : function | URI S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value;
+
+ if (tokenStream.match(Tokens.URI)) {
+ value = tokenStream.token().value;
+ this._readWhitespace();
+ } else {
+ value = this._function();
+ }
+
+ return value;
+ },
+
+ _operator: function(inFunction){
+
+ /*
+ * operator (outside function)
+ * : '/' S* | ',' S* | /( empty )/
+ * operator (inside function)
+ * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token = null;
+
+ if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
+ (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
+ token = tokenStream.token();
+ this._readWhitespace();
+ }
+ return token ? PropertyValuePart.fromToken(token) : null;
+
+ },
+
+ _combinator: function(){
+
+ /*
+ * combinator
+ * : PLUS S* | GREATER S* | TILDE S* | S+
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value = null,
+ token;
+
+ if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){
+ token = tokenStream.token();
+ value = new Combinator(token.value, token.startLine, token.startCol);
+ this._readWhitespace();
+ }
+
+ return value;
+ },
+
+ _unary_operator: function(){
+
+ /*
+ * unary_operator
+ * : '-' | '+'
+ * ;
+ */
+
+ var tokenStream = this._tokenStream;
+
+ if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){
+ return tokenStream.token().value;
+ } else {
+ return null;
+ }
+ },
+
+ _property: function(){
+
+ /*
+ * property
+ * : IDENT S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value = null,
+ hack = null,
+ tokenValue,
+ token,
+ line,
+ col;
+
+ //check for star hack - throws error if not allowed
+ if (tokenStream.peek() === Tokens.STAR && this.options.starHack){
+ tokenStream.get();
+ token = tokenStream.token();
+ hack = token.value;
+ line = token.startLine;
+ col = token.startCol;
+ }
+
+ if(tokenStream.match(Tokens.IDENT)){
+ token = tokenStream.token();
+ tokenValue = token.value;
+
+ //check for underscore hack - no error if not allowed because it's valid CSS syntax
+ if (tokenValue.charAt(0) === "_" && this.options.underscoreHack){
+ hack = "_";
+ tokenValue = tokenValue.substring(1);
+ }
+
+ value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol));
+ this._readWhitespace();
+ }
+
+ return value;
+ },
+
+ //Augmented with CSS3 Selectors
+ _ruleset: function(){
+ /*
+ * ruleset
+ * : selectors_group
+ * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ tt,
+ selectors;
+
+
+ /*
+ * Error Recovery: If even a single selector fails to parse,
+ * then the entire ruleset should be thrown away.
+ */
+ try {
+ selectors = this._selectors_group();
+ } catch (ex){
+ if (ex instanceof SyntaxError && !this.options.strict){
+
+ //fire error event
+ this.fire({
+ type: "error",
+ error: ex,
+ message: ex.message,
+ line: ex.line,
+ col: ex.col
+ });
+
+ //skip over everything until closing brace
+ tt = tokenStream.advance([Tokens.RBRACE]);
+ if (tt === Tokens.RBRACE){
+ //if there's a right brace, the rule is finished so don't do anything
+ } else {
+ //otherwise, rethrow the error because it wasn't handled properly
+ throw ex;
+ }
+
+ } else {
+ //not a syntax error, rethrow it
+ throw ex;
+ }
+
+ //trigger parser to continue
+ return true;
+ }
+
+ //if it got here, all selectors parsed
+ if (selectors){
+
+ this.fire({
+ type: "startrule",
+ selectors: selectors,
+ line: selectors[0].line,
+ col: selectors[0].col
+ });
+
+ this._readDeclarations(true);
+
+ this.fire({
+ type: "endrule",
+ selectors: selectors,
+ line: selectors[0].line,
+ col: selectors[0].col
+ });
+
+ }
+
+ return selectors;
+
+ },
+
+ //CSS3 Selectors
+ _selectors_group: function(){
+
+ /*
+ * selectors_group
+ * : selector [ COMMA S* selector ]*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ selectors = [],
+ selector;
+
+ selector = this._selector();
+ if (selector !== null){
+
+ selectors.push(selector);
+ while(tokenStream.match(Tokens.COMMA)){
+ this._readWhitespace();
+ selector = this._selector();
+ if (selector !== null){
+ selectors.push(selector);
+ } else {
+ this._unexpectedToken(tokenStream.LT(1));
+ }
+ }
+ }
+
+ return selectors.length ? selectors : null;
+ },
+
+ //CSS3 Selectors
+ _selector: function(){
+ /*
+ * selector
+ * : simple_selector_sequence [ combinator simple_selector_sequence ]*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ selector = [],
+ nextSelector = null,
+ combinator = null,
+ ws = null;
+
+ //if there's no simple selector, then there's no selector
+ nextSelector = this._simple_selector_sequence();
+ if (nextSelector === null){
+ return null;
+ }
+
+ selector.push(nextSelector);
+
+ do {
+
+ //look for a combinator
+ combinator = this._combinator();
+
+ if (combinator !== null){
+ selector.push(combinator);
+ nextSelector = this._simple_selector_sequence();
+
+ //there must be a next selector
+ if (nextSelector === null){
+ this._unexpectedToken(tokenStream.LT(1));
+ } else {
+
+ //nextSelector is an instance of SelectorPart
+ selector.push(nextSelector);
+ }
+ } else {
+
+ //if there's not whitespace, we're done
+ if (this._readWhitespace()){
+
+ //add whitespace separator
+ ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
+
+ //combinator is not required
+ combinator = this._combinator();
+
+ //selector is required if there's a combinator
+ nextSelector = this._simple_selector_sequence();
+ if (nextSelector === null){
+ if (combinator !== null){
+ this._unexpectedToken(tokenStream.LT(1));
+ }
+ } else {
+
+ if (combinator !== null){
+ selector.push(combinator);
+ } else {
+ selector.push(ws);
+ }
+
+ selector.push(nextSelector);
+ }
+ } else {
+ break;
+ }
+
+ }
+ } while(true);
+
+ return new Selector(selector, selector[0].line, selector[0].col);
+ },
+
+ //CSS3 Selectors
+ _simple_selector_sequence: function(){
+ /*
+ * simple_selector_sequence
+ * : [ type_selector | universal ]
+ * [ HASH | class | attrib | pseudo | negation ]*
+ * | [ HASH | class | attrib | pseudo | negation ]+
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+
+ //parts of a simple selector
+ elementName = null,
+ modifiers = [],
+
+ //complete selector text
+ selectorText= "",
+
+ //the different parts after the element name to search for
+ components = [
+ //HASH
+ function(){
+ return tokenStream.match(Tokens.HASH) ?
+ new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
+ null;
+ },
+ this._class,
+ this._attrib,
+ this._pseudo,
+ this._negation
+ ],
+ i = 0,
+ len = components.length,
+ component = null,
+ line,
+ col;
+
+
+ //get starting line and column for the selector
+ line = tokenStream.LT(1).startLine;
+ col = tokenStream.LT(1).startCol;
+
+ elementName = this._type_selector();
+ if (!elementName){
+ elementName = this._universal();
+ }
+
+ if (elementName !== null){
+ selectorText += elementName;
+ }
+
+ while(true){
+
+ //whitespace means we're done
+ if (tokenStream.peek() === Tokens.S){
+ break;
+ }
+
+ //check for each component
+ while(i < len && component === null){
+ component = components[i++].call(this);
+ }
+
+ if (component === null){
+
+ //we don't have a selector
+ if (selectorText === ""){
+ return null;
+ } else {
+ break;
+ }
+ } else {
+ i = 0;
+ modifiers.push(component);
+ selectorText += component.toString();
+ component = null;
+ }
+ }
+
+
+ return selectorText !== "" ?
+ new SelectorPart(elementName, modifiers, selectorText, line, col) :
+ null;
+ },
+
+ //CSS3 Selectors
+ _type_selector: function(){
+ /*
+ * type_selector
+ * : [ namespace_prefix ]? element_name
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ ns = this._namespace_prefix(),
+ elementName = this._element_name();
+
+ if (!elementName){
+ /*
+ * Need to back out the namespace that was read due to both
+ * type_selector and universal reading namespace_prefix
+ * first. Kind of hacky, but only way I can figure out
+ * right now how to not change the grammar.
+ */
+ if (ns){
+ tokenStream.unget();
+ if (ns.length > 1){
+ tokenStream.unget();
+ }
+ }
+
+ return null;
+ } else {
+ if (ns){
+ elementName.text = ns + elementName.text;
+ elementName.col -= ns.length;
+ }
+ return elementName;
+ }
+ },
+
+ //CSS3 Selectors
+ _class: function(){
+ /*
+ * class
+ * : '.' IDENT
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token;
+
+ if (tokenStream.match(Tokens.DOT)){
+ tokenStream.mustMatch(Tokens.IDENT);
+ token = tokenStream.token();
+ return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
+ } else {
+ return null;
+ }
+
+ },
+
+ //CSS3 Selectors
+ _element_name: function(){
+ /*
+ * element_name
+ * : IDENT
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token;
+
+ if (tokenStream.match(Tokens.IDENT)){
+ token = tokenStream.token();
+ return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
+
+ } else {
+ return null;
+ }
+ },
+
+ //CSS3 Selectors
+ _namespace_prefix: function(){
+ /*
+ * namespace_prefix
+ * : [ IDENT | '*' ]? '|'
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ value = "";
+
+ //verify that this is a namespace prefix
+ if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){
+
+ if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){
+ value += tokenStream.token().value;
+ }
+
+ tokenStream.mustMatch(Tokens.PIPE);
+ value += "|";
+
+ }
+
+ return value.length ? value : null;
+ },
+
+ //CSS3 Selectors
+ _universal: function(){
+ /*
+ * universal
+ * : [ namespace_prefix ]? '*'
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ value = "",
+ ns;
+
+ ns = this._namespace_prefix();
+ if(ns){
+ value += ns;
+ }
+
+ if(tokenStream.match(Tokens.STAR)){
+ value += "*";
+ }
+
+ return value.length ? value : null;
+
+ },
+
+ //CSS3 Selectors
+ _attrib: function(){
+ /*
+ * attrib
+ * : '[' S* [ namespace_prefix ]? IDENT S*
+ * [ [ PREFIXMATCH |
+ * SUFFIXMATCH |
+ * SUBSTRINGMATCH |
+ * '=' |
+ * INCLUDES |
+ * DASHMATCH ] S* [ IDENT | STRING ] S*
+ * ]? ']'
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value = null,
+ ns,
+ token;
+
+ if (tokenStream.match(Tokens.LBRACKET)){
+ token = tokenStream.token();
+ value = token.value;
+ value += this._readWhitespace();
+
+ ns = this._namespace_prefix();
+
+ if (ns){
+ value += ns;
+ }
+
+ tokenStream.mustMatch(Tokens.IDENT);
+ value += tokenStream.token().value;
+ value += this._readWhitespace();
+
+ if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
+ Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){
+
+ value += tokenStream.token().value;
+ value += this._readWhitespace();
+
+ tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
+ value += tokenStream.token().value;
+ value += this._readWhitespace();
+ }
+
+ tokenStream.mustMatch(Tokens.RBRACKET);
+
+ return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
+ } else {
+ return null;
+ }
+ },
+
+ //CSS3 Selectors
+ _pseudo: function(){
+
+ /*
+ * pseudo
+ * : ':' ':'? [ IDENT | functional_pseudo ]
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ pseudo = null,
+ colons = ":",
+ line,
+ col;
+
+ if (tokenStream.match(Tokens.COLON)){
+
+ if (tokenStream.match(Tokens.COLON)){
+ colons += ":";
+ }
+
+ if (tokenStream.match(Tokens.IDENT)){
+ pseudo = tokenStream.token().value;
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol - colons.length;
+ } else if (tokenStream.peek() === Tokens.FUNCTION){
+ line = tokenStream.LT(1).startLine;
+ col = tokenStream.LT(1).startCol - colons.length;
+ pseudo = this._functional_pseudo();
+ }
+
+ if (pseudo){
+ pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
+ }
+ }
+
+ return pseudo;
+ },
+
+ //CSS3 Selectors
+ _functional_pseudo: function(){
+ /*
+ * functional_pseudo
+ * : FUNCTION S* expression ')'
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value = null;
+
+ if(tokenStream.match(Tokens.FUNCTION)){
+ value = tokenStream.token().value;
+ value += this._readWhitespace();
+ value += this._expression();
+ tokenStream.mustMatch(Tokens.RPAREN);
+ value += ")";
+ }
+
+ return value;
+ },
+
+ //CSS3 Selectors
+ _expression: function(){
+ /*
+ * expression
+ * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ value = "";
+
+ while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
+ Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
+ Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
+ Tokens.RESOLUTION, Tokens.SLASH])){
+
+ value += tokenStream.token().value;
+ value += this._readWhitespace();
+ }
+
+ return value.length ? value : null;
+
+ },
+
+ //CSS3 Selectors
+ _negation: function(){
+ /*
+ * negation
+ * : NOT S* negation_arg S* ')'
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ line,
+ col,
+ value = "",
+ arg,
+ subpart = null;
+
+ if (tokenStream.match(Tokens.NOT)){
+ value = tokenStream.token().value;
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ value += this._readWhitespace();
+ arg = this._negation_arg();
+ value += arg;
+ value += this._readWhitespace();
+ tokenStream.match(Tokens.RPAREN);
+ value += tokenStream.token().value;
+
+ subpart = new SelectorSubPart(value, "not", line, col);
+ subpart.args.push(arg);
+ }
+
+ return subpart;
+ },
+
+ //CSS3 Selectors
+ _negation_arg: function(){
+ /*
+ * negation_arg
+ * : type_selector | universal | HASH | class | attrib | pseudo
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ args = [
+ this._type_selector,
+ this._universal,
+ function(){
+ return tokenStream.match(Tokens.HASH) ?
+ new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
+ null;
+ },
+ this._class,
+ this._attrib,
+ this._pseudo
+ ],
+ arg = null,
+ i = 0,
+ len = args.length,
+ line,
+ col,
+ part;
+
+ line = tokenStream.LT(1).startLine;
+ col = tokenStream.LT(1).startCol;
+
+ while(i < len && arg === null){
+
+ arg = args[i].call(this);
+ i++;
+ }
+
+ //must be a negation arg
+ if (arg === null){
+ this._unexpectedToken(tokenStream.LT(1));
+ }
+
+ //it's an element name
+ if (arg.type === "elementName"){
+ part = new SelectorPart(arg, [], arg.toString(), line, col);
+ } else {
+ part = new SelectorPart(null, [arg], arg.toString(), line, col);
+ }
+
+ return part;
+ },
+
+ _declaration: function(){
+
+ /*
+ * declaration
+ * : property ':' S* expr prio?
+ * | /( empty )/
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ property = null,
+ expr = null,
+ prio = null,
+ invalid = null,
+ propertyName= "";
+
+ property = this._property();
+ if (property !== null){
+
+ tokenStream.mustMatch(Tokens.COLON);
+ this._readWhitespace();
+
+ expr = this._expr();
+
+ //if there's no parts for the value, it's an error
+ if (!expr || expr.length === 0){
+ this._unexpectedToken(tokenStream.LT(1));
+ }
+
+ prio = this._prio();
+
+ /*
+ * If hacks should be allowed, then only check the root
+ * property. If hacks should not be allowed, treat
+ * _property or *property as invalid properties.
+ */
+ propertyName = property.toString();
+ if (this.options.starHack && property.hack === "*" ||
+ this.options.underscoreHack && property.hack === "_") {
+
+ propertyName = property.text;
+ }
+
+ try {
+ this._validateProperty(propertyName, expr);
+ } catch (ex) {
+ invalid = ex;
+ }
+
+ this.fire({
+ type: "property",
+ property: property,
+ value: expr,
+ important: prio,
+ line: property.line,
+ col: property.col,
+ invalid: invalid
+ });
+
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ _prio: function(){
+ /*
+ * prio
+ * : IMPORTANT_SYM S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ result = tokenStream.match(Tokens.IMPORTANT_SYM);
+
+ this._readWhitespace();
+ return result;
+ },
+
+ _expr: function(inFunction){
+ /*
+ * expr
+ * : term [ operator term ]*
+ * ;
+ */
+
+ var values = [],
+ //valueParts = [],
+ value = null,
+ operator = null;
+
+ value = this._term(inFunction);
+ if (value !== null){
+
+ values.push(value);
+
+ do {
+ operator = this._operator(inFunction);
+
+ //if there's an operator, keep building up the value parts
+ if (operator){
+ values.push(operator);
+ } /*else {
+ //if there's not an operator, you have a full value
+ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
+ valueParts = [];
+ }*/
+
+ value = this._term(inFunction);
+
+ if (value === null){
+ break;
+ } else {
+ values.push(value);
+ }
+ } while(true);
+ }
+
+ //cleanup
+ /*if (valueParts.length){
+ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
+ }*/
+
+ return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
+ },
+
+ _term: function(inFunction){
+
+ /*
+ * term
+ * : unary_operator?
+ * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* |
+ * TIME S* | FREQ S* | function | ie_function ]
+ * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ unary = null,
+ value = null,
+ endChar = null,
+ token,
+ line,
+ col;
+
+ //returns the operator or null
+ unary = this._unary_operator();
+ if (unary !== null){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ }
+
+ //exception for IE filters
+ if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters){
+
+ value = this._ie_function();
+ if (unary === null){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ }
+
+ //see if it's a simple block
+ } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){
+
+ token = tokenStream.token();
+ endChar = token.endChar;
+ value = token.value + this._expr(inFunction).text;
+ if (unary === null){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ }
+ tokenStream.mustMatch(Tokens.type(endChar));
+ value += endChar;
+ this._readWhitespace();
+
+ //see if there's a simple match
+ } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
+ Tokens.ANGLE, Tokens.TIME,
+ Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){
+
+ value = tokenStream.token().value;
+ if (unary === null){
+ line = tokenStream.token().startLine;
+ col = tokenStream.token().startCol;
+ }
+ this._readWhitespace();
+ } else {
+
+ //see if it's a color
+ token = this._hexcolor();
+ if (token === null){
+
+ //if there's no unary, get the start of the next token for line/col info
+ if (unary === null){
+ line = tokenStream.LT(1).startLine;
+ col = tokenStream.LT(1).startCol;
+ }
+
+ //has to be a function
+ if (value === null){
+
+ /*
+ * This checks for alpha(opacity=0) style of IE
+ * functions. IE_FUNCTION only presents progid: style.
+ */
+ if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters){
+ value = this._ie_function();
+ } else {
+ value = this._function();
+ }
+ }
+
+ /*if (value === null){
+ return null;
+ //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
+ }*/
+
+ } else {
+ value = token.value;
+ if (unary === null){
+ line = token.startLine;
+ col = token.startCol;
+ }
+ }
+
+ }
+
+ return value !== null ?
+ new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
+ null;
+
+ },
+
+ _function: function(){
+
+ /*
+ * function
+ * : FUNCTION S* expr ')' S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ functionText = null,
+ expr = null,
+ lt;
+
+ if (tokenStream.match(Tokens.FUNCTION)){
+ functionText = tokenStream.token().value;
+ this._readWhitespace();
+ expr = this._expr(true);
+ functionText += expr;
+
+ //START: Horrible hack in case it's an IE filter
+ if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS){
+ do {
+
+ if (this._readWhitespace()){
+ functionText += tokenStream.token().value;
+ }
+
+ //might be second time in the loop
+ if (tokenStream.LA(0) === Tokens.COMMA){
+ functionText += tokenStream.token().value;
+ }
+
+ tokenStream.match(Tokens.IDENT);
+ functionText += tokenStream.token().value;
+
+ tokenStream.match(Tokens.EQUALS);
+ functionText += tokenStream.token().value;
+
+ //functionText += this._term();
+ lt = tokenStream.peek();
+ while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
+ tokenStream.get();
+ functionText += tokenStream.token().value;
+ lt = tokenStream.peek();
+ }
+ } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
+ }
+
+ //END: Horrible Hack
+
+ tokenStream.match(Tokens.RPAREN);
+ functionText += ")";
+ this._readWhitespace();
+ }
+
+ return functionText;
+ },
+
+ _ie_function: function(){
+
+ /* (My own extension)
+ * ie_function
+ * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ functionText = null,
+ lt;
+
+ //IE function can begin like a regular function, too
+ if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){
+ functionText = tokenStream.token().value;
+
+ do {
+
+ if (this._readWhitespace()){
+ functionText += tokenStream.token().value;
+ }
+
+ //might be second time in the loop
+ if (tokenStream.LA(0) === Tokens.COMMA){
+ functionText += tokenStream.token().value;
+ }
+
+ tokenStream.match(Tokens.IDENT);
+ functionText += tokenStream.token().value;
+
+ tokenStream.match(Tokens.EQUALS);
+ functionText += tokenStream.token().value;
+
+ //functionText += this._term();
+ lt = tokenStream.peek();
+ while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
+ tokenStream.get();
+ functionText += tokenStream.token().value;
+ lt = tokenStream.peek();
+ }
+ } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
+
+ tokenStream.match(Tokens.RPAREN);
+ functionText += ")";
+ this._readWhitespace();
+ }
+
+ return functionText;
+ },
+
+ _hexcolor: function(){
+ /*
+ * There is a constraint on the color that it must
+ * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
+ * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
+ *
+ * hexcolor
+ * : HASH S*
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token = null,
+ color;
+
+ if(tokenStream.match(Tokens.HASH)){
+
+ //need to do some validation here
+
+ token = tokenStream.token();
+ color = token.value;
+ if (!/#[a-f0-9]{3,6}/i.test(color)){
+ throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
+ }
+ this._readWhitespace();
+ }
+
+ return token;
+ },
+
+ //-----------------------------------------------------------------
+ // Animations methods
+ //-----------------------------------------------------------------
+
+ _keyframes: function(){
+
+ /*
+ * keyframes:
+ * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ token,
+ tt,
+ name,
+ prefix = "";
+
+ tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
+ token = tokenStream.token();
+ if (/^@\-([^\-]+)\-/.test(token.value)) {
+ prefix = RegExp.$1;
+ }
+
+ this._readWhitespace();
+ name = this._keyframe_name();
+
+ this._readWhitespace();
+ tokenStream.mustMatch(Tokens.LBRACE);
+
+ this.fire({
+ type: "startkeyframes",
+ name: name,
+ prefix: prefix,
+ line: token.startLine,
+ col: token.startCol
+ });
+
+ this._readWhitespace();
+ tt = tokenStream.peek();
+
+ //check for key
+ while(tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
+ this._keyframe_rule();
+ this._readWhitespace();
+ tt = tokenStream.peek();
+ }
+
+ this.fire({
+ type: "endkeyframes",
+ name: name,
+ prefix: prefix,
+ line: token.startLine,
+ col: token.startCol
+ });
+
+ this._readWhitespace();
+ tokenStream.mustMatch(Tokens.RBRACE);
+
+ },
+
+ _keyframe_name: function(){
+
+ /*
+ * keyframe_name:
+ * : IDENT
+ * | STRING
+ * ;
+ */
+ var tokenStream = this._tokenStream;
+
+ tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
+ return SyntaxUnit.fromToken(tokenStream.token());
+ },
+
+ _keyframe_rule: function(){
+
+ /*
+ * keyframe_rule:
+ * : key_list S*
+ * '{' S* declaration [ ';' S* declaration ]* '}' S*
+ * ;
+ */
+ var keyList = this._key_list();
+
+ this.fire({
+ type: "startkeyframerule",
+ keys: keyList,
+ line: keyList[0].line,
+ col: keyList[0].col
+ });
+
+ this._readDeclarations(true);
+
+ this.fire({
+ type: "endkeyframerule",
+ keys: keyList,
+ line: keyList[0].line,
+ col: keyList[0].col
+ });
+
+ },
+
+ _key_list: function(){
+
+ /*
+ * key_list:
+ * : key [ S* ',' S* key]*
+ * ;
+ */
+ var tokenStream = this._tokenStream,
+ keyList = [];
+
+ //must be least one key
+ keyList.push(this._key());
+
+ this._readWhitespace();
+
+ while(tokenStream.match(Tokens.COMMA)){
+ this._readWhitespace();
+ keyList.push(this._key());
+ this._readWhitespace();
+ }
+
+ return keyList;
+ },
+
+ _key: function(){
+ /*
+ * There is a restriction that IDENT can be only "from" or "to".
+ *
+ * key
+ * : PERCENTAGE
+ * | IDENT
+ * ;
+ */
+
+ var tokenStream = this._tokenStream,
+ token;
+
+ if (tokenStream.match(Tokens.PERCENTAGE)){
+ return SyntaxUnit.fromToken(tokenStream.token());
+ } else if (tokenStream.match(Tokens.IDENT)){
+ token = tokenStream.token();
+
+ if (/from|to/i.test(token.value)){
+ return SyntaxUnit.fromToken(token);
+ }
+
+ tokenStream.unget();
+ }
+
+ //if it gets here, there wasn't a valid token, so time to explode
+ this._unexpectedToken(tokenStream.LT(1));
+ },
+
+ //-----------------------------------------------------------------
+ // Helper methods
+ //-----------------------------------------------------------------
+
+ /**
+ * Not part of CSS grammar, but useful for skipping over
+ * combination of white space and HTML-style comments.
+ * @return {void}
+ * @method _skipCruft
+ * @private
+ */
+ _skipCruft: function(){
+ while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){
+ //noop
+ }
+ },
+
+ /**
+ * Not part of CSS grammar, but this pattern occurs frequently
+ * in the official CSS grammar. Split out here to eliminate
+ * duplicate code.
+ * @param {Boolean} checkStart Indicates if the rule should check
+ * for the left brace at the beginning.
+ * @param {Boolean} readMargins Indicates if the rule should check
+ * for margin patterns.
+ * @return {void}
+ * @method _readDeclarations
+ * @private
+ */
+ _readDeclarations: function(checkStart, readMargins){
+ /*
+ * Reads the pattern
+ * S* '{' S* declaration [ ';' S* declaration ]* '}' S*
+ * or
+ * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
+ * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
+ * A semicolon is only necessary following a declaration if there's another declaration
+ * or margin afterwards.
+ */
+ var tokenStream = this._tokenStream,
+ tt;
+
+
+ this._readWhitespace();
+
+ if (checkStart){
+ tokenStream.mustMatch(Tokens.LBRACE);
+ }
+
+ this._readWhitespace();
+
+ try {
+
+ while(true){
+ if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
+ //noop
+ } else if (this._declaration()){
+ if (!tokenStream.match(Tokens.SEMICOLON)){
+ break;
+ }
+ } else {
+ break;
+ }
+
+
+ //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
+ // break;
+ //}
+ this._readWhitespace();
+ }
+
+ tokenStream.mustMatch(Tokens.RBRACE);
+ this._readWhitespace();
+
+ } catch (ex) {
+ if (ex instanceof SyntaxError && !this.options.strict){
+
+ //fire error event
+ this.fire({
+ type: "error",
+ error: ex,
+ message: ex.message,
+ line: ex.line,
+ col: ex.col
+ });
+
+ //see if there's another declaration
+ tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
+ if (tt === Tokens.SEMICOLON){
+ //if there's a semicolon, then there might be another declaration
+ this._readDeclarations(false, readMargins);
+ } else if (tt !== Tokens.RBRACE){
+ //if there's a right brace, the rule is finished so don't do anything
+ //otherwise, rethrow the error because it wasn't handled properly
+ throw ex;
+ }
+
+ } else {
+ //not a syntax error, rethrow it
+ throw ex;
+ }
+ }
+
+ },
+
+ /**
+ * In some cases, you can end up with two white space tokens in a
+ * row. Instead of making a change in every function that looks for
+ * white space, this function is used to match as much white space
+ * as necessary.
+ * @method _readWhitespace
+ * @return {String} The white space if found, empty string if not.
+ * @private
+ */
+ _readWhitespace: function(){
+
+ var tokenStream = this._tokenStream,
+ ws = "";
+
+ while(tokenStream.match(Tokens.S)){
+ ws += tokenStream.token().value;
+ }
+
+ return ws;
+ },
+
+
+ /**
+ * Throws an error when an unexpected token is found.
+ * @param {Object} token The token that was found.
+ * @method _unexpectedToken
+ * @return {void}
+ * @private
+ */
+ _unexpectedToken: function(token){
+ throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
+ },
+
+ /**
+ * Helper method used for parsing subparts of a style sheet.
+ * @return {void}
+ * @method _verifyEnd
+ * @private
+ */
+ _verifyEnd: function(){
+ if (this._tokenStream.LA(1) !== Tokens.EOF){
+ this._unexpectedToken(this._tokenStream.LT(1));
+ }
+ },
+
+ //-----------------------------------------------------------------
+ // Validation methods
+ //-----------------------------------------------------------------
+ _validateProperty: function(property, value){
+ Validation.validate(property, value);
+ },
+
+ //-----------------------------------------------------------------
+ // Parsing methods
+ //-----------------------------------------------------------------
+
+ parse: function(input){
+ this._tokenStream = new TokenStream(input, Tokens);
+ this._stylesheet();
+ },
+
+ parseStyleSheet: function(input){
+ //just passthrough
+ return this.parse(input);
+ },
+
+ parseMediaQuery: function(input){
+ this._tokenStream = new TokenStream(input, Tokens);
+ var result = this._media_query();
+
+ //if there's anything more, then it's an invalid selector
+ this._verifyEnd();
+
+ //otherwise return result
+ return result;
+ },
+
+ /**
+ * Parses a property value (everything after the semicolon).
+ * @return {parserlib.css.PropertyValue} The property value.
+ * @throws parserlib.util.SyntaxError If an unexpected token is found.
+ * @method parserPropertyValue
+ */
+ parsePropertyValue: function(input){
+
+ this._tokenStream = new TokenStream(input, Tokens);
+ this._readWhitespace();
+
+ var result = this._expr();
+
+ //okay to have a trailing white space
+ this._readWhitespace();
+
+ //if there's anything more, then it's an invalid selector
+ this._verifyEnd();
+
+ //otherwise return result
+ return result;
+ },
+
+ /**
+ * Parses a complete CSS rule, including selectors and
+ * properties.
+ * @param {String} input The text to parser.
+ * @return {Boolean} True if the parse completed successfully, false if not.
+ * @method parseRule
+ */
+ parseRule: function(input){
+ this._tokenStream = new TokenStream(input, Tokens);
+
+ //skip any leading white space
+ this._readWhitespace();
+
+ var result = this._ruleset();
+
+ //skip any trailing white space
+ this._readWhitespace();
+
+ //if there's anything more, then it's an invalid selector
+ this._verifyEnd();
+
+ //otherwise return result
+ return result;
+ },
+
+ /**
+ * Parses a single CSS selector (no comma)
+ * @param {String} input The text to parse as a CSS selector.
+ * @return {Selector} An object representing the selector.
+ * @throws parserlib.util.SyntaxError If an unexpected token is found.
+ * @method parseSelector
+ */
+ parseSelector: function(input){
+
+ this._tokenStream = new TokenStream(input, Tokens);
+
+ //skip any leading white space
+ this._readWhitespace();
+
+ var result = this._selector();
+
+ //skip any trailing white space
+ this._readWhitespace();
+
+ //if there's anything more, then it's an invalid selector
+ this._verifyEnd();
+
+ //otherwise return result
+ return result;
+ },
+
+ /**
+ * Parses an HTML style attribute: a set of CSS declarations
+ * separated by semicolons.
+ * @param {String} input The text to parse as a style attribute
+ * @return {void}
+ * @method parseStyleAttribute
+ */
+ parseStyleAttribute: function(input){
+ input += "}"; // for error recovery in _readDeclarations()
+ this._tokenStream = new TokenStream(input, Tokens);
+ this._readDeclarations();
+ }
+ };
+
+ //copy over onto prototype
+ for (prop in additions){
+ if (Object.prototype.hasOwnProperty.call(additions, prop)){
+ proto[prop] = additions[prop];
+ }
+ }
+
+ return proto;
+}();
+
+
+/*
+nth
+ : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
+ ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
+ ;
+*/
+var Properties = {
+ __proto__: null,
+
+ //A
+ "align-items" : "flex-start | flex-end | center | baseline | stretch",
+ "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
+ "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
+ "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
+ "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
+ "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
+ "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
+ "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
+ "animation" : 1,
+ "animation-delay" : { multi: "<time>", comma: true },
+ "animation-direction" : { multi: "normal | alternate", comma: true },
+ "animation-duration" : { multi: "<time>", comma: true },
+ "animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
+ "animation-iteration-count" : { multi: "<number> | infinite", comma: true },
+ "animation-name" : { multi: "none | <ident>", comma: true },
+ "animation-play-state" : { multi: "running | paused", comma: true },
+ "animation-timing-function" : 1,
+
+ //vendor prefixed
+ "-moz-animation-delay" : { multi: "<time>", comma: true },
+ "-moz-animation-direction" : { multi: "normal | alternate", comma: true },
+ "-moz-animation-duration" : { multi: "<time>", comma: true },
+ "-moz-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
+ "-moz-animation-name" : { multi: "none | <ident>", comma: true },
+ "-moz-animation-play-state" : { multi: "running | paused", comma: true },
+
+ "-ms-animation-delay" : { multi: "<time>", comma: true },
+ "-ms-animation-direction" : { multi: "normal | alternate", comma: true },
+ "-ms-animation-duration" : { multi: "<time>", comma: true },
+ "-ms-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
+ "-ms-animation-name" : { multi: "none | <ident>", comma: true },
+ "-ms-animation-play-state" : { multi: "running | paused", comma: true },
+
+ "-webkit-animation-delay" : { multi: "<time>", comma: true },
+ "-webkit-animation-direction" : { multi: "normal | alternate", comma: true },
+ "-webkit-animation-duration" : { multi: "<time>", comma: true },
+ "-webkit-animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
+ "-webkit-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
+ "-webkit-animation-name" : { multi: "none | <ident>", comma: true },
+ "-webkit-animation-play-state" : { multi: "running | paused", comma: true },
+
+ "-o-animation-delay" : { multi: "<time>", comma: true },
+ "-o-animation-direction" : { multi: "normal | alternate", comma: true },
+ "-o-animation-duration" : { multi: "<time>", comma: true },
+ "-o-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
+ "-o-animation-name" : { multi: "none | <ident>", comma: true },
+ "-o-animation-play-state" : { multi: "running | paused", comma: true },
+
+ "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",
+ "azimuth" : function (expression) {
+ var simple = "<angle> | leftwards | rightwards | inherit",
+ direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",
+ behind = false,
+ valid = false,
+ part;
+
+ if (!ValidationTypes.isAny(expression, simple)) {
+ if (ValidationTypes.isAny(expression, "behind")) {
+ behind = true;
+ valid = true;
+ }
+
+ if (ValidationTypes.isAny(expression, direction)) {
+ valid = true;
+ if (!behind) {
+ ValidationTypes.isAny(expression, "behind");
+ }
+ }
+ }
+
+ if (expression.hasNext()) {
+ part = expression.next();
+ if (valid) {
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected (<'azimuth'>) but found '" + part + "'.", part.line, part.col);
+ }
+ }
+ },
+
+ //B
+ "backface-visibility" : "visible | hidden",
+ "background" : 1,
+ "background-attachment" : { multi: "<attachment>", comma: true },
+ "background-clip" : { multi: "<box>", comma: true },
+ "background-color" : "<color> | inherit",
+ "background-image" : { multi: "<bg-image>", comma: true },
+ "background-origin" : { multi: "<box>", comma: true },
+ "background-position" : { multi: "<bg-position>", comma: true },
+ "background-repeat" : { multi: "<repeat-style>" },
+ "background-size" : { multi: "<bg-size>", comma: true },
+ "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
+ "behavior" : 1,
+ "binding" : 1,
+ "bleed" : "<length>",
+ "bookmark-label" : "<content> | <attr> | <string>",
+ "bookmark-level" : "none | <integer>",
+ "bookmark-state" : "open | closed",
+ "bookmark-target" : "none | <uri> | <attr>",
+ "border" : "<border-width> || <border-style> || <color>",
+ "border-bottom" : "<border-width> || <border-style> || <color>",
+ "border-bottom-color" : "<color> | inherit",
+ "border-bottom-left-radius" : "<x-one-radius>",
+ "border-bottom-right-radius" : "<x-one-radius>",
+ "border-bottom-style" : "<border-style>",
+ "border-bottom-width" : "<border-width>",
+ "border-collapse" : "collapse | separate | inherit",
+ "border-color" : { multi: "<color> | inherit", max: 4 },
+ "border-image" : 1,
+ "border-image-outset" : { multi: "<length> | <number>", max: 4 },
+ "border-image-repeat" : { multi: "stretch | repeat | round", max: 2 },
+ "border-image-slice" : function(expression) {
+
+ var valid = false,
+ numeric = "<number> | <percentage>",
+ fill = false,
+ count = 0,
+ max = 4,
+ part;
+
+ if (ValidationTypes.isAny(expression, "fill")) {
+ fill = true;
+ valid = true;
+ }
+
+ while (expression.hasNext() && count < max) {
+ valid = ValidationTypes.isAny(expression, numeric);
+ if (!valid) {
+ break;
+ }
+ count++;
+ }
+
+
+ if (!fill) {
+ ValidationTypes.isAny(expression, "fill");
+ } else {
+ valid = true;
+ }
+
+ if (expression.hasNext()) {
+ part = expression.next();
+ if (valid) {
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '" + part + "'.", part.line, part.col);
+ }
+ }
+ },
+ "border-image-source" : "<image> | none",
+ "border-image-width" : { multi: "<length> | <percentage> | <number> | auto", max: 4 },
+ "border-left" : "<border-width> || <border-style> || <color>",
+ "border-left-color" : "<color> | inherit",
+ "border-left-style" : "<border-style>",
+ "border-left-width" : "<border-width>",
+ "border-radius" : function(expression) {
+
+ var valid = false,
+ simple = "<length> | <percentage> | inherit",
+ slash = false,
+ count = 0,
+ max = 8,
+ part;
+
+ while (expression.hasNext() && count < max) {
+ valid = ValidationTypes.isAny(expression, simple);
+ if (!valid) {
+
+ if (String(expression.peek()) === "/" && count > 0 && !slash) {
+ slash = true;
+ max = count + 5;
+ expression.next();
+ } else {
+ break;
+ }
+ }
+ count++;
+ }
+
+ if (expression.hasNext()) {
+ part = expression.next();
+ if (valid) {
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected (<'border-radius'>) but found '" + part + "'.", part.line, part.col);
+ }
+ }
+ },
+ "border-right" : "<border-width> || <border-style> || <color>",
+ "border-right-color" : "<color> | inherit",
+ "border-right-style" : "<border-style>",
+ "border-right-width" : "<border-width>",
+ "border-spacing" : { multi: "<length> | inherit", max: 2 },
+ "border-style" : { multi: "<border-style>", max: 4 },
+ "border-top" : "<border-width> || <border-style> || <color>",
+ "border-top-color" : "<color> | inherit",
+ "border-top-left-radius" : "<x-one-radius>",
+ "border-top-right-radius" : "<x-one-radius>",
+ "border-top-style" : "<border-style>",
+ "border-top-width" : "<border-width>",
+ "border-width" : { multi: "<border-width>", max: 4 },
+ "bottom" : "<margin-width> | inherit",
+ "-moz-box-align" : "start | end | center | baseline | stretch",
+ "-moz-box-decoration-break" : "slice |clone",
+ "-moz-box-direction" : "normal | reverse | inherit",
+ "-moz-box-flex" : "<number>",
+ "-moz-box-flex-group" : "<integer>",
+ "-moz-box-lines" : "single | multiple",
+ "-moz-box-ordinal-group" : "<integer>",
+ "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
+ "-moz-box-pack" : "start | end | center | justify",
+ "-o-box-decoration-break" : "slice | clone",
+ "-webkit-box-align" : "start | end | center | baseline | stretch",
+ "-webkit-box-decoration-break" : "slice |clone",
+ "-webkit-box-direction" : "normal | reverse | inherit",
+ "-webkit-box-flex" : "<number>",
+ "-webkit-box-flex-group" : "<integer>",
+ "-webkit-box-lines" : "single | multiple",
+ "-webkit-box-ordinal-group" : "<integer>",
+ "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
+ "-webkit-box-pack" : "start | end | center | justify",
+ "box-decoration-break" : "slice | clone",
+ "box-shadow" : function (expression) {
+ var part;
+
+ if (!ValidationTypes.isAny(expression, "none")) {
+ Validation.multiProperty("<shadow>", expression, true, Infinity);
+ } else {
+ if (expression.hasNext()) {
+ part = expression.next();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ }
+ }
+ },
+ "box-sizing" : "content-box | border-box | inherit",
+ "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
+ "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
+ "break-inside" : "auto | avoid | avoid-page | avoid-column",
+
+ //C
+ "caption-side" : "top | bottom | inherit",
+ "clear" : "none | right | left | both | inherit",
+ "clip" : 1,
+ "color" : "<color> | inherit",
+ "color-profile" : 1,
+ "column-count" : "<integer> | auto", //http://www.w3.org/TR/css3-multicol/
+ "column-fill" : "auto | balance",
+ "column-gap" : "<length> | normal",
+ "column-rule" : "<border-width> || <border-style> || <color>",
+ "column-rule-color" : "<color>",
+ "column-rule-style" : "<border-style>",
+ "column-rule-width" : "<border-width>",
+ "column-span" : "none | all",
+ "column-width" : "<length> | auto",
+ "columns" : 1,
+ "content" : 1,
+ "counter-increment" : 1,
+ "counter-reset" : 1,
+ "crop" : "<shape> | auto",
+ "cue" : "cue-after | cue-before | inherit",
+ "cue-after" : 1,
+ "cue-before" : 1,
+ "cursor" : 1,
+
+ //D
+ "direction" : "ltr | rtl | inherit",
+ "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
+ "dominant-baseline" : 1,
+ "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
+ "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
+ "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
+ "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
+ "drop-initial-size" : "auto | line | <length> | <percentage>",
+ "drop-initial-value" : "initial | <integer>",
+
+ //E
+ "elevation" : "<angle> | below | level | above | higher | lower | inherit",
+ "empty-cells" : "show | hide | inherit",
+
+ //F
+ "filter" : 1,
+ "fit" : "fill | hidden | meet | slice",
+ "fit-position" : 1,
+ "flex" : "<flex>",
+ "flex-basis" : "<width>",
+ "flex-direction" : "row | row-reverse | column | column-reverse",
+ "flex-flow" : "<flex-direction> || <flex-wrap>",
+ "flex-grow" : "<number>",
+ "flex-shrink" : "<number>",
+ "flex-wrap" : "nowrap | wrap | wrap-reverse",
+ "-webkit-flex" : "<flex>",
+ "-webkit-flex-basis" : "<width>",
+ "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
+ "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
+ "-webkit-flex-grow" : "<number>",
+ "-webkit-flex-shrink" : "<number>",
+ "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
+ "-ms-flex" : "<flex>",
+ "-ms-flex-align" : "start | end | center | stretch | baseline",
+ "-ms-flex-direction" : "row | row-reverse | column | column-reverse | inherit",
+ "-ms-flex-order" : "<number>",
+ "-ms-flex-pack" : "start | end | center | justify",
+ "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
+ "float" : "left | right | none | inherit",
+ "float-offset" : 1,
+ "font" : 1,
+ "font-family" : 1,
+ "font-feature-settings" : "<feature-tag-value> | normal | inherit",
+ "font-kerning" : "auto | normal | none | initial | inherit | unset",
+ "font-size" : "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
+ "font-size-adjust" : "<number> | none | inherit",
+ "font-stretch" : "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
+ "font-style" : "normal | italic | oblique | inherit",
+ "font-variant" : "normal | small-caps | inherit",
+ "font-variant-caps" : "normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps",
+ "font-variant-position" : "normal | sub | super | inherit | initial | unset",
+ "font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
+
+ //G
+ "grid" : 1,
+ "grid-area" : 1,
+ "grid-auto-columns" : 1,
+ "grid-auto-flow" : 1,
+ "grid-auto-position" : 1,
+ "grid-auto-rows" : 1,
+ "grid-cell-stacking" : "columns | rows | layer",
+ "grid-column" : 1,
+ "grid-columns" : 1,
+ "grid-column-align" : "start | end | center | stretch",
+ "grid-column-sizing" : 1,
+ "grid-column-start" : 1,
+ "grid-column-end" : 1,
+ "grid-column-span" : "<integer>",
+ "grid-flow" : "none | rows | columns",
+ "grid-layer" : "<integer>",
+ "grid-row" : 1,
+ "grid-rows" : 1,
+ "grid-row-align" : "start | end | center | stretch",
+ "grid-row-start" : 1,
+ "grid-row-end" : 1,
+ "grid-row-span" : "<integer>",
+ "grid-row-sizing" : 1,
+ "grid-template" : 1,
+ "grid-template-areas" : 1,
+ "grid-template-columns" : 1,
+ "grid-template-rows" : 1,
+
+ //H
+ "hanging-punctuation" : 1,
+ "height" : "<margin-width> | <content-sizing> | inherit",
+ "hyphenate-after" : "<integer> | auto",
+ "hyphenate-before" : "<integer> | auto",
+ "hyphenate-character" : "<string> | auto",
+ "hyphenate-lines" : "no-limit | <integer>",
+ "hyphenate-resource" : 1,
+ "hyphens" : "none | manual | auto",
+
+ //I
+ "icon" : 1,
+ "image-orientation" : "angle | auto",
+ "image-rendering" : 1,
+ "image-resolution" : 1,
+ "ime-mode" : "auto | normal | active | inactive | disabled | inherit",
+ "inline-box-align" : "initial | last | <integer>",
+
+ //J
+ "justify-content" : "flex-start | flex-end | center | space-between | space-around",
+ "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around",
+
+ //L
+ "left" : "<margin-width> | inherit",
+ "letter-spacing" : "<length> | normal | inherit",
+ "line-height" : "<number> | <length> | <percentage> | normal | inherit",
+ "line-break" : "auto | loose | normal | strict",
+ "line-stacking" : 1,
+ "line-stacking-ruby" : "exclude-ruby | include-ruby",
+ "line-stacking-shift" : "consider-shifts | disregard-shifts",
+ "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
+ "list-style" : 1,
+ "list-style-image" : "<uri> | none | inherit",
+ "list-style-position" : "inside | outside | inherit",
+ "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",
+
+ //M
+ "margin" : { multi: "<margin-width> | inherit", max: 4 },
+ "margin-bottom" : "<margin-width> | inherit",
+ "margin-left" : "<margin-width> | inherit",
+ "margin-right" : "<margin-width> | inherit",
+ "margin-top" : "<margin-width> | inherit",
+ "mark" : 1,
+ "mark-after" : 1,
+ "mark-before" : 1,
+ "marks" : 1,
+ "marquee-direction" : 1,
+ "marquee-play-count" : 1,
+ "marquee-speed" : 1,
+ "marquee-style" : 1,
+ "max-height" : "<length> | <percentage> | <content-sizing> | none | inherit",
+ "max-width" : "<length> | <percentage> | <content-sizing> | none | inherit",
+ "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
+ "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
+ "move-to" : 1,
+
+ //N
+ "nav-down" : 1,
+ "nav-index" : 1,
+ "nav-left" : 1,
+ "nav-right" : 1,
+ "nav-up" : 1,
+
+ //O
+ "object-fit" : "fill | contain | cover | none | scale-down",
+ "object-position" : "<bg-position>",
+ "opacity" : "<number> | inherit",
+ "order" : "<integer>",
+ "-webkit-order" : "<integer>",
+ "orphans" : "<integer> | inherit",
+ "outline" : 1,
+ "outline-color" : "<color> | invert | inherit",
+ "outline-offset" : 1,
+ "outline-style" : "<border-style> | inherit",
+ "outline-width" : "<border-width> | inherit",
+ "overflow" : "visible | hidden | scroll | auto | inherit",
+ "overflow-style" : 1,
+ "overflow-wrap" : "normal | break-word",
+ "overflow-x" : 1,
+ "overflow-y" : 1,
+
+ //P
+ "padding" : { multi: "<padding-width> | inherit", max: 4 },
+ "padding-bottom" : "<padding-width> | inherit",
+ "padding-left" : "<padding-width> | inherit",
+ "padding-right" : "<padding-width> | inherit",
+ "padding-top" : "<padding-width> | inherit",
+ "page" : 1,
+ "page-break-after" : "auto | always | avoid | left | right | inherit",
+ "page-break-before" : "auto | always | avoid | left | right | inherit",
+ "page-break-inside" : "auto | avoid | inherit",
+ "page-policy" : 1,
+ "pause" : 1,
+ "pause-after" : 1,
+ "pause-before" : 1,
+ "perspective" : 1,
+ "perspective-origin" : 1,
+ "phonemes" : 1,
+ "pitch" : 1,
+ "pitch-range" : 1,
+ "play-during" : 1,
+ "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",
+ "position" : "static | relative | absolute | fixed | inherit",
+ "presentation-level" : 1,
+ "punctuation-trim" : 1,
+
+ //Q
+ "quotes" : 1,
+
+ //R
+ "rendering-intent" : 1,
+ "resize" : 1,
+ "rest" : 1,
+ "rest-after" : 1,
+ "rest-before" : 1,
+ "richness" : 1,
+ "right" : "<margin-width> | inherit",
+ "rotation" : 1,
+ "rotation-point" : 1,
+ "ruby-align" : 1,
+ "ruby-overhang" : 1,
+ "ruby-position" : 1,
+ "ruby-span" : 1,
+
+ //S
+ "size" : 1,
+ "speak" : "normal | none | spell-out | inherit",
+ "speak-header" : "once | always | inherit",
+ "speak-numeral" : "digits | continuous | inherit",
+ "speak-punctuation" : "code | none | inherit",
+ "speech-rate" : 1,
+ "src" : 1,
+ "stress" : 1,
+ "string-set" : 1,
+
+ "table-layout" : "auto | fixed | inherit",
+ "tab-size" : "<integer> | <length>",
+ "target" : 1,
+ "target-name" : 1,
+ "target-new" : 1,
+ "target-position" : 1,
+ "text-align" : "left | right | center | justify | match-parent | start | end | inherit" ,
+ "text-align-last" : 1,
+ "text-decoration" : 1,
+ "text-emphasis" : 1,
+ "text-height" : 1,
+ "text-indent" : "<length> | <percentage> | inherit",
+ "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
+ "text-outline" : 1,
+ "text-overflow" : 1,
+ "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
+ "text-shadow" : 1,
+ "text-transform" : "capitalize | uppercase | lowercase | none | inherit",
+ "text-wrap" : "normal | none | avoid",
+ "top" : "<margin-width> | inherit",
+ "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
+ "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
+ "transform" : 1,
+ "transform-origin" : 1,
+ "transform-style" : 1,
+ "transition" : 1,
+ "transition-delay" : 1,
+ "transition-duration" : 1,
+ "transition-property" : 1,
+ "transition-timing-function" : 1,
+
+ //U
+ "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext | inherit",
+ "user-modify" : "read-only | read-write | write-only | inherit",
+ "user-select" : "none | text | toggle | element | elements | all | inherit",
+
+ //V
+ "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> | inherit",
+ "visibility" : "visible | hidden | collapse | inherit",
+ "voice-balance" : 1,
+ "voice-duration" : 1,
+ "voice-family" : 1,
+ "voice-pitch" : 1,
+ "voice-pitch-range" : 1,
+ "voice-rate" : 1,
+ "voice-stress" : 1,
+ "voice-volume" : 1,
+ "volume" : 1,
+
+ //W
+ "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", //http://perishablepress.com/wrapping-content/
+ "white-space-collapse" : 1,
+ "widows" : "<integer> | inherit",
+ "width" : "<length> | <percentage> | <content-sizing> | auto | inherit",
+ "will-change" : { multi: "<ident>", comma: true },
+ "word-break" : "normal | keep-all | break-all",
+ "word-spacing" : "<length> | normal | inherit",
+ "word-wrap" : "normal | break-word",
+ "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb | inherit",
+
+ //Z
+ "z-index" : "<integer> | auto | inherit",
+ "zoom" : "<number> | <percentage> | normal"
+};
+/**
+ * Represents a selector combinator (whitespace, +, >).
+ * @namespace parserlib.css
+ * @class PropertyName
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {String} text The text representation of the unit.
+ * @param {String} hack The type of IE hack applied ("*", "_", or null).
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function PropertyName(text, hack, line, col){
+
+ SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
+
+ /**
+ * The type of IE hack applied ("*", "_", or null).
+ * @type String
+ * @property hack
+ */
+ this.hack = hack;
+
+}
+
+PropertyName.prototype = new SyntaxUnit();
+PropertyName.prototype.constructor = PropertyName;
+PropertyName.prototype.toString = function(){
+ return (this.hack ? this.hack : "") + this.text;
+};
+/**
+ * Represents a single part of a CSS property value, meaning that it represents
+ * just everything single part between ":" and ";". If there are multiple values
+ * separated by commas, this type represents just one of the values.
+ * @param {String[]} parts An array of value parts making up this value.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ * @namespace parserlib.css
+ * @class PropertyValue
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ */
+function PropertyValue(parts, line, col){
+
+ SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
+
+ /**
+ * The parts that make up the selector.
+ * @type Array
+ * @property parts
+ */
+ this.parts = parts;
+
+}
+
+PropertyValue.prototype = new SyntaxUnit();
+PropertyValue.prototype.constructor = PropertyValue;
+
+/**
+ * A utility class that allows for easy iteration over the various parts of a
+ * property value.
+ * @param {parserlib.css.PropertyValue} value The property value to iterate over.
+ * @namespace parserlib.css
+ * @class PropertyValueIterator
+ * @constructor
+ */
+function PropertyValueIterator(value){
+
+ /**
+ * Iterator value
+ * @type int
+ * @property _i
+ * @private
+ */
+ this._i = 0;
+
+ /**
+ * The parts that make up the value.
+ * @type Array
+ * @property _parts
+ * @private
+ */
+ this._parts = value.parts;
+
+ /**
+ * Keeps track of bookmarks along the way.
+ * @type Array
+ * @property _marks
+ * @private
+ */
+ this._marks = [];
+
+ /**
+ * Holds the original property value.
+ * @type parserlib.css.PropertyValue
+ * @property value
+ */
+ this.value = value;
+
+}
+
+/**
+ * Returns the total number of parts in the value.
+ * @return {int} The total number of parts in the value.
+ * @method count
+ */
+PropertyValueIterator.prototype.count = function(){
+ return this._parts.length;
+};
+
+/**
+ * Indicates if the iterator is positioned at the first item.
+ * @return {Boolean} True if positioned at first item, false if not.
+ * @method isFirst
+ */
+PropertyValueIterator.prototype.isFirst = function(){
+ return this._i === 0;
+};
+
+/**
+ * Indicates if there are more parts of the property value.
+ * @return {Boolean} True if there are more parts, false if not.
+ * @method hasNext
+ */
+PropertyValueIterator.prototype.hasNext = function(){
+ return (this._i < this._parts.length);
+};
+
+/**
+ * Marks the current spot in the iteration so it can be restored to
+ * later on.
+ * @return {void}
+ * @method mark
+ */
+PropertyValueIterator.prototype.mark = function(){
+ this._marks.push(this._i);
+};
+
+/**
+ * Returns the next part of the property value or null if there is no next
+ * part. Does not move the internal counter forward.
+ * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
+ * part.
+ * @method peek
+ */
+PropertyValueIterator.prototype.peek = function(count){
+ return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
+};
+
+/**
+ * Returns the next part of the property value or null if there is no next
+ * part.
+ * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
+ * part.
+ * @method next
+ */
+PropertyValueIterator.prototype.next = function(){
+ return this.hasNext() ? this._parts[this._i++] : null;
+};
+
+/**
+ * Returns the previous part of the property value or null if there is no
+ * previous part.
+ * @return {parserlib.css.PropertyValuePart} The previous part of the
+ * property value or null if there is no previous part.
+ * @method previous
+ */
+PropertyValueIterator.prototype.previous = function(){
+ return this._i > 0 ? this._parts[--this._i] : null;
+};
+
+/**
+ * Restores the last saved bookmark.
+ * @return {void}
+ * @method restore
+ */
+PropertyValueIterator.prototype.restore = function(){
+ if (this._marks.length){
+ this._i = this._marks.pop();
+ }
+};
+
+/**
+ * Represents a single part of a CSS property value, meaning that it represents
+ * just one part of the data between ":" and ";".
+ * @param {String} text The text representation of the unit.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ * @namespace parserlib.css
+ * @class PropertyValuePart
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ */
+function PropertyValuePart(text, line, col){
+ SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
+
+ /**
+ * Indicates the type of value unit.
+ * @type String
+ * @property type
+ */
+ this.type = "unknown";
+
+ //figure out what type of data it is
+
+ var temp;
+ //it is a measurement?
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Propertiesa
+ var match;
+ if (match = /^([+\-]?[\d\.]+)([a-z]+)$/i.exec(text)){ //dimension
+ this.type = "dimension";
+ this.value = +match[1];
+ this.units = match[2];
+
+ //try to narrow down
+ switch(this.units.toLowerCase()){
+
+ case "em":
+ case "rem":
+ case "ex":
+ case "px":
+ case "cm":
+ case "mm":
+ case "in":
+ case "pt":
+ case "pc":
+ case "ch":
+ case "vh":
+ case "vw":
+ case "vmax":
+ case "vmin":
+ this.type = "length";
+ break;
+
+ case "fr":
+ this.type = "grid";
+ break;
+
+ case "deg":
+ case "rad":
+ case "grad":
+ this.type = "angle";
+ break;
+
+ case "ms":
+ case "s":
+ this.type = "time";
+ break;
+
+ case "hz":
+ case "khz":
+ this.type = "frequency";
+ break;
+
+ case "dpi":
+ case "dpcm":
+ this.type = "resolution";
+ break;
+
+ //default
+
+ }
+
+ } else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
+ this.type = "percentage";
+ this.value = +RegExp.$1;
+ } else if (/^([+\-]?\d+)$/i.test(text)){ //integer
+ this.type = "integer";
+ this.value = +RegExp.$1;
+ } else if (/^([+\-]?[\d\.]+)$/i.test(text)){ //number
+ this.type = "number";
+ this.value = +RegExp.$1;
+
+ } else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
+ this.type = "color";
+ temp = RegExp.$1;
+ if (temp.length === 3){
+ this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
+ this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
+ this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);
+ } else {
+ this.red = parseInt(temp.substring(0,2),16);
+ this.green = parseInt(temp.substring(2,4),16);
+ this.blue = parseInt(temp.substring(4,6),16);
+ }
+ } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){ //rgb() color with absolute numbers
+ this.type = "color";
+ this.red = +RegExp.$1;
+ this.green = +RegExp.$2;
+ this.blue = +RegExp.$3;
+ } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //rgb() color with percentages
+ this.type = "color";
+ this.red = +RegExp.$1 * 255 / 100;
+ this.green = +RegExp.$2 * 255 / 100;
+ this.blue = +RegExp.$3 * 255 / 100;
+ } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with absolute numbers
+ this.type = "color";
+ this.red = +RegExp.$1;
+ this.green = +RegExp.$2;
+ this.blue = +RegExp.$3;
+ this.alpha = +RegExp.$4;
+ } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with percentages
+ this.type = "color";
+ this.red = +RegExp.$1 * 255 / 100;
+ this.green = +RegExp.$2 * 255 / 100;
+ this.blue = +RegExp.$3 * 255 / 100;
+ this.alpha = +RegExp.$4;
+ } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //hsl()
+ this.type = "color";
+ this.hue = +RegExp.$1;
+ this.saturation = +RegExp.$2 / 100;
+ this.lightness = +RegExp.$3 / 100;
+ } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //hsla() color with percentages
+ this.type = "color";
+ this.hue = +RegExp.$1;
+ this.saturation = +RegExp.$2 / 100;
+ this.lightness = +RegExp.$3 / 100;
+ this.alpha = +RegExp.$4;
+ } else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)){ //URI
+ this.type = "uri";
+ this.uri = RegExp.$1;
+ } else if (/^([^\(]+)\(/i.test(text)){
+ this.type = "function";
+ this.name = RegExp.$1;
+ this.value = text;
+ } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)){ //double-quoted string
+ this.type = "string";
+ this.value = PropertyValuePart.parseString(text);
+ } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)){ //single-quoted string
+ this.type = "string";
+ this.value = PropertyValuePart.parseString(text);
+ } else if (Colors[text.toLowerCase()]){ //named color
+ this.type = "color";
+ temp = Colors[text.toLowerCase()].substring(1);
+ this.red = parseInt(temp.substring(0,2),16);
+ this.green = parseInt(temp.substring(2,4),16);
+ this.blue = parseInt(temp.substring(4,6),16);
+ } else if (/^[\,\/]$/.test(text)){
+ this.type = "operator";
+ this.value = text;
+ } else if (/^[a-z\-_\u0080-\uFFFF][a-z0-9\-_\u0080-\uFFFF]*$/i.test(text)){
+ this.type = "identifier";
+ this.value = text;
+ }
+
+}
+
+PropertyValuePart.prototype = new SyntaxUnit();
+PropertyValuePart.prototype.constructor = PropertyValuePart;
+
+/**
+ * Helper method to parse a CSS string.
+ */
+PropertyValuePart.parseString = function(str) {
+ str = str.slice(1, -1); // Strip surrounding single/double quotes
+ var replacer = function(match, esc) {
+ if (/^(\n|\r\n|\r|\f)$/.test(esc)) { return ''; }
+ var m = /^[0-9a-f]{1,6}/i.exec(esc);
+ if (m) {
+ var codePoint = parseInt(m[0], 16);
+ if (String.fromCodePoint) {
+ return String.fromCodePoint(codePoint);
+ } else {
+ // XXX No support for surrogates on old JavaScript engines.
+ return String.fromCharCode(codePoint);
+ }
+ }
+ return esc;
+ };
+ return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
+ replacer);
+};
+
+/**
+ * Helper method to serialize a CSS string.
+ */
+PropertyValuePart.serializeString = function(value) {
+ var replacer = function(match, c) {
+ if (c === '"') {
+ return "\\" + c;
+ }
+ var cp = String.codePointAt ? String.codePointAt(0) :
+ // We only escape non-surrogate chars, so using charCodeAt
+ // is harmless here.
+ String.charCodeAt(0);
+ return "\\" + cp.toString(16) + " ";
+ };
+ return '"' + value.replace(/["\r\n\f]/g, replacer) + '"';
+};
+
+/**
+ * Create a new syntax unit based solely on the given token.
+ * Convenience method for creating a new syntax unit when
+ * it represents a single token instead of multiple.
+ * @param {Object} token The token object to represent.
+ * @return {parserlib.css.PropertyValuePart} The object representing the token.
+ * @static
+ * @method fromToken
+ */
+PropertyValuePart.fromToken = function(token){
+ return new PropertyValuePart(token.value, token.startLine, token.startCol);
+};
+var Pseudos = {
+ __proto__: null,
+ ":first-letter": 1,
+ ":first-line": 1,
+ ":before": 1,
+ ":after": 1
+};
+
+Pseudos.ELEMENT = 1;
+Pseudos.CLASS = 2;
+
+Pseudos.isElement = function(pseudo){
+ return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
+};
+/**
+ * Represents an entire single selector, including all parts but not
+ * including multiple selectors (those separated by commas).
+ * @namespace parserlib.css
+ * @class Selector
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {Array} parts Array of selectors parts making up this selector.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function Selector(parts, line, col){
+
+ SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
+
+ /**
+ * The parts that make up the selector.
+ * @type Array
+ * @property parts
+ */
+ this.parts = parts;
+
+ /**
+ * The specificity of the selector.
+ * @type parserlib.css.Specificity
+ * @property specificity
+ */
+ this.specificity = Specificity.calculate(this);
+
+}
+
+Selector.prototype = new SyntaxUnit();
+Selector.prototype.constructor = Selector;
+
+/**
+ * Represents a single part of a selector string, meaning a single set of
+ * element name and modifiers. This does not include combinators such as
+ * spaces, +, >, etc.
+ * @namespace parserlib.css
+ * @class SelectorPart
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {String} elementName The element name in the selector or null
+ * if there is no element name.
+ * @param {Array} modifiers Array of individual modifiers for the element.
+ * May be empty if there are none.
+ * @param {String} text The text representation of the unit.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function SelectorPart(elementName, modifiers, text, line, col){
+
+ SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
+
+ /**
+ * The tag name of the element to which this part
+ * of the selector affects.
+ * @type String
+ * @property elementName
+ */
+ this.elementName = elementName;
+
+ /**
+ * The parts that come after the element name, such as class names, IDs,
+ * pseudo classes/elements, etc.
+ * @type Array
+ * @property modifiers
+ */
+ this.modifiers = modifiers;
+
+}
+
+SelectorPart.prototype = new SyntaxUnit();
+SelectorPart.prototype.constructor = SelectorPart;
+
+/**
+ * Represents a selector modifier string, meaning a class name, element name,
+ * element ID, pseudo rule, etc.
+ * @namespace parserlib.css
+ * @class SelectorSubPart
+ * @extends parserlib.util.SyntaxUnit
+ * @constructor
+ * @param {String} text The text representation of the unit.
+ * @param {String} type The type of selector modifier.
+ * @param {int} line The line of text on which the unit resides.
+ * @param {int} col The column of text on which the unit resides.
+ */
+function SelectorSubPart(text, type, line, col){
+
+ SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
+
+ /**
+ * The type of modifier.
+ * @type String
+ * @property type
+ */
+ this.type = type;
+
+ /**
+ * Some subparts have arguments, this represents them.
+ * @type Array
+ * @property args
+ */
+ this.args = [];
+
+}
+
+SelectorSubPart.prototype = new SyntaxUnit();
+SelectorSubPart.prototype.constructor = SelectorSubPart;
+
+/**
+ * Represents a selector's specificity.
+ * @namespace parserlib.css
+ * @class Specificity
+ * @constructor
+ * @param {int} a Should be 1 for inline styles, zero for stylesheet styles
+ * @param {int} b Number of ID selectors
+ * @param {int} c Number of classes and pseudo classes
+ * @param {int} d Number of element names and pseudo elements
+ */
+function Specificity(a, b, c, d){
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ this.d = d;
+}
+
+Specificity.prototype = {
+ constructor: Specificity,
+
+ /**
+ * Compare this specificity to another.
+ * @param {Specificity} other The other specificity to compare to.
+ * @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
+ * @method compare
+ */
+ compare: function(other){
+ var comps = ["a", "b", "c", "d"],
+ i, len;
+
+ for (i=0, len=comps.length; i < len; i++){
+ if (this[comps[i]] < other[comps[i]]){
+ return -1;
+ } else if (this[comps[i]] > other[comps[i]]){
+ return 1;
+ }
+ }
+
+ return 0;
+ },
+
+ /**
+ * Creates a numeric value for the specificity.
+ * @return {int} The numeric value for the specificity.
+ * @method valueOf
+ */
+ valueOf: function(){
+ return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
+ },
+
+ /**
+ * Returns a string representation for specificity.
+ * @return {String} The string representation of specificity.
+ * @method toString
+ */
+ toString: function(){
+ return this.a + "," + this.b + "," + this.c + "," + this.d;
+ }
+
+};
+
+/**
+ * Calculates the specificity of the given selector.
+ * @param {parserlib.css.Selector} The selector to calculate specificity for.
+ * @return {parserlib.css.Specificity} The specificity of the selector.
+ * @static
+ * @method calculate
+ */
+Specificity.calculate = function(selector){
+
+ var i, len,
+ part,
+ b=0, c=0, d=0;
+
+ function updateValues(part){
+
+ var i, j, len, num,
+ elementName = part.elementName ? part.elementName.text : "",
+ modifier;
+
+ if (elementName && elementName.charAt(elementName.length-1) !== "*") {
+ d++;
+ }
+
+ for (i=0, len=part.modifiers.length; i < len; i++){
+ modifier = part.modifiers[i];
+ switch(modifier.type){
+ case "class":
+ case "attribute":
+ c++;
+ break;
+
+ case "id":
+ b++;
+ break;
+
+ case "pseudo":
+ if (Pseudos.isElement(modifier.text)){
+ d++;
+ } else {
+ c++;
+ }
+ break;
+
+ case "not":
+ for (j=0, num=modifier.args.length; j < num; j++){
+ updateValues(modifier.args[j]);
+ }
+ }
+ }
+ }
+
+ for (i=0, len=selector.parts.length; i < len; i++){
+ part = selector.parts[i];
+
+ if (part instanceof SelectorPart){
+ updateValues(part);
+ }
+ }
+
+ return new Specificity(0, b, c, d);
+};
+
+var h = /^[0-9a-fA-F]$/,
+ //nonascii = /^[\u0080-\uFFFF]$/,
+ nl = /\n|\r\n|\r|\f/;
+
+//-----------------------------------------------------------------------------
+// Helper functions
+//-----------------------------------------------------------------------------
+
+
+function isHexDigit(c){
+ return c !== null && h.test(c);
+}
+
+function isDigit(c){
+ return c !== null && /\d/.test(c);
+}
+
+function isWhitespace(c){
+ return c !== null && /\s/.test(c);
+}
+
+function isNewLine(c){
+ return c !== null && nl.test(c);
+}
+
+function isNameStart(c){
+ return c !== null && (/[a-z_\u0080-\uFFFF\\]/i.test(c));
+}
+
+function isNameChar(c){
+ return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
+}
+
+function isIdentStart(c){
+ return c !== null && (isNameStart(c) || /\-\\/.test(c));
+}
+
+function mix(receiver, supplier){
+ for (var prop in supplier){
+ if (Object.prototype.hasOwnProperty.call(supplier, prop)){
+ receiver[prop] = supplier[prop];
+ }
+ }
+ return receiver;
+}
+
+//-----------------------------------------------------------------------------
+// CSS Token Stream
+//-----------------------------------------------------------------------------
+
+
+/**
+ * A token stream that produces CSS tokens.
+ * @param {String|Reader} input The source of text to tokenize.
+ * @constructor
+ * @class TokenStream
+ * @namespace parserlib.css
+ */
+function TokenStream(input){
+ TokenStreamBase.call(this, input, Tokens);
+}
+
+TokenStream.prototype = mix(new TokenStreamBase(), {
+
+ /**
+ * Overrides the TokenStreamBase method of the same name
+ * to produce CSS tokens.
+ * @param {variant} channel The name of the channel to use
+ * for the next token.
+ * @return {Object} A token object representing the next token.
+ * @method _getToken
+ * @private
+ */
+ _getToken: function(channel){
+
+ var c,
+ reader = this._reader,
+ token = null,
+ startLine = reader.getLine(),
+ startCol = reader.getCol();
+
+ c = reader.read();
+
+
+ while(c){
+ switch(c){
+
+ /*
+ * Potential tokens:
+ * - COMMENT
+ * - SLASH
+ * - CHAR
+ */
+ case "/":
+
+ if(reader.peek() === "*"){
+ token = this.commentToken(c, startLine, startCol);
+ } else {
+ token = this.charToken(c, startLine, startCol);
+ }
+ break;
+
+ /*
+ * Potential tokens:
+ * - DASHMATCH
+ * - INCLUDES
+ * - PREFIXMATCH
+ * - SUFFIXMATCH
+ * - SUBSTRINGMATCH
+ * - CHAR
+ */
+ case "|":
+ case "~":
+ case "^":
+ case "$":
+ case "*":
+ if(reader.peek() === "="){
+ token = this.comparisonToken(c, startLine, startCol);
+ } else {
+ token = this.charToken(c, startLine, startCol);
+ }
+ break;
+
+ /*
+ * Potential tokens:
+ * - STRING
+ * - INVALID
+ */
+ case "\"":
+ case "'":
+ token = this.stringToken(c, startLine, startCol);
+ break;
+
+ /*
+ * Potential tokens:
+ * - HASH
+ * - CHAR
+ */
+ case "#":
+ if (isNameChar(reader.peek())){
+ token = this.hashToken(c, startLine, startCol);
+ } else {
+ token = this.charToken(c, startLine, startCol);
+ }
+ break;
+
+ /*
+ * Potential tokens:
+ * - DOT
+ * - NUMBER
+ * - DIMENSION
+ * - PERCENTAGE
+ */
+ case ".":
+ if (isDigit(reader.peek())){
+ token = this.numberToken(c, startLine, startCol);
+ } else {
+ token = this.charToken(c, startLine, startCol);
+ }
+ break;
+
+ /*
+ * Potential tokens:
+ * - CDC
+ * - MINUS
+ * - NUMBER
+ * - DIMENSION
+ * - PERCENTAGE
+ */
+ case "-":
+ if (reader.peek() === "-"){ //could be closing HTML-style comment
+ token = this.htmlCommentEndToken(c, startLine, startCol);
+ } else if (isNameStart(reader.peek())){
+ token = this.identOrFunctionToken(c, startLine, startCol);
+ } else {
+ token = this.charToken(c, startLine, startCol);
+ }
+ break;
+
+ /*
+ * Potential tokens:
+ * - IMPORTANT_SYM
+ * - CHAR
+ */
+ case "!":
+ token = this.importantToken(c, startLine, startCol);
+ break;
+
+ /*
+ * Any at-keyword or CHAR
+ */
+ case "@":
+ token = this.atRuleToken(c, startLine, startCol);
+ break;
+
+ /*
+ * Potential tokens:
+ * - NOT
+ * - CHAR
+ */
+ case ":":
+ token = this.notToken(c, startLine, startCol);
+ break;
+
+ /*
+ * Potential tokens:
+ * - CDO
+ * - CHAR
+ */
+ case "<":
+ token = this.htmlCommentStartToken(c, startLine, startCol);
+ break;
+
+ /*
+ * Potential tokens:
+ * - UNICODE_RANGE
+ * - URL
+ * - CHAR
+ */
+ case "U":
+ case "u":
+ if (reader.peek() === "+"){
+ token = this.unicodeRangeToken(c, startLine, startCol);
+ break;
+ }
+ /* falls through */
+ default:
+
+ /*
+ * Potential tokens:
+ * - NUMBER
+ * - DIMENSION
+ * - LENGTH
+ * - FREQ
+ * - TIME
+ * - EMS
+ * - EXS
+ * - ANGLE
+ */
+ if (isDigit(c)){
+ token = this.numberToken(c, startLine, startCol);
+ } else
+
+ /*
+ * Potential tokens:
+ * - S
+ */
+ if (isWhitespace(c)){
+ token = this.whitespaceToken(c, startLine, startCol);
+ } else
+
+ /*
+ * Potential tokens:
+ * - IDENT
+ */
+ if (isIdentStart(c)){
+ token = this.identOrFunctionToken(c, startLine, startCol);
+ } else
+
+ /*
+ * Potential tokens:
+ * - CHAR
+ * - PLUS
+ */
+ {
+ token = this.charToken(c, startLine, startCol);
+ }
+
+
+
+
+
+
+ }
+
+ //make sure this token is wanted
+ //TODO: check channel
+ break;
+ }
+
+ if (!token && c === null){
+ token = this.createToken(Tokens.EOF,null,startLine,startCol);
+ }
+
+ return token;
+ },
+
+ //-------------------------------------------------------------------------
+ // Methods to create tokens
+ //-------------------------------------------------------------------------
+
+ /**
+ * Produces a token based on available data and the current
+ * reader position information. This method is called by other
+ * private methods to create tokens and is never called directly.
+ * @param {int} tt The token type.
+ * @param {String} value The text value of the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @param {Object} options (Optional) Specifies a channel property
+ * to indicate that a different channel should be scanned
+ * and/or a hide property indicating that the token should
+ * be hidden.
+ * @return {Object} A token object.
+ * @method createToken
+ */
+ createToken: function(tt, value, startLine, startCol, options){
+ var reader = this._reader;
+ options = options || {};
+
+ return {
+ value: value,
+ type: tt,
+ channel: options.channel,
+ endChar: options.endChar,
+ hide: options.hide || false,
+ startLine: startLine,
+ startCol: startCol,
+ endLine: reader.getLine(),
+ endCol: reader.getCol()
+ };
+ },
+
+ //-------------------------------------------------------------------------
+ // Methods to create specific tokens
+ //-------------------------------------------------------------------------
+
+ /**
+ * Produces a token for any at-rule. If the at-rule is unknown, then
+ * the token is for a single "@" character.
+ * @param {String} first The first character for the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method atRuleToken
+ */
+ atRuleToken: function(first, startLine, startCol){
+ var rule = first,
+ reader = this._reader,
+ tt = Tokens.CHAR,
+ ident;
+
+ /*
+ * First, mark where we are. There are only four @ rules,
+ * so anything else is really just an invalid token.
+ * Basically, if this doesn't match one of the known @
+ * rules, just return '@' as an unknown token and allow
+ * parsing to continue after that point.
+ */
+ reader.mark();
+
+ //try to find the at-keyword
+ ident = this.readName();
+ rule = first + ident;
+ tt = Tokens.type(rule.toLowerCase());
+
+ //if it's not valid, use the first character only and reset the reader
+ if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN){
+ if (rule.length > 1){
+ tt = Tokens.UNKNOWN_SYM;
+ } else {
+ tt = Tokens.CHAR;
+ rule = first;
+ reader.reset();
+ }
+ }
+
+ return this.createToken(tt, rule, startLine, startCol);
+ },
+
+ /**
+ * Produces a character token based on the given character
+ * and location in the stream. If there's a special (non-standard)
+ * token name, this is used; otherwise CHAR is used.
+ * @param {String} c The character for the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method charToken
+ */
+ charToken: function(c, startLine, startCol){
+ var tt = Tokens.type(c);
+ var opts = {};
+
+ if (tt === -1){
+ tt = Tokens.CHAR;
+ } else {
+ opts.endChar = Tokens[tt].endChar;
+ }
+
+ return this.createToken(tt, c, startLine, startCol, opts);
+ },
+
+ /**
+ * Produces a character token based on the given character
+ * and location in the stream. If there's a special (non-standard)
+ * token name, this is used; otherwise CHAR is used.
+ * @param {String} first The first character for the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method commentToken
+ */
+ commentToken: function(first, startLine, startCol){
+ var comment = this.readComment(first);
+
+ return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
+ },
+
+ /**
+ * Produces a comparison token based on the given character
+ * and location in the stream. The next character must be
+ * read and is already known to be an equals sign.
+ * @param {String} c The character for the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method comparisonToken
+ */
+ comparisonToken: function(c, startLine, startCol){
+ var reader = this._reader,
+ comparison = c + reader.read(),
+ tt = Tokens.type(comparison) || Tokens.CHAR;
+
+ return this.createToken(tt, comparison, startLine, startCol);
+ },
+
+ /**
+ * Produces a hash token based on the specified information. The
+ * first character provided is the pound sign (#) and then this
+ * method reads a name afterward.
+ * @param {String} first The first character (#) in the hash name.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method hashToken
+ */
+ hashToken: function(first, startLine, startCol){
+ var name = this.readName(first);
+
+ return this.createToken(Tokens.HASH, name, startLine, startCol);
+ },
+
+ /**
+ * Produces a CDO or CHAR token based on the specified information. The
+ * first character is provided and the rest is read by the function to determine
+ * the correct token to create.
+ * @param {String} first The first character in the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method htmlCommentStartToken
+ */
+ htmlCommentStartToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ text = first;
+
+ reader.mark();
+ text += reader.readCount(3);
+
+ if (text === "<!--"){
+ return this.createToken(Tokens.CDO, text, startLine, startCol);
+ } else {
+ reader.reset();
+ return this.charToken(first, startLine, startCol);
+ }
+ },
+
+ /**
+ * Produces a CDC or CHAR token based on the specified information. The
+ * first character is provided and the rest is read by the function to determine
+ * the correct token to create.
+ * @param {String} first The first character in the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method htmlCommentEndToken
+ */
+ htmlCommentEndToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ text = first;
+
+ reader.mark();
+ text += reader.readCount(2);
+
+ if (text === "-->"){
+ return this.createToken(Tokens.CDC, text, startLine, startCol);
+ } else {
+ reader.reset();
+ return this.charToken(first, startLine, startCol);
+ }
+ },
+
+ /**
+ * Produces an IDENT or FUNCTION token based on the specified information. The
+ * first character is provided and the rest is read by the function to determine
+ * the correct token to create.
+ * @param {String} first The first character in the identifier.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method identOrFunctionToken
+ */
+ identOrFunctionToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ ident = this.readName(first),
+ tt = Tokens.IDENT,
+ uriFns = ["url(", "url-prefix(", "domain("];
+
+ //if there's a left paren immediately after, it's a URI or function
+ if (reader.peek() === "("){
+ ident += reader.read();
+ if (uriFns.indexOf(ident.toLowerCase()) > -1){
+ tt = Tokens.URI;
+ ident = this.readURI(ident);
+
+ //didn't find a valid URL or there's no closing paren
+ if (uriFns.indexOf(ident.toLowerCase()) > -1){
+ tt = Tokens.FUNCTION;
+ }
+ } else {
+ tt = Tokens.FUNCTION;
+ }
+ } else if (reader.peek() === ":"){ //might be an IE function
+
+ //IE-specific functions always being with progid:
+ if (ident.toLowerCase() === "progid"){
+ ident += reader.readTo("(");
+ tt = Tokens.IE_FUNCTION;
+ }
+ }
+
+ return this.createToken(tt, ident, startLine, startCol);
+ },
+
+ /**
+ * Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
+ * first character is provided and the rest is read by the function to determine
+ * the correct token to create.
+ * @param {String} first The first character in the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method importantToken
+ */
+ importantToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ important = first,
+ tt = Tokens.CHAR,
+ temp,
+ c;
+
+ reader.mark();
+ c = reader.read();
+
+ while(c){
+
+ //there can be a comment in here
+ if (c === "/"){
+
+ //if the next character isn't a star, then this isn't a valid !important token
+ if (reader.peek() !== "*"){
+ break;
+ } else {
+ temp = this.readComment(c);
+ if (temp === ""){ //broken!
+ break;
+ }
+ }
+ } else if (isWhitespace(c)){
+ important += c + this.readWhitespace();
+ } else if (/i/i.test(c)){
+ temp = reader.readCount(8);
+ if (/mportant/i.test(temp)){
+ important += c + temp;
+ tt = Tokens.IMPORTANT_SYM;
+
+ }
+ break; //we're done
+ } else {
+ break;
+ }
+
+ c = reader.read();
+ }
+
+ if (tt === Tokens.CHAR){
+ reader.reset();
+ return this.charToken(first, startLine, startCol);
+ } else {
+ return this.createToken(tt, important, startLine, startCol);
+ }
+
+
+ },
+
+ /**
+ * Produces a NOT or CHAR token based on the specified information. The
+ * first character is provided and the rest is read by the function to determine
+ * the correct token to create.
+ * @param {String} first The first character in the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method notToken
+ */
+ notToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ text = first;
+
+ reader.mark();
+ text += reader.readCount(4);
+
+ if (text.toLowerCase() === ":not("){
+ return this.createToken(Tokens.NOT, text, startLine, startCol);
+ } else {
+ reader.reset();
+ return this.charToken(first, startLine, startCol);
+ }
+ },
+
+ /**
+ * Produces a number token based on the given character
+ * and location in the stream. This may return a token of
+ * NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
+ * or PERCENTAGE.
+ * @param {String} first The first character for the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method numberToken
+ */
+ numberToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ value = this.readNumber(first),
+ ident,
+ tt = Tokens.NUMBER,
+ c = reader.peek();
+
+ if (isIdentStart(c)){
+ ident = this.readName(reader.read());
+ value += ident;
+
+ if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){
+ tt = Tokens.LENGTH;
+ } else if (/^deg|^rad$|^grad$/i.test(ident)){
+ tt = Tokens.ANGLE;
+ } else if (/^ms$|^s$/i.test(ident)){
+ tt = Tokens.TIME;
+ } else if (/^hz$|^khz$/i.test(ident)){
+ tt = Tokens.FREQ;
+ } else if (/^dpi$|^dpcm$/i.test(ident)){
+ tt = Tokens.RESOLUTION;
+ } else {
+ tt = Tokens.DIMENSION;
+ }
+
+ } else if (c === "%"){
+ value += reader.read();
+ tt = Tokens.PERCENTAGE;
+ }
+
+ return this.createToken(tt, value, startLine, startCol);
+ },
+
+ /**
+ * Produces a string token based on the given character
+ * and location in the stream. Since strings may be indicated
+ * by single or double quotes, a failure to match starting
+ * and ending quotes results in an INVALID token being generated.
+ * The first character in the string is passed in and then
+ * the rest are read up to and including the final quotation mark.
+ * @param {String} first The first character in the string.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method stringToken
+ */
+ stringToken: function(first, startLine, startCol){
+ var delim = first,
+ string = first,
+ reader = this._reader,
+ prev = first,
+ tt = Tokens.STRING,
+ c = reader.read();
+
+ while(c){
+ string += c;
+
+ //if the delimiter is found with an escapement, we're done.
+ if (c === delim && prev !== "\\"){
+ break;
+ }
+
+ //if there's a newline without an escapement, it's an invalid string
+ if (isNewLine(reader.peek()) && c !== "\\"){
+ tt = Tokens.INVALID;
+ break;
+ }
+
+ //save previous and get next
+ prev = c;
+ c = reader.read();
+ }
+
+ //if c is null, that means we're out of input and the string was never closed
+ if (c === null){
+ tt = Tokens.INVALID;
+ }
+
+ return this.createToken(tt, string, startLine, startCol);
+ },
+
+ unicodeRangeToken: function(first, startLine, startCol){
+ var reader = this._reader,
+ value = first,
+ temp,
+ tt = Tokens.CHAR;
+
+ //then it should be a unicode range
+ if (reader.peek() === "+"){
+ reader.mark();
+ value += reader.read();
+ value += this.readUnicodeRangePart(true);
+
+ //ensure there's an actual unicode range here
+ if (value.length === 2){
+ reader.reset();
+ } else {
+
+ tt = Tokens.UNICODE_RANGE;
+
+ //if there's a ? in the first part, there can't be a second part
+ if (value.indexOf("?") === -1){
+
+ if (reader.peek() === "-"){
+ reader.mark();
+ temp = reader.read();
+ temp += this.readUnicodeRangePart(false);
+
+ //if there's not another value, back up and just take the first
+ if (temp.length === 1){
+ reader.reset();
+ } else {
+ value += temp;
+ }
+ }
+
+ }
+ }
+ }
+
+ return this.createToken(tt, value, startLine, startCol);
+ },
+
+ /**
+ * Produces a S token based on the specified information. Since whitespace
+ * may have multiple characters, this consumes all whitespace characters
+ * into a single token.
+ * @param {String} first The first character in the token.
+ * @param {int} startLine The beginning line for the character.
+ * @param {int} startCol The beginning column for the character.
+ * @return {Object} A token object.
+ * @method whitespaceToken
+ */
+ whitespaceToken: function(first, startLine, startCol){
+ var value = first + this.readWhitespace();
+ return this.createToken(Tokens.S, value, startLine, startCol);
+ },
+
+
+
+
+ //-------------------------------------------------------------------------
+ // Methods to read values from the string stream
+ //-------------------------------------------------------------------------
+
+ readUnicodeRangePart: function(allowQuestionMark){
+ var reader = this._reader,
+ part = "",
+ c = reader.peek();
+
+ //first read hex digits
+ while(isHexDigit(c) && part.length < 6){
+ reader.read();
+ part += c;
+ c = reader.peek();
+ }
+
+ //then read question marks if allowed
+ if (allowQuestionMark){
+ while(c === "?" && part.length < 6){
+ reader.read();
+ part += c;
+ c = reader.peek();
+ }
+ }
+
+ //there can't be any other characters after this point
+
+ return part;
+ },
+
+ readWhitespace: function(){
+ var reader = this._reader,
+ whitespace = "",
+ c = reader.peek();
+
+ while(isWhitespace(c)){
+ reader.read();
+ whitespace += c;
+ c = reader.peek();
+ }
+
+ return whitespace;
+ },
+ readNumber: function(first){
+ var reader = this._reader,
+ number = first,
+ hasDot = (first === "."),
+ c = reader.peek();
+
+
+ while(c){
+ if (isDigit(c)){
+ number += reader.read();
+ } else if (c === "."){
+ if (hasDot){
+ break;
+ } else {
+ hasDot = true;
+ number += reader.read();
+ }
+ } else {
+ break;
+ }
+
+ c = reader.peek();
+ }
+
+ return number;
+ },
+ readString: function(){
+ var reader = this._reader,
+ delim = reader.read(),
+ string = delim,
+ prev = delim,
+ c = reader.peek();
+
+ while(c){
+ c = reader.read();
+ string += c;
+
+ //if the delimiter is found with an escapement, we're done.
+ if (c === delim && prev !== "\\"){
+ break;
+ }
+
+ //if there's a newline without an escapement, it's an invalid string
+ if (isNewLine(reader.peek()) && c !== "\\"){
+ string = "";
+ break;
+ }
+
+ //save previous and get next
+ prev = c;
+ c = reader.peek();
+ }
+
+ //if c is null, that means we're out of input and the string was never closed
+ if (c === null){
+ string = "";
+ }
+
+ return string;
+ },
+ readURI: function(first){
+ var reader = this._reader,
+ uri = first,
+ inner = "",
+ c = reader.peek();
+
+ reader.mark();
+
+ //skip whitespace before
+ while(c && isWhitespace(c)){
+ reader.read();
+ c = reader.peek();
+ }
+
+ //it's a string
+ if (c === "'" || c === "\""){
+ inner = this.readString();
+ } else {
+ inner = this.readURL();
+ }
+
+ c = reader.peek();
+
+ //skip whitespace after
+ while(c && isWhitespace(c)){
+ reader.read();
+ c = reader.peek();
+ }
+
+ //if there was no inner value or the next character isn't closing paren, it's not a URI
+ if (inner === "" || c !== ")"){
+ uri = first;
+ reader.reset();
+ } else {
+ uri += inner + reader.read();
+ }
+
+ return uri;
+ },
+ readURL: function(){
+ var reader = this._reader,
+ url = "",
+ c = reader.peek();
+
+ //TODO: Check for escape and nonascii
+ while (/^[!#$%&\\*-~]$/.test(c)){
+ url += reader.read();
+ c = reader.peek();
+ }
+
+ return url;
+
+ },
+ readName: function(first){
+ var reader = this._reader,
+ ident = first || "",
+ c = reader.peek();
+
+ while(true){
+ if (c === "\\"){
+ ident += this.readEscape(reader.read());
+ c = reader.peek();
+ } else if(c && isNameChar(c)){
+ ident += reader.read();
+ c = reader.peek();
+ } else {
+ break;
+ }
+ }
+
+ return ident;
+ },
+
+ readEscape: function(first){
+ var reader = this._reader,
+ cssEscape = first || "",
+ i = 0,
+ c = reader.peek();
+
+ if (isHexDigit(c)){
+ do {
+ cssEscape += reader.read();
+ c = reader.peek();
+ } while(c && isHexDigit(c) && ++i < 6);
+ }
+
+ if (cssEscape.length === 3 && /\s/.test(c) ||
+ cssEscape.length === 7 || cssEscape.length === 1){
+ reader.read();
+ } else {
+ c = "";
+ }
+
+ return cssEscape + c;
+ },
+
+ readComment: function(first){
+ var reader = this._reader,
+ comment = first || "",
+ c = reader.read();
+
+ if (c === "*"){
+ while(c){
+ comment += c;
+
+ //look for end of comment
+ if (comment.length > 2 && c === "*" && reader.peek() === "/"){
+ comment += reader.read();
+ break;
+ }
+
+ c = reader.read();
+ }
+
+ return comment;
+ } else {
+ return "";
+ }
+
+ }
+});
+
+var Tokens = [
+
+ /*
+ * The following token names are defined in CSS3 Grammar: http://www.w3.org/TR/css3-syntax/#lexical
+ */
+
+ //HTML-style comments
+ { name: "CDO"},
+ { name: "CDC"},
+
+ //ignorables
+ { name: "S", whitespace: true/*, channel: "ws"*/},
+ { name: "COMMENT", comment: true, hide: true, channel: "comment" },
+
+ //attribute equality
+ { name: "INCLUDES", text: "~="},
+ { name: "DASHMATCH", text: "|="},
+ { name: "PREFIXMATCH", text: "^="},
+ { name: "SUFFIXMATCH", text: "$="},
+ { name: "SUBSTRINGMATCH", text: "*="},
+
+ //identifier types
+ { name: "STRING"},
+ { name: "IDENT"},
+ { name: "HASH"},
+
+ //at-keywords
+ { name: "IMPORT_SYM", text: "@import"},
+ { name: "PAGE_SYM", text: "@page"},
+ { name: "MEDIA_SYM", text: "@media"},
+ { name: "FONT_FACE_SYM", text: "@font-face"},
+ { name: "CHARSET_SYM", text: "@charset"},
+ { name: "NAMESPACE_SYM", text: "@namespace"},
+ { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"]},
+ { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"]},
+ { name: "UNKNOWN_SYM" },
+ //{ name: "ATKEYWORD"},
+
+ //CSS3 animations
+ { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
+
+ //important symbol
+ { name: "IMPORTANT_SYM"},
+
+ //measurements
+ { name: "LENGTH"},
+ { name: "ANGLE"},
+ { name: "TIME"},
+ { name: "FREQ"},
+ { name: "DIMENSION"},
+ { name: "PERCENTAGE"},
+ { name: "NUMBER"},
+
+ //functions
+ { name: "URI"},
+ { name: "FUNCTION"},
+
+ //Unicode ranges
+ { name: "UNICODE_RANGE"},
+
+ /*
+ * The following token names are defined in CSS3 Selectors: http://www.w3.org/TR/css3-selectors/#selector-syntax
+ */
+
+ //invalid string
+ { name: "INVALID"},
+
+ //combinators
+ { name: "PLUS", text: "+" },
+ { name: "GREATER", text: ">"},
+ { name: "COMMA", text: ","},
+ { name: "TILDE", text: "~"},
+
+ //modifier
+ { name: "NOT"},
+
+ /*
+ * Defined in CSS3 Paged Media
+ */
+ { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner"},
+ { name: "TOPLEFT_SYM", text: "@top-left"},
+ { name: "TOPCENTER_SYM", text: "@top-center"},
+ { name: "TOPRIGHT_SYM", text: "@top-right"},
+ { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner"},
+ { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner"},
+ { name: "BOTTOMLEFT_SYM", text: "@bottom-left"},
+ { name: "BOTTOMCENTER_SYM", text: "@bottom-center"},
+ { name: "BOTTOMRIGHT_SYM", text: "@bottom-right"},
+ { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner"},
+ { name: "LEFTTOP_SYM", text: "@left-top"},
+ { name: "LEFTMIDDLE_SYM", text: "@left-middle"},
+ { name: "LEFTBOTTOM_SYM", text: "@left-bottom"},
+ { name: "RIGHTTOP_SYM", text: "@right-top"},
+ { name: "RIGHTMIDDLE_SYM", text: "@right-middle"},
+ { name: "RIGHTBOTTOM_SYM", text: "@right-bottom"},
+
+ /*
+ * The following token names are defined in CSS3 Media Queries: http://www.w3.org/TR/css3-mediaqueries/#syntax
+ */
+ /*{ name: "MEDIA_ONLY", state: "media"},
+ { name: "MEDIA_NOT", state: "media"},
+ { name: "MEDIA_AND", state: "media"},*/
+ { name: "RESOLUTION", state: "media"},
+
+ /*
+ * The following token names are not defined in any CSS specification but are used by the lexer.
+ */
+
+ //not a real token, but useful for stupid IE filters
+ { name: "IE_FUNCTION" },
+
+ //part of CSS3 grammar but not the Flex code
+ { name: "CHAR" },
+
+ //TODO: Needed?
+ //Not defined as tokens, but might as well be
+ {
+ name: "PIPE",
+ text: "|"
+ },
+ {
+ name: "SLASH",
+ text: "/"
+ },
+ {
+ name: "MINUS",
+ text: "-"
+ },
+ {
+ name: "STAR",
+ text: "*"
+ },
+
+ {
+ name: "LBRACE",
+ endChar: "}",
+ text: "{"
+ },
+ {
+ name: "RBRACE",
+ text: "}"
+ },
+ {
+ name: "LBRACKET",
+ endChar: "]",
+ text: "["
+ },
+ {
+ name: "RBRACKET",
+ text: "]"
+ },
+ {
+ name: "EQUALS",
+ text: "="
+ },
+ {
+ name: "COLON",
+ text: ":"
+ },
+ {
+ name: "SEMICOLON",
+ text: ";"
+ },
+
+ {
+ name: "LPAREN",
+ endChar: ")",
+ text: "("
+ },
+ {
+ name: "RPAREN",
+ text: ")"
+ },
+ {
+ name: "DOT",
+ text: "."
+ }
+];
+
+(function(){
+
+ var nameMap = [],
+ typeMap = Object.create(null);
+
+ Tokens.UNKNOWN = -1;
+ Tokens.unshift({name:"EOF"});
+ for (var i=0, len = Tokens.length; i < len; i++){
+ nameMap.push(Tokens[i].name);
+ Tokens[Tokens[i].name] = i;
+ if (Tokens[i].text){
+ if (Tokens[i].text instanceof Array){
+ for (var j=0; j < Tokens[i].text.length; j++){
+ typeMap[Tokens[i].text[j]] = i;
+ }
+ } else {
+ typeMap[Tokens[i].text] = i;
+ }
+ }
+ }
+
+ Tokens.name = function(tt){
+ return nameMap[tt];
+ };
+
+ Tokens.type = function(c){
+ return typeMap[c] || -1;
+ };
+
+})();
+
+
+
+//This file will likely change a lot! Very experimental!
+var Validation = {
+
+ validate: function(property, value){
+
+ //normalize name
+ var name = property.toString().toLowerCase(),
+ expression = new PropertyValueIterator(value),
+ spec = Properties[name];
+
+ if (!spec) {
+ if (name.indexOf("-") !== 0){ //vendor prefixed are ok
+ throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
+ }
+ } else if (typeof spec !== "number"){
+
+ //initialization
+ if (typeof spec === "string"){
+ if (spec.indexOf("||") > -1) {
+ this.groupProperty(spec, expression);
+ } else {
+ this.singleProperty(spec, expression, 1);
+ }
+
+ } else if (spec.multi) {
+ this.multiProperty(spec.multi, expression, spec.comma, spec.max || Infinity);
+ } else if (typeof spec === "function") {
+ spec(expression);
+ }
+
+ }
+
+ },
+
+ singleProperty: function(types, expression, max, partial) {
+
+ var result = false,
+ value = expression.value,
+ count = 0,
+ part;
+
+ while (expression.hasNext() && count < max) {
+ result = ValidationTypes.isAny(expression, types);
+ if (!result) {
+ break;
+ }
+ count++;
+ }
+
+ if (!result) {
+ if (expression.hasNext() && !expression.isFirst()) {
+ part = expression.peek();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
+ }
+ } else if (expression.hasNext()) {
+ part = expression.next();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ }
+
+ },
+
+ multiProperty: function (types, expression, comma, max) {
+
+ var result = false,
+ value = expression.value,
+ count = 0,
+ part;
+
+ while(expression.hasNext() && !result && count < max) {
+ if (ValidationTypes.isAny(expression, types)) {
+ count++;
+ if (!expression.hasNext()) {
+ result = true;
+
+ } else if (comma) {
+ if (String(expression.peek()) === ",") {
+ part = expression.next();
+ } else {
+ break;
+ }
+ }
+ } else {
+ break;
+
+ }
+ }
+
+ if (!result) {
+ if (expression.hasNext() && !expression.isFirst()) {
+ part = expression.peek();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ part = expression.previous();
+ if (comma && String(part) === ",") {
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
+ }
+ }
+
+ } else if (expression.hasNext()) {
+ part = expression.next();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ }
+
+ },
+
+ groupProperty: function (types, expression, comma) {
+
+ var result = false,
+ value = expression.value,
+ typeCount = types.split("||").length,
+ groups = { count: 0 },
+ partial = false,
+ name,
+ part;
+
+ while(expression.hasNext() && !result) {
+ name = ValidationTypes.isAnyOfGroup(expression, types);
+ if (name) {
+
+ //no dupes
+ if (groups[name]) {
+ break;
+ } else {
+ groups[name] = 1;
+ groups.count++;
+ partial = true;
+
+ if (groups.count === typeCount || !expression.hasNext()) {
+ result = true;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (!result) {
+ if (partial && expression.hasNext()) {
+ part = expression.peek();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ } else {
+ throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
+ }
+ } else if (expression.hasNext()) {
+ part = expression.next();
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
+ }
+ }
+
+
+
+};
+/**
+ * Type to use when a validation error occurs.
+ * @class ValidationError
+ * @namespace parserlib.util
+ * @constructor
+ * @param {String} message The error message.
+ * @param {int} line The line at which the error occurred.
+ * @param {int} col The column at which the error occurred.
+ */
+function ValidationError(message, line, col){
+
+ /**
+ * The column at which the error occurred.
+ * @type int
+ * @property col
+ */
+ this.col = col;
+
+ /**
+ * The line at which the error occurred.
+ * @type int
+ * @property line
+ */
+ this.line = line;
+
+ /**
+ * The text representation of the unit.
+ * @type String
+ * @property text
+ */
+ this.message = message;
+
+}
+
+//inherit from Error
+ValidationError.prototype = new Error();
+//This file will likely change a lot! Very experimental!
+var ValidationTypes = {
+
+ isLiteral: function (part, literals) {
+ var text = part.text.toString().toLowerCase(),
+ args = literals.split(" | "),
+ i, len, found = false;
+
+ for (i=0,len=args.length; i < len && !found; i++){
+ if (text === args[i].toLowerCase()){
+ found = true;
+ }
+ }
+
+ return found;
+ },
+
+ isSimple: function(type) {
+ return !!this.simple[type];
+ },
+
+ isComplex: function(type) {
+ return !!this.complex[type];
+ },
+
+ /**
+ * Determines if the next part(s) of the given expression
+ * are any of the given types.
+ */
+ isAny: function (expression, types) {
+ var args = types.split(" | "),
+ i, len, found = false;
+
+ for (i=0,len=args.length; i < len && !found && expression.hasNext(); i++){
+ found = this.isType(expression, args[i]);
+ }
+
+ return found;
+ },
+
+ /**
+ * Determines if the next part(s) of the given expression
+ * are one of a group.
+ */
+ isAnyOfGroup: function(expression, types) {
+ var args = types.split(" || "),
+ i, len, found = false;
+
+ for (i=0,len=args.length; i < len && !found; i++){
+ found = this.isType(expression, args[i]);
+ }
+
+ return found ? args[i-1] : false;
+ },
+
+ /**
+ * Determines if the next part(s) of the given expression
+ * are of a given type.
+ */
+ isType: function (expression, type) {
+ var part = expression.peek(),
+ result = false;
+
+ if (type.charAt(0) !== "<") {
+ result = this.isLiteral(part, type);
+ if (result) {
+ expression.next();
+ }
+ } else if (this.simple[type]) {
+ result = this.simple[type](part);
+ if (result) {
+ expression.next();
+ }
+ } else {
+ result = this.complex[type](expression);
+ }
+
+ return result;
+ },
+
+
+
+ simple: {
+ __proto__: null,
+
+ "<absolute-size>": function(part){
+ return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
+ },
+
+ "<attachment>": function(part){
+ return ValidationTypes.isLiteral(part, "scroll | fixed | local");
+ },
+
+ "<attr>": function(part){
+ return part.type === "function" && part.name === "attr";
+ },
+
+ "<bg-image>": function(part){
+ return this["<image>"](part) || this["<gradient>"](part) || String(part) === "none";
+ },
+
+ "<gradient>": function(part) {
+ return part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
+ },
+
+ "<box>": function(part){
+ return ValidationTypes.isLiteral(part, "padding-box | border-box | content-box");
+ },
+
+ "<content>": function(part){
+ return part.type === "function" && part.name === "content";
+ },
+
+ "<relative-size>": function(part){
+ return ValidationTypes.isLiteral(part, "smaller | larger");
+ },
+
+ //any identifier
+ "<ident>": function(part){
+ return part.type === "identifier";
+ },
+
+ "<length>": function(part){
+ if (part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
+ return true;
+ }else{
+ return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
+ }
+ },
+
+ "<color>": function(part){
+ return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
+ },
+
+ "<number>": function(part){
+ return part.type === "number" || this["<integer>"](part);
+ },
+
+ "<integer>": function(part){
+ return part.type === "integer";
+ },
+
+ "<line>": function(part){
+ return part.type === "integer";
+ },
+
+ "<angle>": function(part){
+ return part.type === "angle";
+ },
+
+ "<uri>": function(part){
+ return part.type === "uri";
+ },
+
+ "<image>": function(part){
+ return this["<uri>"](part);
+ },
+
+ "<percentage>": function(part){
+ return part.type === "percentage" || String(part) === "0";
+ },
+
+ "<border-width>": function(part){
+ return this["<length>"](part) || ValidationTypes.isLiteral(part, "thin | medium | thick");
+ },
+
+ "<border-style>": function(part){
+ return ValidationTypes.isLiteral(part, "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");
+ },
+
+ "<content-sizing>": function(part){ // http://www.w3.org/TR/css3-sizing/#width-height-keywords
+ return ValidationTypes.isLiteral(part, "fill-available | -moz-available | -webkit-fill-available | max-content | -moz-max-content | -webkit-max-content | min-content | -moz-min-content | -webkit-min-content | fit-content | -moz-fit-content | -webkit-fit-content");
+ },
+
+ "<margin-width>": function(part){
+ return this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "auto");
+ },
+
+ "<padding-width>": function(part){
+ return this["<length>"](part) || this["<percentage>"](part);
+ },
+
+ "<shape>": function(part){
+ return part.type === "function" && (part.name === "rect" || part.name === "inset-rect");
+ },
+
+ "<time>": function(part) {
+ return part.type === "time";
+ },
+
+ "<flex-grow>": function(part){
+ return this["<number>"](part);
+ },
+
+ "<flex-shrink>": function(part){
+ return this["<number>"](part);
+ },
+
+ "<width>": function(part){
+ return this["<margin-width>"](part);
+ },
+
+ "<flex-basis>": function(part){
+ return this["<width>"](part);
+ },
+
+ "<flex-direction>": function(part){
+ return ValidationTypes.isLiteral(part, "row | row-reverse | column | column-reverse");
+ },
+
+ "<flex-wrap>": function(part){
+ return ValidationTypes.isLiteral(part, "nowrap | wrap | wrap-reverse");
+ },
+
+ "<feature-tag-value>": function(part){
+ return (part.type === "function" && /^[A-Z0-9]{4}$/i.test(part));
+ }
+ },
+
+ complex: {
+ __proto__: null,
+
+ "<bg-position>": function(expression){
+ var result = false,
+ numeric = "<percentage> | <length>",
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0;
+
+ while (expression.peek(count) && expression.peek(count).text !== ",") {
+ count++;
+ }
+
+/*
+<position> = [
+ [ left | center | right | top | bottom | <percentage> | <length> ]
+|
+ [ left | center | right | <percentage> | <length> ]
+ [ top | center | bottom | <percentage> | <length> ]
+|
+ [ center | [ left | right ] [ <percentage> | <length> ]? ] &&
+ [ center | [ top | bottom ] [ <percentage> | <length> ]? ]
+]
+*/
+
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
+ } else {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
+
+ return result;
+ },
+
+ "<bg-size>": function(expression){
+ //<bg-size> = [ <length> | <percentage> | auto ]{1,2} | cover | contain
+ var result = false,
+ numeric = "<percentage> | <length> | auto";
+
+ if (ValidationTypes.isAny(expression, "cover | contain")) {
+ result = true;
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+
+ return result;
+ },
+
+ "<repeat-style>": function(expression){
+ //repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
+ var result = false,
+ values = "repeat | space | round | no-repeat",
+ part;
+
+ if (expression.hasNext()){
+ part = expression.next();
+
+ if (ValidationTypes.isLiteral(part, "repeat-x | repeat-y")) {
+ result = true;
+ } else if (ValidationTypes.isLiteral(part, values)) {
+ result = true;
+
+ if (expression.hasNext() && ValidationTypes.isLiteral(expression.peek(), values)) {
+ expression.next();
+ }
+ }
+ }
+
+ return result;
+
+ },
+
+ "<shadow>": function(expression) {
+ //inset? && [ <length>{2,4} && <color>? ]
+ var result = false,
+ count = 0,
+ inset = false,
+ color = false;
+
+ if (expression.hasNext()) {
+
+ if (ValidationTypes.isAny(expression, "inset")){
+ inset = true;
+ }
+
+ if (ValidationTypes.isAny(expression, "<color>")) {
+ color = true;
+ }
+
+ while (ValidationTypes.isAny(expression, "<length>") && count < 4) {
+ count++;
+ }
+
+
+ if (expression.hasNext()) {
+ if (!color) {
+ ValidationTypes.isAny(expression, "<color>");
+ }
+
+ if (!inset) {
+ ValidationTypes.isAny(expression, "inset");
+ }
+
+ }
+
+ result = (count >= 2 && count <= 4);
+
+ }
+
+ return result;
+ },
+
+ "<x-one-radius>": function(expression) {
+ //[ <length> | <percentage> ] [ <length> | <percentage> ]?
+ var result = false,
+ simple = "<length> | <percentage> | inherit";
+
+ if (ValidationTypes.isAny(expression, simple)){
+ result = true;
+ ValidationTypes.isAny(expression, simple);
+ }
+
+ return result;
+ },
+
+ "<flex>": function(expression) {
+ // http://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/#flex-property
+ // none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]
+ // Valid syntaxes, according to https://developer.mozilla.org/en-US/docs/Web/CSS/flex#Syntax
+ // * none
+ // * <flex-grow>
+ // * <flex-basis>
+ // * <flex-grow> <flex-basis>
+ // * <flex-grow> <flex-shrink>
+ // * <flex-grow> <flex-shrink> <flex-basis>
+ // * inherit
+ var part,
+ result = false;
+ if (ValidationTypes.isAny(expression, "none | inherit")) {
+ result = true;
+ } else {
+ if (ValidationTypes.isType(expression, "<flex-grow>")) {
+ if (expression.peek()) {
+ if (ValidationTypes.isType(expression, "<flex-shrink>")) {
+ if (expression.peek()) {
+ result = ValidationTypes.isType(expression, "<flex-basis>");
+ } else {
+ result = true;
+ }
+ } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
+ result = expression.peek() === null;
+ }
+ } else {
+ result = true;
+ }
+ } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
+ result = true;
+ }
+ }
+
+ if (!result) {
+ // Generate a more verbose error than "Expected <flex>..."
+ part = expression.peek();
+ throw new ValidationError("Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '" + expression.value.text + "'.", part.line, part.col);
+ }
+
+ return result;
+ }
+ }
+};
+
+parserlib.css = {
+__proto__ :null,
+Colors :Colors,
+Combinator :Combinator,
+Parser :Parser,
+PropertyName :PropertyName,
+PropertyValue :PropertyValue,
+PropertyValuePart :PropertyValuePart,
+MediaFeature :MediaFeature,
+MediaQuery :MediaQuery,
+Selector :Selector,
+SelectorPart :SelectorPart,
+SelectorSubPart :SelectorSubPart,
+Specificity :Specificity,
+TokenStream :TokenStream,
+Tokens :Tokens,
+ValidationError :ValidationError
+};
+})();
+
+(function(){
+/* jshint forin:false */
+for(var prop in parserlib){
+exports[prop] = parserlib[prop];
+}
+})();
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/defineElement.js
@@ -1,0 +1,70 @@
+"use strict";
+
+var attributes = require('./attributes');
+var sloppy = require('./sloppy');
+var isApiWritable = require("./config").isApiWritable;
+
+module.exports = function(spec, defaultConstructor, tagList, tagNameToImpl) {
+ var c = spec.ctor;
+ if (c) {
+ var props = spec.props || {};
+
+ if (spec.attributes) {
+ for (var n in spec.attributes) {
+ var attr = spec.attributes[n];
+ if (typeof attr !== 'object' || Array.isArray(attr)) attr = {type: attr};
+ if (!attr.name) attr.name = n.toLowerCase();
+ props[n] = attributes.property(attr);
+ }
+ }
+
+ props.constructor = { value : c, writable: isApiWritable };
+ c.prototype = Object.create((spec.superclass || defaultConstructor).prototype, props);
+ if (spec.events) {
+ addEventHandlers(c, spec.events);
+ }
+ tagList[c.name] = c;
+ }
+ else {
+ c = defaultConstructor;
+ }
+
+ (spec.tags || spec.tag && [spec.tag] || []).forEach(function(tag) {
+ tagNameToImpl[tag] = c;
+ });
+
+ return c;
+};
+
+function EventHandlerBuilder(body, document, form, element) {
+ this.body = body;
+ this.document = document;
+ this.form = form;
+ this.element = element;
+}
+
+EventHandlerBuilder.prototype.build = sloppy.EventHandlerBuilder_build;
+
+function EventHandlerChangeHandler(elt, name, oldval, newval) {
+ var doc = elt.ownerDocument || Object.create(null);
+ var form = elt.form || Object.create(null);
+ elt[name] = new EventHandlerBuilder(newval, doc, form, elt).build();
+}
+
+function addEventHandlers(c, eventHandlerTypes) {
+ var p = c.prototype;
+ eventHandlerTypes.forEach(function(type) {
+ // Define the event handler registration IDL attribute for this type
+ Object.defineProperty(p, "on" + type, {
+ get: function() {
+ return this._getEventHandler(type);
+ },
+ set: function(v) {
+ this._setEventHandler(type, v);
+ },
+ });
+
+ // Define special behavior for the content attribute as well
+ attributes.registerChangeHandler(c, "on" + type, EventHandlerChangeHandler);
+ });
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/events.js
@@ -1,0 +1,7 @@
+"use strict";
+module.exports = {
+ Event: require('./Event'),
+ UIEvent: require('./UIEvent'),
+ MouseEvent: require('./MouseEvent'),
+ CustomEvent: require('./CustomEvent')
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/htmlelts.js
@@ -1,0 +1,1426 @@
+"use strict";
+var Node = require('./Node');
+var Element = require('./Element');
+var CSSStyleDeclaration = require('./CSSStyleDeclaration');
+var utils = require('./utils');
+var URLUtils = require('./URLUtils');
+var defineElement = require('./defineElement');
+
+var htmlElements = exports.elements = {};
+var htmlNameToImpl = Object.create(null);
+
+exports.createElement = function(doc, localName, prefix) {
+ var impl = htmlNameToImpl[localName] || HTMLUnknownElement;
+ return new impl(doc, localName, prefix);
+};
+
+function define(spec) {
+ return defineElement(spec, HTMLElement, htmlElements, htmlNameToImpl);
+}
+
+function URL(attr) {
+ return {
+ get: function() {
+ var v = this._getattr(attr);
+ if (v === null) { return ''; }
+ var url = this.doc._resolve(v);
+ return (url === null) ? v : url;
+ },
+ set: function(value) {
+ this._setattr(attr, value);
+ }
+ };
+}
+
+function CORS(attr) {
+ return {
+ get: function() {
+ var v = this._getattr(attr);
+ if (v === null) { return null; }
+ if (v.toLowerCase() === 'use-credentials') { return 'use-credentials'; }
+ return 'anonymous';
+ },
+ set: function(value) {
+ if (value===null || value===undefined) {
+ this.removeAttribute(attr);
+ } else {
+ this._setattr(attr, value);
+ }
+ }
+ };
+}
+
+var REFERRER = {
+ type: ["", "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url"],
+ missing: '',
+};
+
+
+// XXX: the default value for tabIndex should be 0 if the element is
+// focusable and -1 if it is not. But the full definition of focusable
+// is actually hard to compute, so for now, I'll follow Firefox and
+// just base the default value on the type of the element.
+var focusableElements = {
+ "A":true, "LINK":true, "BUTTON":true, "INPUT":true,
+ "SELECT":true, "TEXTAREA":true, "COMMAND":true
+};
+
+var HTMLFormElement = function(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ this._form = null; // Prevent later deoptimization
+};
+
+var HTMLElement = exports.HTMLElement = define({
+ superclass: Element,
+ ctor: function HTMLElement(doc, localName, prefix) {
+ Element.call(this, doc, localName, utils.NAMESPACE.HTML, prefix);
+ },
+ props: {
+ innerHTML: {
+ get: function() {
+ return this.serialize();
+ },
+ set: function(v) {
+ var parser = this.ownerDocument.implementation.mozHTMLParser(
+ this.ownerDocument._address,
+ this);
+ parser.parse(v===null ? '' : String(v), true);
+
+ // Remove any existing children of this node
+ var target = (this instanceof htmlNameToImpl.template) ?
+ this.content : this;
+ while(target.hasChildNodes())
+ target.removeChild(target.firstChild);
+
+ // Now copy newly parsed children to this node
+ target.appendChild(parser._asDocumentFragment());
+ }
+ },
+ style: { get: function() {
+ if (!this._style)
+ this._style = new CSSStyleDeclaration(this);
+ return this._style;
+ }, set: function(v) {
+ if (v===null||v===undefined) { v = ''; }
+ this._setattr('style', String(v));
+ }},
+
+ // These can't really be implemented server-side in a reasonable way.
+ blur: { value: function() {}},
+ focus: { value: function() {}},
+ forceSpellCheck: { value: function() {}},
+
+ click: { value: function() {
+ if (this._click_in_progress) return;
+ this._click_in_progress = true;
+ try {
+ if (this._pre_click_activation_steps)
+ this._pre_click_activation_steps();
+
+ var event = this.ownerDocument.createEvent("MouseEvent");
+ event.initMouseEvent("click", true, true,
+ this.ownerDocument.defaultView, 1,
+ 0, 0, 0, 0,
+ // These 4 should be initialized with
+ // the actually current keyboard state
+ // somehow...
+ false, false, false, false,
+ 0, null
+ );
+
+ // Dispatch this as an untrusted event since it is synthetic
+ var success = this.dispatchEvent(event);
+
+ if (success) {
+ if (this._post_click_activation_steps)
+ this._post_click_activation_steps(event);
+ }
+ else {
+ if (this._cancelled_activation_steps)
+ this._cancelled_activation_steps();
+ }
+ }
+ finally {
+ this._click_in_progress = false;
+ }
+ }},
+ submit: { value: utils.nyi },
+ },
+ attributes: {
+ title: String,
+ lang: String,
+ dir: {type: ["ltr", "rtl", "auto"], missing: ''},
+ accessKey: String,
+ hidden: Boolean,
+ tabIndex: {type: "long", default: function() {
+ if (this.tagName in focusableElements ||
+ this.contentEditable)
+ return 0;
+ else
+ return -1;
+ }}
+ },
+ events: [
+ "abort", "canplay", "canplaythrough", "change", "click", "contextmenu",
+ "cuechange", "dblclick", "drag", "dragend", "dragenter", "dragleave",
+ "dragover", "dragstart", "drop", "durationchange", "emptied", "ended",
+ "input", "invalid", "keydown", "keypress", "keyup", "loadeddata",
+ "loadedmetadata", "loadstart", "mousedown", "mousemove", "mouseout",
+ "mouseover", "mouseup", "mousewheel", "pause", "play", "playing",
+ "progress", "ratechange", "readystatechange", "reset", "seeked",
+ "seeking", "select", "show", "stalled", "submit", "suspend",
+ "timeupdate", "volumechange", "waiting",
+
+ // These last 5 event types will be overriden by HTMLBodyElement
+ "blur", "error", "focus", "load", "scroll"
+ ]
+});
+
+
+// XXX: reflect contextmenu as contextMenu, with element type
+
+
+// style: the spec doesn't call this a reflected attribute.
+// may want to handle it manually.
+
+// contentEditable: enumerated, not clear if it is actually
+// reflected or requires custom getter/setter. Not listed as
+// "limited to known values". Raises syntax_err on bad setting,
+// so I think this is custom.
+
+// contextmenu: content is element id, idl type is an element
+// draggable: boolean, but not a reflected attribute
+// dropzone: reflected SettableTokenList, experimental, so don't
+// implement it right away.
+
+// data-* attributes: need special handling in setAttribute?
+// Or maybe that isn't necessary. Can I just scan the attribute list
+// when building the dataset? Liveness and caching issues?
+
+// microdata attributes: many are simple reflected attributes, but
+// I'm not going to implement this now.
+
+
+var HTMLUnknownElement = define({
+ ctor: function HTMLUnknownElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+
+var formAssociatedProps = {
+ // See http://www.w3.org/TR/html5/association-of-controls-and-forms.html#form-owner
+ form: { get: function() {
+ return this._form;
+ }}
+};
+
+define({
+ tag: 'a',
+ ctor: function HTMLAnchorElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ _post_click_activation_steps: { value: function(e) {
+ if (this.href) {
+ // Follow the link
+ // XXX: this is just a quick hack
+ // XXX: the HTML spec probably requires more than this
+ this.ownerDocument.defaultView.location = this.href;
+ }
+ }},
+ },
+ attributes: {
+ href: URL,
+ ping: String,
+ download: String,
+ target: String,
+ rel: String,
+ media: String,
+ hreflang: String,
+ type: String,
+ referrerPolicy: REFERRER,
+ // Obsolete
+ coords: String,
+ charset: String,
+ name: String,
+ rev: String,
+ shape: String,
+ }
+});
+// Latest WhatWG spec says these methods come via HTMLHyperlinkElementUtils
+URLUtils._inherit(htmlNameToImpl.a.prototype);
+
+define({
+ tag: 'area',
+ ctor: function HTMLAreaElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ alt: String,
+ target: String,
+ download: String,
+ rel: String,
+ media: String,
+ href: URL,
+ hreflang: String,
+ type: String,
+ shape: String,
+ coords: String,
+ ping: String,
+ // XXX: also reflect relList
+ referrerPolicy: REFERRER,
+ // Obsolete
+ noHref: Boolean,
+ }
+});
+// Latest WhatWG spec says these methods come via HTMLHyperlinkElementUtils
+URLUtils._inherit(htmlNameToImpl.area.prototype);
+
+define({
+ tag: 'br',
+ ctor: function HTMLBRElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ clear: String
+ },
+});
+
+define({
+ tag: 'base',
+ ctor: function HTMLBaseElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ "target": String
+ }
+});
+
+
+define({
+ tag: 'body',
+ ctor: function HTMLBodyElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ // Certain event handler attributes on a <body> tag actually set
+ // handlers for the window rather than just that element. Define
+ // getters and setters for those here. Note that some of these override
+ // properties on HTMLElement.prototype.
+ // XXX: If I add support for <frameset>, these have to go there, too
+ // XXX
+ // When the Window object is implemented, these attribute will have
+ // to work with the same-named attributes on the Window.
+ events: [
+ "afterprint", "beforeprint", "beforeunload", "blur", "error",
+ "focus","hashchange", "load", "message", "offline", "online",
+ "pagehide", "pageshow","popstate","resize","scroll","storage","unload",
+ ],
+ attributes: {
+ // Obsolete
+ text: { type: String, treatNullAsEmptyString: true },
+ link: { type: String, treatNullAsEmptyString: true },
+ vLink: { type: String, treatNullAsEmptyString: true },
+ aLink: { type: String, treatNullAsEmptyString: true },
+ bgColor: { type: String, treatNullAsEmptyString: true },
+ background: String,
+ }
+});
+
+define({
+ tag: 'button',
+ ctor: function HTMLButtonElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ name: String,
+ value: String,
+ disabled: Boolean,
+ autofocus: Boolean,
+ type: { type:["submit", "reset", "button", "menu"], missing: 'submit' },
+ formTarget: String,
+ formNoValidate: Boolean,
+ formMethod: { type: ["get", "post", "dialog"], invalid: 'get', missing: '' },
+ formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' },
+ }
+});
+
+define({
+ tag: 'dl',
+ ctor: function HTMLDListElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ compact: Boolean,
+ }
+});
+
+define({
+ tag: 'data',
+ ctor: function HTMLDataElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ value: String,
+ }
+});
+
+define({
+ tag: 'datalist',
+ ctor: function HTMLDataListElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'details',
+ ctor: function HTMLDetailsElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ "open": Boolean
+ }
+});
+
+define({
+ tag: 'div',
+ ctor: function HTMLDivElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String
+ }
+});
+
+define({
+ tag: 'embed',
+ ctor: function HTMLEmbedElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ src: URL,
+ type: String,
+ width: String,
+ height: String,
+ // Obsolete
+ align: String,
+ name: String,
+ }
+});
+
+define({
+ tag: 'fieldset',
+ ctor: function HTMLFieldSetElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ disabled: Boolean,
+ name: String
+ }
+});
+
+define({
+ tag: 'form',
+ ctor: function HTMLFormElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ action: String,
+ autocomplete: {type:['on', 'off'], missing: 'on'},
+ name: String,
+ acceptCharset: {name: "accept-charset"},
+ target: String,
+ noValidate: Boolean,
+ method: { type: ["get", "post", "dialog"], invalid: 'get', missing: 'get' },
+ // Both enctype and encoding reflect the enctype content attribute
+ enctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" },
+ encoding: {name: 'enctype', type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" },
+ }
+});
+
+define({
+ tag: 'hr',
+ ctor: function HTMLHRElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ color: String,
+ noShade: Boolean,
+ size: String,
+ width: String,
+ },
+});
+
+define({
+ tag: 'head',
+ ctor: function HTMLHeadElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tags: ['h1','h2','h3','h4','h5','h6'],
+ ctor: function HTMLHeadingElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ },
+});
+
+define({
+ tag: 'html',
+ ctor: function HTMLHtmlElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ version: String
+ }
+});
+
+define({
+ tag: 'iframe',
+ ctor: function HTMLIFrameElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ var Window = require('./Window'); // Avoid circular dependencies.
+ this._contentWindow = new Window();
+ },
+ props: {
+ contentWindow: { get: function() {
+ return this._contentWindow;
+ } },
+ contentDocument: { get: function() {
+ return this.contentWindow.document;
+ } },
+ },
+ attributes: {
+ src: URL,
+ srcdoc: String,
+ name: String,
+ width: String,
+ height: String,
+ // XXX: sandbox is a reflected settable token list
+ seamless: Boolean,
+ allowFullscreen: Boolean,
+ allowUserMedia: Boolean,
+ allowPaymentRequest: Boolean,
+ referrerPolicy: REFERRER,
+ // Obsolete
+ align: String,
+ scrolling: String,
+ frameBorder: String,
+ longDesc: URL,
+ marginHeight: { type: String, treatNullAsEmptyString: true },
+ marginWidth: { type: String, treatNullAsEmptyString: true },
+ }
+});
+
+define({
+ tag: 'img',
+ ctor: function HTMLImageElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ alt: String,
+ src: URL,
+ srcset: String,
+ crossOrigin: CORS,
+ useMap: String,
+ isMap: Boolean,
+ height: { type: "unsigned long", default: 0 },
+ width: { type: "unsigned long", default: 0 },
+ referrerPolicy: REFERRER,
+ // Obsolete:
+ name: String,
+ lowsrc: URL,
+ align: String,
+ hspace: { type: "unsigned long", default: 0 },
+ vspace: { type: "unsigned long", default: 0 },
+ longDesc: URL,
+ border: { type: String, treatNullAsEmptyString: true },
+ }
+});
+
+define({
+ tag: 'input',
+ ctor: function HTMLInputElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ form: formAssociatedProps.form,
+ _post_click_activation_steps: { value: function(e) {
+ if (this.type === 'checkbox') {
+ this.checked = !this.checked;
+ }
+ else if (this.type === 'radio') {
+ var group = this.form.getElementsByName(this.name);
+ for (var i=group.length-1; i >= 0; i--) {
+ var el = group[i];
+ el.checked = (el === this);
+ }
+ }
+ }},
+ },
+ attributes: {
+ name: String,
+ disabled: Boolean,
+ autofocus: Boolean,
+ accept: String,
+ alt: String,
+ max: String,
+ min: String,
+ pattern: String,
+ placeholder: String,
+ step: String,
+ dirName: String,
+ defaultValue: {name: 'value'},
+ multiple: Boolean,
+ required: Boolean,
+ readOnly: Boolean,
+ checked: Boolean,
+ value: String,
+ src: URL,
+ defaultChecked: {name: 'checked', type: Boolean},
+ size: {type: 'unsigned long', default: 20, min: 1, setmin: 1},
+ width: {type: 'unsigned long', min: 0, setmin: 0, default: 0},
+ height: {type: 'unsigned long', min: 0, setmin: 0, default: 0},
+ minLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
+ maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
+ autocomplete: String, // It's complicated
+ type: { type:
+ ["text", "hidden", "search", "tel", "url", "email", "password",
+ "datetime", "date", "month", "week", "time", "datetime-local",
+ "number", "range", "color", "checkbox", "radio", "file", "submit",
+ "image", "reset", "button"],
+ missing: 'text' },
+ formTarget: String,
+ formNoValidate: Boolean,
+ formMethod: { type: ["get", "post"], invalid: 'get', missing: '' },
+ formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' },
+ inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' },
+ // Obsolete
+ align: String,
+ useMap: String,
+ }
+});
+
+define({
+ tag: 'keygen',
+ ctor: function HTMLKeygenElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ name: String,
+ disabled: Boolean,
+ autofocus: Boolean,
+ challenge: String,
+ keytype: { type:["rsa"], missing: '' },
+ }
+});
+
+define({
+ tag: 'li',
+ ctor: function HTMLLIElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ value: {type: "long", default: 0},
+ // Obsolete
+ type: String,
+ }
+});
+
+define({
+ tag: 'label',
+ ctor: function HTMLLabelElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ htmlFor: {name: 'for', type: String}
+ }
+});
+
+define({
+ tag: 'legend',
+ ctor: function HTMLLegendElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String
+ },
+});
+
+define({
+ tag: 'link',
+ ctor: function HTMLLinkElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // XXX Reflect DOMSettableTokenList sizes also DOMTokenList relList
+ href: URL,
+ rel: String,
+ media: String,
+ hreflang: String,
+ type: String,
+ crossOrigin: CORS,
+ nonce: String,
+ integrity: String,
+ referrerPolicy: REFERRER,
+ // Obsolete
+ charset: String,
+ rev: String,
+ target: String,
+ }
+});
+
+define({
+ tag: 'map',
+ ctor: function HTMLMapElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ name: String
+ }
+});
+
+define({
+ tag: 'menu',
+ ctor: function HTMLMenuElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // XXX: not quite right, default should be popup if parent element is
+ // popup.
+ type: { type: [ 'context', 'popup', 'toolbar' ], missing: 'toolbar' },
+ label: String,
+ // Obsolete
+ compact: Boolean,
+ }
+});
+
+define({
+ tag: 'meta',
+ ctor: function HTMLMetaElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ name: String,
+ content: String,
+ httpEquiv: {name: 'http-equiv', type: String},
+ // Obsolete
+ scheme: String,
+ }
+});
+
+define({
+ tag: 'meter',
+ ctor: function HTMLMeterElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps
+});
+
+define({
+ tags: ['ins', 'del'],
+ ctor: function HTMLModElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ cite: URL,
+ dateTime: String
+ }
+});
+
+define({
+ tag: 'ol',
+ ctor: function HTMLOListElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ // Utility function (see the start attribute default value). Returns
+ // the number of <li> children of this element
+ _numitems: { get: function() {
+ var items = 0;
+ this.childNodes.forEach(function(n) {
+ if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "LI")
+ items++;
+ });
+ return items;
+ }}
+ },
+ attributes: {
+ type: String,
+ reversed: Boolean,
+ start: {
+ type: "long",
+ default: function() {
+ // The default value of the start attribute is 1 unless the list is
+ // reversed. Then it is the # of li children
+ if (this.reversed)
+ return this._numitems;
+ else
+ return 1;
+ }
+ },
+ // Obsolete
+ compact: Boolean,
+ }
+});
+
+define({
+ tag: 'object',
+ ctor: function HTMLObjectElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ data: URL,
+ type: String,
+ name: String,
+ useMap: String,
+ typeMustMatch: Boolean,
+ width: String,
+ height: String,
+ // Obsolete
+ align: String,
+ archive: String,
+ code: String,
+ declare: Boolean,
+ hspace: { type: "unsigned long", default: 0 },
+ standby: String,
+ vspace: { type: "unsigned long", default: 0 },
+ codeBase: URL,
+ codeType: String,
+ border: { type: String, treatNullAsEmptyString: true },
+ }
+});
+
+define({
+ tag: 'optgroup',
+ ctor: function HTMLOptGroupElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ disabled: Boolean,
+ label: String
+ }
+});
+
+define({
+ tag: 'option',
+ ctor: function HTMLOptionElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ form: { get: function() {
+ var p = this.parentNode;
+ while (p && p.nodeType === Node.ELEMENT_NODE) {
+ if (p.localName === 'select') return p.form;
+ p = p.parentNode;
+ }
+ }},
+ value: {
+ get: function() { return this._getattr('value') || this.text; },
+ set: function(v) { this._setattr('value', v); },
+ },
+ text: {
+ get: function() {
+ // Strip and collapse whitespace
+ return this.textContent.replace(/[ \t\n\f\r]+/g, ' ').trim();
+ },
+ set: function(v) { this.textContent = v; },
+ },
+ // missing: index
+ },
+ attributes: {
+ disabled: Boolean,
+ defaultSelected: {name: 'selected', type: Boolean},
+ label: String,
+ }
+});
+
+define({
+ tag: 'output',
+ ctor: function HTMLOutputElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ // XXX Reflect for/htmlFor as a settable token list
+ name: String
+ }
+});
+
+define({
+ tag: 'p',
+ ctor: function HTMLParagraphElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String
+ }
+});
+
+define({
+ tag: 'param',
+ ctor: function HTMLParamElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ name: String,
+ value: String,
+ // Obsolete
+ type: String,
+ valueType: String,
+ }
+});
+
+define({
+ tags: ['pre',/*legacy elements:*/'listing','xmp'],
+ ctor: function HTMLPreElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ width: { type: "long", default: 0 },
+ }
+});
+
+define({
+ tag: 'progress',
+ ctor: function HTMLProgressElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: formAssociatedProps,
+ attributes: {
+ max: {type: Number, float: true, default: 1.0, min: 0}
+ }
+});
+
+define({
+ tags: ['q', 'blockquote'],
+ ctor: function HTMLQuoteElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ cite: URL
+ }
+});
+
+define({
+ tag: 'script',
+ ctor: function HTMLScriptElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ text: {
+ get: function() {
+ var s = "";
+ for(var i = 0, n = this.childNodes.length; i < n; i++) {
+ var child = this.childNodes[i];
+ if (child.nodeType === Node.TEXT_NODE)
+ s += child._data;
+ }
+ return s;
+ },
+ set: function(value) {
+ this.removeChildren();
+ if (value !== null && value !== "") {
+ this.appendChild(this.ownerDocument.createTextNode(value));
+ }
+ }
+ }
+ },
+ attributes: {
+ src: URL,
+ type: String,
+ charset: String,
+ defer: Boolean,
+ async: Boolean,
+ crossOrigin: CORS,
+ nonce: String,
+ integrity: String,
+ }
+});
+
+define({
+ tag: 'select',
+ ctor: function HTMLSelectElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ form: formAssociatedProps.form,
+ options: { get: function() {
+ return this.getElementsByTagName('option');
+ }}
+ },
+ attributes: {
+ autocomplete: String, // It's complicated
+ name: String,
+ disabled: Boolean,
+ autofocus: Boolean,
+ multiple: Boolean,
+ required: Boolean,
+ size: {type: "unsigned long", default: 0}
+ }
+});
+
+define({
+ tag: 'source',
+ ctor: function HTMLSourceElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ src: URL,
+ type: String,
+ media: String
+ }
+});
+
+define({
+ tag: 'span',
+ ctor: function HTMLSpanElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'style',
+ ctor: function HTMLStyleElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ media: String,
+ type: String,
+ scoped: Boolean
+ }
+});
+
+define({
+ tag: 'caption',
+ ctor: function HTMLTableCaptionElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ }
+});
+
+
+define({
+ ctor: function HTMLTableCellElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ colSpan: {type: "unsigned long", default: 1},
+ rowSpan: {type: "unsigned long", default: 1},
+ //XXX Also reflect settable token list headers
+ scope: { type: ['row','col','rowgroup','colgroup'], missing: '' },
+ abbr: String,
+ // Obsolete
+ align: String,
+ axis: String,
+ height: String,
+ width: String,
+ ch: { name: 'char', type: String },
+ chOff: { name: 'charoff', type: String },
+ noWrap: Boolean,
+ vAlign: String,
+ bgColor: { type: String, treatNullAsEmptyString: true },
+ }
+});
+
+define({
+ tags: ['col', 'colgroup'],
+ ctor: function HTMLTableColElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ span: {type: 'limited unsigned long with fallback', default: 1, min: 1},
+ // Obsolete
+ align: String,
+ ch: { name: 'char', type: String },
+ chOff: { name: 'charoff', type: String },
+ vAlign: String,
+ width: String,
+ }
+});
+
+define({
+ tag: 'table',
+ ctor: function HTMLTableElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ rows: { get: function() {
+ return this.getElementsByTagName('tr');
+ }}
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ border: String,
+ frame: String,
+ rules: String,
+ summary: String,
+ width: String,
+ bgColor: { type: String, treatNullAsEmptyString: true },
+ cellPadding: { type: String, treatNullAsEmptyString: true },
+ cellSpacing: { type: String, treatNullAsEmptyString: true },
+ }
+});
+
+define({
+ tag: 'template',
+ ctor: function HTMLTemplateElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ this._contentFragment = doc._templateDoc.createDocumentFragment();
+ },
+ props: {
+ content: { get: function() { return this._contentFragment; } },
+ serialize: { value: function() { return this.content.serialize(); } }
+ }
+});
+
+define({
+ tag: 'tr',
+ ctor: function HTMLTableRowElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ cells: { get: function() {
+ return this.querySelectorAll('td,th');
+ }}
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ ch: { name: 'char', type: String },
+ chOff: { name: 'charoff', type: String },
+ vAlign: String,
+ bgColor: { type: String, treatNullAsEmptyString: true },
+ },
+});
+
+define({
+ tags: ['thead', 'tfoot', 'tbody'],
+ ctor: function HTMLTableSectionElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ rows: { get: function() {
+ return this.getElementsByTagName('tr');
+ }}
+ },
+ attributes: {
+ // Obsolete
+ align: String,
+ ch: { name: 'char', type: String },
+ chOff: { name: 'charoff', type: String },
+ vAlign: String,
+ }
+});
+
+define({
+ tag: 'textarea',
+ ctor: function HTMLTextAreaElement(doc, localName, prefix) {
+ HTMLFormElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ form: formAssociatedProps.form,
+ type: { get: function() { return 'textarea'; } },
+ defaultValue: {
+ get: function() { return this.textContent; },
+ set: function(v) { this.textContent = v; },
+ },
+ value: {
+ get: function() { return this.defaultValue; /* never dirty */ },
+ set: function(v) {
+ // This isn't completely correct: according to the spec, this
+ // should "dirty" the API value, and result in
+ // `this.value !== this.defaultValue`. But for most of what
+ // folks want to do, this implementation should be fine:
+ this.defaultValue = v;
+ },
+ },
+ textLength: { get: function() { return this.value.length; } },
+ },
+ attributes: {
+ autocomplete: String, // It's complicated
+ name: String,
+ disabled: Boolean,
+ autofocus: Boolean,
+ placeholder: String,
+ wrap: String,
+ dirName: String,
+ required: Boolean,
+ readOnly: Boolean,
+ rows: {type: 'limited unsigned long with fallback', default: 2 },
+ cols: {type: 'limited unsigned long with fallback', default: 20 },
+ maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
+ minLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
+ inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' },
+ }
+});
+
+define({
+ tag: 'time',
+ ctor: function HTMLTimeElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ dateTime: String,
+ pubDate: Boolean
+ }
+});
+
+define({
+ tag: 'title',
+ ctor: function HTMLTitleElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ text: { get: function() {
+ return this.textContent;
+ }}
+ }
+});
+
+define({
+ tag: 'ul',
+ ctor: function HTMLUListElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ type: String,
+ // Obsolete
+ compact: Boolean,
+ }
+});
+
+define({
+ ctor: function HTMLMediaElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ src: URL,
+ crossOrigin: CORS,
+ preload: { type:["metadata", "none", "auto", {value: "", alias: "auto"}], missing: 'auto' },
+ loop: Boolean,
+ autoplay: Boolean,
+ mediaGroup: String,
+ controls: Boolean,
+ defaultMuted: {name: "muted", type: Boolean}
+ }
+});
+
+define({
+ tag: 'audio',
+ superclass: htmlElements.HTMLMediaElement,
+ ctor: function HTMLAudioElement(doc, localName, prefix) {
+ htmlElements.HTMLMediaElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'video',
+ superclass: htmlElements.HTMLMediaElement,
+ ctor: function HTMLVideoElement(doc, localName, prefix) {
+ htmlElements.HTMLMediaElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ poster: URL,
+ width: {type: "unsigned long", min: 0, default: 0 },
+ height: {type: "unsigned long", min: 0, default: 0 }
+ }
+});
+
+define({
+ tag: 'td',
+ superclass: htmlElements.HTMLTableCellElement,
+ ctor: function HTMLTableDataCellElement(doc, localName, prefix) {
+ htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'th',
+ superclass: htmlElements.HTMLTableCellElement,
+ ctor: function HTMLTableHeaderCellElement(doc, localName, prefix) {
+ htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix);
+ },
+});
+
+define({
+ tag: 'frameset',
+ ctor: function HTMLFrameSetElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'frame',
+ ctor: function HTMLFrameElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ }
+});
+
+define({
+ tag: 'canvas',
+ ctor: function HTMLCanvasElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ getContext: { value: utils.nyi },
+ probablySupportsContext: { value: utils.nyi },
+ setContext: { value: utils.nyi },
+ transferControlToProxy: { value: utils.nyi },
+ toDataURL: { value: utils.nyi },
+ toBlob: { value: utils.nyi }
+ },
+ attributes: {
+ width: { type: "unsigned long", default: 300},
+ height: { type: "unsigned long", default: 150}
+ }
+});
+
+define({
+ tag: 'dialog',
+ ctor: function HTMLDialogElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ show: { value: utils.nyi },
+ showModal: { value: utils.nyi },
+ close: { value: utils.nyi }
+ },
+ attributes: {
+ open: Boolean,
+ returnValue: String
+ }
+});
+
+define({
+ tag: 'menuitem',
+ ctor: function HTMLMenuItemElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ props: {
+ // The menuitem's label
+ _label: {
+ get: function() {
+ var val = this._getattr('label');
+ if (val !== null && val !== '') { return val; }
+ val = this.textContent;
+ // Strip and collapse whitespace
+ return val.replace(/[ \t\n\f\r]+/g, ' ').trim();
+ }
+ },
+ // The menuitem label IDL attribute
+ label: {
+ get: function() {
+ var val = this._getattr('label');
+ if (val !== null) { return val; }
+ return this._label;
+ },
+ set: function(v) {
+ this._setattr('label', v);
+ },
+ }
+ },
+ attributes: {
+ type: { type: ["command","checkbox","radio"], missing: 'command' },
+ icon: URL,
+ disabled: Boolean,
+ checked: Boolean,
+ radiogroup: String,
+ default: Boolean
+ }
+});
+
+define({
+ tag: 'source',
+ ctor: function HTMLSourceElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ srcset: String,
+ sizes: String,
+ media: String,
+ src: URL,
+ type: String
+ }
+});
+
+define({
+ tag: 'track',
+ ctor: function HTMLTrackElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ src: URL,
+ srclang: String,
+ label: String,
+ default: Boolean,
+ kind: { type: ["subtitles", "captions", "descriptions", "chapters", "metadata"], missing: 'subtitles', invalid: 'metadata' },
+ },
+ props: {
+ NONE: { get: function() { return 0; } },
+ LOADING: { get: function() { return 1; } },
+ LOADED: { get: function() { return 2; } },
+ ERROR: { get: function() { return 3; } },
+ readyState: { get: utils.nyi },
+ track: { get: utils.nyi }
+ }
+});
+
+define({
+ // obsolete
+ tag: 'font',
+ ctor: function HTMLFontElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ color: { type: String, treatNullAsEmptyString: true },
+ face: { type: String },
+ size: { type: String },
+ },
+});
+
+define({
+ // obsolete
+ tag: 'dir',
+ ctor: function HTMLDirectoryElement(doc, localName, prefix) {
+ HTMLElement.call(this, doc, localName, prefix);
+ },
+ attributes: {
+ compact: Boolean,
+ },
+});
+
+define({
+ tags: [
+ "abbr", "address", "article", "aside", "b", "bdi", "bdo",
+ "cite", "code", "dd", "dfn", "dt", "em", "figcaption", "figure",
+ "footer", "header", "hgroup", "i", "kbd", "main", "mark", "nav", "noscript",
+ "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "section", "small", "strong",
+ "sub", "summary", "sup", "u", "var", "wbr",
+ // Legacy elements
+ "acronym", "basefont", "big", "center", "nobr", "noembed", "noframes",
+ "plaintext", "strike", "tt"
+ ]
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/impl.js
@@ -1,0 +1,27 @@
+"use strict";
+var utils = require('./utils');
+
+exports = module.exports = {
+ CSSStyleDeclaration: require('./CSSStyleDeclaration'),
+ CharacterData: require('./CharacterData'),
+ Comment: require('./Comment'),
+ DOMException: require('./DOMException'),
+ DOMImplementation: require('./DOMImplementation'),
+ DOMTokenList: require('./DOMTokenList'),
+ Document: require('./Document'),
+ DocumentFragment: require('./DocumentFragment'),
+ DocumentType: require('./DocumentType'),
+ Element: require('./Element'),
+ HTMLParser: require('./HTMLParser'),
+ NamedNodeMap: require('./NamedNodeMap'),
+ Node: require('./Node'),
+ NodeList: require('./NodeList'),
+ NodeFilter: require('./NodeFilter'),
+ ProcessingInstruction: require('./ProcessingInstruction'),
+ Text: require('./Text'),
+ Window: require('./Window')
+};
+
+utils.merge(exports, require('./events'));
+utils.merge(exports, require('./htmlelts').elements);
+utils.merge(exports, require('./svg').elements);
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/index.d.ts
@@ -1,0 +1,5 @@
+declare module "domino" {
+ function createDOMImplementation(): DOMImplementation;
+ function createDocument(html?: string, force?: boolean): Document;
+ function createWindow(html?: string, address?: string): Window;
+}
\ No newline at end of file
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/index.js
@@ -1,0 +1,79 @@
+"use strict";
+var DOMImplementation = require('./DOMImplementation');
+var HTMLParser = require('./HTMLParser');
+var Window = require('./Window');
+
+exports.createDOMImplementation = function() {
+ return new DOMImplementation(null);
+};
+
+exports.createDocument = function(html, force) {
+ // Previous API couldn't let you pass '' as a document, and that
+ // yields a slightly different document than createHTMLDocument('')
+ // does. The new `force` parameter lets you pass '' if you want to.
+ if (html || force) {
+ var parser = new HTMLParser();
+ parser.parse(html || '', true);
+ return parser.document();
+ }
+ return new DOMImplementation(null).createHTMLDocument("");
+};
+
+exports.createIncrementalHTMLParser = function() {
+ var parser = new HTMLParser();
+ /** API for incremental parser. */
+ return {
+ /** Provide an additional chunk of text to be parsed. */
+ write: function(s) {
+ if (s.length > 0) {
+ parser.parse(s, false, function() { return true; });
+ }
+ },
+ /**
+ * Signal that we are done providing input text, optionally
+ * providing one last chunk as a parameter.
+ */
+ end: function(s) {
+ parser.parse(s || '', true, function() { return true; });
+ },
+ /**
+ * Performs a chunk of parsing work, returning at the end of
+ * the next token as soon as shouldPauseFunc() returns true.
+ * Returns true iff there is more work to do.
+ *
+ * For example:
+ * ```
+ * var incrParser = domino.createIncrementalHTMLParser();
+ * incrParser.end('...long html document...');
+ * while (true) {
+ * // Pause every 10ms
+ * var start = Date.now();
+ * var pauseIn10 = function() { return (Date.now() - start) >= 10; };
+ * if (!incrParser.process(pauseIn10)) {
+ * break;
+ * }
+ * ...yield to other tasks, do other housekeeping, etc...
+ * }
+ * ```
+ */
+ process: function(shouldPauseFunc) {
+ return parser.parse('', false, shouldPauseFunc);
+ },
+ /**
+ * Returns the result of the incremental parse. Valid after
+ * `this.end()` has been called and `this.process()` has returned
+ * false.
+ */
+ document: function() {
+ return parser.document();
+ },
+ };
+};
+
+exports.createWindow = function(html, address) {
+ var document = exports.createDocument(html);
+ if (address !== undefined) { document._address = address; }
+ return new Window(document);
+};
+
+exports.impl = require('./impl');
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/select.js
@@ -1,0 +1,933 @@
+"use strict";
+/* jshint eqnull: true */
+/**
+ * Zest (https://github.com/chjj/zest)
+ * A css selector engine.
+ * Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed)
+ * Domino version based on Zest v0.1.3 with bugfixes applied.
+ */
+
+/**
+ * Helpers
+ */
+
+var window = Object.create(null, {
+ location: { get: function() {
+ throw new Error('window.location is not supported.');
+ } }
+});
+
+var compareDocumentPosition = function(a, b) {
+ return a.compareDocumentPosition(b);
+};
+
+var order = function(a, b) {
+ /* jshint bitwise: false */
+ return compareDocumentPosition(a, b) & 2 ? 1 : -1;
+};
+
+var next = function(el) {
+ while ((el = el.nextSibling)
+ && el.nodeType !== 1);
+ return el;
+};
+
+var prev = function(el) {
+ while ((el = el.previousSibling)
+ && el.nodeType !== 1);
+ return el;
+};
+
+var child = function(el) {
+ /*jshint -W084 */
+ if (el = el.firstChild) {
+ while (el.nodeType !== 1
+ && (el = el.nextSibling));
+ }
+ return el;
+};
+
+var lastChild = function(el) {
+ /*jshint -W084 */
+ if (el = el.lastChild) {
+ while (el.nodeType !== 1
+ && (el = el.previousSibling));
+ }
+ return el;
+};
+
+var parentIsElement = function(n) {
+ if (!n.parentNode) { return false; }
+ var nodeType = n.parentNode.nodeType;
+ // The root `html` element can be a first- or last-child, too.
+ return nodeType === 1 || nodeType === 9;
+};
+
+var unquote = function(str) {
+ if (!str) return str;
+ var ch = str[0];
+ if (ch === '"' || ch === '\'') {
+ if (str[str.length-1] === ch) {
+ str = str.slice(1, -1);
+ } else {
+ // bad string.
+ str = str.slice(1);
+ }
+ return str.replace(rules.str_escape, function(s) {
+ var m = /^\\(?:([0-9A-Fa-f]+)|([\r\n\f]+))/.exec(s);
+ if (!m) { return s.slice(1); }
+ if (m[2]) { return ''; /* escaped newlines are ignored in strings. */ }
+ var cp = parseInt(m[1], 16);
+ return String.fromCodePoint ? String.fromCodePoint(cp) :
+ // Not all JavaScript implementations have String.fromCodePoint yet.
+ String.fromCharCode(cp);
+ });
+ } else if (rules.ident.test(str)) {
+ return decodeid(str);
+ } else {
+ // NUMBER, PERCENTAGE, DIMENSION, etc
+ return str;
+ }
+};
+
+var decodeid = function(str) {
+ return str.replace(rules.escape, function(s) {
+ var m = /^\\([0-9A-Fa-f]+)/.exec(s);
+ if (!m) { return s[1]; }
+ var cp = parseInt(m[1], 16);
+ return String.fromCodePoint ? String.fromCodePoint(cp) :
+ // Not all JavaScript implementations have String.fromCodePoint yet.
+ String.fromCharCode(cp);
+ });
+};
+
+var indexOf = (function() {
+ if (Array.prototype.indexOf) {
+ return Array.prototype.indexOf;
+ }
+ return function(obj, item) {
+ var i = this.length;
+ while (i--) {
+ if (this[i] === item) return i;
+ }
+ return -1;
+ };
+})();
+
+var makeInside = function(start, end) {
+ var regex = rules.inside.source
+ .replace(/</g, start)
+ .replace(/>/g, end);
+
+ return new RegExp(regex);
+};
+
+var replace = function(regex, name, val) {
+ regex = regex.source;
+ regex = regex.replace(name, val.source || val);
+ return new RegExp(regex);
+};
+
+var truncateUrl = function(url, num) {
+ return url
+ .replace(/^(?:\w+:\/\/|\/+)/, '')
+ .replace(/(?:\/+|\/*#.*?)$/, '')
+ .split('/', num)
+ .join('/');
+};
+
+/**
+ * Handle `nth` Selectors
+ */
+
+var parseNth = function(param_, test) {
+ var param = param_.replace(/\s+/g, '')
+ , cap;
+
+ if (param === 'even') {
+ param = '2n+0';
+ } else if (param === 'odd') {
+ param = '2n+1';
+ } else if (param.indexOf('n') === -1) {
+ param = '0n' + param;
+ }
+
+ cap = /^([+-])?(\d+)?n([+-])?(\d+)?$/.exec(param);
+
+ return {
+ group: cap[1] === '-'
+ ? -(cap[2] || 1)
+ : +(cap[2] || 1),
+ offset: cap[4]
+ ? (cap[3] === '-' ? -cap[4] : +cap[4])
+ : 0
+ };
+};
+
+var nth = function(param_, test, last) {
+ var param = parseNth(param_)
+ , group = param.group
+ , offset = param.offset
+ , find = !last ? child : lastChild
+ , advance = !last ? next : prev;
+
+ return function(el) {
+ if (!parentIsElement(el)) return;
+
+ var rel = find(el.parentNode)
+ , pos = 0;
+
+ while (rel) {
+ if (test(rel, el)) pos++;
+ if (rel === el) {
+ pos -= offset;
+ return group && pos
+ ? (pos % group) === 0 && (pos < 0 === group < 0)
+ : !pos;
+ }
+ rel = advance(rel);
+ }
+ };
+};
+
+/**
+ * Simple Selectors
+ */
+
+var selectors = {
+ '*': (function() {
+ if (false/*function() {
+ var el = document.createElement('div');
+ el.appendChild(document.createComment(''));
+ return !!el.getElementsByTagName('*')[0];
+ }()*/) {
+ return function(el) {
+ if (el.nodeType === 1) return true;
+ };
+ }
+ return function() {
+ return true;
+ };
+ })(),
+ 'type': function(type) {
+ type = type.toLowerCase();
+ return function(el) {
+ return el.nodeName.toLowerCase() === type;
+ };
+ },
+ 'attr': function(key, op, val, i) {
+ op = operators[op];
+ return function(el) {
+ var attr;
+ switch (key) {
+ case 'for':
+ attr = el.htmlFor;
+ break;
+ case 'class':
+ // className is '' when non-existent
+ // getAttribute('class') is null
+ attr = el.className;
+ if (attr === '' && el.getAttribute('class') == null) {
+ attr = null;
+ }
+ break;
+ case 'href':
+ case 'src':
+ attr = el.getAttribute(key, 2);
+ break;
+ case 'title':
+ // getAttribute('title') can be '' when non-existent sometimes?
+ attr = el.getAttribute('title') || null;
+ break;
+ // careful with attributes with special getter functions
+ case 'id':
+ case 'lang':
+ case 'dir':
+ case 'accessKey':
+ case 'hidden':
+ case 'tabIndex':
+ case 'style':
+ if (el.getAttribute) {
+ attr = el.getAttribute(key);
+ break;
+ }
+ /* falls through */
+ default:
+ if (el.hasAttribute && !el.hasAttribute(key)) {
+ break;
+ }
+ attr = el[key] != null
+ ? el[key]
+ : el.getAttribute && el.getAttribute(key);
+ break;
+ }
+ if (attr == null) return;
+ attr = attr + '';
+ if (i) {
+ attr = attr.toLowerCase();
+ val = val.toLowerCase();
+ }
+ return op(attr, val);
+ };
+ },
+ ':first-child': function(el) {
+ return !prev(el) && parentIsElement(el);
+ },
+ ':last-child': function(el) {
+ return !next(el) && parentIsElement(el);
+ },
+ ':only-child': function(el) {
+ return !prev(el) && !next(el) && parentIsElement(el);
+ },
+ ':nth-child': function(param, last) {
+ return nth(param, function() {
+ return true;
+ }, last);
+ },
+ ':nth-last-child': function(param) {
+ return selectors[':nth-child'](param, true);
+ },
+ ':root': function(el) {
+ return el.ownerDocument.documentElement === el;
+ },
+ ':empty': function(el) {
+ return !el.firstChild;
+ },
+ ':not': function(sel) {
+ var test = compileGroup(sel);
+ return function(el) {
+ return !test(el);
+ };
+ },
+ ':first-of-type': function(el) {
+ if (!parentIsElement(el)) return;
+ var type = el.nodeName;
+ /*jshint -W084 */
+ while (el = prev(el)) {
+ if (el.nodeName === type) return;
+ }
+ return true;
+ },
+ ':last-of-type': function(el) {
+ if (!parentIsElement(el)) return;
+ var type = el.nodeName;
+ /*jshint -W084 */
+ while (el = next(el)) {
+ if (el.nodeName === type) return;
+ }
+ return true;
+ },
+ ':only-of-type': function(el) {
+ return selectors[':first-of-type'](el)
+ && selectors[':last-of-type'](el);
+ },
+ ':nth-of-type': function(param, last) {
+ return nth(param, function(rel, el) {
+ return rel.nodeName === el.nodeName;
+ }, last);
+ },
+ ':nth-last-of-type': function(param) {
+ return selectors[':nth-of-type'](param, true);
+ },
+ ':checked': function(el) {
+ return !!(el.checked || el.selected);
+ },
+ ':indeterminate': function(el) {
+ return !selectors[':checked'](el);
+ },
+ ':enabled': function(el) {
+ return !el.disabled && el.type !== 'hidden';
+ },
+ ':disabled': function(el) {
+ return !!el.disabled;
+ },
+ ':target': function(el) {
+ return el.id === window.location.hash.substring(1);
+ },
+ ':focus': function(el) {
+ return el === el.ownerDocument.activeElement;
+ },
+ ':is': function(sel) {
+ return compileGroup(sel);
+ },
+ // :matches is an older name for :is; see
+ // https://github.com/w3c/csswg-drafts/issues/3258
+ ':matches': function(sel) {
+ return selectors[':is'](sel);
+ },
+ ':nth-match': function(param, last) {
+ var args = param.split(/\s*,\s*/)
+ , arg = args.shift()
+ , test = compileGroup(args.join(','));
+
+ return nth(arg, test, last);
+ },
+ ':nth-last-match': function(param) {
+ return selectors[':nth-match'](param, true);
+ },
+ ':links-here': function(el) {
+ return el + '' === window.location + '';
+ },
+ ':lang': function(param) {
+ return function(el) {
+ while (el) {
+ if (el.lang) return el.lang.indexOf(param) === 0;
+ el = el.parentNode;
+ }
+ };
+ },
+ ':dir': function(param) {
+ return function(el) {
+ while (el) {
+ if (el.dir) return el.dir === param;
+ el = el.parentNode;
+ }
+ };
+ },
+ ':scope': function(el, con) {
+ var context = con || el.ownerDocument;
+ if (context.nodeType === 9) {
+ return el === context.documentElement;
+ }
+ return el === context;
+ },
+ ':any-link': function(el) {
+ return typeof el.href === 'string';
+ },
+ ':local-link': function(el) {
+ if (el.nodeName) {
+ return el.href && el.host === window.location.host;
+ }
+ var param = +el + 1;
+ return function(el) {
+ if (!el.href) return;
+
+ var url = window.location + ''
+ , href = el + '';
+
+ return truncateUrl(url, param) === truncateUrl(href, param);
+ };
+ },
+ ':default': function(el) {
+ return !!el.defaultSelected;
+ },
+ ':valid': function(el) {
+ return el.willValidate || (el.validity && el.validity.valid);
+ },
+ ':invalid': function(el) {
+ return !selectors[':valid'](el);
+ },
+ ':in-range': function(el) {
+ return el.value > el.min && el.value <= el.max;
+ },
+ ':out-of-range': function(el) {
+ return !selectors[':in-range'](el);
+ },
+ ':required': function(el) {
+ return !!el.required;
+ },
+ ':optional': function(el) {
+ return !el.required;
+ },
+ ':read-only': function(el) {
+ if (el.readOnly) return true;
+
+ var attr = el.getAttribute('contenteditable')
+ , prop = el.contentEditable
+ , name = el.nodeName.toLowerCase();
+
+ name = name !== 'input' && name !== 'textarea';
+
+ return (name || el.disabled) && attr == null && prop !== 'true';
+ },
+ ':read-write': function(el) {
+ return !selectors[':read-only'](el);
+ },
+ ':hover': function() {
+ throw new Error(':hover is not supported.');
+ },
+ ':active': function() {
+ throw new Error(':active is not supported.');
+ },
+ ':link': function() {
+ throw new Error(':link is not supported.');
+ },
+ ':visited': function() {
+ throw new Error(':visited is not supported.');
+ },
+ ':column': function() {
+ throw new Error(':column is not supported.');
+ },
+ ':nth-column': function() {
+ throw new Error(':nth-column is not supported.');
+ },
+ ':nth-last-column': function() {
+ throw new Error(':nth-last-column is not supported.');
+ },
+ ':current': function() {
+ throw new Error(':current is not supported.');
+ },
+ ':past': function() {
+ throw new Error(':past is not supported.');
+ },
+ ':future': function() {
+ throw new Error(':future is not supported.');
+ },
+ // Non-standard, for compatibility purposes.
+ ':contains': function(param) {
+ return function(el) {
+ var text = el.innerText || el.textContent || el.value || '';
+ return text.indexOf(param) !== -1;
+ };
+ },
+ ':has': function(param) {
+ return function(el) {
+ return find(param, el).length > 0;
+ };
+ }
+ // Potentially add more pseudo selectors for
+ // compatibility with sizzle and most other
+ // selector engines (?).
+};
+
+/**
+ * Attribute Operators
+ */
+
+var operators = {
+ '-': function() {
+ return true;
+ },
+ '=': function(attr, val) {
+ return attr === val;
+ },
+ '*=': function(attr, val) {
+ return attr.indexOf(val) !== -1;
+ },
+ '~=': function(attr, val) {
+ var i
+ , s
+ , f
+ , l;
+
+ for (s = 0; true; s = i + 1) {
+ i = attr.indexOf(val, s);
+ if (i === -1) return false;
+ f = attr[i - 1];
+ l = attr[i + val.length];
+ if ((!f || f === ' ') && (!l || l === ' ')) return true;
+ }
+ },
+ '|=': function(attr, val) {
+ var i = attr.indexOf(val)
+ , l;
+
+ if (i !== 0) return;
+ l = attr[i + val.length];
+
+ return l === '-' || !l;
+ },
+ '^=': function(attr, val) {
+ return attr.indexOf(val) === 0;
+ },
+ '$=': function(attr, val) {
+ var i = attr.lastIndexOf(val);
+ return i !== -1 && i + val.length === attr.length;
+ },
+ // non-standard
+ '!=': function(attr, val) {
+ return attr !== val;
+ }
+};
+
+/**
+ * Combinator Logic
+ */
+
+var combinators = {
+ ' ': function(test) {
+ return function(el) {
+ /*jshint -W084 */
+ while (el = el.parentNode) {
+ if (test(el)) return el;
+ }
+ };
+ },
+ '>': function(test) {
+ return function(el) {
+ /*jshint -W084 */
+ if (el = el.parentNode) {
+ return test(el) && el;
+ }
+ };
+ },
+ '+': function(test) {
+ return function(el) {
+ /*jshint -W084 */
+ if (el = prev(el)) {
+ return test(el) && el;
+ }
+ };
+ },
+ '~': function(test) {
+ return function(el) {
+ /*jshint -W084 */
+ while (el = prev(el)) {
+ if (test(el)) return el;
+ }
+ };
+ },
+ 'noop': function(test) {
+ return function(el) {
+ return test(el) && el;
+ };
+ },
+ 'ref': function(test, name) {
+ var node;
+
+ function ref(el) {
+ var doc = el.ownerDocument
+ , nodes = doc.getElementsByTagName('*')
+ , i = nodes.length;
+
+ while (i--) {
+ node = nodes[i];
+ if (ref.test(el)) {
+ node = null;
+ return true;
+ }
+ }
+
+ node = null;
+ }
+
+ ref.combinator = function(el) {
+ if (!node || !node.getAttribute) return;
+
+ var attr = node.getAttribute(name) || '';
+ if (attr[0] === '#') attr = attr.substring(1);
+
+ if (attr === el.id && test(node)) {
+ return node;
+ }
+ };
+
+ return ref;
+ }
+};
+
+/**
+ * Grammar
+ */
+
+var rules = {
+ escape: /\\(?:[^0-9A-Fa-f\r\n]|[0-9A-Fa-f]{1,6}[\r\n\t ]?)/g,
+ str_escape: /(escape)|\\(\n|\r\n?|\f)/g,
+ nonascii: /[\u00A0-\uFFFF]/,
+ cssid: /(?:(?!-?[0-9])(?:escape|nonascii|[-_a-zA-Z0-9])+)/,
+ qname: /^ *(cssid|\*)/,
+ simple: /^(?:([.#]cssid)|pseudo|attr)/,
+ ref: /^ *\/(cssid)\/ */,
+ combinator: /^(?: +([^ \w*.#\\]) +|( )+|([^ \w*.#\\]))(?! *$)/,
+ attr: /^\[(cssid)(?:([^\w]?=)(inside))?\]/,
+ pseudo: /^(:cssid)(?:\((inside)\))?/,
+ inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
+ ident: /^(cssid)$/
+};
+
+rules.cssid = replace(rules.cssid, 'nonascii', rules.nonascii);
+rules.cssid = replace(rules.cssid, 'escape', rules.escape);
+rules.qname = replace(rules.qname, 'cssid', rules.cssid);
+rules.simple = replace(rules.simple, 'cssid', rules.cssid);
+rules.ref = replace(rules.ref, 'cssid', rules.cssid);
+rules.attr = replace(rules.attr, 'cssid', rules.cssid);
+rules.pseudo = replace(rules.pseudo, 'cssid', rules.cssid);
+rules.inside = replace(rules.inside, '[^"\'>]*', rules.inside);
+rules.attr = replace(rules.attr, 'inside', makeInside('\\[', '\\]'));
+rules.pseudo = replace(rules.pseudo, 'inside', makeInside('\\(', '\\)'));
+rules.simple = replace(rules.simple, 'pseudo', rules.pseudo);
+rules.simple = replace(rules.simple, 'attr', rules.attr);
+rules.ident = replace(rules.ident, 'cssid', rules.cssid);
+rules.str_escape = replace(rules.str_escape, 'escape', rules.escape);
+
+/**
+ * Compiling
+ */
+
+var compile = function(sel_) {
+ var sel = sel_.replace(/^\s+|\s+$/g, '')
+ , test
+ , filter = []
+ , buff = []
+ , subject
+ , qname
+ , cap
+ , op
+ , ref;
+
+ /*jshint -W084 */
+ while (sel) {
+ if (cap = rules.qname.exec(sel)) {
+ sel = sel.substring(cap[0].length);
+ qname = decodeid(cap[1]);
+ buff.push(tok(qname, true));
+ } else if (cap = rules.simple.exec(sel)) {
+ sel = sel.substring(cap[0].length);
+ qname = '*';
+ buff.push(tok(qname, true));
+ buff.push(tok(cap));
+ } else {
+ throw new SyntaxError('Invalid selector.');
+ }
+
+ while (cap = rules.simple.exec(sel)) {
+ sel = sel.substring(cap[0].length);
+ buff.push(tok(cap));
+ }
+
+ if (sel[0] === '!') {
+ sel = sel.substring(1);
+ subject = makeSubject();
+ subject.qname = qname;
+ buff.push(subject.simple);
+ }
+
+ if (cap = rules.ref.exec(sel)) {
+ sel = sel.substring(cap[0].length);
+ ref = combinators.ref(makeSimple(buff), decodeid(cap[1]));
+ filter.push(ref.combinator);
+ buff = [];
+ continue;
+ }
+
+ if (cap = rules.combinator.exec(sel)) {
+ sel = sel.substring(cap[0].length);
+ op = cap[1] || cap[2] || cap[3];
+ if (op === ',') {
+ filter.push(combinators.noop(makeSimple(buff)));
+ break;
+ }
+ } else {
+ op = 'noop';
+ }
+
+ if (!combinators[op]) { throw new SyntaxError('Bad combinator.'); }
+ filter.push(combinators[op](makeSimple(buff)));
+ buff = [];
+ }
+
+ test = makeTest(filter);
+ test.qname = qname;
+ test.sel = sel;
+
+ if (subject) {
+ subject.lname = test.qname;
+
+ subject.test = test;
+ subject.qname = subject.qname;
+ subject.sel = test.sel;
+ test = subject;
+ }
+
+ if (ref) {
+ ref.test = test;
+ ref.qname = test.qname;
+ ref.sel = test.sel;
+ test = ref;
+ }
+
+ return test;
+};
+
+var tok = function(cap, qname) {
+ // qname
+ if (qname) {
+ return cap === '*'
+ ? selectors['*']
+ : selectors.type(cap);
+ }
+
+ // class/id
+ if (cap[1]) {
+ return cap[1][0] === '.'
+ // XXX unescape here? or in attr?
+ ? selectors.attr('class', '~=', decodeid(cap[1].substring(1)), false)
+ : selectors.attr('id', '=', decodeid(cap[1].substring(1)), false);
+ }
+
+ // pseudo-name
+ // inside-pseudo
+ if (cap[2]) {
+ return cap[3]
+ ? selectors[decodeid(cap[2])](unquote(cap[3]))
+ : selectors[decodeid(cap[2])];
+ }
+
+ // attr name
+ // attr op
+ // attr value
+ if (cap[4]) {
+ var value = cap[6];
+ var i = /["'\s]\s*I$/i.test(value);
+ if (i) {
+ value = value.replace(/\s*I$/i, '');
+ }
+ return selectors.attr(decodeid(cap[4]), cap[5] || '-', unquote(value), i);
+ }
+
+ throw new SyntaxError('Unknown Selector.');
+};
+
+var makeSimple = function(func) {
+ var l = func.length
+ , i;
+
+ // Potentially make sure
+ // `el` is truthy.
+ if (l < 2) return func[0];
+
+ return function(el) {
+ if (!el) return;
+ for (i = 0; i < l; i++) {
+ if (!func[i](el)) return;
+ }
+ return true;
+ };
+};
+
+var makeTest = function(func) {
+ if (func.length < 2) {
+ return function(el) {
+ return !!func[0](el);
+ };
+ }
+ return function(el) {
+ var i = func.length;
+ while (i--) {
+ if (!(el = func[i](el))) return;
+ }
+ return true;
+ };
+};
+
+var makeSubject = function() {
+ var target;
+
+ function subject(el) {
+ var node = el.ownerDocument
+ , scope = node.getElementsByTagName(subject.lname)
+ , i = scope.length;
+
+ while (i--) {
+ if (subject.test(scope[i]) && target === el) {
+ target = null;
+ return true;
+ }
+ }
+
+ target = null;
+ }
+
+ subject.simple = function(el) {
+ target = el;
+ return true;
+ };
+
+ return subject;
+};
+
+var compileGroup = function(sel) {
+ var test = compile(sel)
+ , tests = [ test ];
+
+ while (test.sel) {
+ test = compile(test.sel);
+ tests.push(test);
+ }
+
+ if (tests.length < 2) return test;
+
+ return function(el) {
+ var l = tests.length
+ , i = 0;
+
+ for (; i < l; i++) {
+ if (tests[i](el)) return true;
+ }
+ };
+};
+
+/**
+ * Selection
+ */
+
+var find = function(sel, node) {
+ var results = []
+ , test = compile(sel)
+ , scope = node.getElementsByTagName(test.qname)
+ , i = 0
+ , el;
+
+ /*jshint -W084 */
+ while (el = scope[i++]) {
+ if (test(el)) results.push(el);
+ }
+
+ if (test.sel) {
+ while (test.sel) {
+ test = compile(test.sel);
+ scope = node.getElementsByTagName(test.qname);
+ i = 0;
+ /*jshint -W084 */
+ while (el = scope[i++]) {
+ if (test(el) && indexOf.call(results, el) === -1) {
+ results.push(el);
+ }
+ }
+ }
+ results.sort(order);
+ }
+
+ return results;
+};
+
+/**
+ * Expose
+ */
+
+module.exports = exports = function(sel, context) {
+ /* when context isn't a DocumentFragment and the selector is simple: */
+ var id, r;
+ if (context.nodeType !== 11 && sel.indexOf(' ') === -1) {
+ if (sel[0] === '#' && context.rooted && /^#[A-Z_][-A-Z0-9_]*$/i.test(sel)) {
+ if (context.doc._hasMultipleElementsWithId) {
+ id = sel.substring(1);
+ if (!context.doc._hasMultipleElementsWithId(id)) {
+ r = context.doc.getElementById(id);
+ return r ? [r] : [];
+ }
+ }
+ }
+ if (sel[0] === '.' && /^\.\w+$/.test(sel)) {
+ return context.getElementsByClassName(sel.substring(1));
+ }
+ if (/^\w+$/.test(sel)) {
+ return context.getElementsByTagName(sel);
+ }
+ }
+ /* do things the hard/slow way */
+ return find(sel, context);
+};
+
+exports.selectors = selectors;
+exports.operators = operators;
+exports.combinators = combinators;
+
+exports.matches = function(el, sel) {
+ var test = { sel: sel };
+ do {
+ test = compile(test.sel);
+ if (test(el)) { return true; }
+ } while (test.sel);
+ return false;
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/sloppy.js
@@ -1,0 +1,24 @@
+/* Domino uses sloppy-mode features (in particular, `with`) for a few
+ * minor things. This file encapsulates all the sloppiness; every
+ * other module should be strict. */
+/* jshint strict: false */
+/* jshint evil: true */
+/* jshint -W085 */
+module.exports = {
+ Window_run: function _run(code, file) {
+ if (file) code += '\n//@ sourceURL=' + file;
+ with(this) eval(code);
+ },
+ EventHandlerBuilder_build: function build() {
+ try {
+ with(this.document.defaultView || Object.create(null))
+ with(this.document)
+ with(this.form)
+ with(this.element)
+ return eval("(function(event){" + this.body + "})");
+ }
+ catch (err) {
+ return function() { throw err; };
+ }
+ }
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/svg.js
@@ -1,0 +1,57 @@
+"use strict";
+var Element = require('./Element');
+var defineElement = require('./defineElement');
+var utils = require('./utils');
+var CSSStyleDeclaration = require('./CSSStyleDeclaration');
+
+var svgElements = exports.elements = {};
+var svgNameToImpl = Object.create(null);
+
+exports.createElement = function(doc, localName, prefix) {
+ var impl = svgNameToImpl[localName] || SVGElement;
+ return new impl(doc, localName, prefix);
+};
+
+function define(spec) {
+ return defineElement(spec, SVGElement, svgElements, svgNameToImpl);
+}
+
+var SVGElement = define({
+ superclass: Element,
+ ctor: function SVGElement(doc, localName, prefix) {
+ Element.call(this, doc, localName, utils.NAMESPACE.SVG, prefix);
+ },
+ props: {
+ style: { get: function() {
+ if (!this._style)
+ this._style = new CSSStyleDeclaration(this);
+ return this._style;
+ }}
+ }
+});
+
+define({
+ ctor: function SVGSVGElement(doc, localName, prefix) {
+ SVGElement.call(this, doc, localName, prefix);
+ },
+ tag: 'svg',
+ props: {
+ createSVGRect: { value: function () {
+ return exports.createElement(this.ownerDocument, 'rect', null);
+ } }
+ }
+});
+
+define({
+ tags: [
+ 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform',
+ 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix',
+ 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight',
+ 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode',
+ 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter',
+ 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g',
+ 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph',
+ 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style',
+ 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'
+ ]
+});
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/utils.js
@@ -1,0 +1,85 @@
+"use strict";
+var DOMException = require('./DOMException');
+var ERR = DOMException;
+var isApiWritable = require("./config").isApiWritable;
+
+exports.NAMESPACE = {
+ HTML: 'http://www.w3.org/1999/xhtml',
+ XML: 'http://www.w3.org/XML/1998/namespace',
+ XMLNS: 'http://www.w3.org/2000/xmlns/',
+ MATHML: 'http://www.w3.org/1998/Math/MathML',
+ SVG: 'http://www.w3.org/2000/svg',
+ XLINK: 'http://www.w3.org/1999/xlink'
+};
+
+//
+// Shortcut functions for throwing errors of various types.
+//
+exports.IndexSizeError = function() { throw new DOMException(ERR.INDEX_SIZE_ERR); };
+exports.HierarchyRequestError = function() { throw new DOMException(ERR.HIERARCHY_REQUEST_ERR); };
+exports.WrongDocumentError = function() { throw new DOMException(ERR.WRONG_DOCUMENT_ERR); };
+exports.InvalidCharacterError = function() { throw new DOMException(ERR.INVALID_CHARACTER_ERR); };
+exports.NoModificationAllowedError = function() { throw new DOMException(ERR.NO_MODIFICATION_ALLOWED_ERR); };
+exports.NotFoundError = function() { throw new DOMException(ERR.NOT_FOUND_ERR); };
+exports.NotSupportedError = function() { throw new DOMException(ERR.NOT_SUPPORTED_ERR); };
+exports.InvalidStateError = function() { throw new DOMException(ERR.INVALID_STATE_ERR); };
+exports.SyntaxError = function() { throw new DOMException(ERR.SYNTAX_ERR); };
+exports.InvalidModificationError = function() { throw new DOMException(ERR.INVALID_MODIFICATION_ERR); };
+exports.NamespaceError = function() { throw new DOMException(ERR.NAMESPACE_ERR); };
+exports.InvalidAccessError = function() { throw new DOMException(ERR.INVALID_ACCESS_ERR); };
+exports.TypeMismatchError = function() { throw new DOMException(ERR.TYPE_MISMATCH_ERR); };
+exports.SecurityError = function() { throw new DOMException(ERR.SECURITY_ERR); };
+exports.NetworkError = function() { throw new DOMException(ERR.NETWORK_ERR); };
+exports.AbortError = function() { throw new DOMException(ERR.ABORT_ERR); };
+exports.UrlMismatchError = function() { throw new DOMException(ERR.URL_MISMATCH_ERR); };
+exports.QuotaExceededError = function() { throw new DOMException(ERR.QUOTA_EXCEEDED_ERR); };
+exports.TimeoutError = function() { throw new DOMException(ERR.TIMEOUT_ERR); };
+exports.InvalidNodeTypeError = function() { throw new DOMException(ERR.INVALID_NODE_TYPE_ERR); };
+exports.DataCloneError = function() { throw new DOMException(ERR.DATA_CLONE_ERR); };
+
+exports.nyi = function(what) {
+ throw new Error("NotYetImplemented " + what);
+};
+
+exports.shouldOverride = function() {
+ throw new Error("Abstract function; should be overriding in subclass.");
+};
+
+exports.assert = function(expr, msg) {
+ if (!expr) {
+ throw new Error("Assertion failed: " + (msg || "") + "\n" + new Error().stack);
+ }
+};
+
+exports.expose = function(src, c) {
+ for (var n in src) {
+ Object.defineProperty(c.prototype, n, { value: src[n], writable: isApiWritable });
+ }
+};
+
+exports.merge = function(a, b) {
+ for (var n in b) {
+ a[n] = b[n];
+ }
+};
+
+// Compare two nodes based on their document order. This function is intended
+// to be passed to sort(). Assumes that the array being sorted does not
+// contain duplicates. And that all nodes are connected and comparable.
+// Clever code by ppk via jeresig.
+exports.documentOrder = function(n,m) {
+ /* jshint bitwise: false */
+ return 3 - (n.compareDocumentPosition(m) & 6);
+};
+
+exports.toASCIILowerCase = function(s) {
+ return s.replace(/[A-Z]+/g, function(c) {
+ return c.toLowerCase();
+ });
+};
+
+exports.toASCIIUpperCase = function(s) {
+ return s.replace(/[a-z]+/g, function(c) {
+ return c.toUpperCase();
+ });
+};
--- /dev/null
+++ b/cmd/gojafs/domino/domino-lib/xmlnames.js
@@ -1,0 +1,91 @@
+"use strict";
+// This grammar is from the XML and XML Namespace specs. It specifies whether
+// a string (such as an element or attribute name) is a valid Name or QName.
+//
+// Name ::= NameStartChar (NameChar)*
+// NameStartChar ::= ":" | [A-Z] | "_" | [a-z] |
+// [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
+// [#x370-#x37D] | [#x37F-#x1FFF] |
+// [#x200C-#x200D] | [#x2070-#x218F] |
+// [#x2C00-#x2FEF] | [#x3001-#xD7FF] |
+// [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
+// [#x10000-#xEFFFF]
+//
+// NameChar ::= NameStartChar | "-" | "." | [0-9] |
+// #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+//
+// QName ::= PrefixedName| UnprefixedName
+// PrefixedName ::= Prefix ':' LocalPart
+// UnprefixedName ::= LocalPart
+// Prefix ::= NCName
+// LocalPart ::= NCName
+// NCName ::= Name - (Char* ':' Char*)
+// # An XML Name, minus the ":"
+//
+
+exports.isValidName = isValidName;
+exports.isValidQName = isValidQName;
+
+// Most names will be ASCII only. Try matching against simple regexps first
+var simplename = /^[_:A-Za-z][-.:\w]+$/;
+var simpleqname = /^([_A-Za-z][-.\w]+|[_A-Za-z][-.\w]+:[_A-Za-z][-.\w]+)$/;
+
+// If the regular expressions above fail, try more complex ones that work
+// for any identifiers using codepoints from the Unicode BMP
+var ncnamestartchars = "_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
+var ncnamechars = "-._A-Za-z0-9\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0300-\u037D\u037F-\u1FFF\u200C\u200D\u203f\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
+
+var ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*";
+var namestartchars = ncnamestartchars + ":";
+var namechars = ncnamechars + ":";
+var name = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$");
+var qname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$");
+
+// XML says that these characters are also legal:
+// [#x10000-#xEFFFF]. So if the patterns above fail, and the
+// target string includes surrogates, then try the following
+// patterns that allow surrogates and then run an extra validation
+// step to make sure that the surrogates are in valid pairs and in
+// the right range. Note that since the characters \uf0000 to \u1f0000
+// are not allowed, it means that the high surrogate can only go up to
+// \uDB7f instead of \uDBFF.
+var hassurrogates = /[\uD800-\uDB7F\uDC00-\uDFFF]/;
+var surrogatechars = /[\uD800-\uDB7F\uDC00-\uDFFF]/g;
+var surrogatepairs = /[\uD800-\uDB7F][\uDC00-\uDFFF]/g;
+
+// Modify the variables above to allow surrogates
+ncnamestartchars += "\uD800-\uDB7F\uDC00-\uDFFF";
+ncnamechars += "\uD800-\uDB7F\uDC00-\uDFFF";
+ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*";
+namestartchars = ncnamestartchars + ":";
+namechars = ncnamechars + ":";
+
+// Build another set of regexps that include surrogates
+var surrogatename = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$");
+var surrogateqname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$");
+
+function isValidName(s) {
+ if (simplename.test(s)) return true; // Plain ASCII
+ if (name.test(s)) return true; // Unicode BMP
+
+ // Maybe the tests above failed because s includes surrogate pairs
+ // Most likely, though, they failed for some more basic syntax problem
+ if (!hassurrogates.test(s)) return false;
+
+ // Is the string a valid name if we allow surrogates?
+ if (!surrogatename.test(s)) return false;
+
+ // Finally, are the surrogates all correctly paired up?
+ var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs);
+ return pairs !== null && 2*pairs.length === chars.length;
+}
+
+function isValidQName(s) {
+ if (simpleqname.test(s)) return true; // Plain ASCII
+ if (qname.test(s)) return true; // Unicode BMP
+
+ if (!hassurrogates.test(s)) return false;
+ if (!surrogateqname.test(s)) return false;
+ var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs);
+ return pairs !== null && 2*pairs.length === chars.length;
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domino.go
@@ -1,0 +1,401 @@
+package domino
+
+import (
+ "bytes"
+ "embed"
+ "errors"
+ "fmt"
+ "github.com/dop251/goja"
+ "github.com/dop251/goja/parser"
+ "github.com/dop251/goja_nodejs/console"
+ "github.com/dop251/goja_nodejs/eventloop"
+ "github.com/dop251/goja_nodejs/require"
+ "io/ioutil"
+ "github.com/psilva261/opossum/logger"
+ "net/http"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "strconv"
+ "strings"
+ "syscall"
+ "time"
+)
+
+var DebugDumpJS *bool
+var log *logger.Logger
+var timeout = 60*time.Second
+
+//go:embed domino-lib/*js
+var lib embed.FS
+
+//go:embed domintf.js
+var domIntfJs embed.FS
+
+var domIntf string
+
+func init() {
+ data, err := domIntfJs.ReadFile("domintf.js")
+ if err != nil {
+ panic(err.Error())
+ }
+ domIntf = string(data)
+}
+
+func SetLogger(l *logger.Logger) {
+ log = l
+}
+
+type Mutation struct {
+ time.Time
+ Type int
+ Sel string
+}
+
+type Domino struct {
+ loop *eventloop.EventLoop
+ html string
+ outputHtml string
+ domChange chan Mutation
+ query func(sel, prop string) (val string, err error)
+ xhrq func(req *http.Request) (resp *http.Response, err error)
+}
+
+func NewDomino(
+ html string,
+ xhr func(req *http.Request) (resp *http.Response, err error),
+ query func(sel, prop string) (val string, err error),
+) (d *Domino) {
+ d = &Domino{
+ html: html,
+ xhrq: xhr,
+ domChange: make(chan Mutation, 100),
+ query: query,
+ }
+ return
+}
+
+func (d *Domino) Start() {
+ log.Printf("Start event loop")
+ d.loop = eventloop.NewEventLoop()
+
+ d.loop.Start()
+ log.Printf("event loop started")
+}
+
+func (d *Domino) Stop() {
+ d.loop.Stop()
+}
+
+func IntrospectError(err error, script string) {
+ prefix := "Line "
+ i := strings.Index(err.Error(), prefix)
+ if i > 0 {
+ i += len(prefix)
+ s := err.Error()[i:]
+ yxStart := strings.Split(s, " ")[0]
+ yx := strings.Split(yxStart, ":")
+ y, _ := strconv.Atoi(yx[0])
+ x, _ := strconv.Atoi(yx[1])
+ lines := strings.Split(script, "\n")
+
+ if y - 1 > len(lines) - 1 {
+ y = len(lines)
+ }
+
+ if wholeLine := lines[y-1]; len(wholeLine) > 100 {
+ from := x - 50
+ to := x + 50
+ if from < 0 {
+ from = 0
+ }
+ if to >= len(wholeLine) {
+ to = len(wholeLine) - 1
+ }
+ log.Printf("the line: %v", wholeLine[from:to])
+ } else {
+ if y > 0 && len(lines[y-1]) < 120 {
+ log.Printf("%v: %v", y-1, lines[y-1])
+ }
+ if y < len(lines) {
+ log.Printf("%v: %v", y, lines[y])
+ }
+ if y+1 < len(lines) && len(lines[y+1]) < 120 {
+ log.Printf("%v: %v", y+1, lines[y+1])
+ }
+ }
+ }
+}
+
+func printCode(code string, maxWidth int) {
+ if maxWidth > len(code) {
+ maxWidth = len(code)
+ }
+ log.Infof("js code: %v", code[:maxWidth])
+}
+
+func srcLoader(fn string) ([]byte, error) {
+ path := filepath.FromSlash(fn)
+ if !strings.Contains(path, "domino-lib/") || !strings.HasSuffix(path, ".js") {
+ return nil, require.ModuleFileDoesNotExistError
+ }
+ data, err := lib.ReadFile(path)
+ if err != nil {
+ if os.IsNotExist(err) || errors.Is(err, syscall.EISDIR) {
+ err = require.ModuleFileDoesNotExistError
+ } else {
+ log.Errorf("srcLoader: handling of require('%v') is not implemented", fn)
+ }
+ }
+ return data, err
+}
+
+func (d *Domino) Exec(script string, initial bool) (res string, err error) {
+ r := regexp.MustCompile(`^\s*<!--`)
+ script = r.ReplaceAllString(script, "//")
+ SCRIPT := domIntf + script
+ if !initial {
+ SCRIPT = script
+ }
+
+ if *DebugDumpJS {
+ ioutil.WriteFile("main.js", []byte(SCRIPT), 0644)
+ }
+
+ ready := make(chan goja.Value)
+ errCh := make(chan error)
+ intCh := make(chan int)
+ go func() {
+ d.loop.RunOnLoop(func(vm *goja.Runtime) {
+ log.Printf("RunOnLoop")
+
+ if initial {
+ vm.SetParserOptions(parser.WithDisableSourceMaps)
+
+ // find domino-lib folder
+ registry := require.NewRegistry(
+ require.WithGlobalFolders("."),
+ require.WithLoader(
+ require.SourceLoader(srcLoader),
+ ),
+ )
+
+ console.Enable(vm)
+ registry.Enable(vm)
+
+ type S struct {
+ Buf string `json:"buf"`
+ HTML string `json:"html"`
+ Referrer func() string `json:"referrer"`
+ Style func(string, string, string, string) string `json:"style"`
+ XHR func(string, string, map[string]string, string, func(string, string)) `json:"xhr"`
+ Mutated func(int, string) `json:"mutated"`
+ }
+
+ vm.SetFieldNameMapper(goja.TagFieldNameMapper("json", true))
+ vm.Set("opossum", S{
+ HTML: d.html,
+ Buf: "yolo",
+ Referrer: func() string { return "https://example.com" },
+ Style: func(sel, pseudo, prop, prop2 string) string {
+ v, err := d.query(sel, prop)
+ if err != nil {
+ log.Errorf("devjs: domino: query %v: %v", sel, err)
+ return ""
+ }
+ return v
+ },
+ XHR: d.xhr,
+ Mutated: d.mutated,
+ })
+ }
+
+ go func() {
+ for _ = range intCh {
+ vm.Interrupt("halt")
+ }
+ }()
+
+ vv, err := vm.RunString(SCRIPT)
+ if err != nil {
+ IntrospectError(err, script)
+ errCh <- fmt.Errorf("run program: %w", err)
+ } else {
+ ready <- vv
+ }
+ })
+ }()
+
+ for {
+ select {
+ case v := <-ready:
+ log.Infof("ready")
+ <-time.After(10 * time.Millisecond)
+ if v != nil {
+ res = v.String()
+ }
+ goto cleanup
+ case er := <- errCh:
+ log.Infof("err")
+ <-time.After(10 * time.Millisecond)
+ err = fmt.Errorf("event loop: %w", er)
+ goto cleanup
+ case <-time.After(timeout):
+ log.Errorf("Interrupt JS after %v", timeout)
+ intCh <- 1
+ }
+ }
+
+cleanup:
+ close(ready)
+ close(errCh)
+ close(intCh)
+
+ return
+}
+
+func (d *Domino) Exec6(script string, initial bool) (res string, err error) {
+ cmd := exec.Command("6to5")
+ cmd.Stdin = strings.NewReader(script)
+ var out bytes.Buffer
+ cmd.Stdout = &out
+ if err = cmd.Run(); err != nil {
+ return "", fmt.Errorf("6to5: %w", err)
+ }
+ return d.Exec(out.String(), initial)
+}
+
+// CloseDoc fires DOMContentLoaded to trigger $(document).ready(..)
+func (d *Domino) CloseDoc() (err error) {
+ _, err = d.Exec("if (this.document) document.close();", false)
+ return
+}
+
+// TriggerClick, and return the result html
+// ...then HTML5 parse it, diff the node tree
+// (probably faster and cleaner than anything else)
+func (d *Domino) TriggerClick(selector string) (newHTML string, ok bool, err error) {
+ res, err := d.Exec(`
+ var sel = '` + selector + `';
+ var el = document.querySelector(sel);
+
+ console.log('query ' + sel);
+
+ if (!el) {
+ console.log('el is null/undefined');
+ //console.log('html:');
+ //console.log(document.documentElement.innerHTML)
+ null;
+ } else if (el._listeners && el._listeners.click) {
+ var fn = el.click.bind(el);
+
+ if (fn) {
+ console.log(' call click handler...');
+ fn();
+ }
+
+ !!fn;
+ } else {
+ false;
+ }
+ `, false)
+
+ if ok = res == "true"; ok {
+ newHTML, ok, err = d.TrackChanges()
+ }
+
+ return
+}
+
+// Put change into html (e.g. from input field mutation)
+func (d *Domino) PutAttr(selector, attr, val string) (ok bool, err error) {
+ res, err := d.Exec(`
+ var sel = '` + selector + `';
+ var el = document.querySelector(sel);
+ el.attr('` + attr + `', '` + val + `');
+ !!el;
+ `, false)
+
+ ok = res == "true"
+
+ return
+}
+
+func (d *Domino) TrackChanges() (html string, changed bool, err error) {
+ outer:
+ for {
+ // TODO: either add other change types like ajax begin/end or
+ // just have one channel for all events worth waiting for.
+ select {
+ case <-d.domChange:
+ changed = true
+ case <-time.After(time.Second):
+ break outer
+ }
+ }
+
+ if changed {
+ html, err = d.Exec("document.querySelector('html').innerHTML;", false)
+ if err != nil {
+ return
+ }
+ }
+ d.outputHtml = html
+ return
+}
+
+func (d *Domino) xhr(method, uri string, h map[string]string, data string, cb func(data string, err string)) {
+ req, err := http.NewRequest(method, /*u.String()*/uri, strings.NewReader(data))
+ if err != nil {
+ cb("", err.Error())
+ return
+ }
+ for k, v := range h {
+ req.Header.Add(k, v)
+ }
+ go func() {
+ resp, err := d.xhrq(req)
+ if err != nil {
+ cb("", err.Error())
+ return
+ }
+ //defer resp.Body.Close()
+ bs, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ cb("", err.Error())
+ return
+ }
+ d.loop.RunOnLoop(func(*goja.Runtime) {
+ defer func() {
+ if r := recover(); r != nil {
+ log.Errorf("recovered in xhr: %v", r)
+ }
+ }()
+ cb(string(bs), "")
+ })
+ }()
+}
+
+func (d *Domino) mutated(t int, q string) {
+ m := Mutation{
+ Time: time.Now(),
+ Type: t,
+ Sel: q,
+ }
+
+ select {
+ case d.domChange <- m:
+ default:
+ log.Printf("dom changes backlog full")
+ }
+}
+
+// AJAX:
+// https://stackoverflow.com/questions/7086858/loading-ajax-app-with-jsdom
+
+// Babel on Goja:
+// https://github.com/dop251/goja/issues/5#issuecomment-259996573
+
+// Goja supports ES5.1 which is essentially JS assembly:
+// https://github.com/dop251/goja/issues/76#issuecomment-399253779
--- /dev/null
+++ b/cmd/gojafs/domino/domino_test.go
@@ -1,0 +1,648 @@
+package domino
+
+import (
+ "github.com/psilva261/opossum/logger"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "time"
+)
+
+const simpleHTML = `
+<html>
+<body>
+<h1 id="title">Hello</h1>
+</body>
+</html>
+`
+
+func init() {
+ f := false
+ t := true
+ DebugDumpJS = &t
+ logger.Quiet = &f
+ logger.Init()
+ log = &logger.Logger{Debug: true}
+}
+
+func TestSimple(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ s := `
+ var state = 'empty';
+ var a = 1;
+ b = 2;
+ `
+ _, err := d.Exec(s, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ s2 := `
+ (function() {
+ if (state !== 'empty') throw new Exception(state);
+
+ state = a + b;
+ })()
+ var a = 1;
+ b = 2;
+ `
+ _, err = d.Exec(s2, false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d.Stop()
+}
+
+func TestGlobals(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+}
+
+func TestTrackChanges(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ _, err := d.Exec(``, true)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ // 0th time: init
+ if _, _, err = d.TrackChanges(); err != nil {
+ t.Fatalf(err.Error())
+ }
+ // 1st time: no change
+ html, changed, err := d.TrackChanges()
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if changed == true {
+ t.Fatal()
+ }
+ // 2nd time: no change
+ html, changed, err = d.TrackChanges()
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if changed == true {
+ t.Fatal()
+ }
+ _, err = d.Exec("document.getElementById('title').innerHTML='new title'; true;", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ // 3rd time: yes change
+ html, changed, err = d.TrackChanges()
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if html == "" {
+ t.Fatalf(err.Error())
+ }
+ if changed == false {
+ t.Fatal()
+ }
+ if !strings.Contains(html, "new title") {
+ t.Fatalf(html)
+ }
+ d.Stop()
+}
+
+/*func TestWindowEqualsGlobal(t *testing.T) {
+ const h = `
+ <html>
+ <body>
+ <script>
+ a = 2;
+ window.b = 5;
+ </script>
+ <script>
+ console.log('window.a=', window.a);
+ console.log('wot');
+ console.log('window.b=', window.b);
+ console.log('wit');
+ window.a++;
+ b++;
+ </script>
+ </body>
+ </html>
+ `
+ d := NewDomino(h)
+ d.Start()
+ err := d.ExecInlinedScripts()
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ res, err := d.Export("window.a")
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if !strings.Contains(res, "3") {
+ t.Fatalf(res)
+ }
+ res, err = d.Export("window.b")
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if !strings.Contains(res, "6") {
+ t.Fatalf(res)
+ }
+ d.Stop()
+}*/
+
+func TestES6(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ script := `
+ var foo = function(data={}) {}
+ var h = {
+ a: 1,
+ b: 11
+ };
+ var {a, b} = h;
+ `
+ _, err := d.Exec6(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ res, err := d.Exec("a+b", false)
+ t.Logf("res=%v", res)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if res != "12" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestWindowParent(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ script := `
+ console.log('Hello!!')
+ `
+ _, err := d.Exec(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ res, err := d.Exec("window === window.parent", false)
+ t.Logf("res=%v", res)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if res != "true" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestReferrer(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ script := `
+ document.referrer;
+ `
+ res, err := d.Exec(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if res != "https://example.com" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func handler(w http.ResponseWriter, r *http.Request) {
+ io.WriteString(w, "<html><body>Hello World!</body></html>")
+}
+
+func xhr(req *http.Request) (resp *http.Response, err error) {
+ w := httptest.NewRecorder()
+ handler(w, req)
+ resp = w.Result()
+ return resp, nil
+}
+
+func TestXMLHttpRequest(t *testing.T) {
+ d := NewDomino(simpleHTML, xhr, nil)
+ d.Start()
+ script := `
+ var oReq = new XMLHttpRequest();
+ var loaded = false;
+ oReq.addEventListener("load", function() {
+ loaded = true;
+ });
+ oReq.open("GET", "http://www.example.org/example.txt");
+ oReq.send();
+ `
+ _, err := d.Exec(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ <-time.After(time.Second)
+ res, err := d.Exec("oReq.responseText;", false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if !strings.Contains(res, "<html") {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestJQueryAjax(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(simpleHTML, xhr, nil)
+ d.Start()
+ script := `
+ var res;
+ $.ajax({
+ url: '/',
+ success: function() {
+ res = 'success';
+ },
+ error: function() {
+ res = 'err';
+ }
+ });
+ `
+ _, err = d.Exec(string(buf) + ";" + script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if err = d.CloseDoc(); err != nil {
+ t.Fatalf("%v", err)
+ }
+ <-time.After(time.Second)
+ res, err := d.Exec("res;", false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if res != "success" {
+ t.Fatalf(res)
+ }
+ d.Stop()
+}
+
+func TestJQueryAjax182(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/godoc/jquery-1.8.2.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(simpleHTML, xhr, nil)
+ d.Start()
+ script := `
+ var res;
+ $.ajax({
+ url: '/',
+ success: function() {
+ res = 'success';
+ },
+ error: function() {
+ res = 'err';
+ }
+ });
+ `
+ _, err = d.Exec(string(buf) + ";" + script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if err = d.CloseDoc(); err != nil {
+ t.Fatalf("%v", err)
+ }
+ <-time.After(5*time.Second)
+ res, err := d.Exec("res;", false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if res != "success" {
+ t.Fatalf(res)
+ }
+ d.Stop()
+}
+
+func TestNoJsCompatComment(t *testing.T) {
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ script := `
+
+<!-- This is an actual comment
+
+ ''.replace(/^\s*<!--/g, '');
+ const a = 1;
+ a + 7;
+// -->
+ `
+ res, err := d.Exec(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if res != "8" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestJQuery(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ script := `
+ $(document).ready(function() {
+ undefinedExpr
+ });
+ setTimeout(function() {
+ console.log("ok");
+ }, 1000);
+ var a = 1;
+ `
+ _, err = d.Exec(string(buf) + ";" + script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ res, err := d.Exec("a+1", false)
+ t.Logf("res=%v", res)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if res != "2" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestJQueryCss(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ h := `
+ <html>
+ <body>
+ <h1 id="title" style="display: inline-block;">Hello</h1>
+ </body>
+ </html>
+ `
+ q := func(sel, prop string) (val string, err error) {
+ if sel != "HTML > :nth-child(2) > :nth-child(1)" {
+ panic(sel)
+ }
+ if prop != "display" {
+ panic(prop)
+ }
+ return "inline-block", nil
+ }
+ d := NewDomino(h, nil, q)
+ d.Start()
+ _, err = d.Exec(string(buf), true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ res, err := d.Exec("$('h1').css('display')", false)
+ t.Logf("res=%v", res)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if res != "inline-block" {
+ t.Fatal()
+ }
+ d.Stop()
+}
+
+func TestGodoc(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/godoc/pkg.html")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(string(buf), nil, nil)
+ d.Start()
+ for i, fn := range []string{"initfuncs.js", "jquery-1.8.2.js", "goversion.js", "godocs.js"} {
+ buf, err := ioutil.ReadFile("../../../js/godoc/"+fn)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ _, err = d.Exec(string(buf), i == 0)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ }
+ d.Stop()
+}
+
+func TestGoplayground(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/godoc/golang.html")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(string(buf), nil, nil)
+ d.Start()
+ for i, fn := range []string{"initfuncs.js", "jquery-1.8.2.js", "playground.js", "goversion.js", "godocs.js", "golang.js"} {
+ buf, err := ioutil.ReadFile("../../../js/godoc/"+fn)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ _, err = d.Exec(string(buf), i == 0)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ }
+ res, err := d.Exec("window.playground", false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if !strings.Contains(res, "function playground(opts) {") {
+ t.Fatalf("%v", res)
+ }
+
+ d.Stop()
+}
+
+func TestJqueryUI(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/jqueryui/tabs.html")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d := NewDomino(string(buf), nil, nil)
+ d.Start()
+ script := `
+ Object.assign(this, window);
+ `
+ _ = script
+ for i, fn := range []string{"jquery-1.12.4.js", "jquery-ui.js", "tabs.js"} {
+ buf, err := ioutil.ReadFile("../../../js/jqueryui/"+fn)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ _, err = d.Exec(string(buf), i == 0)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ }
+ d.Stop()
+}
+
+func TestRun(t *testing.T) {
+ jQuery, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ SCRIPT := string(jQuery) + `
+ setTimeout(function() {
+ var h = document.querySelector('html');
+ console.log(h.innerHTML);
+ }, 1000);
+ Object.assign(this, window);
+ $(document).ready(function() {
+ console.log('READDDYYYYY!!!!!!!');
+ });
+ console.log(window.location.href);
+ `
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ _, err = d.Exec(SCRIPT, true)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+
+ res, err := d.Exec("$('h1').html()", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if res != "Hello" {
+ t.Fatalf(res)
+ }
+ d.Stop()
+}
+
+func TestTriggerClick(t *testing.T) {
+ jQuery, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ SCRIPT := string(jQuery) + `
+ var clicked = false;
+ $(document).ready(function() {
+ $('h1').click(function() {
+ clicked = true;
+ });
+ });
+ `
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ _, err = d.Exec(SCRIPT, true)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ d.CloseDoc()
+
+ res, err := d.Exec("$('h1').html()", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if res != "Hello" {
+ t.Fatalf(res)
+ }
+
+ if _, _, err = d.TrackChanges(); err != nil {
+ t.Fatalf(err.Error())
+ }
+ _, changed, err := d.TriggerClick("h1")
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if changed {
+ t.Fatal()
+ }
+ res, err = d.Exec("clicked", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ if res != "true" {
+ t.Fatalf(res)
+ }
+ d.Stop()
+}
+
+func TestDomChanged(t *testing.T) {
+ jQuery, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ //t.Parallel()
+ SCRIPT := string(jQuery) + `
+ setTimeout(function() {
+ var h = document.querySelector('html');
+ console.log(h.innerHTML);
+ }, 1000);
+ Object.assign(this, window);
+ $(document).ready(function() {
+ console.log('READDDYYYYY!!!!!!!');
+ });
+ `
+ d := NewDomino(simpleHTML, nil, nil)
+ d.Start()
+ _, err = d.Exec(SCRIPT, true)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+
+ res, err := d.Exec("$('h1').html()", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ _=res
+ res, err = d.Exec("$('h1').html('minor updates :-)'); $('h1').html();", false)
+ if err != nil {
+ t.Fatalf(err.Error())
+ }
+ t.Logf("new res=%v", res)
+ d.Stop()
+}
+
+func TestMutationEvents(t *testing.T) {
+ buf, err := ioutil.ReadFile("../../../js/jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ q := func(sel, prop string) (val string, err error) {
+ if sel != "HTML > :nth-child(2) > :nth-child(1)" {
+ panic(sel)
+ }
+ if prop != "display" {
+ panic(prop)
+ }
+ return "inline-block", nil
+ }
+ d := NewDomino(simpleHTML, nil, q)
+ d.Start()
+ script := `
+ $('h1').hide();
+ $('h1').show();
+ `
+ _, err = d.Exec(string(buf) + ";" + script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if err = d.CloseDoc(); err != nil {
+ t.Fatalf("%v", err)
+ }
+ res, err := d.Exec("$('h1').attr('style')", false)
+ t.Logf("res=%v", res)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ d.Stop()
+}
--- /dev/null
+++ b/cmd/gojafs/domino/domintf.js
@@ -1,0 +1,195 @@
+global = {};
+//global.__domino_frozen__ = true; // Must precede any require('domino')
+var domino = require('domino-lib/index');
+
+Object.assign(this, domino.createWindow(opossum.html, 'http://example.com'));
+window = this;
+window.self = window;
+window.parent = window;
+window.top = window;
+window.history = {
+ replaceState: function() {}
+};
+window.location.href = 'http://example.com';
+window.screen = {
+ width: 1280,
+ height: 1024
+};
+window.screenX = 0;
+window.screenY = 25;
+window.getComputedStyle = function(el, pseudo) {
+ this.el = el;
+ this.getPropertyValue = function(prop) {
+ return opossum.style(___fq('', el), pseudo, prop, arguments[2]);
+ };
+ return this;
+};
+(function() {
+ var utils = require('domino-lib/utils');
+ utils.merge(window, domino.impl);
+})()
+
+location = window.location;
+navigator = {
+ platform: 'plan9(port)',
+ userAgent: 'opossum'
+};
+Element.prototype.getClientRects = function() { /* I'm a stub */ return []; }
+
+document._setMutationHandler(function(a) {
+ // a provides attributes type, target and node or attr
+ // (cf Object.keys(a))
+ opossum.mutated(a.type, ___fq('yolo', a.target));
+});
+
+addEventListener = function() {};
+removeEventListener = function() {};
+
+function XMLHttpRequest() {
+ var _method, _uri;
+ var h = {};
+ var ls = {};
+
+ this.readyState = 0;
+
+ var cb = function(data, err) {
+ if (data !== '') {
+ this.responseText = data;
+ this.readyState = 4;
+ this.state = 200;
+ this.status = 200;
+ if (ls['load']) ls['load'].bind(this)();
+ if (this.onload) this.onload.bind(this)();
+
+ if (this.onreadystatechange) this.onreadystatechange.bind(this)();
+ }
+ }.bind(this);
+
+ this.addEventListener = function(k, fn) {
+ ls[k] = fn;
+ };
+ this.open = function(method, uri) {
+ _method = method;
+ _uri = uri;
+ };
+ this.setRequestHeader = function(k, v) {
+ h[k] = v;
+ };
+ this.send = function(data) {
+ opossum.xhr(_method, _uri, h, data, cb);
+ this.readyState = 2;
+ };
+ this.getAllResponseHeaders = function() {
+ return '';
+ };
+}
+
+var ___fq;
+___fq = function(pre, el) {
+ var i, p;
+
+ if (!el) {
+ return undefined;
+ }
+ p = el.parentElement;
+
+ if (p) {
+ for (i = 0; i < p.children.length; i++) {
+ if (p.children[i] === el) {
+ return ___fq('', p) + ' > :nth-child(' + (i+1) + ')';
+ }
+ }
+ } else {
+ return el.tagName;
+ }
+};
+
+// https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
+// CC0
+if (typeof TextEncoder === "undefined") {
+ TextEncoder=function TextEncoder(){};
+ TextEncoder.prototype.encode = function encode(str) {
+ "use strict";
+ var Len = str.length, resPos = -1;
+ // The Uint8Array's length must be at least 3x the length of the string because an invalid UTF-16
+ // takes up the equivelent space of 3 UTF-8 characters to encode it properly. However, Array's
+ // have an auto expanding length and 1.5x should be just the right balance for most uses.
+ var resArr = typeof Uint8Array === "undefined" ? new Array(Len * 1.5) : new Uint8Array(Len * 3);
+ for (var point=0, nextcode=0, i = 0; i !== Len; ) {
+ point = str.charCodeAt(i), i += 1;
+ if (point >= 0xD800 && point <= 0xDBFF) {
+ if (i === Len) {
+ resArr[resPos += 1] = 0xef/*0b11101111*/; resArr[resPos += 1] = 0xbf/*0b10111111*/;
+ resArr[resPos += 1] = 0xbd/*0b10111101*/; break;
+ }
+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ nextcode = str.charCodeAt(i);
+ if (nextcode >= 0xDC00 && nextcode <= 0xDFFF) {
+ point = (point - 0xD800) * 0x400 + nextcode - 0xDC00 + 0x10000;
+ i += 1;
+ if (point > 0xffff) {
+ resArr[resPos += 1] = (0x1e/*0b11110*/<<3) | (point>>>18);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>12)&0x3f/*0b00111111*/);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
+ continue;
+ }
+ } else {
+ resArr[resPos += 1] = 0xef/*0b11101111*/; resArr[resPos += 1] = 0xbf/*0b10111111*/;
+ resArr[resPos += 1] = 0xbd/*0b10111101*/; continue;
+ }
+ }
+ if (point <= 0x007f) {
+ resArr[resPos += 1] = (0x0/*0b0*/<<7) | point;
+ } else if (point <= 0x07ff) {
+ resArr[resPos += 1] = (0x6/*0b110*/<<5) | (point>>>6);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
+ } else {
+ resArr[resPos += 1] = (0xe/*0b1110*/<<4) | (point>>>12);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/);
+ resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
+ }
+ }
+ if (typeof Uint8Array !== "undefined") return resArr.subarray(0, resPos + 1);
+ // else // IE 6-9
+ resArr.length = resPos + 1; // trim off extra weight
+ return resArr;
+ };
+ TextEncoder.prototype.toString = function(){return "[object TextEncoder]"};
+ try { // Object.defineProperty only works on DOM prototypes in IE8
+ Object.defineProperty(TextEncoder.prototype,"encoding",{
+ get:function(){if(TextEncoder.prototype.isPrototypeOf(this)) return"utf-8";
+ else throw TypeError("Illegal invocation");}
+ });
+ } catch(e) { /*IE6-8 fallback*/ TextEncoder.prototype.encoding = "utf-8"; }
+ if(typeof Symbol!=="undefined")TextEncoder.prototype[Symbol.toStringTag]="TextEncoder";
+}
+
+function LocalStorage() {
+ var data = {};
+ this.setItem = function(id, val) {
+ return data[id] = String(val);
+ };
+ this.getItem = function(id) {
+ return data.hasOwnProperty(id) ? data[id] : undefined;
+ };
+ this.removeItem = function(id) {
+ return delete data[id];
+ };
+ this.clear = function() {
+ return data = {};
+ };
+}
+window.localStorage = new LocalStorage();
+
+const imageHandler = {
+ construct(target, args) {
+ var el = document.createElement('img');
+
+ if (args.length >= 1) el.width = args[0];
+ if (args.length >= 2) el.height = args[1];
+
+ return el;
+ }
+};
+const Image = new Proxy(HTMLImageElement, imageHandler);
--- /dev/null
+++ b/cmd/gojafs/main.go
@@ -1,0 +1,236 @@
+// js package as separate program (very wip)
+package main
+
+import (
+ "bufio"
+ "encoding/json"
+ "fmt"
+ "github.com/knusbaum/go9p"
+ "github.com/knusbaum/go9p/fs"
+ "github.com/psilva261/opossum"
+ "github.com/psilva261/opossum/cmd/gojafs/domino"
+ "github.com/psilva261/opossum/logger"
+ "github.com/psilva261/opossum/nodes"
+ "io"
+ "net"
+ "net/http"
+ "os"
+ "os/user"
+ "strings"
+ "sync"
+)
+
+var (
+ d *domino.Domino
+ log *logger.Logger
+ service string
+ mtpt string
+ htm string
+ js []string
+ mu sync.Mutex
+)
+
+func init() {
+ f := false
+ t := true
+ domino.DebugDumpJS = &f
+ logger.Quiet = &t
+ logger.Init()
+ log = &logger.Logger{Debug: true}
+ domino.SetLogger(log)
+}
+
+func usage() {
+ log.Printf("usage: gojafs [-s service] [-m mtpt] [-h htmlfile jsfile1 [jsfile2] [..]]")
+ os.Exit(1)
+}
+
+func Main(r io.Reader, w io.Writer) (err error) {
+ log.Infof("Main...\n")
+ u, err := user.Current()
+ if err != nil {
+ return fmt.Errorf("get user: %v", err)
+ }
+ un := u.Username
+ gn, err := opossum.Group(u)
+ if err != nil {
+ return fmt.Errorf("get group: %v", err)
+ }
+
+ gojafs, root := fs.NewFS(un, gn, 0500)
+ c := fs.NewListenFile(gojafs.NewStat("ctl", un, gn, 0600))
+ root.AddChild(c)
+ lctl := (*fs.ListenFileListener)(c)
+ go Ctl(lctl)
+ log.Infof("go9p.ServeReadWriter...\n")
+ return go9p.ServeReadWriter(r, w, gojafs.Server())
+}
+
+func Ctl(lctl *fs.ListenFileListener) {
+ for {
+ conn, err := lctl.Accept()
+ if err != nil {
+ log.Errorf("accept: %v", err)
+ continue
+ }
+ go ctl(conn)
+ }
+}
+
+func ctl(conn net.Conn) {
+ r := bufio.NewReader(conn)
+ w := bufio.NewWriter(conn)
+ defer conn.Close()
+
+ l, err := r.ReadString('\n')
+ if err != nil {
+ log.Errorf("gojafs: read string: %v", err)
+ return
+ }
+ l = strings.TrimSpace(l)
+
+ mu.Lock()
+ defer mu.Unlock()
+
+ switch l {
+ case "start":
+ d = domino.NewDomino(htm, xhr, query)
+ d.Start()
+ initialized := false
+ for _, s := range js {
+ if _, err := d.Exec(s, !initialized); err != nil {
+ if strings.Contains(err.Error(), "halt at") {
+ log.Errorf("execution halted: %v", err)
+ return
+ }
+ log.Printf("exec <script>: %v", err)
+ }
+ initialized = true
+ }
+ if err := d.CloseDoc(); err != nil {
+ log.Errorf("close doc: %v", err)
+ return
+ }
+ resHtm, changed, err := d.TrackChanges()
+ if err != nil {
+ log.Errorf("track changes: %v", err)
+ return
+ }
+ log.Printf("gojafs: processJS: changed = %v", changed)
+ if changed {
+ w.WriteString(resHtm)
+ w.Flush()
+ }
+ case "stop":
+ if d != nil {
+ d.Stop()
+ d = nil
+ }
+ case "click":
+ sel, err := r.ReadString('\n')
+ if err != nil {
+ log.Errorf("gojafs: click: read string: %v", err)
+ return
+ }
+ sel = strings.TrimSpace(sel)
+ resHtm, changed, err := d.TriggerClick(sel)
+ if err != nil {
+ log.Errorf("track changes: %v", err)
+ return
+ }
+ log.Printf("gojafs: processJS: changed = %v", changed)
+ if changed {
+ w.WriteString(resHtm)
+ w.Flush()
+ }
+ default:
+ log.Errorf("unknown cmd")
+ }
+}
+
+func query(sel, prop string) (val string, err error) {
+ log.Infof("query: sel=%+v, prop=%+v\n", sel, prop)
+ rwc, err := openQuery()
+ if err != nil {
+ return "", fmt.Errorf("open query: %w", err)
+ }
+ defer rwc.Close()
+ r := json.NewDecoder(rwc)
+ _, err = io.WriteString(rwc, sel + "\n")
+ if err != nil {
+ return "", fmt.Errorf("write: %w", err)
+ }
+ log.Printf("devjs: query: sent")
+ var res []*nodes.Node
+ if err := r.Decode(&res); err != nil {
+ return "", fmt.Errorf("decodeeee: >%w<", err)
+ }
+ if n := len(res); n != 1 {
+ return "", fmt.Errorf("query returned %v results", n)
+ }
+ log.Printf("devjs: query: recvd: %v", res[0])
+ return res[0].Css(prop), nil
+}
+
+func xhr(req *http.Request) (resp *http.Response, err error) {
+ rwc, err := openXhr()
+ if err != nil {
+ return nil, fmt.Errorf("open xhr: %w", err)
+ }
+ // defer rwc.Close()
+ if err := req.Write(rwc); err != nil {
+ return nil, fmt.Errorf("write: %v", err)
+ }
+ r := bufio.NewReader(rwc)
+ if resp, err = http.ReadResponse(r, req); err != nil {
+ return nil, fmt.Errorf("read: %v", err)
+ }
+ return
+}
+
+func main() {
+ args := os.Args[1:]
+ if len(args) == 0 {
+ usage()
+ }
+
+ htmlfile := ""
+ jsfiles := make([]string, 0, len(args))
+
+ for len(args) > 0 {
+ switch args[0] {
+ case "-s":
+ service, args = args[1], args[2:]
+ case "-h":
+ htmlfile, args = args[1], args[2:]
+ default:
+ var jsfile string
+ jsfile, args = args[0], args[1:]
+ jsfiles = append(jsfiles, jsfile)
+ }
+ }
+
+ js = make([]string, 0, len(jsfiles))
+ if htmlfile != "" {
+ b, err := os.ReadFile(htmlfile)
+ if err != nil {
+ log.Fatalf(err.Error())
+ }
+ htm = string(b)
+ }
+ for _, jsfile := range jsfiles {
+ b, err := os.ReadFile(jsfile)
+ if err != nil {
+ log.Fatalf(err.Error())
+ }
+ js = append(js, string(b))
+ }
+
+ if err := Init(); err != nil {
+ log.Fatalf("Init: %+v", err)
+ }
+
+ if err := Main(os.Stdin, os.Stdout); err != nil {
+ log.Fatalf("Main: %+v", err)
+ }
+}
--- /dev/null
+++ b/cmd/gojafs/main_plan9.go
@@ -1,0 +1,42 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "os"
+)
+
+func Init() (err error) {
+ mtpt = "/mnt/opossum"
+ if htm != "" || len(js) > 0 {
+ log.Printf("not loading htm/js from mtpt")
+ return
+ }
+ bs, err := os.ReadFile(mtpt+"/html")
+ if err != nil {
+ return
+ }
+ htm = string(bs)
+ ds, err := os.ReadDir(mtpt+"/js")
+ if err != nil {
+ return
+ }
+ for i := 0; i < len(ds); i++ {
+ fn := fmt.Sprintf(mtpt+"/js/%v.js", i)
+ log.Infof("fn=%v", fn)
+ bs, err := os.ReadFile(fn)
+ if err != nil {
+ return fmt.Errorf("read all: %w", err)
+ }
+ js = append(js, string(bs))
+ }
+ return
+}
+
+func openQuery() (rwc io.ReadWriteCloser, err error) {
+ return os.OpenFile(mtpt+"/query", os.O_RDWR, 0600)
+}
+
+func openXhr() (rwc io.ReadWriteCloser, err error) {
+ return os.OpenFile(mtpt+"/xhr", os.O_RDWR, 0600)
+}
--- /dev/null
+++ b/cmd/gojafs/main_test.go
@@ -1,0 +1,119 @@
+package main
+
+import (
+ "9fans.net/go/plan9"
+ "9fans.net/go/plan9/client"
+ "bytes"
+ "fmt"
+ "io"
+ "bufio"
+ "net"
+ "os/user"
+ "strings"
+ "testing"
+)
+
+func connect() (fsys *client.Fsys, c io.Closer, err error) {
+ u, err := user.Current()
+ if err != nil {
+ return
+ }
+ un := u.Username
+ c1, c2 := net.Pipe()
+
+ go func() {
+ if err = Main(c1, c1); err != nil && err != io.EOF {
+ panic(err.Error())
+ }
+ }()
+
+ conn, err := client.NewConn(c2)
+ if err != nil {
+ return
+ }
+ fsys, err = conn.Attach(nil, un, "")
+ if err != nil {
+ return
+ }
+ return fsys, conn, nil
+}
+
+func call(fsys *client.Fsys, fn, cmd string, args... string) (resp string, err error) {
+ fid, err := fsys.Open(fn, plan9.ORDWR)
+ if err != nil {
+ return
+ }
+ defer fid.Close()
+ fid.Write([]byte(cmd+"\n"))
+ for _, arg := range args {
+ fid.Write([]byte(arg+"\n"))
+ }
+ r := bufio.NewReader(fid)
+ b := bytes.NewBuffer([]byte{})
+ _, err = io.Copy(b, r)
+ if !strings.Contains(err.Error(), io.ErrClosedPipe.Error()) {
+ return "", fmt.Errorf("unexpected error: %v", err)
+ }
+ return b.String(), nil
+}
+
+func TestMain(t *testing.T) {
+ t.Logf("connect...")
+ fsys, c, err := connect()
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ defer c.Close()
+ t.Logf("stat...")
+ d, err := fsys.Stat("ctl")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ if d.Name != "ctl" {
+ t.Fail()
+ }
+ htm = "<html><h1 id=title>hello</h1></html>"
+ js = []string{
+ "document.getElementById('title').innerHTML='world'",
+ }
+ t.Logf("call start...")
+ resp, err := call(fsys, "ctl", "start")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("%v", resp)
+ if !strings.Contains(resp, `<h1 id="title">world</h1>`) {
+ t.Fail()
+ }
+}
+
+func TestClick(t *testing.T) {
+ fsys, c, err := connect()
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ defer c.Close()
+ htm = "<html><h1 id=title>hello</h1></html>"
+ js = []string{
+ `var c = 1;
+ document.getElementById('title').addEventListener('click', function(event) {
+ c = 3;
+ });`,
+ }
+ _, err = call(fsys, "ctl", "start")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ _, err = call(fsys, "ctl", "click", "#title")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ resp, err := d.Exec("c", false)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("%v", resp)
+ if resp != "3" {
+ t.Fail()
+ }
+}
--- /dev/null
+++ b/cmd/gojafs/main_unix.go
@@ -1,0 +1,86 @@
+// +build !plan9
+
+package main
+
+import (
+ "9fans.net/go/plan9"
+ "9fans.net/go/plan9/client"
+ "fmt"
+ "github.com/knusbaum/go9p"
+ "io"
+ "os/user"
+)
+
+var fsys *client.Fsys
+
+func Init() (err error) {
+ log.Infof("Init...")
+ if service == "" {
+ return
+ }
+ log.Infof("dial service...")
+ conn, err := client.DialService(service)
+ if err != nil {
+ log.Fatalf("dial: %v", err)
+ }
+ u, err := user.Current()
+ if err != nil {
+ return
+ }
+ un := u.Username
+ fsys, err = conn.Attach(nil, un, "")
+ if err != nil {
+ log.Fatalf("attach: %v", err)
+ }
+ if htm != "" || len(js) > 0 {
+ log.Infof("not loading htm/js from service")
+ return
+ }
+ log.Infof("open html...")
+ fid, err := fsys.Open("html", plan9.OREAD)
+ if err != nil {
+ return
+ }
+ defer fid.Close()
+ bs, err := io.ReadAll(fid)
+ if err != nil {
+ return
+ }
+ htm = string(bs)
+ log.Infof("htm: %v", htm)
+ log.Infof("open js...")
+ dfid, err := fsys.Open("js", plan9.OREAD)
+ if err != nil {
+ return
+ }
+ defer dfid.Close()
+ ds, err := dfid.Dirreadall()
+ if err != nil {
+ return
+ }
+ log.Infof("ds=%+v", ds)
+ for i := 0; i < len(ds); i++ {
+ fn := fmt.Sprintf("js/%v.js", i)
+ log.Infof("fn=%v", fn)
+ fid, err := fsys.Open(fn, plan9.OREAD)
+ if err != nil {
+ return fmt.Errorf("open: %w", err)
+ }
+ bs, err := io.ReadAll(fid)
+ if err != nil {
+ fid.Close()
+ return fmt.Errorf("read all: %w", err)
+ }
+ js = append(js, string(bs))
+ fid.Close()
+ }
+ return
+}
+
+func openQuery() (rwc io.ReadWriteCloser, err error) {
+ return fsys.Open("query", plan9.ORDWR)
+}
+
+func openXhr() (rwc io.ReadWriteCloser, err error) {
+ return fsys.Open("xhr", plan9.ORDWR)
+}
--- a/cmd/jsfs/main.go
+++ /dev/null
@@ -1,183 +1,0 @@
-// js package as separate program (very wip)
-package main
-
-import (
- "bufio"
- "fmt"
- "github.com/knusbaum/go9p"
- "github.com/knusbaum/go9p/fs"
- "github.com/psilva261/opossum"
- "github.com/psilva261/opossum/domino"
- "github.com/psilva261/opossum/logger"
- "io"
- "net"
- "os"
- "os/user"
- "strings"
- "sync"
-)
-
-var (
- d *domino.Domino
- log *logger.Logger
- htm string
- js []string
- mu sync.Mutex
-)
-
-func init() {
- f := false
- t := true
- domino.DebugDumpJS = &t
- logger.Quiet = &f
- logger.Init()
- log = &logger.Logger{Debug: true}
- domino.SetLogger(log)
-}
-
-func usage() {
- log.Printf("usage: jsfs -h htmlfile jsfile1 [jsfile2 [..]]")
- os.Exit(1)
-}
-
-func Main(r io.Reader, w io.Writer) (err error) {
- u, err := user.Current()
- if err != nil {
- return fmt.Errorf("get user: %v", err)
- }
- un := u.Username
- gn, err := opossum.Group(u)
- if err != nil {
- return fmt.Errorf("get group: %v", err)
- }
-
- jsFS, root := fs.NewFS(un, gn, 0500)
- c := fs.NewListenFile(jsFS.NewStat("ctl", un, gn, 0600))
- root.AddChild(c)
- lctl := (*fs.ListenFileListener)(c)
- go Ctl(lctl)
- return go9p.ServeReadWriter(r, w, jsFS.Server())
-}
-
-func Ctl(lctl *fs.ListenFileListener) {
- for {
- conn, err := lctl.Accept()
- if err != nil {
- log.Errorf("accept: %v", err)
- continue
- }
- go ctl(conn)
- }
-}
-
-func ctl(conn net.Conn) {
- r := bufio.NewReader(conn)
- w := bufio.NewWriter(conn)
- defer conn.Close()
-
- l, err := r.ReadString('\n')
- if err != nil {
- log.Errorf("jsfs: read string: %v", err)
- return
- }
- l = strings.TrimSpace(l)
-
- mu.Lock()
- defer mu.Unlock()
-
- switch l {
- case "start":
- d = domino.NewDomino(htm, nil, nil)
- d.Start()
- initialized := false
- for _, s := range js {
- if _, err := d.Exec(s, !initialized); err != nil {
- if strings.Contains(err.Error(), "halt at") {
- log.Errorf("execution halted: %v", err)
- return
- }
- log.Printf("exec <script>: %v", err)
- }
- initialized = true
- }
- if err := d.CloseDoc(); err != nil {
- log.Errorf("close doc: %v", err)
- return
- }
- resHtm, changed, err := d.TrackChanges()
- if err != nil {
- log.Errorf("track changes: %v", err)
- return
- }
- log.Printf("jsfs: processJS: changed = %v", changed)
- if changed {
- w.WriteString(resHtm)
- w.Flush()
- }
- case "stop":
- if d != nil {
- d.Stop()
- d = nil
- }
- case "click":
- sel, err := r.ReadString('\n')
- if err != nil {
- log.Errorf("jsfs: click: read string: %v", err)
- return
- }
- sel = strings.TrimSpace(sel)
- resHtm, changed, err := d.TriggerClick(sel)
- if err != nil {
- log.Errorf("track changes: %v", err)
- return
- }
- log.Printf("jsfs: processJS: changed = %v", changed)
- if changed {
- w.WriteString(resHtm)
- w.Flush()
- }
- default:
- log.Errorf("unknown cmd")
- }
-}
-
-func main() {
- args := os.Args[1:]
- if len(args) == 0 {
- usage()
- }
-
- htmlfile := ""
- jsfiles := make([]string, 0, len(args))
-
- for len(args) > 0 {
- switch args[0] {
- case "-h":
- htmlfile, args = args[1], args[2:]
- default:
- var jsfile string
- jsfile, args = args[0], args[1:]
- jsfiles = append(jsfiles, jsfile)
- }
- }
-
- js = make([]string, 0, len(jsfiles))
- if htmlfile != "" {
- b, err := os.ReadFile(htmlfile)
- if err != nil {
- log.Fatalf(err.Error())
- }
- htm = string(b)
- }
- for _, jsfile := range jsfiles {
- b, err := os.ReadFile(jsfile)
- if err != nil {
- log.Fatalf(err.Error())
- }
- js = append(js, string(b))
- }
-
- if err := Main(os.Stdin, os.Stdout); err != nil {
- log.Fatalf("Main: %+v", err)
- }
-}
--- a/cmd/jsfs/main_test.go
+++ /dev/null
@@ -1,115 +1,0 @@
-package main
-
-import (
- "9fans.net/go/plan9"
- "9fans.net/go/plan9/client"
- "bytes"
- "fmt"
- "io"
- "bufio"
- "net"
- "os/user"
- "strings"
- "testing"
-)
-
-func connect() (fsys *client.Fsys, c io.Closer, err error) {
- u, err := user.Current()
- if err != nil {
- return
- }
- un := u.Username
- c1, c2 := net.Pipe()
- go func() {
- if err = Main(c1, c1); err != nil && err != io.EOF {
- panic(err.Error())
- }
- }()
- conn, err := client.NewConn(c2)
- if err != nil {
- return
- }
- fsys, err = conn.Attach(nil, un, "")
- if err != nil {
- return
- }
- return fsys, conn, nil
-}
-
-func call(fsys *client.Fsys, fn, cmd string, args... string) (resp string, err error) {
- fid, err := fsys.Open(fn, plan9.ORDWR)
- if err != nil {
- return
- }
- defer fid.Close()
- fid.Write([]byte(cmd+"\n"))
- for _, arg := range args {
- fid.Write([]byte(arg+"\n"))
- }
- r := bufio.NewReader(fid)
- b := bytes.NewBuffer([]byte{})
- _, err = io.Copy(b, r)
- if !strings.Contains(err.Error(), io.ErrClosedPipe.Error()) {
- return "", fmt.Errorf("unexpected error: %v", err)
- }
- return b.String(), nil
-}
-
-func TestMain(t *testing.T) {
- fsys, c, err := connect()
- if err != nil {
- t.Fatalf("%v", err)
- }
- defer c.Close()
- d, err := fsys.Stat("ctl")
- if err != nil {
- t.Fatalf("%v", err)
- }
- if d.Name != "ctl" {
- t.Fail()
- }
- htm = "<html><h1 id=title>hello</h1></html>"
- js = []string{
- "document.getElementById('title').innerHTML='world'",
- }
- resp, err := call(fsys, "ctl", "start")
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("%v", resp)
- if !strings.Contains(resp, `<h1 id="title">world</h1>`) {
- t.Fail()
- }
-}
-
-
-func TestClick(t *testing.T) {
- fsys, c, err := connect()
- if err != nil {
- t.Fatalf("%v", err)
- }
- defer c.Close()
- htm = "<html><h1 id=title>hello</h1></html>"
- js = []string{
- `var c = 1;
- document.getElementById('title').addEventListener('click', function(event) {
- c = 3;
- });`,
- }
- _, err = call(fsys, "ctl", "start")
- if err != nil {
- t.Fatalf("%v", err)
- }
- _, err = call(fsys, "ctl", "click", "#title")
- if err != nil {
- t.Fatalf("%v", err)
- }
- resp, err := d.Exec("c", false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("%v", resp)
- if resp != "3" {
- t.Fail()
- }
-}
--- a/domino/domino-lib/CSSStyleDeclaration.js
+++ /dev/null
@@ -1,579 +1,0 @@
-"use strict";
-var parserlib = require('./cssparser');
-
-module.exports = CSSStyleDeclaration;
-
-function CSSStyleDeclaration(elt) {
- this._element = elt;
-}
-
-// Utility function for parsing style declarations
-// Pass in a string like "margin-left: 5px; border-style: solid"
-// and this function returns an object like
-// {"margin-left":"5px", "border-style":"solid"}
-function parseStyles(s) {
- var parser = new parserlib.css.Parser();
- var result = { property: Object.create(null), priority: Object.create(null) };
- parser.addListener("property", function(e) {
- if (e.invalid) return; // Skip errors
- result.property[e.property.text] = e.value.text;
- if (e.important) result.priority[e.property.text] = 'important';
- });
- s = (''+s).replace(/^;/, '');
- parser.parseStyleAttribute(s);
- return result;
-}
-
-var NO_CHANGE = {}; // Private marker object
-
-CSSStyleDeclaration.prototype = Object.create(Object.prototype, {
-
- // Return the parsed form of the element's style attribute.
- // If the element's style attribute has never been parsed
- // or if it has changed since the last parse, then reparse it
- // Note that the styles don't get parsed until they're actually needed
- _parsed: { get: function() {
- if (!this._parsedStyles || this.cssText !== this._lastParsedText) {
- var text = this.cssText;
- this._parsedStyles = parseStyles(text);
- this._lastParsedText = text;
- delete this._names;
- }
- return this._parsedStyles;
- }},
-
- // Call this method any time the parsed representation of the
- // style changes. It converts the style properties to a string and
- // sets cssText and the element's style attribute
- _serialize: { value: function() {
- var styles = this._parsed;
- var s = "";
-
- for(var name in styles.property) {
- if (s) s += " ";
- s += name + ": " + styles.property[name];
- if (styles.priority[name]) {
- s += " !" + styles.priority[name];
- }
- s += ";";
- }
-
- this.cssText = s; // also sets the style attribute
- this._lastParsedText = s; // so we don't reparse
- delete this._names;
- }},
-
- cssText: {
- get: function() {
- // XXX: this is a CSSStyleDeclaration for an element.
- // A different impl might be necessary for a set of styles
- // associated returned by getComputedStyle(), e.g.
- return this._element.getAttribute("style");
- },
- set: function(value) {
- // XXX: I should parse and serialize the value to
- // normalize it and remove errors. FF and chrome do that.
- this._element.setAttribute("style", value);
- }
- },
-
- length: { get: function() {
- if (!this._names)
- this._names = Object.getOwnPropertyNames(this._parsed.property);
- return this._names.length;
- }},
-
- item: { value: function(n) {
- if (!this._names)
- this._names = Object.getOwnPropertyNames(this._parsed.property);
- return this._names[n];
- }},
-
- getPropertyValue: { value: function(property) {
- property = property.toLowerCase();
- return this._parsed.property[property] || "";
- }},
-
- getPropertyPriority: { value: function(property) {
- property = property.toLowerCase();
- return this._parsed.priority[property] || "";
- }},
-
- setProperty: { value: function(property, value, priority) {
- property = property.toLowerCase();
- if (value === null || value === undefined) {
- value = "";
- }
- if (priority === null || priority === undefined) {
- priority = "";
- }
-
- // String coercion
- if (value !== NO_CHANGE) {
- value = "" + value;
- }
-
- if (value === "") {
- this.removeProperty(property);
- return;
- }
-
- if (priority !== "" && priority !== NO_CHANGE &&
- !/^important$/i.test(priority)) {
- return;
- }
-
- var styles = this._parsed;
- if (value === NO_CHANGE) {
- if (!styles.property[property]) {
- return; // Not a valid property name.
- }
- if (priority !== "") {
- styles.priority[property] = "important";
- } else {
- delete styles.priority[property];
- }
- } else {
- // We don't just accept the property value. Instead
- // we parse it to ensure that it is something valid.
- // If it contains a semicolon it is invalid
- if (value.indexOf(";") !== -1) return;
-
- var newprops = parseStyles(property + ":" + value);
- if (Object.getOwnPropertyNames(newprops.property).length === 0) {
- return; // no valid property found
- }
- if (Object.getOwnPropertyNames(newprops.priority).length !== 0) {
- return; // if the value included '!important' it wasn't valid.
- }
-
- // XXX handle shorthand properties
-
- for (var p in newprops.property) {
- styles.property[p] = newprops.property[p];
- if (priority === NO_CHANGE) {
- continue;
- } else if (priority !== "") {
- styles.priority[p] = "important";
- } else if (styles.priority[p]) {
- delete styles.priority[p];
- }
- }
- }
-
- // Serialize and update cssText and element.style!
- this._serialize();
- }},
-
- setPropertyValue: { value: function(property, value) {
- return this.setProperty(property, value, NO_CHANGE);
- }},
-
- setPropertyPriority: { value: function(property, priority) {
- return this.setProperty(property, NO_CHANGE, priority);
- }},
-
- removeProperty: { value: function(property) {
- property = property.toLowerCase();
- var styles = this._parsed;
- if (property in styles.property) {
- delete styles.property[property];
- delete styles.priority[property];
-
- // Serialize and update cssText and element.style!
- this._serialize();
- }
- }},
-});
-
-var cssProperties = {
- alignContent: "align-content",
- alignItems: "align-items",
- alignmentBaseline: "alignment-baseline",
- alignSelf: "align-self",
- animation: "animation",
- animationDelay: "animation-delay",
- animationDirection: "animation-direction",
- animationDuration: "animation-duration",
- animationFillMode: "animation-fill-mode",
- animationIterationCount: "animation-iteration-count",
- animationName: "animation-name",
- animationPlayState: "animation-play-state",
- animationTimingFunction: "animation-timing-function",
- backfaceVisibility: "backface-visibility",
- background: "background",
- backgroundAttachment: "background-attachment",
- backgroundClip: "background-clip",
- backgroundColor: "background-color",
- backgroundImage: "background-image",
- backgroundOrigin: "background-origin",
- backgroundPosition: "background-position",
- backgroundPositionX: "background-position-x",
- backgroundPositionY: "background-position-y",
- backgroundRepeat: "background-repeat",
- backgroundSize: "background-size",
- baselineShift: "baseline-shift",
- border: "border",
- borderBottom: "border-bottom",
- borderBottomColor: "border-bottom-color",
- borderBottomLeftRadius: "border-bottom-left-radius",
- borderBottomRightRadius: "border-bottom-right-radius",
- borderBottomStyle: "border-bottom-style",
- borderBottomWidth: "border-bottom-width",
- borderCollapse: "border-collapse",
- borderColor: "border-color",
- borderImage: "border-image",
- borderImageOutset: "border-image-outset",
- borderImageRepeat: "border-image-repeat",
- borderImageSlice: "border-image-slice",
- borderImageSource: "border-image-source",
- borderImageWidth: "border-image-width",
- borderLeft: "border-left",
- borderLeftColor: "border-left-color",
- borderLeftStyle: "border-left-style",
- borderLeftWidth: "border-left-width",
- borderRadius: "border-radius",
- borderRight: "border-right",
- borderRightColor: "border-right-color",
- borderRightStyle: "border-right-style",
- borderRightWidth: "border-right-width",
- borderSpacing: "border-spacing",
- borderStyle: "border-style",
- borderTop: "border-top",
- borderTopColor: "border-top-color",
- borderTopLeftRadius: "border-top-left-radius",
- borderTopRightRadius: "border-top-right-radius",
- borderTopStyle: "border-top-style",
- borderTopWidth: "border-top-width",
- borderWidth: "border-width",
- bottom: "bottom",
- boxShadow: "box-shadow",
- boxSizing: "box-sizing",
- breakAfter: "break-after",
- breakBefore: "break-before",
- breakInside: "break-inside",
- captionSide: "caption-side",
- clear: "clear",
- clip: "clip",
- clipPath: "clip-path",
- clipRule: "clip-rule",
- color: "color",
- colorInterpolationFilters: "color-interpolation-filters",
- columnCount: "column-count",
- columnFill: "column-fill",
- columnGap: "column-gap",
- columnRule: "column-rule",
- columnRuleColor: "column-rule-color",
- columnRuleStyle: "column-rule-style",
- columnRuleWidth: "column-rule-width",
- columns: "columns",
- columnSpan: "column-span",
- columnWidth: "column-width",
- content: "content",
- counterIncrement: "counter-increment",
- counterReset: "counter-reset",
- cssFloat: "float",
- cursor: "cursor",
- direction: "direction",
- display: "display",
- dominantBaseline: "dominant-baseline",
- emptyCells: "empty-cells",
- enableBackground: "enable-background",
- fill: "fill",
- fillOpacity: "fill-opacity",
- fillRule: "fill-rule",
- filter: "filter",
- flex: "flex",
- flexBasis: "flex-basis",
- flexDirection: "flex-direction",
- flexFlow: "flex-flow",
- flexGrow: "flex-grow",
- flexShrink: "flex-shrink",
- flexWrap: "flex-wrap",
- floodColor: "flood-color",
- floodOpacity: "flood-opacity",
- font: "font",
- fontFamily: "font-family",
- fontFeatureSettings: "font-feature-settings",
- fontSize: "font-size",
- fontSizeAdjust: "font-size-adjust",
- fontStretch: "font-stretch",
- fontStyle: "font-style",
- fontVariant: "font-variant",
- fontWeight: "font-weight",
- glyphOrientationHorizontal: "glyph-orientation-horizontal",
- glyphOrientationVertical: "glyph-orientation-vertical",
- grid: "grid",
- gridArea: "grid-area",
- gridAutoColumns: "grid-auto-columns",
- gridAutoFlow: "grid-auto-flow",
- gridAutoRows: "grid-auto-rows",
- gridColumn: "grid-column",
- gridColumnEnd: "grid-column-end",
- gridColumnGap: "grid-column-gap",
- gridColumnStart: "grid-column-start",
- gridGap: "grid-gap",
- gridRow: "grid-row",
- gridRowEnd: "grid-row-end",
- gridRowGap: "grid-row-gap",
- gridRowStart: "grid-row-start",
- gridTemplate: "grid-template",
- gridTemplateAreas: "grid-template-areas",
- gridTemplateColumns: "grid-template-columns",
- gridTemplateRows: "grid-template-rows",
- height: "height",
- imeMode: "ime-mode",
- justifyContent: "justify-content",
- kerning: "kerning",
- layoutGrid: "layout-grid",
- layoutGridChar: "layout-grid-char",
- layoutGridLine: "layout-grid-line",
- layoutGridMode: "layout-grid-mode",
- layoutGridType: "layout-grid-type",
- left: "left",
- letterSpacing: "letter-spacing",
- lightingColor: "lighting-color",
- lineBreak: "line-break",
- lineHeight: "line-height",
- listStyle: "list-style",
- listStyleImage: "list-style-image",
- listStylePosition: "list-style-position",
- listStyleType: "list-style-type",
- margin: "margin",
- marginBottom: "margin-bottom",
- marginLeft: "margin-left",
- marginRight: "margin-right",
- marginTop: "margin-top",
- marker: "marker",
- markerEnd: "marker-end",
- markerMid: "marker-mid",
- markerStart: "marker-start",
- mask: "mask",
- maxHeight: "max-height",
- maxWidth: "max-width",
- minHeight: "min-height",
- minWidth: "min-width",
- msContentZoomChaining: "-ms-content-zoom-chaining",
- msContentZooming: "-ms-content-zooming",
- msContentZoomLimit: "-ms-content-zoom-limit",
- msContentZoomLimitMax: "-ms-content-zoom-limit-max",
- msContentZoomLimitMin: "-ms-content-zoom-limit-min",
- msContentZoomSnap: "-ms-content-zoom-snap",
- msContentZoomSnapPoints: "-ms-content-zoom-snap-points",
- msContentZoomSnapType: "-ms-content-zoom-snap-type",
- msFlowFrom: "-ms-flow-from",
- msFlowInto: "-ms-flow-into",
- msFontFeatureSettings: "-ms-font-feature-settings",
- msGridColumn: "-ms-grid-column",
- msGridColumnAlign: "-ms-grid-column-align",
- msGridColumns: "-ms-grid-columns",
- msGridColumnSpan: "-ms-grid-column-span",
- msGridRow: "-ms-grid-row",
- msGridRowAlign: "-ms-grid-row-align",
- msGridRows: "-ms-grid-rows",
- msGridRowSpan: "-ms-grid-row-span",
- msHighContrastAdjust: "-ms-high-contrast-adjust",
- msHyphenateLimitChars: "-ms-hyphenate-limit-chars",
- msHyphenateLimitLines: "-ms-hyphenate-limit-lines",
- msHyphenateLimitZone: "-ms-hyphenate-limit-zone",
- msHyphens: "-ms-hyphens",
- msImeAlign: "-ms-ime-align",
- msOverflowStyle: "-ms-overflow-style",
- msScrollChaining: "-ms-scroll-chaining",
- msScrollLimit: "-ms-scroll-limit",
- msScrollLimitXMax: "-ms-scroll-limit-x-max",
- msScrollLimitXMin: "-ms-scroll-limit-x-min",
- msScrollLimitYMax: "-ms-scroll-limit-y-max",
- msScrollLimitYMin: "-ms-scroll-limit-y-min",
- msScrollRails: "-ms-scroll-rails",
- msScrollSnapPointsX: "-ms-scroll-snap-points-x",
- msScrollSnapPointsY: "-ms-scroll-snap-points-y",
- msScrollSnapType: "-ms-scroll-snap-type",
- msScrollSnapX: "-ms-scroll-snap-x",
- msScrollSnapY: "-ms-scroll-snap-y",
- msScrollTranslation: "-ms-scroll-translation",
- msTextCombineHorizontal: "-ms-text-combine-horizontal",
- msTextSizeAdjust: "-ms-text-size-adjust",
- msTouchAction: "-ms-touch-action",
- msTouchSelect: "-ms-touch-select",
- msUserSelect: "-ms-user-select",
- msWrapFlow: "-ms-wrap-flow",
- msWrapMargin: "-ms-wrap-margin",
- msWrapThrough: "-ms-wrap-through",
- opacity: "opacity",
- order: "order",
- orphans: "orphans",
- outline: "outline",
- outlineColor: "outline-color",
- outlineOffset: "outline-offset",
- outlineStyle: "outline-style",
- outlineWidth: "outline-width",
- overflow: "overflow",
- overflowX: "overflow-x",
- overflowY: "overflow-y",
- padding: "padding",
- paddingBottom: "padding-bottom",
- paddingLeft: "padding-left",
- paddingRight: "padding-right",
- paddingTop: "padding-top",
- page: "page",
- pageBreakAfter: "page-break-after",
- pageBreakBefore: "page-break-before",
- pageBreakInside: "page-break-inside",
- perspective: "perspective",
- perspectiveOrigin: "perspective-origin",
- pointerEvents: "pointer-events",
- position: "position",
- quotes: "quotes",
- right: "right",
- rotate: "rotate",
- rubyAlign: "ruby-align",
- rubyOverhang: "ruby-overhang",
- rubyPosition: "ruby-position",
- scale: "scale",
- size: "size",
- stopColor: "stop-color",
- stopOpacity: "stop-opacity",
- stroke: "stroke",
- strokeDasharray: "stroke-dasharray",
- strokeDashoffset: "stroke-dashoffset",
- strokeLinecap: "stroke-linecap",
- strokeLinejoin: "stroke-linejoin",
- strokeMiterlimit: "stroke-miterlimit",
- strokeOpacity: "stroke-opacity",
- strokeWidth: "stroke-width",
- tableLayout: "table-layout",
- textAlign: "text-align",
- textAlignLast: "text-align-last",
- textAnchor: "text-anchor",
- textDecoration: "text-decoration",
- textIndent: "text-indent",
- textJustify: "text-justify",
- textKashida: "text-kashida",
- textKashidaSpace: "text-kashida-space",
- textOverflow: "text-overflow",
- textShadow: "text-shadow",
- textTransform: "text-transform",
- textUnderlinePosition: "text-underline-position",
- top: "top",
- touchAction: "touch-action",
- transform: "transform",
- transformOrigin: "transform-origin",
- transformStyle: "transform-style",
- transition: "transition",
- transitionDelay: "transition-delay",
- transitionDuration: "transition-duration",
- transitionProperty: "transition-property",
- transitionTimingFunction: "transition-timing-function",
- translate: "translate",
- unicodeBidi: "unicode-bidi",
- verticalAlign: "vertical-align",
- visibility: "visibility",
- webkitAlignContent: "-webkit-align-content",
- webkitAlignItems: "-webkit-align-items",
- webkitAlignSelf: "-webkit-align-self",
- webkitAnimation: "-webkit-animation",
- webkitAnimationDelay: "-webkit-animation-delay",
- webkitAnimationDirection: "-webkit-animation-direction",
- webkitAnimationDuration: "-webkit-animation-duration",
- webkitAnimationFillMode: "-webkit-animation-fill-mode",
- webkitAnimationIterationCount: "-webkit-animation-iteration-count",
- webkitAnimationName: "-webkit-animation-name",
- webkitAnimationPlayState: "-webkit-animation-play-state",
- webkitAnimationTimingFunction: "-webkit-animation-timing-funciton",
- webkitAppearance: "-webkit-appearance",
- webkitBackfaceVisibility: "-webkit-backface-visibility",
- webkitBackgroundClip: "-webkit-background-clip",
- webkitBackgroundOrigin: "-webkit-background-origin",
- webkitBackgroundSize: "-webkit-background-size",
- webkitBorderBottomLeftRadius: "-webkit-border-bottom-left-radius",
- webkitBorderBottomRightRadius: "-webkit-border-bottom-right-radius",
- webkitBorderImage: "-webkit-border-image",
- webkitBorderRadius: "-webkit-border-radius",
- webkitBorderTopLeftRadius: "-webkit-border-top-left-radius",
- webkitBorderTopRightRadius: "-webkit-border-top-right-radius",
- webkitBoxAlign: "-webkit-box-align",
- webkitBoxDirection: "-webkit-box-direction",
- webkitBoxFlex: "-webkit-box-flex",
- webkitBoxOrdinalGroup: "-webkit-box-ordinal-group",
- webkitBoxOrient: "-webkit-box-orient",
- webkitBoxPack: "-webkit-box-pack",
- webkitBoxSizing: "-webkit-box-sizing",
- webkitColumnBreakAfter: "-webkit-column-break-after",
- webkitColumnBreakBefore: "-webkit-column-break-before",
- webkitColumnBreakInside: "-webkit-column-break-inside",
- webkitColumnCount: "-webkit-column-count",
- webkitColumnGap: "-webkit-column-gap",
- webkitColumnRule: "-webkit-column-rule",
- webkitColumnRuleColor: "-webkit-column-rule-color",
- webkitColumnRuleStyle: "-webkit-column-rule-style",
- webkitColumnRuleWidth: "-webkit-column-rule-width",
- webkitColumns: "-webkit-columns",
- webkitColumnSpan: "-webkit-column-span",
- webkitColumnWidth: "-webkit-column-width",
- webkitFilter: "-webkit-filter",
- webkitFlex: "-webkit-flex",
- webkitFlexBasis: "-webkit-flex-basis",
- webkitFlexDirection: "-webkit-flex-direction",
- webkitFlexFlow: "-webkit-flex-flow",
- webkitFlexGrow: "-webkit-flex-grow",
- webkitFlexShrink: "-webkit-flex-shrink",
- webkitFlexWrap: "-webkit-flex-wrap",
- webkitJustifyContent: "-webkit-justify-content",
- webkitOrder: "-webkit-order",
- webkitPerspective: "-webkit-perspective-origin",
- webkitPerspectiveOrigin: "-webkit-perspective-origin",
- webkitTapHighlightColor: "-webkit-tap-highlight-color",
- webkitTextFillColor: "-webkit-text-fill-color",
- webkitTextSizeAdjust: "-webkit-text-size-adjust",
- webkitTextStroke: "-webkit-text-stroke",
- webkitTextStrokeColor: "-webkit-text-stroke-color",
- webkitTextStrokeWidth: "-webkit-text-stroke-width",
- webkitTransform: "-webkit-transform",
- webkitTransformOrigin: "-webkit-transform-origin",
- webkitTransformStyle: "-webkit-transform-style",
- webkitTransition: "-webkit-transition",
- webkitTransitionDelay: "-webkit-transition-delay",
- webkitTransitionDuration: "-webkit-transition-duration",
- webkitTransitionProperty: "-webkit-transition-property",
- webkitTransitionTimingFunction: "-webkit-transition-timing-function",
- webkitUserModify: "-webkit-user-modify",
- webkitUserSelect: "-webkit-user-select",
- webkitWritingMode: "-webkit-writing-mode",
- whiteSpace: "white-space",
- widows: "widows",
- width: "width",
- wordBreak: "word-break",
- wordSpacing: "word-spacing",
- wordWrap: "word-wrap",
- writingMode: "writing-mode",
- zIndex: "z-index",
- zoom: "zoom",
- resize: "resize",
- userSelect: "user-select",
-};
-
-for(var prop in cssProperties) defineStyleProperty(prop);
-
-function defineStyleProperty(jsname) {
- var cssname = cssProperties[jsname];
- Object.defineProperty(CSSStyleDeclaration.prototype, jsname, {
- get: function() {
- return this.getPropertyValue(cssname);
- },
- set: function(value) {
- this.setProperty(cssname, value);
- }
- });
-
- if (!CSSStyleDeclaration.prototype.hasOwnProperty(cssname)) {
- Object.defineProperty(CSSStyleDeclaration.prototype, cssname, {
- get: function() {
- return this.getPropertyValue(cssname);
- },
- set: function(value) {
- this.setProperty(cssname, value);
- }
- });
- }
-}
--- a/domino/domino-lib/CharacterData.js
+++ /dev/null
@@ -1,120 +1,0 @@
-/* jshint bitwise: false */
-"use strict";
-module.exports = CharacterData;
-
-var Leaf = require('./Leaf');
-var utils = require('./utils');
-var ChildNode = require('./ChildNode');
-var NonDocumentTypeChildNode = require('./NonDocumentTypeChildNode');
-
-function CharacterData() {
- Leaf.call(this);
-}
-
-CharacterData.prototype = Object.create(Leaf.prototype, {
- // DOMString substringData(unsigned long offset,
- // unsigned long count);
- // The substringData(offset, count) method must run these steps:
- //
- // If offset is greater than the context object's
- // length, throw an INDEX_SIZE_ERR exception and
- // terminate these steps.
- //
- // If offset+count is greater than the context
- // object's length, return a DOMString whose value is
- // the UTF-16 code units from the offsetth UTF-16 code
- // unit to the end of data.
- //
- // Return a DOMString whose value is the UTF-16 code
- // units from the offsetth UTF-16 code unit to the
- // offset+countth UTF-16 code unit in data.
- substringData: { value: function substringData(offset, count) {
- if (arguments.length < 2) { throw new TypeError("Not enough arguments"); }
- // Convert arguments to WebIDL "unsigned long"
- offset = offset >>> 0;
- count = count >>> 0;
- if (offset > this.data.length || offset < 0 || count < 0) {
- utils.IndexSizeError();
- }
- return this.data.substring(offset, offset+count);
- }},
-
- // void appendData(DOMString data);
- // The appendData(data) method must append data to the context
- // object's data.
- appendData: { value: function appendData(data) {
- if (arguments.length < 1) { throw new TypeError("Not enough arguments"); }
- this.data += String(data);
- }},
-
- // void insertData(unsigned long offset, DOMString data);
- // The insertData(offset, data) method must run these steps:
- //
- // If offset is greater than the context object's
- // length, throw an INDEX_SIZE_ERR exception and
- // terminate these steps.
- //
- // Insert data into the context object's data after
- // offset UTF-16 code units.
- //
- insertData: { value: function insertData(offset, data) {
- return this.replaceData(offset, 0, data);
- }},
-
-
- // void deleteData(unsigned long offset, unsigned long count);
- // The deleteData(offset, count) method must run these steps:
- //
- // If offset is greater than the context object's
- // length, throw an INDEX_SIZE_ERR exception and
- // terminate these steps.
- //
- // If offset+count is greater than the context
- // object's length var count be length-offset.
- //
- // Starting from offset UTF-16 code units remove count
- // UTF-16 code units from the context object's data.
- deleteData: { value: function deleteData(offset, count) {
- return this.replaceData(offset, count, '');
- }},
-
-
- // void replaceData(unsigned long offset, unsigned long count,
- // DOMString data);
- //
- // The replaceData(offset, count, data) method must act as
- // if the deleteData() method is invoked with offset and
- // count as arguments followed by the insertData() method
- // with offset and data as arguments and re-throw any
- // exceptions these methods might have thrown.
- replaceData: { value: function replaceData(offset, count, data) {
- var curtext = this.data, len = curtext.length;
- // Convert arguments to correct WebIDL type
- offset = offset >>> 0;
- count = count >>> 0;
- data = String(data);
-
- if (offset > len || offset < 0) utils.IndexSizeError();
-
- if (offset+count > len)
- count = len - offset;
-
- var prefix = curtext.substring(0, offset),
- suffix = curtext.substring(offset+count);
-
- this.data = prefix + data + suffix;
- }},
-
- // Utility method that Node.isEqualNode() calls to test Text and
- // Comment nodes for equality. It is okay to put it here, since
- // Node will have already verified that nodeType is equal
- isEqual: { value: function isEqual(n) {
- return this._data === n._data;
- }},
-
- length: { get: function() { return this.data.length; }}
-
-});
-
-Object.defineProperties(CharacterData.prototype, ChildNode);
-Object.defineProperties(CharacterData.prototype, NonDocumentTypeChildNode);
--- a/domino/domino-lib/ChildNode.js
+++ /dev/null
@@ -1,119 +1,0 @@
-"use strict";
-
-var Node = require('./Node');
-var LinkedList = require('./LinkedList');
-
-var createDocumentFragmentFromArguments = function(document, args) {
- var docFrag = document.createDocumentFragment();
-
- for (var i=0; i<args.length; i++) {
- var argItem = args[i];
- var isNode = argItem instanceof Node;
- docFrag.appendChild(isNode ? argItem :
- document.createTextNode(String(argItem)));
- }
-
- return docFrag;
-};
-
-// The ChildNode interface contains methods that are particular to `Node`
-// objects that can have a parent. It is implemented by `Element`,
-// `DocumentType`, and `CharacterData` objects.
-var ChildNode = {
-
- // Inserts a set of Node or String objects in the children list of this
- // ChildNode's parent, just after this ChildNode. String objects are
- // inserted as the equivalent Text nodes.
- after: { value: function after() {
- var argArr = Array.prototype.slice.call(arguments);
- var parentNode = this.parentNode, nextSibling = this.nextSibling;
- if (parentNode === null) { return; }
- // Find "viable next sibling"; that is, next one not in argArr
- while (nextSibling && argArr.some(function(v) { return v===nextSibling; }))
- nextSibling = nextSibling.nextSibling;
- // ok, parent and sibling are saved away since this node could itself
- // appear in argArr and we're about to move argArr to a document fragment.
- var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
-
- parentNode.insertBefore(docFrag, nextSibling);
- }},
-
- // Inserts a set of Node or String objects in the children list of this
- // ChildNode's parent, just before this ChildNode. String objects are
- // inserted as the equivalent Text nodes.
- before: { value: function before() {
- var argArr = Array.prototype.slice.call(arguments);
- var parentNode = this.parentNode, prevSibling = this.previousSibling;
- if (parentNode === null) { return; }
- // Find "viable prev sibling"; that is, prev one not in argArr
- while (prevSibling && argArr.some(function(v) { return v===prevSibling; }))
- prevSibling = prevSibling.previousSibling;
- // ok, parent and sibling are saved away since this node could itself
- // appear in argArr and we're about to move argArr to a document fragment.
- var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
-
- var nextSibling =
- prevSibling ? prevSibling.nextSibling : parentNode.firstChild;
- parentNode.insertBefore(docFrag, nextSibling);
- }},
-
- // Remove this node from its parent
- remove: { value: function remove() {
- if (this.parentNode === null) return;
-
- // Send mutation events if necessary
- if (this.doc) {
- this.doc._preremoveNodeIterators(this);
- if (this.rooted) {
- this.doc.mutateRemove(this);
- }
- }
-
- // Remove this node from its parents array of children
- // and update the structure id for all ancestors
- this._remove();
-
- // Forget this node's parent
- this.parentNode = null;
- }},
-
- // Remove this node w/o uprooting or sending mutation events
- // (But do update the structure id for all ancestors)
- _remove: { value: function _remove() {
- var parent = this.parentNode;
- if (parent === null) return;
- if (parent._childNodes) {
- parent._childNodes.splice(this.index, 1);
- } else if (parent._firstChild === this) {
- if (this._nextSibling === this) {
- parent._firstChild = null;
- } else {
- parent._firstChild = this._nextSibling;
- }
- }
- LinkedList.remove(this);
- parent.modify();
- }},
-
- // Replace this node with the nodes or strings provided as arguments.
- replaceWith: { value: function replaceWith() {
- var argArr = Array.prototype.slice.call(arguments);
- var parentNode = this.parentNode, nextSibling = this.nextSibling;
- if (parentNode === null) { return; }
- // Find "viable next sibling"; that is, next one not in argArr
- while (nextSibling && argArr.some(function(v) { return v===nextSibling; }))
- nextSibling = nextSibling.nextSibling;
- // ok, parent and sibling are saved away since this node could itself
- // appear in argArr and we're about to move argArr to a document fragment.
- var docFrag = createDocumentFragmentFromArguments(this.doc, argArr);
- if (this.parentNode === parentNode) {
- parentNode.replaceChild(docFrag, this);
- } else {
- // `this` was inserted into docFrag
- parentNode.insertBefore(docFrag, nextSibling);
- }
- }},
-
-};
-
-module.exports = ChildNode;
--- a/domino/domino-lib/Comment.js
+++ /dev/null
@@ -1,39 +1,0 @@
-"use strict";
-module.exports = Comment;
-
-var Node = require('./Node');
-var CharacterData = require('./CharacterData');
-
-function Comment(doc, data) {
- CharacterData.call(this);
- this.nodeType = Node.COMMENT_NODE;
- this.ownerDocument = doc;
- this._data = data;
-}
-
-var nodeValue = {
- get: function() { return this._data; },
- set: function(v) {
- if (v === null || v === undefined) { v = ''; } else { v = String(v); }
- this._data = v;
- if (this.rooted)
- this.ownerDocument.mutateValue(this);
- }
-};
-
-Comment.prototype = Object.create(CharacterData.prototype, {
- nodeName: { value: '#comment' },
- nodeValue: nodeValue,
- textContent: nodeValue,
- data: {
- get: nodeValue.get,
- set: function(v) {
- nodeValue.set.call(this, v===null ? '' : String(v));
- },
- },
-
- // Utility methods
- clone: { value: function clone() {
- return new Comment(this.ownerDocument, this._data);
- }},
-});
--- a/domino/domino-lib/ContainerNode.js
+++ /dev/null
@@ -1,80 +1,0 @@
-"use strict";
-module.exports = ContainerNode;
-
-var Node = require('./Node');
-var NodeList = require('./NodeList');
-
-// This class defines common functionality for node subtypes that
-// can have children
-
-function ContainerNode() {
- Node.call(this);
- this._firstChild = this._childNodes = null;
-}
-
-// Primary representation is a circular linked list of siblings
-ContainerNode.prototype = Object.create(Node.prototype, {
-
- hasChildNodes: { value: function() {
- if (this._childNodes) {
- return this._childNodes.length > 0;
- }
- return this._firstChild !== null;
- }},
-
- childNodes: { get: function() {
- this._ensureChildNodes();
- return this._childNodes;
- }},
-
- firstChild: { get: function() {
- if (this._childNodes) {
- return this._childNodes.length === 0 ? null : this._childNodes[0];
- }
- return this._firstChild;
- }},
-
- lastChild: { get: function() {
- var kids = this._childNodes, first;
- if (kids) {
- return kids.length === 0 ? null: kids[kids.length-1];
- }
- first = this._firstChild;
- if (first === null) { return null; }
- return first._previousSibling; // circular linked list
- }},
-
- _ensureChildNodes: { value: function() {
- if (this._childNodes) { return; }
- var first = this._firstChild,
- kid = first,
- childNodes = this._childNodes = new NodeList();
- if (first) do {
- childNodes.push(kid);
- kid = kid._nextSibling;
- } while (kid !== first); // circular linked list
- this._firstChild = null; // free memory
- }},
-
- // Remove all of this node's children. This is a minor
- // optimization that only calls modify() once.
- removeChildren: { value: function removeChildren() {
- var root = this.rooted ? this.ownerDocument : null,
- next = this.firstChild,
- kid;
- while (next !== null) {
- kid = next;
- next = kid.nextSibling;
-
- if (root) root.mutateRemove(kid);
- kid.parentNode = null;
- }
- if (this._childNodes) {
- this._childNodes.length = 0;
- } else {
- this._firstChild = null;
- }
- this.modify(); // Update last modified type once only
- }},
-
-});
--- a/domino/domino-lib/CustomEvent.js
+++ /dev/null
@@ -1,12 +1,0 @@
-"use strict";
-module.exports = CustomEvent;
-
-var Event = require('./Event');
-
-function CustomEvent(type, dictionary) {
- // Just use the superclass constructor to initialize
- Event.call(this, type, dictionary);
-}
-CustomEvent.prototype = Object.create(Event.prototype, {
- constructor: { value: CustomEvent }
-});
--- a/domino/domino-lib/DOMException.js
+++ /dev/null
@@ -1,134 +1,0 @@
-"use strict";
-module.exports = DOMException;
-
-var INDEX_SIZE_ERR = 1;
-var HIERARCHY_REQUEST_ERR = 3;
-var WRONG_DOCUMENT_ERR = 4;
-var INVALID_CHARACTER_ERR = 5;
-var NO_MODIFICATION_ALLOWED_ERR = 7;
-var NOT_FOUND_ERR = 8;
-var NOT_SUPPORTED_ERR = 9;
-var INVALID_STATE_ERR = 11;
-var SYNTAX_ERR = 12;
-var INVALID_MODIFICATION_ERR = 13;
-var NAMESPACE_ERR = 14;
-var INVALID_ACCESS_ERR = 15;
-var TYPE_MISMATCH_ERR = 17;
-var SECURITY_ERR = 18;
-var NETWORK_ERR = 19;
-var ABORT_ERR = 20;
-var URL_MISMATCH_ERR = 21;
-var QUOTA_EXCEEDED_ERR = 22;
-var TIMEOUT_ERR = 23;
-var INVALID_NODE_TYPE_ERR = 24;
-var DATA_CLONE_ERR = 25;
-
-// Code to name
-var names = [
- null, // No error with code 0
- 'INDEX_SIZE_ERR',
- null, // historical
- 'HIERARCHY_REQUEST_ERR',
- 'WRONG_DOCUMENT_ERR',
- 'INVALID_CHARACTER_ERR',
- null, // historical
- 'NO_MODIFICATION_ALLOWED_ERR',
- 'NOT_FOUND_ERR',
- 'NOT_SUPPORTED_ERR',
- 'INUSE_ATTRIBUTE_ERR', // historical
- 'INVALID_STATE_ERR',
- 'SYNTAX_ERR',
- 'INVALID_MODIFICATION_ERR',
- 'NAMESPACE_ERR',
- 'INVALID_ACCESS_ERR',
- null, // historical
- 'TYPE_MISMATCH_ERR',
- 'SECURITY_ERR',
- 'NETWORK_ERR',
- 'ABORT_ERR',
- 'URL_MISMATCH_ERR',
- 'QUOTA_EXCEEDED_ERR',
- 'TIMEOUT_ERR',
- 'INVALID_NODE_TYPE_ERR',
- 'DATA_CLONE_ERR',
-];
-
-// Code to message
-// These strings are from the 13 May 2011 Editor's Draft of DOM Core.
-// http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
-// Copyright © 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved.
-// Used under the terms of the W3C Document License:
-// http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
-var messages = [
- null, // No error with code 0
- 'INDEX_SIZE_ERR (1): the index is not in the allowed range',
- null,
- 'HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model',
- 'WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required',
- 'INVALID_CHARACTER_ERR (5): the string contains invalid characters',
- null,
- 'NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified',
- 'NOT_FOUND_ERR (8): the object can not be found here',
- 'NOT_SUPPORTED_ERR (9): this operation is not supported',
- 'INUSE_ATTRIBUTE_ERR (10): setAttributeNode called on owned Attribute',
- 'INVALID_STATE_ERR (11): the object is in an invalid state',
- 'SYNTAX_ERR (12): the string did not match the expected pattern',
- 'INVALID_MODIFICATION_ERR (13): the object can not be modified in this way',
- 'NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML',
- 'INVALID_ACCESS_ERR (15): the object does not support the operation or argument',
- null,
- 'TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type',
- 'SECURITY_ERR (18): the operation is insecure',
- 'NETWORK_ERR (19): a network error occurred',
- 'ABORT_ERR (20): the user aborted an operation',
- 'URL_MISMATCH_ERR (21): the given URL does not match another URL',
- 'QUOTA_EXCEEDED_ERR (22): the quota has been exceeded',
- 'TIMEOUT_ERR (23): a timeout occurred',
- 'INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation',
- 'DATA_CLONE_ERR (25): the object can not be cloned.'
-];
-
-// Name to code
-var constants = {
- INDEX_SIZE_ERR: INDEX_SIZE_ERR,
- DOMSTRING_SIZE_ERR: 2, // historical
- HIERARCHY_REQUEST_ERR: HIERARCHY_REQUEST_ERR,
- WRONG_DOCUMENT_ERR: WRONG_DOCUMENT_ERR,
- INVALID_CHARACTER_ERR: INVALID_CHARACTER_ERR,
- NO_DATA_ALLOWED_ERR: 6, // historical
- NO_MODIFICATION_ALLOWED_ERR: NO_MODIFICATION_ALLOWED_ERR,
- NOT_FOUND_ERR: NOT_FOUND_ERR,
- NOT_SUPPORTED_ERR: NOT_SUPPORTED_ERR,
- INUSE_ATTRIBUTE_ERR: 10, // historical
- INVALID_STATE_ERR: INVALID_STATE_ERR,
- SYNTAX_ERR: SYNTAX_ERR,
- INVALID_MODIFICATION_ERR: INVALID_MODIFICATION_ERR,
- NAMESPACE_ERR: NAMESPACE_ERR,
- INVALID_ACCESS_ERR: INVALID_ACCESS_ERR,
- VALIDATION_ERR: 16, // historical
- TYPE_MISMATCH_ERR: TYPE_MISMATCH_ERR,
- SECURITY_ERR: SECURITY_ERR,
- NETWORK_ERR: NETWORK_ERR,
- ABORT_ERR: ABORT_ERR,
- URL_MISMATCH_ERR: URL_MISMATCH_ERR,
- QUOTA_EXCEEDED_ERR: QUOTA_EXCEEDED_ERR,
- TIMEOUT_ERR: TIMEOUT_ERR,
- INVALID_NODE_TYPE_ERR: INVALID_NODE_TYPE_ERR,
- DATA_CLONE_ERR: DATA_CLONE_ERR
-};
-
-function DOMException(code) {
- Error.call(this);
- Error.captureStackTrace(this, this.constructor);
- this.code = code;
- this.message = messages[code];
- this.name = names[code];
-}
-DOMException.prototype.__proto__ = Error.prototype;
-
-// Initialize the constants on DOMException and DOMException.prototype
-for(var c in constants) {
- var v = { value: constants[c] };
- Object.defineProperty(DOMException, c, v);
- Object.defineProperty(DOMException.prototype, c, v);
-}
--- a/domino/domino-lib/DOMImplementation.js
+++ /dev/null
@@ -1,94 +1,0 @@
-"use strict";
-module.exports = DOMImplementation;
-
-var Document = require('./Document');
-var DocumentType = require('./DocumentType');
-var HTMLParser = require('./HTMLParser');
-var utils = require('./utils');
-var xml = require('./xmlnames');
-
-// Each document must have its own instance of the domimplementation object
-function DOMImplementation(contextObject) {
- this.contextObject = contextObject;
-}
-
-
-// Feature/version pairs that DOMImplementation.hasFeature() returns
-// true for. It returns false for anything else.
-var supportedFeatures = {
- 'xml': { '': true, '1.0': true, '2.0': true }, // DOM Core
- 'core': { '': true, '2.0': true }, // DOM Core
- 'html': { '': true, '1.0': true, '2.0': true} , // HTML
- 'xhtml': { '': true, '1.0': true, '2.0': true} , // HTML
-};
-
-DOMImplementation.prototype = {
- hasFeature: function hasFeature(feature, version) {
- var f = supportedFeatures[(feature || '').toLowerCase()];
- return (f && f[version || '']) || false;
- },
-
- createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) {
- if (!xml.isValidQName(qualifiedName)) utils.InvalidCharacterError();
-
- return new DocumentType(this.contextObject, qualifiedName, publicId, systemId);
- },
-
- createDocument: function createDocument(namespace, qualifiedName, doctype) {
- //
- // Note that the current DOMCore spec makes it impossible to
- // create an HTML document with this function, even if the
- // namespace and doctype are propertly set. See this thread:
- // http://lists.w3.org/Archives/Public/www-dom/2011AprJun/0132.html
- //
- var d = new Document(false, null);
- var e;
-
- if (qualifiedName)
- e = d.createElementNS(namespace, qualifiedName);
- else
- e = null;
-
- if (doctype) {
- d.appendChild(doctype);
- }
-
- if (e) d.appendChild(e);
- if (namespace === utils.NAMESPACE.HTML) {
- d._contentType = 'application/xhtml+xml';
- } else if (namespace === utils.NAMESPACE.SVG) {
- d._contentType = 'image/svg+xml';
- } else {
- d._contentType = 'application/xml';
- }
-
- return d;
- },
-
- createHTMLDocument: function createHTMLDocument(titleText) {
- var d = new Document(true, null);
- d.appendChild(new DocumentType(d, 'html'));
- var html = d.createElement('html');
- d.appendChild(html);
- var head = d.createElement('head');
- html.appendChild(head);
- if (titleText !== undefined) {
- var title = d.createElement('title');
- head.appendChild(title);
- title.appendChild(d.createTextNode(titleText));
- }
- html.appendChild(d.createElement('body'));
- d.modclock = 1; // Start tracking modifications
- return d;
- },
-
- mozSetOutputMutationHandler: function(doc, handler) {
- doc.mutationHandler = handler;
- },
-
- mozGetInputMutationHandler: function(doc) {
- utils.nyi();
- },
-
- mozHTMLParser: HTMLParser,
-};
--- a/domino/domino-lib/DOMTokenList.js
+++ /dev/null
@@ -1,186 +1,0 @@
-"use strict";
-// DOMTokenList implementation based on https://github.com/Raynos/DOM-shim
-var utils = require('./utils');
-
-module.exports = DOMTokenList;
-
-function DOMTokenList(getter, setter) {
- this._getString = getter;
- this._setString = setter;
- this._length = 0;
- this._lastStringValue = '';
- this._update();
-}
-
-Object.defineProperties(DOMTokenList.prototype, {
- length: { get: function() { return this._length; } },
- item: { value: function(index) {
- var list = getList(this);
- if (index < 0 || index >= list.length) {
- return null;
- }
- return list[index];
- }},
-
- contains: { value: function(token) {
- token = String(token); // no error checking for contains()
- var list = getList(this);
- return list.indexOf(token) > -1;
- }},
-
- add: { value: function() {
- var list = getList(this);
- for (var i = 0, len = arguments.length; i < len; i++) {
- var token = handleErrors(arguments[i]);
- if (list.indexOf(token) < 0) {
- list.push(token);
- }
- }
- // Note: as per spec, if handleErrors() throws any errors, we never
- // make it here and none of the changes take effect.
- // Also per spec: we run the "update steps" even if no change was
- // made (ie, if the token already existed)
- this._update(list);
- }},
-
- remove: { value: function() {
- var list = getList(this);
- for (var i = 0, len = arguments.length; i < len; i++) {
- var token = handleErrors(arguments[i]);
- var index = list.indexOf(token);
- if (index > -1) {
- list.splice(index, 1);
- }
- }
- // Note: as per spec, if handleErrors() throws any errors, we never
- // make it here and none of the changes take effect.
- // Also per spec: we run the "update steps" even if no change was
- // made (ie, if the token wasn't previously present)
- this._update(list);
- }},
-
- toggle: { value: function toggle(token, force) {
- token = handleErrors(token);
- if (this.contains(token)) {
- if (force === undefined || force === false) {
- this.remove(token);
- return false;
- }
- return true;
- } else {
- if (force === undefined || force === true) {
- this.add(token);
- return true;
- }
- return false;
- }
- }},
-
- replace: { value: function replace(token, newToken) {
- // weird corner case of spec: if `token` contains whitespace, but
- // `newToken` is the empty string, we must throw SyntaxError not
- // InvalidCharacterError (sigh)
- if (String(newToken)==='') { utils.SyntaxError(); }
- token = handleErrors(token);
- newToken = handleErrors(newToken);
- var list = getList(this);
- var idx = list.indexOf(token);
- if (idx < 0) {
- // Note that, per spec, we do not run the update steps on this path.
- return false;
- }
- var idx2 = list.indexOf(newToken);
- if (idx2 < 0) {
- list[idx] = newToken;
- } else {
- // "replace the first instance of either `token` or `newToken` with
- // `newToken` and remove all other instances"
- if (idx < idx2) {
- list[idx] = newToken;
- list.splice(idx2, 1);
- } else {
- // idx2 is already `newToken`
- list.splice(idx, 1);
- }
- }
- this._update(list);
- return true;
- }},
-
- toString: { value: function() {
- return this._getString();
- }},
-
- value: {
- get: function() {
- return this._getString();
- },
- set: function(v) {
- this._setString(v);
- this._update();
- }
- },
-
- // Called when the setter is called from outside this interface.
- _update: { value: function(list) {
- if (list) {
- fixIndex(this, list);
- this._setString(list.join(" ").trim());
- } else {
- fixIndex(this, getList(this));
- }
- this._lastStringValue = this._getString();
- } },
-});
-
-function fixIndex(clist, list) {
- var oldLength = clist._length;
- var i;
- clist._length = list.length;
- for (i = 0; i < list.length; i++) {
- clist[i] = list[i];
- }
- // Clear/free old entries.
- for (; i < oldLength; i++) {
- clist[i] = undefined;
- }
-}
-
-function handleErrors(token) {
- token = String(token);
- if (token === "") {
- utils.SyntaxError();
- }
- if (/[ \t\r\n\f]/.test(token)) {
- utils.InvalidCharacterError();
- }
- return token;
-}
-
-function toArray(clist) {
- var length = clist._length;
- var arr = Array(length);
- for (var i = 0; i < length; i++) {
- arr[i] = clist[i];
- }
- return arr;
-}
-
-function getList(clist) {
- var strProp = clist._getString();
- if (strProp === clist._lastStringValue) {
- return toArray(clist);
- }
- var str = strProp.replace(/(^[ \t\r\n\f]+)|([ \t\r\n\f]+$)/g, '');
- if (str === "") {
- return [];
- } else {
- var seen = Object.create(null);
- return str.split(/[ \t\r\n\f]+/g).filter(function(n) {
- var key = '$' + n;
- if (seen[key]) { return false; }
- seen[key] = true;
- return true;
- });
- }
-}
--- a/domino/domino-lib/Document.js
+++ /dev/null
@@ -1,884 +1,0 @@
-"use strict";
-module.exports = Document;
-
-var Node = require('./Node');
-var NodeList = require('./NodeList');
-var ContainerNode = require('./ContainerNode');
-var Element = require('./Element');
-var Text = require('./Text');
-var Comment = require('./Comment');
-var Event = require('./Event');
-var DocumentFragment = require('./DocumentFragment');
-var ProcessingInstruction = require('./ProcessingInstruction');
-var DOMImplementation = require('./DOMImplementation');
-var TreeWalker = require('./TreeWalker');
-var NodeIterator = require('./NodeIterator');
-var NodeFilter = require('./NodeFilter');
-var URL = require('./URL');
-var select = require('./select');
-var events = require('./events');
-var xml = require('./xmlnames');
-var html = require('./htmlelts');
-var svg = require('./svg');
-var utils = require('./utils');
-var MUTATE = require('./MutationConstants');
-var NAMESPACE = utils.NAMESPACE;
-var isApiWritable = require("./config").isApiWritable;
-
-function Document(isHTML, address) {
- ContainerNode.call(this);
- this.nodeType = Node.DOCUMENT_NODE;
- this.isHTML = isHTML;
- this._address = address || 'about:blank';
- this.readyState = 'loading';
- this.implementation = new DOMImplementation(this);
-
- // DOMCore says that documents are always associated with themselves
- this.ownerDocument = null; // ... but W3C tests expect null
- this._contentType = isHTML ? 'text/html' : 'application/xml';
-
- // These will be initialized by our custom versions of
- // appendChild and insertBefore that override the inherited
- // Node methods.
- // XXX: override those methods!
- this.doctype = null;
- this.documentElement = null;
-
- // "Associated inert template document"
- this._templateDocCache = null;
- // List of active NodeIterators, see NodeIterator#_preremove()
- this._nodeIterators = null;
-
- // Documents are always rooted, by definition
- this._nid = 1;
- this._nextnid = 2; // For numbering children of the document
- this._nodes = [null, this]; // nid to node map
-
- // This maintains the mapping from element ids to element nodes.
- // We may need to update this mapping every time a node is rooted
- // or uprooted, and any time an attribute is added, removed or changed
- // on a rooted element.
- this.byId = Object.create(null);
-
- // This property holds a monotonically increasing value akin to
- // a timestamp used to record the last modification time of nodes
- // and their subtrees. See the lastModTime attribute and modify()
- // method of the Node class. And see FilteredElementList for an example
- // of the use of lastModTime
- this.modclock = 0;
-}
-
-// Map from lowercase event category names (used as arguments to
-// createEvent()) to the property name in the impl object of the
-// event constructor.
-var supportedEvents = {
- event: 'Event',
- customevent: 'CustomEvent',
- uievent: 'UIEvent',
- mouseevent: 'MouseEvent'
-};
-
-// Certain arguments to document.createEvent() must be treated specially
-var replacementEvent = {
- events: 'event',
- htmlevents: 'event',
- mouseevents: 'mouseevent',
- mutationevents: 'mutationevent',
- uievents: 'uievent'
-};
-
-var mirrorAttr = function(f, name, defaultValue) {
- return {
- get: function() {
- var o = f.call(this);
- if (o) { return o[name]; }
- return defaultValue;
- },
- set: function(value) {
- var o = f.call(this);
- if (o) { o[name] = value; }
- },
- };
-};
-
-/** @spec https://dom.spec.whatwg.org/#validate-and-extract */
-function validateAndExtract(namespace, qualifiedName) {
- var prefix, localName, pos;
- if (namespace==='') { namespace = null; }
- // See https://github.com/whatwg/dom/issues/671
- // and https://github.com/whatwg/dom/issues/319
- if (!xml.isValidQName(qualifiedName)) {
- utils.InvalidCharacterError();
- }
- prefix = null;
- localName = qualifiedName;
-
- pos = qualifiedName.indexOf(':');
- if (pos >= 0) {
- prefix = qualifiedName.substring(0, pos);
- localName = qualifiedName.substring(pos+1);
- }
- if (prefix !== null && namespace === null) {
- utils.NamespaceError();
- }
- if (prefix === 'xml' && namespace !== NAMESPACE.XML) {
- utils.NamespaceError();
- }
- if ((prefix === 'xmlns' || qualifiedName === 'xmlns') &&
- namespace !== NAMESPACE.XMLNS) {
- utils.NamespaceError();
- }
- if (namespace === NAMESPACE.XMLNS && !(prefix==='xmlns' || qualifiedName==='xmlns')) {
- utils.NamespaceError();
- }
- return { namespace: namespace, prefix: prefix, localName: localName };
-}
-
-Document.prototype = Object.create(ContainerNode.prototype, {
- // This method allows dom.js to communicate with a renderer
- // that displays the document in some way
- // XXX: I should probably move this to the window object
- _setMutationHandler: { value: function(handler) {
- this.mutationHandler = handler;
- }},
-
- // This method allows dom.js to receive event notifications
- // from the renderer.
- // XXX: I should probably move this to the window object
- _dispatchRendererEvent: { value: function(targetNid, type, details) {
- var target = this._nodes[targetNid];
- if (!target) return;
- target._dispatchEvent(new Event(type, details), true);
- }},
-
- nodeName: { value: '#document'},
- nodeValue: {
- get: function() {
- return null;
- },
- set: function() {}
- },
-
- // XXX: DOMCore may remove documentURI, so it is NYI for now
- documentURI: { get: function() { return this._address; }, set: utils.nyi.bind(this, 'set documentURI') },
- compatMode: { get: function() {
- // The _quirks property is set by the HTML parser
- return this._quirks ? 'BackCompat' : 'CSS1Compat';
- }},
-
- createTextNode: { value: function(data) {
- return new Text(this, String(data));
- }},
- createComment: { value: function(data) {
- return new Comment(this, data);
- }},
- createDocumentFragment: { value: function() {
- return new DocumentFragment(this);
- }},
- createProcessingInstruction: { value: function(target, data) {
- if (!xml.isValidName(target) || data.indexOf('?>') !== -1)
- utils.InvalidCharacterError();
- return new ProcessingInstruction(this, target, data);
- }},
-
- createAttribute: { value: function(localName) {
- localName = String(localName);
- if (!xml.isValidName(localName)) utils.InvalidCharacterError();
- if (this.isHTML) {
- localName = utils.toASCIILowerCase(localName);
- }
- return new Element._Attr(null, localName, null, null, '');
- }},
- createAttributeNS: { value: function(namespace, qualifiedName) {
- // Convert parameter types according to WebIDL
- namespace =
- (namespace === null || namespace === undefined || namespace === '') ? null :
- String(namespace);
- qualifiedName = String(qualifiedName);
- var ve = validateAndExtract(namespace, qualifiedName);
- return new Element._Attr(null, ve.localName, ve.prefix, ve.namespace, '');
- }},
-
- createElement: { value: function(localName) {
- localName = String(localName);
- if (!xml.isValidName(localName)) utils.InvalidCharacterError();
- // Per spec, namespace should be HTML namespace if "context object is
- // an HTML document or context object's content type is
- // "application/xhtml+xml", and null otherwise.
- if (this.isHTML) {
- if (/[A-Z]/.test(localName))
- localName = utils.toASCIILowerCase(localName);
- return html.createElement(this, localName, null);
- } else if (this.contentType === 'application/xhtml+xml') {
- return html.createElement(this, localName, null);
- } else {
- return new Element(this, localName, null, null);
- }
- }, writable: isApiWritable },
-
- createElementNS: { value: function(namespace, qualifiedName) {
- // Convert parameter types according to WebIDL
- namespace =
- (namespace === null || namespace === undefined || namespace === '') ? null :
- String(namespace);
- qualifiedName = String(qualifiedName);
- var ve = validateAndExtract(namespace, qualifiedName);
- return this._createElementNS(ve.localName, ve.namespace, ve.prefix);
- }, writable: isApiWritable },
-
- // This is used directly by HTML parser, which allows it to create
- // elements with localNames containing ':' and non-default namespaces
- _createElementNS: { value: function(localName, namespace, prefix) {
- if (namespace === NAMESPACE.HTML) {
- return html.createElement(this, localName, prefix);
- }
- else if (namespace === NAMESPACE.SVG) {
- return svg.createElement(this, localName, prefix);
- }
-
- return new Element(this, localName, namespace, prefix);
- }},
-
- createEvent: { value: function createEvent(interfaceName) {
- interfaceName = interfaceName.toLowerCase();
- var name = replacementEvent[interfaceName] || interfaceName;
- var constructor = events[supportedEvents[name]];
-
- if (constructor) {
- var e = new constructor();
- e._initialized = false;
- return e;
- }
- else {
- utils.NotSupportedError();
- }
- }},
-
- // See: http://www.w3.org/TR/dom/#dom-document-createtreewalker
- createTreeWalker: {value: function (root, whatToShow, filter) {
- if (!root) { throw new TypeError("root argument is required"); }
- if (!(root instanceof Node)) { throw new TypeError("root not a node"); }
- whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : (+whatToShow);
- filter = filter === undefined ? null : filter;
-
- return new TreeWalker(root, whatToShow, filter);
- }},
-
- // See: http://www.w3.org/TR/dom/#dom-document-createnodeiterator
- createNodeIterator: {value: function (root, whatToShow, filter) {
- if (!root) { throw new TypeError("root argument is required"); }
- if (!(root instanceof Node)) { throw new TypeError("root not a node"); }
- whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : (+whatToShow);
- filter = filter === undefined ? null : filter;
-
- return new NodeIterator(root, whatToShow, filter);
- }},
-
- _attachNodeIterator: { value: function(ni) {
- // XXX ideally this should be a weak reference from Document to NodeIterator
- if (!this._nodeIterators) { this._nodeIterators = []; }
- this._nodeIterators.push(ni);
- }},
-
- _detachNodeIterator: { value: function(ni) {
- // ni should always be in list of node iterators
- var idx = this._nodeIterators.indexOf(ni);
- this._nodeIterators.splice(idx, 1);
- }},
-
- _preremoveNodeIterators: { value: function(toBeRemoved) {
- if (this._nodeIterators) {
- this._nodeIterators.forEach(function(ni) { ni._preremove(toBeRemoved); });
- }
- }},
-
- // Maintain the documentElement and
- // doctype properties of the document. Each of the following
- // methods chains to the Node implementation of the method
- // to do the actual inserting, removal or replacement.
-
- _updateDocTypeElement: { value: function _updateDocTypeElement() {
- this.doctype = this.documentElement = null;
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === Node.DOCUMENT_TYPE_NODE)
- this.doctype = kid;
- else if (kid.nodeType === Node.ELEMENT_NODE)
- this.documentElement = kid;
- }
- }},
-
- insertBefore: { value: function insertBefore(child, refChild) {
- Node.prototype.insertBefore.call(this, child, refChild);
- this._updateDocTypeElement();
- return child;
- }},
-
- replaceChild: { value: function replaceChild(node, child) {
- Node.prototype.replaceChild.call(this, node, child);
- this._updateDocTypeElement();
- return child;
- }},
-
- removeChild: { value: function removeChild(child) {
- Node.prototype.removeChild.call(this, child);
- this._updateDocTypeElement();
- return child;
- }},
-
- getElementById: { value: function(id) {
- var n = this.byId[id];
- if (!n) return null;
- if (n instanceof MultiId) { // there was more than one element with this id
- return n.getFirst();
- }
- return n;
- }},
-
- _hasMultipleElementsWithId: { value: function(id) {
- // Used internally by querySelectorAll optimization
- return (this.byId[id] instanceof MultiId);
- }},
-
- // Just copy this method from the Element prototype
- getElementsByName: { value: Element.prototype.getElementsByName },
- getElementsByTagName: { value: Element.prototype.getElementsByTagName },
- getElementsByTagNameNS: { value: Element.prototype.getElementsByTagNameNS },
- getElementsByClassName: { value: Element.prototype.getElementsByClassName },
-
- adoptNode: { value: function adoptNode(node) {
- if (node.nodeType === Node.DOCUMENT_NODE) utils.NotSupportedError();
- if (node.nodeType === Node.ATTRIBUTE_NODE) { return node; }
-
- if (node.parentNode) node.parentNode.removeChild(node);
-
- if (node.ownerDocument !== this)
- recursivelySetOwner(node, this);
-
- return node;
- }},
-
- importNode: { value: function importNode(node, deep) {
- return this.adoptNode(node.cloneNode(deep));
- }, writable: isApiWritable },
-
- // The following attributes and methods are from the HTML spec
- origin: { get: function origin() { return null; } },
- characterSet: { get: function characterSet() { return "UTF-8"; } },
- contentType: { get: function contentType() { return this._contentType; } },
- URL: { get: function URL() { return this._address; } },
- domain: { get: utils.nyi.bind(this, 'domain'), set: utils.nyi.bind(this, 'domain') },
- referrer: { get: opossum.referrer },
- //cookie: { get: utils.nyi.bind(this, 'cookie get'), set: utils.nyi.bind(this, 'cookie set') },
- lastModified: { get: utils.nyi.bind(this, 'lastModified get') },
- location: {
- get: function() {
- return this.defaultView ? this.defaultView.location : null; // gh #75
- },
- set: utils.nyi.bind(this, 'location set')
- },
- _titleElement: {
- get: function() {
- // The title element of a document is the first title element in the
- // document in tree order, if there is one, or null otherwise.
- return this.getElementsByTagName('title').item(0) || null;
- }
- },
- title: {
- get: function() {
- var elt = this._titleElement;
- // The child text content of the title element, or '' if null.
- var value = elt ? elt.textContent : '';
- // Strip and collapse whitespace in value
- return value.replace(/[ \t\n\r\f]+/g, ' ').replace(/(^ )|( $)/g, '');
- },
- set: function(value) {
- var elt = this._titleElement;
- var head = this.head;
- if (!elt && !head) { return; /* according to spec */ }
- if (!elt) {
- elt = this.createElement('title');
- head.appendChild(elt);
- }
- elt.textContent = value;
- }
- },
- dir: mirrorAttr(function() {
- var htmlElement = this.documentElement;
- if (htmlElement && htmlElement.tagName === 'HTML') { return htmlElement; }
- }, 'dir', ''),
- fgColor: mirrorAttr(function() { return this.body; }, 'text', ''),
- linkColor: mirrorAttr(function() { return this.body; }, 'link', ''),
- vlinkColor: mirrorAttr(function() { return this.body; }, 'vLink', ''),
- alinkColor: mirrorAttr(function() { return this.body; }, 'aLink', ''),
- bgColor: mirrorAttr(function() { return this.body; }, 'bgColor', ''),
-
- // Historical aliases of Document#characterSet
- charset: { get: function() { return this.characterSet; } },
- inputEncoding: { get: function() { return this.characterSet; } },
-
- scrollingElement: {
- get: function() {
- return this._quirks ? this.body : this.documentElement;
- }
- },
-
- // Return the first <body> child of the document element.
- // XXX For now, setting this attribute is not implemented.
- body: {
- get: function() {
- return namedHTMLChild(this.documentElement, 'body');
- },
- set: utils.nyi.bind(this, 'body set')
- },
- // Return the first <head> child of the document element.
- head: { get: function() {
- return namedHTMLChild(this.documentElement, 'head');
- }},
- images: { get: utils.nyi.bind(this, 'images get') },
- embeds: { get: utils.nyi.bind(this, 'embeds get') },
- plugins: { get: utils.nyi.bind(this, 'plugins get') },
- links: { get: utils.nyi.bind(this, 'links get') },
- forms: { get: utils.nyi.bind(this, 'forms get') },
- scripts: { get: utils.nyi.bind(this, 'scripts get') },
- applets: { get: function() { return []; } },
- activeElement: { get: function() { return null; } },
- innerHTML: {
- get: function() { return this.serialize(); },
- set: utils.nyi
- },
- outerHTML: {
- get: function() { return this.serialize(); },
- set: utils.nyi
- },
-
- write: { value: function(args) {
- if (!this.isHTML) utils.InvalidStateError();
-
- // XXX: still have to implement the ignore part
- if (!this._parser /* && this._ignore_destructive_writes > 0 */ )
- return;
-
- if (!this._parser) {
- // XXX call document.open, etc.
- }
-
- var s = arguments.join('');
-
- // If the Document object's reload override flag is set, then
- // append the string consisting of the concatenation of all the
- // arguments to the method to the Document's reload override
- // buffer.
- // XXX: don't know what this is about. Still have to do it
-
- // If there is no pending parsing-blocking script, have the
- // tokenizer process the characters that were inserted, one at a
- // time, processing resulting tokens as they are emitted, and
- // stopping when the tokenizer reaches the insertion point or when
- // the processing of the tokenizer is aborted by the tree
- // construction stage (this can happen if a script end tag token is
- // emitted by the tokenizer).
-
- // XXX: still have to do the above. Sounds as if we don't
- // always call parse() here. If we're blocked, then we just
- // insert the text into the stream but don't parse it reentrantly...
-
- // Invoke the parser reentrantly
- this._parser.parse(s);
- }},
-
- writeln: { value: function writeln(args) {
- this.write(Array.prototype.join.call(arguments, '') + '\n');
- }},
-
- open: { value: function() {
- this.documentElement = null;
- }},
-
- close: { value: function() {
- this.readyState = 'interactive';
- this._dispatchEvent(new Event('readystatechange'), true);
- this._dispatchEvent(new Event('DOMContentLoaded'), true);
- this.readyState = 'complete';
- this._dispatchEvent(new Event('readystatechange'), true);
- if (this.defaultView) {
- this.defaultView._dispatchEvent(new Event('load'), true);
- }
- }},
-
- // Utility methods
- clone: { value: function clone() {
- var d = new Document(this.isHTML, this._address);
- d._quirks = this._quirks;
- d._contentType = this._contentType;
- return d;
- }},
-
- // We need to adopt the nodes if we do a deep clone
- cloneNode: { value: function cloneNode(deep) {
- var clone = Node.prototype.cloneNode.call(this, false);
- if (deep) {
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- clone._appendChild(clone.importNode(kid, true));
- }
- }
- clone._updateDocTypeElement();
- return clone;
- }},
-
- isEqual: { value: function isEqual(n) {
- // Any two documents are shallowly equal.
- // Node.isEqualNode will also test the children
- return true;
- }},
-
- // Implementation-specific function. Called when a text, comment,
- // or pi value changes.
- mutateValue: { value: function(node) {
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.VALUE,
- target: node,
- data: node.data
- });
- }
- }},
-
- // Invoked when an attribute's value changes. Attr holds the new
- // value. oldval is the old value. Attribute mutations can also
- // involve changes to the prefix (and therefore the qualified name)
- mutateAttr: { value: function(attr, oldval) {
- // Manage id->element mapping for getElementsById()
- // XXX: this special case id handling should not go here,
- // but in the attribute declaration for the id attribute
- /*
- if (attr.localName === 'id' && attr.namespaceURI === null) {
- if (oldval) delId(oldval, attr.ownerElement);
- addId(attr.value, attr.ownerElement);
- }
- */
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.ATTR,
- target: attr.ownerElement,
- attr: attr
- });
- }
- }},
-
- // Used by removeAttribute and removeAttributeNS for attributes.
- mutateRemoveAttr: { value: function(attr) {
-/*
-* This is now handled in Attributes.js
- // Manage id to element mapping
- if (attr.localName === 'id' && attr.namespaceURI === null) {
- this.delId(attr.value, attr.ownerElement);
- }
-*/
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.REMOVE_ATTR,
- target: attr.ownerElement,
- attr: attr
- });
- }
- }},
-
- // Called by Node.removeChild, etc. to remove a rooted element from
- // the tree. Only needs to generate a single mutation event when a
- // node is removed, but must recursively mark all descendants as not
- // rooted.
- mutateRemove: { value: function(node) {
- // Send a single mutation event
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.REMOVE,
- target: node.parentNode,
- node: node
- });
- }
-
- // Mark this and all descendants as not rooted
- recursivelyUproot(node);
- }},
-
- // Called when a new element becomes rooted. It must recursively
- // generate mutation events for each of the children, and mark them all
- // as rooted.
- mutateInsert: { value: function(node) {
- // Mark node and its descendants as rooted
- recursivelyRoot(node);
-
- // Send a single mutation event
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.INSERT,
- target: node.parentNode,
- node: node
- });
- }
- }},
-
- // Called when a rooted element is moved within the document
- mutateMove: { value: function(node) {
- if (this.mutationHandler) {
- this.mutationHandler({
- type: MUTATE.MOVE,
- target: node
- });
- }
- }},
-
-
- // Add a mapping from id to n for n.ownerDocument
- addId: { value: function addId(id, n) {
- var val = this.byId[id];
- if (!val) {
- this.byId[id] = n;
- }
- else {
- // TODO: Add a way to opt-out console warnings
- //console.warn('Duplicate element id ' + id);
- if (!(val instanceof MultiId)) {
- val = new MultiId(val);
- this.byId[id] = val;
- }
- val.add(n);
- }
- }},
-
- // Delete the mapping from id to n for n.ownerDocument
- delId: { value: function delId(id, n) {
- var val = this.byId[id];
- utils.assert(val);
-
- if (val instanceof MultiId) {
- val.del(n);
- if (val.length === 1) { // convert back to a single node
- this.byId[id] = val.downgrade();
- }
- }
- else {
- this.byId[id] = undefined;
- }
- }},
-
- _resolve: { value: function(href) {
- //XXX: Cache the URL
- return new URL(this._documentBaseURL).resolve(href);
- }},
-
- _documentBaseURL: { get: function() {
- // XXX: This is not implemented correctly yet
- var url = this._address;
- if (url === 'about:blank') url = '/';
-
- var base = this.querySelector('base[href]');
- if (base) {
- return new URL(url).resolve(base.getAttribute('href'));
- }
- return url;
-
- // The document base URL of a Document object is the
- // absolute URL obtained by running these substeps:
-
- // Let fallback base url be the document's address.
-
- // If fallback base url is about:blank, and the
- // Document's browsing context has a creator browsing
- // context, then let fallback base url be the document
- // base URL of the creator Document instead.
-
- // If the Document is an iframe srcdoc document, then
- // let fallback base url be the document base URL of
- // the Document's browsing context's browsing context
- // container's Document instead.
-
- // If there is no base element that has an href
- // attribute, then the document base URL is fallback
- // base url; abort these steps. Otherwise, let url be
- // the value of the href attribute of the first such
- // element.
-
- // Resolve url relative to fallback base url (thus,
- // the base href attribute isn't affected by xml:base
- // attributes).
-
- // The document base URL is the result of the previous
- // step if it was successful; otherwise it is fallback
- // base url.
- }},
-
- _templateDoc: { get: function() {
- if (!this._templateDocCache) {
- // "associated inert template document"
- var newDoc = new Document(this.isHTML, this._address);
- this._templateDocCache = newDoc._templateDocCache = newDoc;
- }
- return this._templateDocCache;
- }},
-
- querySelector: { value: function(selector) {
- return select(selector, this)[0];
- }},
-
- querySelectorAll: { value: function(selector) {
- var nodes = select(selector, this);
- return nodes.item ? nodes : new NodeList(nodes);
- }}
-
-});
-
-
-var eventHandlerTypes = [
- 'abort', 'canplay', 'canplaythrough', 'change', 'click', 'contextmenu',
- 'cuechange', 'dblclick', 'drag', 'dragend', 'dragenter', 'dragleave',
- 'dragover', 'dragstart', 'drop', 'durationchange', 'emptied', 'ended',
- 'input', 'invalid', 'keydown', 'keypress', 'keyup', 'loadeddata',
- 'loadedmetadata', 'loadstart', 'mousedown', 'mousemove', 'mouseout',
- 'mouseover', 'mouseup', 'mousewheel', 'pause', 'play', 'playing',
- 'progress', 'ratechange', 'readystatechange', 'reset', 'seeked',
- 'seeking', 'select', 'show', 'stalled', 'submit', 'suspend',
- 'timeupdate', 'volumechange', 'waiting',
-
- 'blur', 'error', 'focus', 'load', 'scroll'
-];
-
-// Add event handler idl attribute getters and setters to Document
-eventHandlerTypes.forEach(function(type) {
- // Define the event handler registration IDL attribute for this type
- Object.defineProperty(Document.prototype, 'on' + type, {
- get: function() {
- return this._getEventHandler(type);
- },
- set: function(v) {
- this._setEventHandler(type, v);
- }
- });
-});
-
-function namedHTMLChild(parent, name) {
- if (parent && parent.isHTML) {
- for (var kid = parent.firstChild; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === Node.ELEMENT_NODE &&
- kid.localName === name &&
- kid.namespaceURI === NAMESPACE.HTML) {
- return kid;
- }
- }
- }
- return null;
-}
-
-function root(n) {
- n._nid = n.ownerDocument._nextnid++;
- n.ownerDocument._nodes[n._nid] = n;
- // Manage id to element mapping
- if (n.nodeType === Node.ELEMENT_NODE) {
- var id = n.getAttribute('id');
- if (id) n.ownerDocument.addId(id, n);
-
- // Script elements need to know when they're inserted
- // into the document
- if (n._roothook) n._roothook();
- }
-}
-
-function uproot(n) {
- // Manage id to element mapping
- if (n.nodeType === Node.ELEMENT_NODE) {
- var id = n.getAttribute('id');
- if (id) n.ownerDocument.delId(id, n);
- }
- n.ownerDocument._nodes[n._nid] = undefined;
- n._nid = undefined;
-}
-
-function recursivelyRoot(node) {
- root(node);
- // XXX:
- // accessing childNodes on a leaf node creates a new array the
- // first time, so be careful to write this loop so that it
- // doesn't do that. node is polymorphic, so maybe this is hard to
- // optimize? Try switching on nodeType?
-/*
- if (node.hasChildNodes()) {
- var kids = node.childNodes;
- for(var i = 0, n = kids.length; i < n; i++)
- recursivelyRoot(kids[i]);
- }
-*/
- if (node.nodeType === Node.ELEMENT_NODE) {
- for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
- recursivelyRoot(kid);
- }
-}
-
-function recursivelyUproot(node) {
- uproot(node);
- for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
- recursivelyUproot(kid);
-}
-
-function recursivelySetOwner(node, owner) {
- node.ownerDocument = owner;
- node._lastModTime = undefined; // mod times are document-based
- if (Object.prototype.hasOwnProperty.call(node, '_tagName')) {
- node._tagName = undefined; // Element subclasses might need to change case
- }
- for (var kid = node.firstChild; kid !== null; kid = kid.nextSibling)
- recursivelySetOwner(kid, owner);
-}
-
-// A class for storing multiple nodes with the same ID
-function MultiId(node) {
- this.nodes = Object.create(null);
- this.nodes[node._nid] = node;
- this.length = 1;
- this.firstNode = undefined;
-}
-
-// Add a node to the list, with O(1) time
-MultiId.prototype.add = function(node) {
- if (!this.nodes[node._nid]) {
- this.nodes[node._nid] = node;
- this.length++;
- this.firstNode = undefined;
- }
-};
-
-// Remove a node from the list, with O(1) time
-MultiId.prototype.del = function(node) {
- if (this.nodes[node._nid]) {
- delete this.nodes[node._nid];
- this.length--;
- this.firstNode = undefined;
- }
-};
-
-// Get the first node from the list, in the document order
-// Takes O(N) time in the size of the list, with a cache that is invalidated
-// when the list is modified.
-MultiId.prototype.getFirst = function() {
- /* jshint bitwise: false */
- if (!this.firstNode) {
- var nid;
- for (nid in this.nodes) {
- if (this.firstNode === undefined ||
- this.firstNode.compareDocumentPosition(this.nodes[nid]) & Node.DOCUMENT_POSITION_PRECEDING) {
- this.firstNode = this.nodes[nid];
- }
- }
- }
- return this.firstNode;
-};
-
-// If there is only one node left, return it. Otherwise return "this".
-MultiId.prototype.downgrade = function() {
- if (this.length === 1) {
- var nid;
- for (nid in this.nodes) {
- return this.nodes[nid];
- }
- }
- return this;
-};
--- a/domino/domino-lib/DocumentFragment.js
+++ /dev/null
@@ -1,68 +1,0 @@
-"use strict";
-module.exports = DocumentFragment;
-
-var Node = require('./Node');
-var NodeList = require('./NodeList');
-var ContainerNode = require('./ContainerNode');
-var Element = require('./Element');
-var select = require('./select');
-var utils = require('./utils');
-
-function DocumentFragment(doc) {
- ContainerNode.call(this);
- this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
- this.ownerDocument = doc;
-}
-
-DocumentFragment.prototype = Object.create(ContainerNode.prototype, {
- nodeName: { value: '#document-fragment' },
- nodeValue: {
- get: function() {
- return null;
- },
- set: function() {}
- },
- // Copy the text content getter/setter from Element
- textContent: Object.getOwnPropertyDescriptor(Element.prototype, 'textContent'),
-
- querySelector: { value: function(selector) {
- // implement in terms of querySelectorAll
- var nodes = this.querySelectorAll(selector);
- return nodes.length ? nodes[0] : null;
- }},
- querySelectorAll: { value: function(selector) {
- // create a context
- var context = Object.create(this);
- // add some methods to the context for zest implementation, without
- // adding them to the public DocumentFragment API
- context.isHTML = true; // in HTML namespace (case-insensitive match)
- context.getElementsByTagName = Element.prototype.getElementsByTagName;
- context.nextElement =
- Object.getOwnPropertyDescriptor(Element.prototype, 'firstElementChild').
- get;
- // invoke zest
- var nodes = select(selector, context);
- return nodes.item ? nodes : new NodeList(nodes);
- }},
-
- // Utility methods
- clone: { value: function clone() {
- return new DocumentFragment(this.ownerDocument);
- }},
- isEqual: { value: function isEqual(n) {
- // Any two document fragments are shallowly equal.
- // Node.isEqualNode() will test their children for equality
- return true;
- }},
-
- // Non-standard, but useful (github issue #73)
- innerHTML: {
- get: function() { return this.serialize(); },
- set: utils.nyi
- },
- outerHTML: {
- get: function() { return this.serialize(); },
- set: utils.nyi
- },
-
-});
--- a/domino/domino-lib/DocumentType.js
+++ /dev/null
@@ -1,36 +1,0 @@
-"use strict";
-module.exports = DocumentType;
-
-var Node = require('./Node');
-var Leaf = require('./Leaf');
-var ChildNode = require('./ChildNode');
-
-function DocumentType(ownerDocument, name, publicId, systemId) {
- Leaf.call(this);
- this.nodeType = Node.DOCUMENT_TYPE_NODE;
- this.ownerDocument = ownerDocument || null;
- this.name = name;
- this.publicId = publicId || "";
- this.systemId = systemId || "";
-}
-
-DocumentType.prototype = Object.create(Leaf.prototype, {
- nodeName: { get: function() { return this.name; }},
- nodeValue: {
- get: function() { return null; },
- set: function() {}
- },
-
- // Utility methods
- clone: { value: function clone() {
- return new DocumentType(this.ownerDocument, this.name, this.publicId, this.systemId);
- }},
-
- isEqual: { value: function isEqual(n) {
- return this.name === n.name &&
- this.publicId === n.publicId &&
- this.systemId === n.systemId;
- }}
-});
-
-Object.defineProperties(DocumentType.prototype, ChildNode);
--- a/domino/domino-lib/Element.js
+++ /dev/null
@@ -1,1202 +1,0 @@
-"use strict";
-module.exports = Element;
-
-var xml = require('./xmlnames');
-var utils = require('./utils');
-var NAMESPACE = utils.NAMESPACE;
-var attributes = require('./attributes');
-var Node = require('./Node');
-var NodeList = require('./NodeList');
-var NodeUtils = require('./NodeUtils');
-var FilteredElementList = require('./FilteredElementList');
-var DOMException = require('./DOMException');
-var DOMTokenList = require('./DOMTokenList');
-var select = require('./select');
-var ContainerNode = require('./ContainerNode');
-var ChildNode = require('./ChildNode');
-var NonDocumentTypeChildNode = require('./NonDocumentTypeChildNode');
-var NamedNodeMap = require('./NamedNodeMap');
-
-var uppercaseCache = Object.create(null);
-
-function Element(doc, localName, namespaceURI, prefix) {
- ContainerNode.call(this);
- this.nodeType = Node.ELEMENT_NODE;
- this.ownerDocument = doc;
- this.localName = localName;
- this.namespaceURI = namespaceURI;
- this.prefix = prefix;
- this._tagName = undefined;
-
- // These properties maintain the set of attributes
- this._attrsByQName = Object.create(null); // The qname->Attr map
- this._attrsByLName = Object.create(null); // The ns|lname->Attr map
- this._attrKeys = []; // attr index -> ns|lname
-}
-
-function recursiveGetText(node, a) {
- if (node.nodeType === Node.TEXT_NODE) {
- a.push(node._data);
- }
- else {
- for(var i = 0, n = node.childNodes.length; i < n; i++)
- recursiveGetText(node.childNodes[i], a);
- }
-}
-
-Element.prototype = Object.create(ContainerNode.prototype, {
- isHTML: { get: function isHTML() {
- return this.namespaceURI === NAMESPACE.HTML && this.ownerDocument.isHTML;
- }},
- tagName: { get: function tagName() {
- if (this._tagName === undefined) {
- var tn;
- if (this.prefix === null) {
- tn = this.localName;
- } else {
- tn = this.prefix + ':' + this.localName;
- }
- if (this.isHTML) {
- var up = uppercaseCache[tn];
- if (!up) {
- // Converting to uppercase can be slow, so cache the conversion.
- uppercaseCache[tn] = up = utils.toASCIIUpperCase(tn);
- }
- tn = up;
- }
- this._tagName = tn;
- }
- return this._tagName;
- }},
- nodeName: { get: function() { return this.tagName; }},
- nodeValue: {
- get: function() {
- return null;
- },
- set: function() {}
- },
- textContent: {
- get: function() {
- var strings = [];
- recursiveGetText(this, strings);
- return strings.join('');
- },
- set: function(newtext) {
- this.removeChildren();
- if (newtext !== null && newtext !== undefined && newtext !== '') {
- this._appendChild(this.ownerDocument.createTextNode(newtext));
- }
- }
- },
- innerHTML: {
- get: function() {
- return this.serialize();
- },
- set: utils.nyi
- },
- outerHTML: {
- get: function() {
- // "the attribute must return the result of running the HTML fragment
- // serialization algorithm on a fictional node whose only child is
- // the context object"
- //
- // The serialization logic is intentionally implemented in a separate
- // `NodeUtils` helper instead of the more obvious choice of a private
- // `_serializeOne()` method on the `Node.prototype` in order to avoid
- // the megamorphic `this._serializeOne` property access, which reduces
- // performance unnecessarily. If you need specialized behavior for a
- // certain subclass, you'll need to implement that in `NodeUtils`.
- // See https://github.com/fgnass/domino/pull/142 for more information.
- return NodeUtils.serializeOne(this, { nodeType: 0 });
- },
- set: function(v) {
- var document = this.ownerDocument;
- var parent = this.parentNode;
- if (parent === null) { return; }
- if (parent.nodeType === Node.DOCUMENT_NODE) {
- utils.NoModificationAllowedError();
- }
- if (parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
- parent = parent.ownerDocument.createElement("body");
- }
- var parser = document.implementation.mozHTMLParser(
- document._address,
- parent
- );
- parser.parse(v===null?'':String(v), true);
- this.replaceWith(parser._asDocumentFragment());
- },
- },
-
- _insertAdjacent: { value: function _insertAdjacent(position, node) {
- var first = false;
- switch(position) {
- case 'beforebegin':
- first = true;
- /* falls through */
- case 'afterend':
- var parent = this.parentNode;
- if (parent === null) { return null; }
- return parent.insertBefore(node, first ? this : this.nextSibling);
- case 'afterbegin':
- first = true;
- /* falls through */
- case 'beforeend':
- return this.insertBefore(node, first ? this.firstChild : null);
- default:
- return utils.SyntaxError();
- }
- }},
-
- insertAdjacentElement: { value: function insertAdjacentElement(position, element) {
- if (element.nodeType !== Node.ELEMENT_NODE) {
- throw new TypeError('not an element');
- }
- position = utils.toASCIILowerCase(String(position));
- return this._insertAdjacent(position, element);
- }},
-
- insertAdjacentText: { value: function insertAdjacentText(position, data) {
- var textNode = this.ownerDocument.createTextNode(data);
- position = utils.toASCIILowerCase(String(position));
- this._insertAdjacent(position, textNode);
- // "This method returns nothing because it existed before we had a chance
- // to design it."
- }},
-
- insertAdjacentHTML: { value: function insertAdjacentHTML(position, text) {
- position = utils.toASCIILowerCase(String(position));
- text = String(text);
- var context;
- switch(position) {
- case 'beforebegin':
- case 'afterend':
- context = this.parentNode;
- if (context === null || context.nodeType === Node.DOCUMENT_NODE) {
- utils.NoModificationAllowedError();
- }
- break;
- case 'afterbegin':
- case 'beforeend':
- context = this;
- break;
- default:
- utils.SyntaxError();
- }
- if ( (!(context instanceof Element)) || (
- context.ownerDocument.isHTML &&
- context.localName === 'html' &&
- context.namespaceURI === NAMESPACE.HTML
- ) ) {
- context = context.ownerDocument.createElementNS(NAMESPACE.HTML, 'body');
- }
- var parser = this.ownerDocument.implementation.mozHTMLParser(
- this.ownerDocument._address, context
- );
- parser.parse(text, true);
- this._insertAdjacent(position, parser._asDocumentFragment());
- }},
-
- children: { get: function() {
- if (!this._children) {
- this._children = new ChildrenCollection(this);
- }
- return this._children;
- }},
-
- attributes: { get: function() {
- if (!this._attributes) {
- this._attributes = new AttributesArray(this);
- }
- return this._attributes;
- }},
-
-
- firstElementChild: { get: function() {
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === Node.ELEMENT_NODE) return kid;
- }
- return null;
- }},
-
- lastElementChild: { get: function() {
- for (var kid = this.lastChild; kid !== null; kid = kid.previousSibling) {
- if (kid.nodeType === Node.ELEMENT_NODE) return kid;
- }
- return null;
- }},
-
- childElementCount: { get: function() {
- return this.children.length;
- }},
-
-
- // Return the next element, in source order, after this one or
- // null if there are no more. If root element is specified,
- // then don't traverse beyond its subtree.
- //
- // This is not a DOM method, but is convenient for
- // lazy traversals of the tree.
- nextElement: { value: function(root) {
- if (!root) root = this.ownerDocument.documentElement;
- var next = this.firstElementChild;
- if (!next) {
- // don't use sibling if we're at root
- if (this===root) return null;
- next = this.nextElementSibling;
- }
- if (next) return next;
-
- // If we can't go down or across, then we have to go up
- // and across to the parent sibling or another ancestor's
- // sibling. Be careful, though: if we reach the root
- // element, or if we reach the documentElement, then
- // the traversal ends.
- for(var parent = this.parentElement;
- parent && parent !== root;
- parent = parent.parentElement) {
-
- next = parent.nextElementSibling;
- if (next) return next;
- }
-
- return null;
- }},
-
- // XXX:
- // Tests are currently failing for this function.
- // Awaiting resolution of:
- // http://lists.w3.org/Archives/Public/www-dom/2011JulSep/0016.html
- getElementsByTagName: { value: function getElementsByTagName(lname) {
- var filter;
- if (!lname) return new NodeList();
- if (lname === '*')
- filter = function() { return true; };
- else if (this.isHTML)
- filter = htmlLocalNameElementFilter(lname);
- else
- filter = localNameElementFilter(lname);
-
- return new FilteredElementList(this, filter);
- }},
-
- getElementsByTagNameNS: { value: function getElementsByTagNameNS(ns, lname){
- var filter;
- if (ns === '*' && lname === '*')
- filter = function() { return true; };
- else if (ns === '*')
- filter = localNameElementFilter(lname);
- else if (lname === '*')
- filter = namespaceElementFilter(ns);
- else
- filter = namespaceLocalNameElementFilter(ns, lname);
-
- return new FilteredElementList(this, filter);
- }},
-
- getElementsByClassName: { value: function getElementsByClassName(names){
- names = String(names).trim();
- if (names === '') {
- var result = new NodeList(); // Empty node list
- return result;
- }
- names = names.split(/[ \t\r\n\f]+/); // Split on ASCII whitespace
- return new FilteredElementList(this, classNamesElementFilter(names));
- }},
-
- getElementsByName: { value: function getElementsByName(name) {
- return new FilteredElementList(this, elementNameFilter(String(name)));
- }},
-
- // Utility methods used by the public API methods above
- clone: { value: function clone() {
- var e;
-
- // XXX:
- // Modify this to use the constructor directly or
- // avoid error checking in some other way. In case we try
- // to clone an invalid node that the parser inserted.
- //
- if (this.namespaceURI !== NAMESPACE.HTML || this.prefix || !this.ownerDocument.isHTML) {
- e = this.ownerDocument.createElementNS(
- this.namespaceURI, (this.prefix !== null) ?
- (this.prefix + ':' + this.localName) : this.localName
- );
- } else {
- e = this.ownerDocument.createElement(this.localName);
- }
-
- for(var i = 0, n = this._attrKeys.length; i < n; i++) {
- var lname = this._attrKeys[i];
- var a = this._attrsByLName[lname];
- var b = a.cloneNode();
- b._setOwnerElement(e);
- e._attrsByLName[lname] = b;
- e._addQName(b);
- }
- e._attrKeys = this._attrKeys.concat();
-
- return e;
- }},
-
- isEqual: { value: function isEqual(that) {
- if (this.localName !== that.localName ||
- this.namespaceURI !== that.namespaceURI ||
- this.prefix !== that.prefix ||
- this._numattrs !== that._numattrs)
- return false;
-
- // Compare the sets of attributes, ignoring order
- // and ignoring attribute prefixes.
- for(var i = 0, n = this._numattrs; i < n; i++) {
- var a = this._attr(i);
- if (!that.hasAttributeNS(a.namespaceURI, a.localName))
- return false;
- if (that.getAttributeNS(a.namespaceURI,a.localName) !== a.value)
- return false;
- }
-
- return true;
- }},
-
- // This is the 'locate a namespace prefix' algorithm from the
- // DOM specification. It is used by Node.lookupPrefix()
- // (Be sure to compare DOM3 and DOM4 versions of spec.)
- _lookupNamespacePrefix: { value: function _lookupNamespacePrefix(ns, originalElement) {
- if (
- this.namespaceURI &&
- this.namespaceURI === ns &&
- this.prefix !== null &&
- originalElement.lookupNamespaceURI(this.prefix) === ns
- ) {
- return this.prefix;
- }
-
- for(var i = 0, n = this._numattrs; i < n; i++) {
- var a = this._attr(i);
- if (
- a.prefix === 'xmlns' &&
- a.value === ns &&
- originalElement.lookupNamespaceURI(a.localName) === ns
- ) {
- return a.localName;
- }
- }
-
- var parent = this.parentElement;
- return parent ? parent._lookupNamespacePrefix(ns, originalElement) : null;
- }},
-
- // This is the 'locate a namespace' algorithm for Element nodes
- // from the DOM Core spec. It is used by Node#lookupNamespaceURI()
- lookupNamespaceURI: { value: function lookupNamespaceURI(prefix) {
- if (prefix === '' || prefix === undefined) { prefix = null; }
- if (this.namespaceURI !== null && this.prefix === prefix)
- return this.namespaceURI;
-
- for(var i = 0, n = this._numattrs; i < n; i++) {
- var a = this._attr(i);
- if (a.namespaceURI === NAMESPACE.XMLNS) {
- if (
- (a.prefix === 'xmlns' && a.localName === prefix) ||
- (prefix === null && a.prefix === null && a.localName === 'xmlns')
- ) {
- return a.value || null;
- }
- }
- }
-
- var parent = this.parentElement;
- return parent ? parent.lookupNamespaceURI(prefix) : null;
- }},
-
- //
- // Attribute handling methods and utilities
- //
-
- /*
- * Attributes in the DOM are tricky:
- *
- * - there are the 8 basic get/set/has/removeAttribute{NS} methods
- *
- * - but many HTML attributes are also 'reflected' through IDL
- * attributes which means that they can be queried and set through
- * regular properties of the element. There is just one attribute
- * value, but two ways to get and set it.
- *
- * - Different HTML element types have different sets of reflected
- attributes.
- *
- * - attributes can also be queried and set through the .attributes
- * property of an element. This property behaves like an array of
- * Attr objects. The value property of each Attr is writeable, so
- * this is a third way to read and write attributes.
- *
- * - for efficiency, we really want to store attributes in some kind
- * of name->attr map. But the attributes[] array is an array, not a
- * map, which is kind of unnatural.
- *
- * - When using namespaces and prefixes, and mixing the NS methods
- * with the non-NS methods, it is apparently actually possible for
- * an attributes[] array to have more than one attribute with the
- * same qualified name. And certain methods must operate on only
- * the first attribute with such a name. So for these methods, an
- * inefficient array-like data structure would be easier to
- * implement.
- *
- * - The attributes[] array is live, not a snapshot, so changes to the
- * attributes must be immediately visible through existing arrays.
- *
- * - When attributes are queried and set through IDL properties
- * (instead of the get/setAttributes() method or the attributes[]
- * array) they may be subject to type conversions, URL
- * normalization, etc., so some extra processing is required in that
- * case.
- *
- * - But access through IDL properties is probably the most common
- * case, so we'd like that to be as fast as possible.
- *
- * - We can't just store attribute values in their parsed idl form,
- * because setAttribute() has to return whatever string is passed to
- * getAttribute even if it is not a legal, parseable value. So
- * attribute values must be stored in unparsed string form.
- *
- * - We need to be able to send change notifications or mutation
- * events of some sort to the renderer whenever an attribute value
- * changes, regardless of the way in which it changes.
- *
- * - Some attributes, such as id and class affect other parts of the
- * DOM API, like getElementById and getElementsByClassName and so
- * for efficiency, we need to specially track changes to these
- * special attributes.
- *
- * - Some attributes like class have different names (className) when
- * reflected.
- *
- * - Attributes whose names begin with the string 'data-' are treated
- specially.
- *
- * - Reflected attributes that have a boolean type in IDL have special
- * behavior: setting them to false (in IDL) is the same as removing
- * them with removeAttribute()
- *
- * - numeric attributes (like HTMLElement.tabIndex) can have default
- * values that must be returned by the idl getter even if the
- * content attribute does not exist. (The default tabIndex value
- * actually varies based on the type of the element, so that is a
- * tricky one).
- *
- * See
- * http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#reflect
- * for rules on how attributes are reflected.
- *
- */
-
- getAttribute: { value: function getAttribute(qname) {
- var attr = this.getAttributeNode(qname);
- return attr ? attr.value : null;
- }},
-
- getAttributeNS: { value: function getAttributeNS(ns, lname) {
- var attr = this.getAttributeNodeNS(ns, lname);
- return attr ? attr.value : null;
- }},
-
- getAttributeNode: { value: function getAttributeNode(qname) {
- qname = String(qname);
- if (/[A-Z]/.test(qname) && this.isHTML)
- qname = utils.toASCIILowerCase(qname);
- var attr = this._attrsByQName[qname];
- if (!attr) return null;
-
- if (Array.isArray(attr)) // If there is more than one
- attr = attr[0]; // use the first
-
- return attr;
- }},
-
- getAttributeNodeNS: { value: function getAttributeNodeNS(ns, lname) {
- ns = (ns === undefined || ns === null) ? '' : String(ns);
- lname = String(lname);
- var attr = this._attrsByLName[ns + '|' + lname];
- return attr ? attr : null;
- }},
-
- hasAttribute: { value: function hasAttribute(qname) {
- qname = String(qname);
- if (/[A-Z]/.test(qname) && this.isHTML)
- qname = utils.toASCIILowerCase(qname);
- return this._attrsByQName[qname] !== undefined;
- }},
-
- hasAttributeNS: { value: function hasAttributeNS(ns, lname) {
- ns = (ns === undefined || ns === null) ? '' : String(ns);
- lname = String(lname);
- var key = ns + '|' + lname;
- return this._attrsByLName[key] !== undefined;
- }},
-
- hasAttributes: { value: function hasAttributes() {
- return this._numattrs > 0;
- }},
-
- toggleAttribute: { value: function toggleAttribute(qname, force) {
- qname = String(qname);
- if (!xml.isValidName(qname)) utils.InvalidCharacterError();
- if (/[A-Z]/.test(qname) && this.isHTML)
- qname = utils.toASCIILowerCase(qname);
- var a = this._attrsByQName[qname];
- if (a === undefined) {
- if (force === undefined || force === true) {
- this._setAttribute(qname, '');
- return true;
- }
- return false;
- } else {
- if (force === undefined || force === false) {
- this.removeAttribute(qname);
- return false;
- }
- return true;
- }
- }},
-
- // Set the attribute without error checking. The parser uses this.
- _setAttribute: { value: function _setAttribute(qname, value) {
- // XXX: the spec says that this next search should be done
- // on the local name, but I think that is an error.
- // email pending on www-dom about it.
- var attr = this._attrsByQName[qname];
- var isnew;
- if (!attr) {
- attr = this._newattr(qname);
- isnew = true;
- }
- else {
- if (Array.isArray(attr)) attr = attr[0];
- }
-
- // Now set the attribute value on the new or existing Attr object.
- // The Attr.value setter method handles mutation events, etc.
- attr.value = value;
- if (this._attributes) this._attributes[qname] = attr;
- if (isnew && this._newattrhook) this._newattrhook(qname, value);
- }},
-
- // Check for errors, and then set the attribute
- setAttribute: { value: function setAttribute(qname, value) {
- qname = String(qname);
- if (!xml.isValidName(qname)) utils.InvalidCharacterError();
- if (/[A-Z]/.test(qname) && this.isHTML)
- qname = utils.toASCIILowerCase(qname);
- this._setAttribute(qname, String(value));
- }},
-
-
- // The version with no error checking used by the parser
- _setAttributeNS: { value: function _setAttributeNS(ns, qname, value) {
- var pos = qname.indexOf(':'), prefix, lname;
- if (pos < 0) {
- prefix = null;
- lname = qname;
- }
- else {
- prefix = qname.substring(0, pos);
- lname = qname.substring(pos+1);
- }
-
- if (ns === '' || ns === undefined) ns = null;
- var key = (ns === null ? '' : ns) + '|' + lname;
-
- var attr = this._attrsByLName[key];
- var isnew;
- if (!attr) {
- attr = new Attr(this, lname, prefix, ns);
- isnew = true;
- this._attrsByLName[key] = attr;
- if (this._attributes) {
- this._attributes[this._attrKeys.length] = attr;
- }
- this._attrKeys.push(key);
-
- // We also have to make the attr searchable by qname.
- // But we have to be careful because there may already
- // be an attr with this qname.
- this._addQName(attr);
- }
- else if (false /* changed in DOM 4 */) {
- // Calling setAttributeNS() can change the prefix of an
- // existing attribute in DOM 2/3.
- if (attr.prefix !== prefix) {
- // Unbind the old qname
- this._removeQName(attr);
- // Update the prefix
- attr.prefix = prefix;
- // Bind the new qname
- this._addQName(attr);
- }
-
- }
- attr.value = value; // Automatically sends mutation event
- if (isnew && this._newattrhook) this._newattrhook(qname, value);
- }},
-
- // Do error checking then call _setAttributeNS
- setAttributeNS: { value: function setAttributeNS(ns, qname, value) {
- // Convert parameter types according to WebIDL
- ns = (ns === null || ns === undefined || ns === '') ? null : String(ns);
- qname = String(qname);
- if (!xml.isValidQName(qname)) utils.InvalidCharacterError();
-
- var pos = qname.indexOf(':');
- var prefix = (pos < 0) ? null : qname.substring(0, pos);
-
- if ((prefix !== null && ns === null) ||
- (prefix === 'xml' && ns !== NAMESPACE.XML) ||
- ((qname === 'xmlns' || prefix === 'xmlns') &&
- (ns !== NAMESPACE.XMLNS)) ||
- (ns === NAMESPACE.XMLNS &&
- !(qname === 'xmlns' || prefix === 'xmlns')))
- utils.NamespaceError();
-
- this._setAttributeNS(ns, qname, String(value));
- }},
-
- setAttributeNode: { value: function setAttributeNode(attr) {
- if (attr.ownerElement !== null && attr.ownerElement !== this) {
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
- }
- var result = null;
- var oldAttrs = this._attrsByQName[attr.name];
- if (oldAttrs) {
- if (!Array.isArray(oldAttrs)) { oldAttrs = [ oldAttrs ]; }
- if (oldAttrs.some(function(a) { return a===attr; })) {
- return attr;
- } else if (attr.ownerElement !== null) {
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
- }
- oldAttrs.forEach(function(a) { this.removeAttributeNode(a); }, this);
- result = oldAttrs[0];
- }
- this.setAttributeNodeNS(attr);
- return result;
- }},
-
- setAttributeNodeNS: { value: function setAttributeNodeNS(attr) {
- if (attr.ownerElement !== null) {
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
- }
- var ns = attr.namespaceURI;
- var key = (ns === null ? '' : ns) + '|' + attr.localName;
- var oldAttr = this._attrsByLName[key];
- if (oldAttr) { this.removeAttributeNode(oldAttr); }
- attr._setOwnerElement(this);
- this._attrsByLName[key] = attr;
- if (this._attributes) {
- this._attributes[this._attrKeys.length] = attr;
- }
- this._attrKeys.push(key);
- this._addQName(attr);
- if (this._newattrhook) this._newattrhook(attr.name, attr.value);
- return oldAttr || null;
- }},
-
- removeAttribute: { value: function removeAttribute(qname) {
- qname = String(qname);
- if (/[A-Z]/.test(qname) && this.isHTML)
- qname = utils.toASCIILowerCase(qname);
-
- var attr = this._attrsByQName[qname];
- if (!attr) return;
-
- // If there is more than one match for this qname
- // so don't delete the qname mapping, just remove the first
- // element from it.
- if (Array.isArray(attr)) {
- if (attr.length > 2) {
- attr = attr.shift(); // remove it from the array
- }
- else {
- this._attrsByQName[qname] = attr[1];
- attr = attr[0];
- }
- }
- else {
- // only a single match, so remove the qname mapping
- this._attrsByQName[qname] = undefined;
- }
-
- var ns = attr.namespaceURI;
- // Now attr is the removed attribute. Figure out its
- // ns+lname key and remove it from the other mapping as well.
- var key = (ns === null ? '' : ns) + '|' + attr.localName;
- this._attrsByLName[key] = undefined;
-
- var i = this._attrKeys.indexOf(key);
- if (this._attributes) {
- Array.prototype.splice.call(this._attributes, i, 1);
- this._attributes[qname] = undefined;
- }
- this._attrKeys.splice(i, 1);
-
- // Onchange handler for the attribute
- var onchange = attr.onchange;
- attr._setOwnerElement(null);
- if (onchange) {
- onchange.call(attr, this, attr.localName, attr.value, null);
- }
- // Mutation event
- if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr);
- }},
-
- removeAttributeNS: { value: function removeAttributeNS(ns, lname) {
- ns = (ns === undefined || ns === null) ? '' : String(ns);
- lname = String(lname);
- var key = ns + '|' + lname;
- var attr = this._attrsByLName[key];
- if (!attr) return;
-
- this._attrsByLName[key] = undefined;
-
- var i = this._attrKeys.indexOf(key);
- if (this._attributes) {
- Array.prototype.splice.call(this._attributes, i, 1);
- }
- this._attrKeys.splice(i, 1);
-
- // Now find the same Attr object in the qname mapping and remove it
- // But be careful because there may be more than one match.
- this._removeQName(attr);
-
- // Onchange handler for the attribute
- var onchange = attr.onchange;
- attr._setOwnerElement(null);
- if (onchange) {
- onchange.call(attr, this, attr.localName, attr.value, null);
- }
- // Mutation event
- if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr);
- }},
-
- removeAttributeNode: { value: function removeAttributeNode(attr) {
- var ns = attr.namespaceURI;
- var key = (ns === null ? '' : ns) + '|' + attr.localName;
- if (this._attrsByLName[key] !== attr) {
- utils.NotFoundError();
- }
- this.removeAttributeNS(ns, attr.localName);
- return attr;
- }},
-
- getAttributeNames: { value: function getAttributeNames() {
- var elt = this;
- return this._attrKeys.map(function(key) {
- return elt._attrsByLName[key].name;
- });
- }},
-
- // This 'raw' version of getAttribute is used by the getter functions
- // of reflected attributes. It skips some error checking and
- // namespace steps
- _getattr: { value: function _getattr(qname) {
- // Assume that qname is already lowercased, so don't do it here.
- // Also don't check whether attr is an array: a qname with no
- // prefix will never have two matching Attr objects (because
- // setAttributeNS doesn't allow a non-null namespace with a
- // null prefix.
- var attr = this._attrsByQName[qname];
- return attr ? attr.value : null;
- }},
-
- // The raw version of setAttribute for reflected idl attributes.
- _setattr: { value: function _setattr(qname, value) {
- var attr = this._attrsByQName[qname];
- var isnew;
- if (!attr) {
- attr = this._newattr(qname);
- isnew = true;
- }
- attr.value = String(value);
- if (this._attributes) this._attributes[qname] = attr;
- if (isnew && this._newattrhook) this._newattrhook(qname, value);
- }},
-
- // Create a new Attr object, insert it, and return it.
- // Used by setAttribute() and by set()
- _newattr: { value: function _newattr(qname) {
- var attr = new Attr(this, qname, null, null);
- var key = '|' + qname;
- this._attrsByQName[qname] = attr;
- this._attrsByLName[key] = attr;
- if (this._attributes) {
- this._attributes[this._attrKeys.length] = attr;
- }
- this._attrKeys.push(key);
- return attr;
- }},
-
- // Add a qname->Attr mapping to the _attrsByQName object, taking into
- // account that there may be more than one attr object with the
- // same qname
- _addQName: { value: function(attr) {
- var qname = attr.name;
- var existing = this._attrsByQName[qname];
- if (!existing) {
- this._attrsByQName[qname] = attr;
- }
- else if (Array.isArray(existing)) {
- existing.push(attr);
- }
- else {
- this._attrsByQName[qname] = [existing, attr];
- }
- if (this._attributes) this._attributes[qname] = attr;
- }},
-
- // Remove a qname->Attr mapping to the _attrsByQName object, taking into
- // account that there may be more than one attr object with the
- // same qname
- _removeQName: { value: function(attr) {
- var qname = attr.name;
- var target = this._attrsByQName[qname];
-
- if (Array.isArray(target)) {
- var idx = target.indexOf(attr);
- utils.assert(idx !== -1); // It must be here somewhere
- if (target.length === 2) {
- this._attrsByQName[qname] = target[1-idx];
- if (this._attributes) {
- this._attributes[qname] = this._attrsByQName[qname];
- }
- } else {
- target.splice(idx, 1);
- if (this._attributes && this._attributes[qname] === attr) {
- this._attributes[qname] = target[0];
- }
- }
- }
- else {
- utils.assert(target === attr); // If only one, it must match
- this._attrsByQName[qname] = undefined;
- if (this._attributes) {
- this._attributes[qname] = undefined;
- }
- }
- }},
-
- // Return the number of attributes
- _numattrs: { get: function() { return this._attrKeys.length; }},
- // Return the nth Attr object
- _attr: { value: function(n) {
- return this._attrsByLName[this._attrKeys[n]];
- }},
-
- // Define getters and setters for an 'id' property that reflects
- // the content attribute 'id'.
- id: attributes.property({name: 'id'}),
-
- // Define getters and setters for a 'className' property that reflects
- // the content attribute 'class'.
- className: attributes.property({name: 'class'}),
-
- classList: { get: function() {
- var self = this;
- if (this._classList) {
- return this._classList;
- }
- var dtlist = new DOMTokenList(
- function() {
- return self.className || "";
- },
- function(v) {
- self.className = v;
- }
- );
- this._classList = dtlist;
- return dtlist;
- }, set: function(v) { this.className = v; }},
-
- matches: { value: function(selector) {
- return select.matches(this, selector);
- }},
-
- closest: { value: function(selector) {
- var el = this;
- do {
- if (el.matches && el.matches(selector)) { return el; }
- el = el.parentElement || el.parentNode;
- } while (el !== null && el.nodeType === Node.ELEMENT_NODE);
- return null;
- }},
-
- querySelector: { value: function(selector) {
- return select(selector, this)[0];
- }},
-
- querySelectorAll: { value: function(selector) {
- var nodes = select(selector, this);
- return nodes.item ? nodes : new NodeList(nodes);
- }}
-
-});
-
-Object.defineProperties(Element.prototype, ChildNode);
-Object.defineProperties(Element.prototype, NonDocumentTypeChildNode);
-
-// Register special handling for the id attribute
-attributes.registerChangeHandler(Element, 'id',
- function(element, lname, oldval, newval) {
- if (element.rooted) {
- if (oldval) {
- element.ownerDocument.delId(oldval, element);
- }
- if (newval) {
- element.ownerDocument.addId(newval, element);
- }
- }
- }
-);
-attributes.registerChangeHandler(Element, 'class',
- function(element, lname, oldval, newval) {
- if (element._classList) { element._classList._update(); }
- }
-);
-
-// The Attr class represents a single attribute. The values in
-// _attrsByQName and _attrsByLName are instances of this class.
-function Attr(elt, lname, prefix, namespace, value) {
- // localName and namespace are constant for any attr object.
- // But value may change. And so can prefix, and so, therefore can name.
- this.localName = lname;
- this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix);
- this.namespaceURI = (namespace===null || namespace==='') ? null : ('' + namespace);
- this.data = value;
- // Set ownerElement last to ensure it is hooked up to onchange handler
- this._setOwnerElement(elt);
-}
-
-// In DOM 3 Attr was supposed to extend Node; in DOM 4 that was abandoned.
-Attr.prototype = Object.create(Object.prototype, {
- ownerElement: {
- get: function() { return this._ownerElement; },
- },
- _setOwnerElement: { value: function _setOwnerElement(elt) {
- this._ownerElement = elt;
- if (this.prefix === null && this.namespaceURI === null && elt) {
- this.onchange = elt._attributeChangeHandlers[this.localName];
- } else {
- this.onchange = null;
- }
- }},
-
- name: { get: function() {
- return this.prefix ? this.prefix + ':' + this.localName : this.localName;
- }},
-
- specified: { get: function() {
- // Deprecated
- return true;
- }},
-
- value: {
- get: function() {
- return this.data;
- },
- set: function(value) {
- var oldval = this.data;
- value = (value === undefined) ? '' : value + '';
- if (value === oldval) return;
-
- this.data = value;
-
- // Run the onchange hook for the attribute
- // if there is one.
- if (this.ownerElement) {
- if (this.onchange)
- this.onchange(this.ownerElement,this.localName, oldval, value);
-
- // Generate a mutation event if the element is rooted
- if (this.ownerElement.rooted)
- this.ownerElement.ownerDocument.mutateAttr(this, oldval);
- }
- },
- },
-
- cloneNode: { value: function cloneNode(deep) {
- // Both this method and Document#createAttribute*() create unowned Attrs
- return new Attr(
- null, this.localName, this.prefix, this.namespaceURI, this.data
- );
- }},
-
- // Legacy aliases (see gh#70 and https://dom.spec.whatwg.org/#interface-attr)
- nodeType: { get: function() { return Node.ATTRIBUTE_NODE; } },
- nodeName: { get: function() { return this.name; } },
- nodeValue: {
- get: function() { return this.value; },
- set: function(v) { this.value = v; },
- },
- textContent: {
- get: function() { return this.value; },
- set: function(v) {
- if (v === null || v === undefined) { v = ''; }
- this.value = v;
- },
- },
-});
-// Sneakily export this class for use by Document.createAttribute()
-Element._Attr = Attr;
-
-// The attributes property of an Element will be an instance of this class.
-// This class is really just a dummy, though. It only defines a length
-// property and an item() method. The AttrArrayProxy that
-// defines the public API just uses the Element object itself.
-function AttributesArray(elt) {
- NamedNodeMap.call(this, elt);
- for (var name in elt._attrsByQName) {
- this[name] = elt._attrsByQName[name];
- }
- for (var i = 0; i < elt._attrKeys.length; i++) {
- this[i] = elt._attrsByLName[elt._attrKeys[i]];
- }
-}
-AttributesArray.prototype = Object.create(NamedNodeMap.prototype, {
- length: { get: function() {
- return this.element._attrKeys.length;
- }, set: function() { /* ignore */ } },
- item: { value: function(n) {
- /* jshint bitwise: false */
- n = n >>> 0;
- if (n >= this.length) { return null; }
- return this.element._attrsByLName[this.element._attrKeys[n]];
- /* jshint bitwise: true */
- } },
-});
-
-// We can't make direct array access work (without Proxies, node >=6)
-// but we can make `Array.from(node.attributes)` and for-of loops work.
-if (global.Symbol && global.Symbol.iterator) {
- AttributesArray.prototype[global.Symbol.iterator] = function() {
- var i=0, n=this.length, self=this;
- return {
- next: function() {
- if (i<n) return { value: self.item(i++) };
- return { done: true };
- }
- };
- };
-}
-
-
-// The children property of an Element will be an instance of this class.
-// It defines length, item() and namedItem() and will be wrapped by an
-// HTMLCollection when exposed through the DOM.
-function ChildrenCollection(e) {
- this.element = e;
- this.updateCache();
-}
-
-ChildrenCollection.prototype = Object.create(Object.prototype, {
- length: { get: function() {
- this.updateCache();
- return this.childrenByNumber.length;
- } },
- item: { value: function item(n) {
- this.updateCache();
- return this.childrenByNumber[n] || null;
- } },
-
- namedItem: { value: function namedItem(name) {
- this.updateCache();
- return this.childrenByName[name] || null;
- } },
-
- // This attribute returns the entire name->element map.
- // It is not part of the HTMLCollection API, but we need it in
- // src/HTMLCollectionProxy
- namedItems: { get: function() {
- this.updateCache();
- return this.childrenByName;
- } },
-
- updateCache: { value: function updateCache() {
- var namedElts = /^(a|applet|area|embed|form|frame|frameset|iframe|img|object)$/;
- if (this.lastModTime !== this.element.lastModTime) {
- this.lastModTime = this.element.lastModTime;
-
- var n = this.childrenByNumber && this.childrenByNumber.length || 0;
- for(var i = 0; i < n; i++) {
- this[i] = undefined;
- }
-
- this.childrenByNumber = [];
- this.childrenByName = Object.create(null);
-
- for (var c = this.element.firstChild; c !== null; c = c.nextSibling) {
- if (c.nodeType === Node.ELEMENT_NODE) {
-
- this[this.childrenByNumber.length] = c;
- this.childrenByNumber.push(c);
-
- // XXX Are there any requirements about the namespace
- // of the id property?
- var id = c.getAttribute('id');
-
- // If there is an id that is not already in use...
- if (id && !this.childrenByName[id])
- this.childrenByName[id] = c;
-
- // For certain HTML elements we check the name attribute
- var name = c.getAttribute('name');
- if (name &&
- this.element.namespaceURI === NAMESPACE.HTML &&
- namedElts.test(this.element.localName) &&
- !this.childrenByName[name])
- this.childrenByName[id] = c;
- }
- }
- }
- } },
-});
-
-// These functions return predicates for filtering elements.
-// They're used by the Document and Element classes for methods like
-// getElementsByTagName and getElementsByClassName
-
-function localNameElementFilter(lname) {
- return function(e) { return e.localName === lname; };
-}
-
-function htmlLocalNameElementFilter(lname) {
- var lclname = utils.toASCIILowerCase(lname);
- if (lclname === lname)
- return localNameElementFilter(lname);
-
- return function(e) {
- return e.isHTML ? e.localName === lclname : e.localName === lname;
- };
-}
-
-function namespaceElementFilter(ns) {
- return function(e) { return e.namespaceURI === ns; };
-}
-
-function namespaceLocalNameElementFilter(ns, lname) {
- return function(e) {
- return e.namespaceURI === ns && e.localName === lname;
- };
-}
-
-function classNamesElementFilter(names) {
- return function(e) {
- return names.every(function(n) { return e.classList.contains(n); });
- };
-}
-
-function elementNameFilter(name) {
- return function(e) {
- // All the *HTML elements* in the document with the given name attribute
- if (e.namespaceURI !== NAMESPACE.HTML) { return false; }
- return e.getAttribute('name') === name;
- };
-}
--- a/domino/domino-lib/Event.js
+++ /dev/null
@@ -1,66 +1,0 @@
-"use strict";
-module.exports = Event;
-
-Event.CAPTURING_PHASE = 1;
-Event.AT_TARGET = 2;
-Event.BUBBLING_PHASE = 3;
-
-function Event(type, dictionary) {
- // Initialize basic event properties
- this.type = '';
- this.target = null;
- this.currentTarget = null;
- this.eventPhase = Event.AT_TARGET;
- this.bubbles = false;
- this.cancelable = false;
- this.isTrusted = false;
- this.defaultPrevented = false;
- this.timeStamp = Date.now();
-
- // Initialize internal flags
- // XXX: Would it be better to inherit these defaults from the prototype?
- this._propagationStopped = false;
- this._immediatePropagationStopped = false;
- this._initialized = true;
- this._dispatching = false;
-
- // Now initialize based on the constructor arguments (if any)
- if (type) this.type = type;
- if (dictionary) {
- for(var p in dictionary) {
- this[p] = dictionary[p];
- }
- }
-}
-
-Event.prototype = Object.create(Object.prototype, {
- constructor: { value: Event },
- stopPropagation: { value: function stopPropagation() {
- this._propagationStopped = true;
- }},
-
- stopImmediatePropagation: { value: function stopImmediatePropagation() {
- this._propagationStopped = true;
- this._immediatePropagationStopped = true;
- }},
-
- preventDefault: { value: function preventDefault() {
- if (this.cancelable) this.defaultPrevented = true;
- }},
-
- initEvent: { value: function initEvent(type, bubbles, cancelable) {
- this._initialized = true;
- if (this._dispatching) return;
-
- this._propagationStopped = false;
- this._immediatePropagationStopped = false;
- this.defaultPrevented = false;
- this.isTrusted = false;
-
- this.target = null;
- this.type = type;
- this.bubbles = bubbles;
- this.cancelable = cancelable;
- }},
-
-});
--- a/domino/domino-lib/EventTarget.js
+++ /dev/null
@@ -1,298 +1,0 @@
-"use strict";
-var Event = require('./Event');
-var MouseEvent = require('./MouseEvent');
-var utils = require('./utils');
-
-module.exports = EventTarget;
-
-function EventTarget() {}
-
-EventTarget.prototype = {
- // XXX
- // See WebIDL §4.8 for details on object event handlers
- // and how they should behave. We actually have to accept
- // any object to addEventListener... Can't type check it.
- // on registration.
-
- // XXX:
- // Capturing event listeners are sort of rare. I think I can optimize
- // them so that dispatchEvent can skip the capturing phase (or much of
- // it). Each time a capturing listener is added, increment a flag on
- // the target node and each of its ancestors. Decrement when removed.
- // And update the counter when nodes are added and removed from the
- // tree as well. Then, in dispatch event, the capturing phase can
- // abort if it sees any node with a zero count.
- addEventListener: function addEventListener(type, listener, capture) {
- if (!listener) return;
- if (capture === undefined) capture = false;
- if (!this._listeners) this._listeners = Object.create(null);
- if (!this._listeners[type]) this._listeners[type] = [];
- var list = this._listeners[type];
-
- // If this listener has already been registered, just return
- for(var i = 0, n = list.length; i < n; i++) {
- var l = list[i];
- if (l.listener === listener && l.capture === capture)
- return;
- }
-
- // Add an object to the list of listeners
- var obj = { listener: listener, capture: capture };
- if (typeof listener === 'function') obj.f = listener;
- list.push(obj);
- },
-
- removeEventListener: function removeEventListener(type,
- listener,
- capture) {
- if (capture === undefined) capture = false;
- if (this._listeners) {
- var list = this._listeners[type];
- if (list) {
- // Find the listener in the list and remove it
- for(var i = 0, n = list.length; i < n; i++) {
- var l = list[i];
- if (l.listener === listener && l.capture === capture) {
- if (list.length === 1) {
- this._listeners[type] = undefined;
- }
- else {
- list.splice(i, 1);
- }
- return;
- }
- }
- }
- }
- },
-
- // This is the public API for dispatching untrusted public events.
- // See _dispatchEvent for the implementation
- dispatchEvent: function dispatchEvent(event) {
- // Dispatch an untrusted event
- return this._dispatchEvent(event, false);
- },
-
- //
- // See DOMCore §4.4
- // XXX: I'll probably need another version of this method for
- // internal use, one that does not set isTrusted to false.
- // XXX: see Document._dispatchEvent: perhaps that and this could
- // call a common internal function with different settings of
- // a trusted boolean argument
- //
- // XXX:
- // The spec has changed in how to deal with handlers registered
- // on idl or content attributes rather than with addEventListener.
- // Used to say that they always ran first. That's how webkit does it
- // Spec now says that they run in a position determined by
- // when they were first set. FF does it that way. See:
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handlers
- //
- _dispatchEvent: function _dispatchEvent(event, trusted) {
- if (typeof trusted !== 'boolean') trusted = false;
- function invoke(target, event) {
- var type = event.type, phase = event.eventPhase;
- event.currentTarget = target;
-
- // If there was an individual handler defined, invoke it first
- // XXX: see comment above: this shouldn't always be first.
- if (phase !== Event.CAPTURING_PHASE &&
- target._handlers && target._handlers[type])
- {
- var handler = target._handlers[type];
- var rv;
- if (typeof handler === 'function') {
- rv=handler.call(event.currentTarget, event);
- }
- else {
- var f = handler.handleEvent;
- if (typeof f !== 'function')
- throw new TypeError('handleEvent property of ' +
- 'event handler object is' +
- 'not a function.');
- rv=f.call(handler, event);
- }
-
- switch(event.type) {
- case 'mouseover':
- if (rv === true) // Historical baggage
- event.preventDefault();
- break;
- case 'beforeunload':
- // XXX: eventually we need a special case here
- /* falls through */
- default:
- if (rv === false)
- event.preventDefault();
- break;
- }
- }
-
- // Now invoke list list of listeners for this target and type
- var list = target._listeners && target._listeners[type];
- if (!list) return;
- list = list.slice();
- for(var i = 0, n = list.length; i < n; i++) {
- if (event._immediatePropagationStopped) return;
- var l = list[i];
- if ((phase === Event.CAPTURING_PHASE && !l.capture) ||
- (phase === Event.BUBBLING_PHASE && l.capture))
- continue;
- if (l.f) {
- l.f.call(event.currentTarget, event);
- }
- else {
- var fn = l.listener.handleEvent;
- if (typeof fn !== 'function')
- throw new TypeError('handleEvent property of event listener object is not a function.');
- fn.call(l.listener, event);
- }
- }
- }
-
- if (!event._initialized || event._dispatching) utils.InvalidStateError();
- event.isTrusted = trusted;
-
- // Begin dispatching the event now
- event._dispatching = true;
- event.target = this;
-
- // Build the list of targets for the capturing and bubbling phases
- // XXX: we'll eventually have to add Window to this list.
- var ancestors = [];
- for(var n = this.parentNode; n; n = n.parentNode)
- ancestors.push(n);
-
- // Capturing phase
- event.eventPhase = Event.CAPTURING_PHASE;
- for(var i = ancestors.length-1; i >= 0; i--) {
- invoke(ancestors[i], event);
- if (event._propagationStopped) break;
- }
-
- // At target phase
- if (!event._propagationStopped) {
- event.eventPhase = Event.AT_TARGET;
- invoke(this, event);
- }
-
- // Bubbling phase
- if (event.bubbles && !event._propagationStopped) {
- event.eventPhase = Event.BUBBLING_PHASE;
- for(var ii = 0, nn = ancestors.length; ii < nn; ii++) {
- invoke(ancestors[ii], event);
- if (event._propagationStopped) break;
- }
- }
-
- event._dispatching = false;
- event.eventPhase = Event.AT_TARGET;
- event.currentTarget = null;
-
- // Deal with mouse events and figure out when
- // a click has happened
- if (trusted && !event.defaultPrevented && event instanceof MouseEvent) {
- switch(event.type) {
- case 'mousedown':
- this._armed = {
- x: event.clientX,
- y: event.clientY,
- t: event.timeStamp
- };
- break;
- case 'mouseout':
- case 'mouseover':
- this._armed = null;
- break;
- case 'mouseup':
- if (this._isClick(event)) this._doClick(event);
- this._armed = null;
- break;
- }
- }
-
-
-
- return !event.defaultPrevented;
- },
-
- // Determine whether a click occurred
- // XXX We don't support double clicks for now
- _isClick: function(event) {
- return (this._armed !== null &&
- event.type === 'mouseup' &&
- event.isTrusted &&
- event.button === 0 &&
- event.timeStamp - this._armed.t < 1000 &&
- Math.abs(event.clientX - this._armed.x) < 10 &&
- Math.abs(event.clientY - this._armed.Y) < 10);
- },
-
- // Clicks are handled like this:
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#interactive-content-0
- //
- // Note that this method is similar to the HTMLElement.click() method
- // The event argument must be the trusted mouseup event
- _doClick: function(event) {
- if (this._click_in_progress) return;
- this._click_in_progress = true;
-
- // Find the nearest enclosing element that is activatable
- // An element is activatable if it has a
- // _post_click_activation_steps hook
- var activated = this;
- while(activated && !activated._post_click_activation_steps)
- activated = activated.parentNode;
-
- if (activated && activated._pre_click_activation_steps) {
- activated._pre_click_activation_steps();
- }
-
- var click = this.ownerDocument.createEvent('MouseEvent');
- click.initMouseEvent('click', true, true,
- this.ownerDocument.defaultView, 1,
- event.screenX, event.screenY,
- event.clientX, event.clientY,
- event.ctrlKey, event.altKey,
- event.shiftKey, event.metaKey,
- event.button, null);
-
- var result = this._dispatchEvent(click, true);
-
- if (activated) {
- if (result) {
- // This is where hyperlinks get followed, for example.
- if (activated._post_click_activation_steps)
- activated._post_click_activation_steps(click);
- }
- else {
- if (activated._cancelled_activation_steps)
- activated._cancelled_activation_steps();
- }
- }
- },
-
- //
- // An event handler is like an event listener, but it registered
- // by setting an IDL or content attribute like onload or onclick.
- // There can only be one of these at a time for any event type.
- // This is an internal method for the attribute accessors and
- // content attribute handlers that need to register events handlers.
- // The type argument is the same as in addEventListener().
- // The handler argument is the same as listeners in addEventListener:
- // it can be a function or an object. Pass null to remove any existing
- // handler. Handlers are always invoked before any listeners of
- // the same type. They are not invoked during the capturing phase
- // of event dispatch.
- //
- _setEventHandler: function _setEventHandler(type, handler) {
- if (!this._handlers) this._handlers = Object.create(null);
- this._handlers[type] = handler;
- },
-
- _getEventHandler: function _getEventHandler(type) {
- return (this._handlers && this._handlers[type]) || null;
- }
-
-};
--- a/domino/domino-lib/FilteredElementList.js
+++ /dev/null
@@ -1,92 +1,0 @@
-"use strict";
-module.exports = FilteredElementList;
-
-var Node = require('./Node');
-
-//
-// This file defines node list implementation that lazily traverses
-// the document tree (or a subtree rooted at any element) and includes
-// only those elements for which a specified filter function returns true.
-// It is used to implement the
-// {Document,Element}.getElementsBy{TagName,ClassName}{,NS} methods.
-//
-// XXX this should inherit from NodeList
-
-function FilteredElementList(root, filter) {
- this.root = root;
- this.filter = filter;
- this.lastModTime = root.lastModTime;
- this.done = false;
- this.cache = [];
- this.traverse();
-}
-
-FilteredElementList.prototype = Object.create(Object.prototype, {
- length: { get: function() {
- this.checkcache();
- if (!this.done) this.traverse();
- return this.cache.length;
- } },
-
- item: { value: function(n) {
- this.checkcache();
- if (!this.done && n >= this.cache.length) {
- // This can lead to O(N^2) behavior if we stop when we get to n
- // and the caller is iterating through the items in order; so
- // be sure to do the full traverse here.
- this.traverse(/*n*/);
- }
- return this.cache[n];
- } },
-
- checkcache: { value: function() {
- if (this.lastModTime !== this.root.lastModTime) {
- // subtree has changed, so invalidate cache
- for (var i = this.cache.length-1; i>=0; i--) {
- this[i] = undefined;
- }
- this.cache.length = 0;
- this.done = false;
- this.lastModTime = this.root.lastModTime;
- }
- } },
-
- // If n is specified, then traverse the tree until we've found the nth
- // item (or until we've found all items). If n is not specified,
- // traverse until we've found all items.
- traverse: { value: function(n) {
- // increment n so we can compare to length, and so it is never falsy
- if (n !== undefined) n++;
-
- var elt;
- while ((elt = this.next()) !== null) {
- this[this.cache.length] = elt; //XXX Use proxy instead
- this.cache.push(elt);
- if (n && this.cache.length === n) return;
- }
-
- // no next element, so we've found everything
- this.done = true;
- } },
-
- // Return the next element under root that matches filter
- next: { value: function() {
- var start = (this.cache.length === 0) ? this.root // Start at the root or at
- : this.cache[this.cache.length-1]; // the last element we found
-
- var elt;
- if (start.nodeType === Node.DOCUMENT_NODE)
- elt = start.documentElement;
- else
- elt = start.nextElement(this.root);
-
- while(elt) {
- if (this.filter(elt)) {
- return elt;
- }
-
- elt = elt.nextElement(this.root);
- }
- return null;
- } },
-});
--- a/domino/domino-lib/HTMLParser.js
+++ /dev/null
@@ -1,7264 +1,0 @@
-"use strict";
-module.exports = HTMLParser;
-
-var Document = require('./Document');
-var DocumentType = require('./DocumentType');
-var Node = require('./Node');
-var NAMESPACE = require('./utils').NAMESPACE;
-var html = require('./htmlelts');
-var impl = html.elements;
-
-var pushAll = Function.prototype.apply.bind(Array.prototype.push);
-
-/*
- * This file contains an implementation of the HTML parsing algorithm.
- * The algorithm and the implementation are complex because HTML
- * explicitly defines how the parser should behave for all possible
- * valid and invalid inputs.
- *
- * Usage:
- *
- * The file defines a single HTMLParser() function, which dom.js exposes
- * publicly as document.implementation.mozHTMLParser(). This is a
- * factory function, not a constructor.
- *
- * When you call document.implementation.mozHTMLParser(), it returns
- * an object that has parse() and document() methods. To parse HTML text,
- * pass the text (in one or more chunks) to the parse() method. When
- * you've passed all the text (on the last chunk, or afterward) pass
- * true as the second argument to parse() to tell the parser that there
- * is no more coming. Call document() to get the document object that
- * the parser is parsing into. You can call this at any time, before
- * or after calling parse().
- *
- * The first argument to mozHTMLParser is the absolute URL of the document.
- *
- * The second argument is optional and is for internal use only. Pass an
- * element as the fragmentContext to do innerHTML parsing for the
- * element. To do innerHTML parsing on a document, pass null. Otherwise,
- * omit the 2nd argument. See HTMLElement.innerHTML for an example. Note
- * that if you pass a context element, the end() method will return an
- * unwrapped document instead of a wrapped one.
- *
- * Implementation details:
- *
- * This is a long file of almost 7000 lines. It is structured as one
- * big function nested within another big function. The outer
- * function defines a bunch of constant data, utility functions
- * that use that data, and a couple of classes used by the parser.
- * The outer function also defines and returns the
- * inner function. This inner function is the HTMLParser factory
- * function that implements the parser and holds all the parser state
- * as local variables. The HTMLParser function is quite big because
- * it defines many nested functions that use those local variables.
- *
- * There are three tightly coupled parser stages: a scanner, a
- * tokenizer and a tree builder. In a (possibly misguided) attempt at
- * efficiency, the stages are not implemented as separate classes:
- * everything shares state and is (mostly) implemented in imperative
- * (rather than OO) style.
- *
- * The stages of the parser work like this: When the client code calls
- * the parser's parse() method, the specified string is passed to
- * scanChars(). The scanner loops through that string and passes characters
- * (sometimes one at a time, sometimes in chunks) to the tokenizer stage.
- * The tokenizer groups the characters into tokens: tags, endtags, runs
- * of text, comments, doctype declarations, and the end-of-file (EOF)
- * token. These tokens are then passed to the tree building stage via
- * the insertToken() function. The tree building stage builds up the
- * document tree.
- *
- * The tokenizer stage is a finite state machine. Each state is
- * implemented as a function with a name that ends in "_state". The
- * initial state is data_state(). The current tokenizer state is stored
- * in the variable 'tokenizer'. Most state functions expect a single
- * integer argument which represents a single UTF-16 codepoint. Some
- * states want more characters and set a lookahead property on
- * themselves. The scanChars() function in the scanner checks for this
- * lookahead property. If it doesn't exist, then scanChars() just passes
- * the next input character to the current tokenizer state function.
- * Otherwise, scanChars() looks ahead (a given # of characters, or for a
- * matching string, or for a matching regexp) and passes a string of
- * characters to the current tokenizer state function.
- *
- * As a shortcut, certain states of the tokenizer use regular expressions
- * to look ahead in the scanner's input buffer for runs of text, simple
- * tags and attributes. For well-formed input, these shortcuts skip a
- * lot of state transitions and speed things up a bit.
- *
- * When a tokenizer state function has consumed a complete token, it
- * emits that token, by calling insertToken(), or by calling a utility
- * function that itself calls insertToken(). These tokens are passed to
- * the tree building stage, which is also a state machine. Like the
- * tokenizer, the tree building states are implemented as functions, and
- * these functions have names that end with _mode (because the HTML spec
- * refers to them as insertion modes). The current insertion mode is held
- * by the 'parser' variable. Each insertion mode function takes up to 4
- * arguments. The first is a token type, represented by the constants
- * TAG, ENDTAG, TEXT, COMMENT, DOCTYPE and EOF. The second argument is
- * the value of the token: the text or comment data, or tagname or
- * doctype. For tags, the 3rd argument is an array of attributes. For
- * DOCTYPES it is the optional public id. For tags, the 4th argument is
- * true if the tag is self-closing. For doctypes, the 4th argument is the
- * optional system id.
- *
- * Search for "***" to find the major sub-divisions in the code.
- */
-
-
-/***
- * Data prolog. Lots of constants declared here, including some
- * very large objects. They're used throughout the code that follows
- */
-// Token types for the tree builder.
-var EOF = -1;
-var TEXT = 1;
-var TAG = 2;
-var ENDTAG = 3;
-var COMMENT = 4;
-var DOCTYPE = 5;
-
-// A re-usable empty array
-var NOATTRS = [];
-
-// These DTD public ids put the browser in quirks mode
-var quirkyPublicIds = /^HTML$|^-\/\/W3O\/\/DTD W3 HTML Strict 3\.0\/\/EN\/\/$|^-\/W3C\/DTD HTML 4\.0 Transitional\/EN$|^\+\/\/Silmaril\/\/dtd html Pro v0r11 19970101\/\/|^-\/\/AdvaSoft Ltd\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/AS\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict\/\/|^-\/\/IETF\/\/DTD HTML 2\.0\/\/|^-\/\/IETF\/\/DTD HTML 2\.1E\/\/|^-\/\/IETF\/\/DTD HTML 3\.0\/\/|^-\/\/IETF\/\/DTD HTML 3\.2 Final\/\/|^-\/\/IETF\/\/DTD HTML 3\.2\/\/|^-\/\/IETF\/\/DTD HTML 3\/\/|^-\/\/IETF\/\/DTD HTML Level 0\/\/|^-\/\/IETF\/\/DTD HTML Level 1\/\/|^-\/\/IETF\/\/DTD HTML Level 2\/\/|^-\/\/IETF\/\/DTD HTML Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 0\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict\/\/|^-\/\/IETF\/\/DTD HTML\/\/|^-\/\/Metrius\/\/DTD Metrius Presentational\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 Tables\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 Tables\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD HTML\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD Strict HTML\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML 2\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended 1\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended Relaxed 1\.0\/\/|^-\/\/SoftQuad Software\/\/DTD HoTMetaL PRO 6\.0::19990601::extensions to HTML 4\.0\/\/|^-\/\/SoftQuad\/\/DTD HoTMetaL PRO 4\.0::19971010::extensions to HTML 4\.0\/\/|^-\/\/Spyglass\/\/DTD HTML 2\.0 Extended\/\/|^-\/\/SQ\/\/DTD HTML 2\.0 HoTMetaL \+ extensions\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava HTML\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava Strict HTML\/\/|^-\/\/W3C\/\/DTD HTML 3 1995-03-24\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Draft\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Final\/\/|^-\/\/W3C\/\/DTD HTML 3\.2\/\/|^-\/\/W3C\/\/DTD HTML 3\.2S Draft\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Transitional\/\/|^-\/\/W3C\/\/DTD HTML Experimental 19960712\/\/|^-\/\/W3C\/\/DTD HTML Experimental 970421\/\/|^-\/\/W3C\/\/DTD W3 HTML\/\/|^-\/\/W3O\/\/DTD W3 HTML 3\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML 2\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML\/\//i;
-
-var quirkySystemId = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd";
-
-var conditionallyQuirkyPublicIds = /^-\/\/W3C\/\/DTD HTML 4\.01 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.01 Transitional\/\//i;
-
-// These DTD public ids put the browser in limited quirks mode
-var limitedQuirkyPublicIds = /^-\/\/W3C\/\/DTD XHTML 1\.0 Frameset\/\/|^-\/\/W3C\/\/DTD XHTML 1\.0 Transitional\/\//i;
-
-
-// Element sets below. See the isA() function for a way to test
-// whether an element is a member of a set
-var specialSet = Object.create(null);
-specialSet[NAMESPACE.HTML] = {
- __proto__: null,
- "address":true, "applet":true, "area":true, "article":true,
- "aside":true, "base":true, "basefont":true, "bgsound":true,
- "blockquote":true, "body":true, "br":true, "button":true,
- "caption":true, "center":true, "col":true, "colgroup":true,
- "dd":true, "details":true, "dir":true,
- "div":true, "dl":true, "dt":true, "embed":true,
- "fieldset":true, "figcaption":true, "figure":true, "footer":true,
- "form":true, "frame":true, "frameset":true, "h1":true,
- "h2":true, "h3":true, "h4":true, "h5":true,
- "h6":true, "head":true, "header":true, "hgroup":true,
- "hr":true, "html":true, "iframe":true, "img":true,
- "input":true, "li":true, "link":true,
- "listing":true, "main":true, "marquee":true, "menu":true, "meta":true,
- "nav":true, "noembed":true, "noframes":true, "noscript":true,
- "object":true, "ol":true, "p":true, "param":true,
- "plaintext":true, "pre":true, "script":true, "section":true,
- "select":true, "source":true, "style":true, "summary":true, "table":true,
- "tbody":true, "td":true, "template":true, "textarea":true, "tfoot":true,
- "th":true, "thead":true, "title":true, "tr":true, "track":true,
- // Note that "xmp" was removed from the "special" set in the latest
- // spec, apparently by accident; see
- // https://github.com/whatwg/html/pull/1919
- "ul":true, "wbr":true, "xmp":true
-};
-specialSet[NAMESPACE.SVG] = {
- __proto__: null,
- "foreignObject": true, "desc": true, "title": true
-};
-specialSet[NAMESPACE.MATHML] = {
- __proto__: null,
- "mi":true, "mo":true, "mn":true, "ms":true,
- "mtext":true, "annotation-xml":true
-};
-
-// The set of address, div, and p HTML tags
-var addressdivpSet = Object.create(null);
-addressdivpSet[NAMESPACE.HTML] = {
- __proto__: null,
- "address":true, "div":true, "p":true
-};
-
-var dddtSet = Object.create(null);
-dddtSet[NAMESPACE.HTML] = {
- __proto__: null,
- "dd":true, "dt":true
-};
-
-var tablesectionrowSet = Object.create(null);
-tablesectionrowSet[NAMESPACE.HTML] = {
- __proto__: null,
- "table":true, "thead":true, "tbody":true, "tfoot":true, "tr":true
-};
-
-var impliedEndTagsSet = Object.create(null);
-impliedEndTagsSet[NAMESPACE.HTML] = {
- __proto__: null,
- "dd": true, "dt": true, "li": true, "menuitem": true, "optgroup": true,
- "option": true, "p": true, "rb": true, "rp": true, "rt": true, "rtc": true
-};
-
-var thoroughImpliedEndTagsSet = Object.create(null);
-thoroughImpliedEndTagsSet[NAMESPACE.HTML] = {
- __proto__: null,
- "caption": true, "colgroup": true, "dd": true, "dt": true, "li": true,
- "optgroup": true, "option": true, "p": true, "rb": true, "rp": true,
- "rt": true, "rtc": true, "tbody": true, "td": true, "tfoot": true,
- "th": true, "thead": true, "tr": true
-};
-
-var tableContextSet = Object.create(null);
-tableContextSet[NAMESPACE.HTML] = {
- __proto__: null,
- "table": true, "template": true, "html": true
-};
-
-var tableBodyContextSet = Object.create(null);
-tableBodyContextSet[NAMESPACE.HTML] = {
- __proto__: null,
- "tbody": true, "tfoot": true, "thead": true, "template": true, "html": true
-};
-
-var tableRowContextSet = Object.create(null);
-tableRowContextSet[NAMESPACE.HTML] = {
- __proto__: null,
- "tr": true, "template": true, "html": true
-};
-
-// See http://www.w3.org/TR/html5/forms.html#form-associated-element
-var formassociatedSet = Object.create(null);
-formassociatedSet[NAMESPACE.HTML] = {
- __proto__: null,
- "button": true, "fieldset": true, "input": true, "keygen": true,
- "object": true, "output": true, "select": true, "textarea": true,
- "img": true
-};
-
-var inScopeSet = Object.create(null);
-inScopeSet[NAMESPACE.HTML]= {
- __proto__: null,
- "applet":true, "caption":true, "html":true, "table":true,
- "td":true, "th":true, "marquee":true, "object":true,
- "template":true
-};
-inScopeSet[NAMESPACE.MATHML] = {
- __proto__: null,
- "mi":true, "mo":true, "mn":true, "ms":true,
- "mtext":true, "annotation-xml":true
-};
-inScopeSet[NAMESPACE.SVG] = {
- __proto__: null,
- "foreignObject":true, "desc":true, "title":true
-};
-
-var inListItemScopeSet = Object.create(inScopeSet);
-inListItemScopeSet[NAMESPACE.HTML] =
- Object.create(inScopeSet[NAMESPACE.HTML]);
-inListItemScopeSet[NAMESPACE.HTML].ol = true;
-inListItemScopeSet[NAMESPACE.HTML].ul = true;
-
-var inButtonScopeSet = Object.create(inScopeSet);
-inButtonScopeSet[NAMESPACE.HTML] =
- Object.create(inScopeSet[NAMESPACE.HTML]);
-inButtonScopeSet[NAMESPACE.HTML].button = true;
-
-var inTableScopeSet = Object.create(null);
-inTableScopeSet[NAMESPACE.HTML] = {
- __proto__: null,
- "html":true, "table":true, "template":true
-};
-
-// The set of elements for select scope is the everything *except* these
-var invertedSelectScopeSet = Object.create(null);
-invertedSelectScopeSet[NAMESPACE.HTML] = {
- __proto__: null,
- "optgroup":true, "option":true
-};
-
-var mathmlTextIntegrationPointSet = Object.create(null);
-mathmlTextIntegrationPointSet[NAMESPACE.MATHML] = {
- __proto__: null,
- mi: true,
- mo: true,
- mn: true,
- ms: true,
- mtext: true
-};
-
-var htmlIntegrationPointSet = Object.create(null);
-htmlIntegrationPointSet[NAMESPACE.SVG] = {
- __proto__: null,
- foreignObject: true,
- desc: true,
- title: true
-};
-
-var foreignAttributes = {
- __proto__: null,
- "xlink:actuate": NAMESPACE.XLINK, "xlink:arcrole": NAMESPACE.XLINK,
- "xlink:href": NAMESPACE.XLINK, "xlink:role": NAMESPACE.XLINK,
- "xlink:show": NAMESPACE.XLINK, "xlink:title": NAMESPACE.XLINK,
- "xlink:type": NAMESPACE.XLINK, "xml:base": NAMESPACE.XML,
- "xml:lang": NAMESPACE.XML, "xml:space": NAMESPACE.XML,
- "xmlns": NAMESPACE.XMLNS, "xmlns:xlink": NAMESPACE.XMLNS
-};
-
-
-// Lowercase to mixed case mapping for SVG attributes and tagnames
-var svgAttrAdjustments = {
- __proto__: null,
- attributename: "attributeName", attributetype: "attributeType",
- basefrequency: "baseFrequency", baseprofile: "baseProfile",
- calcmode: "calcMode", clippathunits: "clipPathUnits",
- diffuseconstant: "diffuseConstant",
- edgemode: "edgeMode",
- filterunits: "filterUnits",
- glyphref: "glyphRef", gradienttransform: "gradientTransform",
- gradientunits: "gradientUnits", kernelmatrix: "kernelMatrix",
- kernelunitlength: "kernelUnitLength", keypoints: "keyPoints",
- keysplines: "keySplines", keytimes: "keyTimes",
- lengthadjust: "lengthAdjust", limitingconeangle: "limitingConeAngle",
- markerheight: "markerHeight", markerunits: "markerUnits",
- markerwidth: "markerWidth", maskcontentunits: "maskContentUnits",
- maskunits: "maskUnits", numoctaves: "numOctaves",
- pathlength: "pathLength", patterncontentunits: "patternContentUnits",
- patterntransform: "patternTransform", patternunits: "patternUnits",
- pointsatx: "pointsAtX", pointsaty: "pointsAtY",
- pointsatz: "pointsAtZ", preservealpha: "preserveAlpha",
- preserveaspectratio: "preserveAspectRatio",
- primitiveunits: "primitiveUnits", refx: "refX",
- refy: "refY", repeatcount: "repeatCount",
- repeatdur: "repeatDur", requiredextensions: "requiredExtensions",
- requiredfeatures: "requiredFeatures",
- specularconstant: "specularConstant",
- specularexponent: "specularExponent", spreadmethod: "spreadMethod",
- startoffset: "startOffset", stddeviation: "stdDeviation",
- stitchtiles: "stitchTiles", surfacescale: "surfaceScale",
- systemlanguage: "systemLanguage", tablevalues: "tableValues",
- targetx: "targetX", targety: "targetY",
- textlength: "textLength", viewbox: "viewBox",
- viewtarget: "viewTarget", xchannelselector: "xChannelSelector",
- ychannelselector: "yChannelSelector", zoomandpan: "zoomAndPan"
-};
-
-var svgTagNameAdjustments = {
- __proto__: null,
- altglyph: "altGlyph", altglyphdef: "altGlyphDef",
- altglyphitem: "altGlyphItem", animatecolor: "animateColor",
- animatemotion: "animateMotion", animatetransform: "animateTransform",
- clippath: "clipPath", feblend: "feBlend",
- fecolormatrix: "feColorMatrix",
- fecomponenttransfer: "feComponentTransfer", fecomposite: "feComposite",
- feconvolvematrix: "feConvolveMatrix",
- fediffuselighting: "feDiffuseLighting",
- fedisplacementmap: "feDisplacementMap",
- fedistantlight: "feDistantLight", feflood: "feFlood",
- fefunca: "feFuncA", fefuncb: "feFuncB",
- fefuncg: "feFuncG", fefuncr: "feFuncR",
- fegaussianblur: "feGaussianBlur", feimage: "feImage",
- femerge: "feMerge", femergenode: "feMergeNode",
- femorphology: "feMorphology", feoffset: "feOffset",
- fepointlight: "fePointLight", fespecularlighting: "feSpecularLighting",
- fespotlight: "feSpotLight", fetile: "feTile",
- feturbulence: "feTurbulence", foreignobject: "foreignObject",
- glyphref: "glyphRef", lineargradient: "linearGradient",
- radialgradient: "radialGradient", textpath: "textPath"
-};
-
-
-// Data for parsing numeric and named character references
-// These next 3 objects are direct translations of tables
-// in the HTML spec into JavaScript object format
-var numericCharRefReplacements = {
- __proto__: null,
- 0x00:0xFFFD, 0x80:0x20AC, 0x82:0x201A, 0x83:0x0192, 0x84:0x201E,
- 0x85:0x2026, 0x86:0x2020, 0x87:0x2021, 0x88:0x02C6, 0x89:0x2030,
- 0x8A:0x0160, 0x8B:0x2039, 0x8C:0x0152, 0x8E:0x017D, 0x91:0x2018,
- 0x92:0x2019, 0x93:0x201C, 0x94:0x201D, 0x95:0x2022, 0x96:0x2013,
- 0x97:0x2014, 0x98:0x02DC, 0x99:0x2122, 0x9A:0x0161, 0x9B:0x203A,
- 0x9C:0x0153, 0x9E:0x017E, 0x9F:0x0178
-};
-
-/*
- * This table is generated with test/tools/update-entities.js
- */
-var namedCharRefs = {
- __proto__: null,
- "AElig":0xc6, "AElig;":0xc6,
- "AMP":0x26, "AMP;":0x26,
- "Aacute":0xc1, "Aacute;":0xc1,
- "Abreve;":0x102, "Acirc":0xc2,
- "Acirc;":0xc2, "Acy;":0x410,
- "Afr;":[0xd835,0xdd04], "Agrave":0xc0,
- "Agrave;":0xc0, "Alpha;":0x391,
- "Amacr;":0x100, "And;":0x2a53,
- "Aogon;":0x104, "Aopf;":[0xd835,0xdd38],
- "ApplyFunction;":0x2061, "Aring":0xc5,
- "Aring;":0xc5, "Ascr;":[0xd835,0xdc9c],
- "Assign;":0x2254, "Atilde":0xc3,
- "Atilde;":0xc3, "Auml":0xc4,
- "Auml;":0xc4, "Backslash;":0x2216,
- "Barv;":0x2ae7, "Barwed;":0x2306,
- "Bcy;":0x411, "Because;":0x2235,
- "Bernoullis;":0x212c, "Beta;":0x392,
- "Bfr;":[0xd835,0xdd05], "Bopf;":[0xd835,0xdd39],
- "Breve;":0x2d8, "Bscr;":0x212c,
- "Bumpeq;":0x224e, "CHcy;":0x427,
- "COPY":0xa9, "COPY;":0xa9,
- "Cacute;":0x106, "Cap;":0x22d2,
- "CapitalDifferentialD;":0x2145, "Cayleys;":0x212d,
- "Ccaron;":0x10c, "Ccedil":0xc7,
- "Ccedil;":0xc7, "Ccirc;":0x108,
- "Cconint;":0x2230, "Cdot;":0x10a,
- "Cedilla;":0xb8, "CenterDot;":0xb7,
- "Cfr;":0x212d, "Chi;":0x3a7,
- "CircleDot;":0x2299, "CircleMinus;":0x2296,
- "CirclePlus;":0x2295, "CircleTimes;":0x2297,
- "ClockwiseContourIntegral;":0x2232, "CloseCurlyDoubleQuote;":0x201d,
- "CloseCurlyQuote;":0x2019, "Colon;":0x2237,
- "Colone;":0x2a74, "Congruent;":0x2261,
- "Conint;":0x222f, "ContourIntegral;":0x222e,
- "Copf;":0x2102, "Coproduct;":0x2210,
- "CounterClockwiseContourIntegral;":0x2233, "Cross;":0x2a2f,
- "Cscr;":[0xd835,0xdc9e], "Cup;":0x22d3,
- "CupCap;":0x224d, "DD;":0x2145,
- "DDotrahd;":0x2911, "DJcy;":0x402,
- "DScy;":0x405, "DZcy;":0x40f,
- "Dagger;":0x2021, "Darr;":0x21a1,
- "Dashv;":0x2ae4, "Dcaron;":0x10e,
- "Dcy;":0x414, "Del;":0x2207,
- "Delta;":0x394, "Dfr;":[0xd835,0xdd07],
- "DiacriticalAcute;":0xb4, "DiacriticalDot;":0x2d9,
- "DiacriticalDoubleAcute;":0x2dd, "DiacriticalGrave;":0x60,
- "DiacriticalTilde;":0x2dc, "Diamond;":0x22c4,
- "DifferentialD;":0x2146, "Dopf;":[0xd835,0xdd3b],
- "Dot;":0xa8, "DotDot;":0x20dc,
- "DotEqual;":0x2250, "DoubleContourIntegral;":0x222f,
- "DoubleDot;":0xa8, "DoubleDownArrow;":0x21d3,
- "DoubleLeftArrow;":0x21d0, "DoubleLeftRightArrow;":0x21d4,
- "DoubleLeftTee;":0x2ae4, "DoubleLongLeftArrow;":0x27f8,
- "DoubleLongLeftRightArrow;":0x27fa, "DoubleLongRightArrow;":0x27f9,
- "DoubleRightArrow;":0x21d2, "DoubleRightTee;":0x22a8,
- "DoubleUpArrow;":0x21d1, "DoubleUpDownArrow;":0x21d5,
- "DoubleVerticalBar;":0x2225, "DownArrow;":0x2193,
- "DownArrowBar;":0x2913, "DownArrowUpArrow;":0x21f5,
- "DownBreve;":0x311, "DownLeftRightVector;":0x2950,
- "DownLeftTeeVector;":0x295e, "DownLeftVector;":0x21bd,
- "DownLeftVectorBar;":0x2956, "DownRightTeeVector;":0x295f,
- "DownRightVector;":0x21c1, "DownRightVectorBar;":0x2957,
- "DownTee;":0x22a4, "DownTeeArrow;":0x21a7,
- "Downarrow;":0x21d3, "Dscr;":[0xd835,0xdc9f],
- "Dstrok;":0x110, "ENG;":0x14a,
- "ETH":0xd0, "ETH;":0xd0,
- "Eacute":0xc9, "Eacute;":0xc9,
- "Ecaron;":0x11a, "Ecirc":0xca,
- "Ecirc;":0xca, "Ecy;":0x42d,
- "Edot;":0x116, "Efr;":[0xd835,0xdd08],
- "Egrave":0xc8, "Egrave;":0xc8,
- "Element;":0x2208, "Emacr;":0x112,
- "EmptySmallSquare;":0x25fb, "EmptyVerySmallSquare;":0x25ab,
- "Eogon;":0x118, "Eopf;":[0xd835,0xdd3c],
- "Epsilon;":0x395, "Equal;":0x2a75,
- "EqualTilde;":0x2242, "Equilibrium;":0x21cc,
- "Escr;":0x2130, "Esim;":0x2a73,
- "Eta;":0x397, "Euml":0xcb,
- "Euml;":0xcb, "Exists;":0x2203,
- "ExponentialE;":0x2147, "Fcy;":0x424,
- "Ffr;":[0xd835,0xdd09], "FilledSmallSquare;":0x25fc,
- "FilledVerySmallSquare;":0x25aa, "Fopf;":[0xd835,0xdd3d],
- "ForAll;":0x2200, "Fouriertrf;":0x2131,
- "Fscr;":0x2131, "GJcy;":0x403,
- "GT":0x3e, "GT;":0x3e,
- "Gamma;":0x393, "Gammad;":0x3dc,
- "Gbreve;":0x11e, "Gcedil;":0x122,
- "Gcirc;":0x11c, "Gcy;":0x413,
- "Gdot;":0x120, "Gfr;":[0xd835,0xdd0a],
- "Gg;":0x22d9, "Gopf;":[0xd835,0xdd3e],
- "GreaterEqual;":0x2265, "GreaterEqualLess;":0x22db,
- "GreaterFullEqual;":0x2267, "GreaterGreater;":0x2aa2,
- "GreaterLess;":0x2277, "GreaterSlantEqual;":0x2a7e,
- "GreaterTilde;":0x2273, "Gscr;":[0xd835,0xdca2],
- "Gt;":0x226b, "HARDcy;":0x42a,
- "Hacek;":0x2c7, "Hat;":0x5e,
- "Hcirc;":0x124, "Hfr;":0x210c,
- "HilbertSpace;":0x210b, "Hopf;":0x210d,
- "HorizontalLine;":0x2500, "Hscr;":0x210b,
- "Hstrok;":0x126, "HumpDownHump;":0x224e,
- "HumpEqual;":0x224f, "IEcy;":0x415,
- "IJlig;":0x132, "IOcy;":0x401,
- "Iacute":0xcd, "Iacute;":0xcd,
- "Icirc":0xce, "Icirc;":0xce,
- "Icy;":0x418, "Idot;":0x130,
- "Ifr;":0x2111, "Igrave":0xcc,
- "Igrave;":0xcc, "Im;":0x2111,
- "Imacr;":0x12a, "ImaginaryI;":0x2148,
- "Implies;":0x21d2, "Int;":0x222c,
- "Integral;":0x222b, "Intersection;":0x22c2,
- "InvisibleComma;":0x2063, "InvisibleTimes;":0x2062,
- "Iogon;":0x12e, "Iopf;":[0xd835,0xdd40],
- "Iota;":0x399, "Iscr;":0x2110,
- "Itilde;":0x128, "Iukcy;":0x406,
- "Iuml":0xcf, "Iuml;":0xcf,
- "Jcirc;":0x134, "Jcy;":0x419,
- "Jfr;":[0xd835,0xdd0d], "Jopf;":[0xd835,0xdd41],
- "Jscr;":[0xd835,0xdca5], "Jsercy;":0x408,
- "Jukcy;":0x404, "KHcy;":0x425,
- "KJcy;":0x40c, "Kappa;":0x39a,
- "Kcedil;":0x136, "Kcy;":0x41a,
- "Kfr;":[0xd835,0xdd0e], "Kopf;":[0xd835,0xdd42],
- "Kscr;":[0xd835,0xdca6], "LJcy;":0x409,
- "LT":0x3c, "LT;":0x3c,
- "Lacute;":0x139, "Lambda;":0x39b,
- "Lang;":0x27ea, "Laplacetrf;":0x2112,
- "Larr;":0x219e, "Lcaron;":0x13d,
- "Lcedil;":0x13b, "Lcy;":0x41b,
- "LeftAngleBracket;":0x27e8, "LeftArrow;":0x2190,
- "LeftArrowBar;":0x21e4, "LeftArrowRightArrow;":0x21c6,
- "LeftCeiling;":0x2308, "LeftDoubleBracket;":0x27e6,
- "LeftDownTeeVector;":0x2961, "LeftDownVector;":0x21c3,
- "LeftDownVectorBar;":0x2959, "LeftFloor;":0x230a,
- "LeftRightArrow;":0x2194, "LeftRightVector;":0x294e,
- "LeftTee;":0x22a3, "LeftTeeArrow;":0x21a4,
- "LeftTeeVector;":0x295a, "LeftTriangle;":0x22b2,
- "LeftTriangleBar;":0x29cf, "LeftTriangleEqual;":0x22b4,
- "LeftUpDownVector;":0x2951, "LeftUpTeeVector;":0x2960,
- "LeftUpVector;":0x21bf, "LeftUpVectorBar;":0x2958,
- "LeftVector;":0x21bc, "LeftVectorBar;":0x2952,
- "Leftarrow;":0x21d0, "Leftrightarrow;":0x21d4,
- "LessEqualGreater;":0x22da, "LessFullEqual;":0x2266,
- "LessGreater;":0x2276, "LessLess;":0x2aa1,
- "LessSlantEqual;":0x2a7d, "LessTilde;":0x2272,
- "Lfr;":[0xd835,0xdd0f], "Ll;":0x22d8,
- "Lleftarrow;":0x21da, "Lmidot;":0x13f,
- "LongLeftArrow;":0x27f5, "LongLeftRightArrow;":0x27f7,
- "LongRightArrow;":0x27f6, "Longleftarrow;":0x27f8,
- "Longleftrightarrow;":0x27fa, "Longrightarrow;":0x27f9,
- "Lopf;":[0xd835,0xdd43], "LowerLeftArrow;":0x2199,
- "LowerRightArrow;":0x2198, "Lscr;":0x2112,
- "Lsh;":0x21b0, "Lstrok;":0x141,
- "Lt;":0x226a, "Map;":0x2905,
- "Mcy;":0x41c, "MediumSpace;":0x205f,
- "Mellintrf;":0x2133, "Mfr;":[0xd835,0xdd10],
- "MinusPlus;":0x2213, "Mopf;":[0xd835,0xdd44],
- "Mscr;":0x2133, "Mu;":0x39c,
- "NJcy;":0x40a, "Nacute;":0x143,
- "Ncaron;":0x147, "Ncedil;":0x145,
- "Ncy;":0x41d, "NegativeMediumSpace;":0x200b,
- "NegativeThickSpace;":0x200b, "NegativeThinSpace;":0x200b,
- "NegativeVeryThinSpace;":0x200b, "NestedGreaterGreater;":0x226b,
- "NestedLessLess;":0x226a, "NewLine;":0xa,
- "Nfr;":[0xd835,0xdd11], "NoBreak;":0x2060,
- "NonBreakingSpace;":0xa0, "Nopf;":0x2115,
- "Not;":0x2aec, "NotCongruent;":0x2262,
- "NotCupCap;":0x226d, "NotDoubleVerticalBar;":0x2226,
- "NotElement;":0x2209, "NotEqual;":0x2260,
- "NotEqualTilde;":[0x2242,0x338], "NotExists;":0x2204,
- "NotGreater;":0x226f, "NotGreaterEqual;":0x2271,
- "NotGreaterFullEqual;":[0x2267,0x338], "NotGreaterGreater;":[0x226b,0x338],
- "NotGreaterLess;":0x2279, "NotGreaterSlantEqual;":[0x2a7e,0x338],
- "NotGreaterTilde;":0x2275, "NotHumpDownHump;":[0x224e,0x338],
- "NotHumpEqual;":[0x224f,0x338], "NotLeftTriangle;":0x22ea,
- "NotLeftTriangleBar;":[0x29cf,0x338], "NotLeftTriangleEqual;":0x22ec,
- "NotLess;":0x226e, "NotLessEqual;":0x2270,
- "NotLessGreater;":0x2278, "NotLessLess;":[0x226a,0x338],
- "NotLessSlantEqual;":[0x2a7d,0x338], "NotLessTilde;":0x2274,
- "NotNestedGreaterGreater;":[0x2aa2,0x338], "NotNestedLessLess;":[0x2aa1,0x338],
- "NotPrecedes;":0x2280, "NotPrecedesEqual;":[0x2aaf,0x338],
- "NotPrecedesSlantEqual;":0x22e0, "NotReverseElement;":0x220c,
- "NotRightTriangle;":0x22eb, "NotRightTriangleBar;":[0x29d0,0x338],
- "NotRightTriangleEqual;":0x22ed, "NotSquareSubset;":[0x228f,0x338],
- "NotSquareSubsetEqual;":0x22e2, "NotSquareSuperset;":[0x2290,0x338],
- "NotSquareSupersetEqual;":0x22e3, "NotSubset;":[0x2282,0x20d2],
- "NotSubsetEqual;":0x2288, "NotSucceeds;":0x2281,
- "NotSucceedsEqual;":[0x2ab0,0x338], "NotSucceedsSlantEqual;":0x22e1,
- "NotSucceedsTilde;":[0x227f,0x338], "NotSuperset;":[0x2283,0x20d2],
- "NotSupersetEqual;":0x2289, "NotTilde;":0x2241,
- "NotTildeEqual;":0x2244, "NotTildeFullEqual;":0x2247,
- "NotTildeTilde;":0x2249, "NotVerticalBar;":0x2224,
- "Nscr;":[0xd835,0xdca9], "Ntilde":0xd1,
- "Ntilde;":0xd1, "Nu;":0x39d,
- "OElig;":0x152, "Oacute":0xd3,
- "Oacute;":0xd3, "Ocirc":0xd4,
- "Ocirc;":0xd4, "Ocy;":0x41e,
- "Odblac;":0x150, "Ofr;":[0xd835,0xdd12],
- "Ograve":0xd2, "Ograve;":0xd2,
- "Omacr;":0x14c, "Omega;":0x3a9,
- "Omicron;":0x39f, "Oopf;":[0xd835,0xdd46],
- "OpenCurlyDoubleQuote;":0x201c, "OpenCurlyQuote;":0x2018,
- "Or;":0x2a54, "Oscr;":[0xd835,0xdcaa],
- "Oslash":0xd8, "Oslash;":0xd8,
- "Otilde":0xd5, "Otilde;":0xd5,
- "Otimes;":0x2a37, "Ouml":0xd6,
- "Ouml;":0xd6, "OverBar;":0x203e,
- "OverBrace;":0x23de, "OverBracket;":0x23b4,
- "OverParenthesis;":0x23dc, "PartialD;":0x2202,
- "Pcy;":0x41f, "Pfr;":[0xd835,0xdd13],
- "Phi;":0x3a6, "Pi;":0x3a0,
- "PlusMinus;":0xb1, "Poincareplane;":0x210c,
- "Popf;":0x2119, "Pr;":0x2abb,
- "Precedes;":0x227a, "PrecedesEqual;":0x2aaf,
- "PrecedesSlantEqual;":0x227c, "PrecedesTilde;":0x227e,
- "Prime;":0x2033, "Product;":0x220f,
- "Proportion;":0x2237, "Proportional;":0x221d,
- "Pscr;":[0xd835,0xdcab], "Psi;":0x3a8,
- "QUOT":0x22, "QUOT;":0x22,
- "Qfr;":[0xd835,0xdd14], "Qopf;":0x211a,
- "Qscr;":[0xd835,0xdcac], "RBarr;":0x2910,
- "REG":0xae, "REG;":0xae,
- "Racute;":0x154, "Rang;":0x27eb,
- "Rarr;":0x21a0, "Rarrtl;":0x2916,
- "Rcaron;":0x158, "Rcedil;":0x156,
- "Rcy;":0x420, "Re;":0x211c,
- "ReverseElement;":0x220b, "ReverseEquilibrium;":0x21cb,
- "ReverseUpEquilibrium;":0x296f, "Rfr;":0x211c,
- "Rho;":0x3a1, "RightAngleBracket;":0x27e9,
- "RightArrow;":0x2192, "RightArrowBar;":0x21e5,
- "RightArrowLeftArrow;":0x21c4, "RightCeiling;":0x2309,
- "RightDoubleBracket;":0x27e7, "RightDownTeeVector;":0x295d,
- "RightDownVector;":0x21c2, "RightDownVectorBar;":0x2955,
- "RightFloor;":0x230b, "RightTee;":0x22a2,
- "RightTeeArrow;":0x21a6, "RightTeeVector;":0x295b,
- "RightTriangle;":0x22b3, "RightTriangleBar;":0x29d0,
- "RightTriangleEqual;":0x22b5, "RightUpDownVector;":0x294f,
- "RightUpTeeVector;":0x295c, "RightUpVector;":0x21be,
- "RightUpVectorBar;":0x2954, "RightVector;":0x21c0,
- "RightVectorBar;":0x2953, "Rightarrow;":0x21d2,
- "Ropf;":0x211d, "RoundImplies;":0x2970,
- "Rrightarrow;":0x21db, "Rscr;":0x211b,
- "Rsh;":0x21b1, "RuleDelayed;":0x29f4,
- "SHCHcy;":0x429, "SHcy;":0x428,
- "SOFTcy;":0x42c, "Sacute;":0x15a,
- "Sc;":0x2abc, "Scaron;":0x160,
- "Scedil;":0x15e, "Scirc;":0x15c,
- "Scy;":0x421, "Sfr;":[0xd835,0xdd16],
- "ShortDownArrow;":0x2193, "ShortLeftArrow;":0x2190,
- "ShortRightArrow;":0x2192, "ShortUpArrow;":0x2191,
- "Sigma;":0x3a3, "SmallCircle;":0x2218,
- "Sopf;":[0xd835,0xdd4a], "Sqrt;":0x221a,
- "Square;":0x25a1, "SquareIntersection;":0x2293,
- "SquareSubset;":0x228f, "SquareSubsetEqual;":0x2291,
- "SquareSuperset;":0x2290, "SquareSupersetEqual;":0x2292,
- "SquareUnion;":0x2294, "Sscr;":[0xd835,0xdcae],
- "Star;":0x22c6, "Sub;":0x22d0,
- "Subset;":0x22d0, "SubsetEqual;":0x2286,
- "Succeeds;":0x227b, "SucceedsEqual;":0x2ab0,
- "SucceedsSlantEqual;":0x227d, "SucceedsTilde;":0x227f,
- "SuchThat;":0x220b, "Sum;":0x2211,
- "Sup;":0x22d1, "Superset;":0x2283,
- "SupersetEqual;":0x2287, "Supset;":0x22d1,
- "THORN":0xde, "THORN;":0xde,
- "TRADE;":0x2122, "TSHcy;":0x40b,
- "TScy;":0x426, "Tab;":0x9,
- "Tau;":0x3a4, "Tcaron;":0x164,
- "Tcedil;":0x162, "Tcy;":0x422,
- "Tfr;":[0xd835,0xdd17], "Therefore;":0x2234,
- "Theta;":0x398, "ThickSpace;":[0x205f,0x200a],
- "ThinSpace;":0x2009, "Tilde;":0x223c,
- "TildeEqual;":0x2243, "TildeFullEqual;":0x2245,
- "TildeTilde;":0x2248, "Topf;":[0xd835,0xdd4b],
- "TripleDot;":0x20db, "Tscr;":[0xd835,0xdcaf],
- "Tstrok;":0x166, "Uacute":0xda,
- "Uacute;":0xda, "Uarr;":0x219f,
- "Uarrocir;":0x2949, "Ubrcy;":0x40e,
- "Ubreve;":0x16c, "Ucirc":0xdb,
- "Ucirc;":0xdb, "Ucy;":0x423,
- "Udblac;":0x170, "Ufr;":[0xd835,0xdd18],
- "Ugrave":0xd9, "Ugrave;":0xd9,
- "Umacr;":0x16a, "UnderBar;":0x5f,
- "UnderBrace;":0x23df, "UnderBracket;":0x23b5,
- "UnderParenthesis;":0x23dd, "Union;":0x22c3,
- "UnionPlus;":0x228e, "Uogon;":0x172,
- "Uopf;":[0xd835,0xdd4c], "UpArrow;":0x2191,
- "UpArrowBar;":0x2912, "UpArrowDownArrow;":0x21c5,
- "UpDownArrow;":0x2195, "UpEquilibrium;":0x296e,
- "UpTee;":0x22a5, "UpTeeArrow;":0x21a5,
- "Uparrow;":0x21d1, "Updownarrow;":0x21d5,
- "UpperLeftArrow;":0x2196, "UpperRightArrow;":0x2197,
- "Upsi;":0x3d2, "Upsilon;":0x3a5,
- "Uring;":0x16e, "Uscr;":[0xd835,0xdcb0],
- "Utilde;":0x168, "Uuml":0xdc,
- "Uuml;":0xdc, "VDash;":0x22ab,
- "Vbar;":0x2aeb, "Vcy;":0x412,
- "Vdash;":0x22a9, "Vdashl;":0x2ae6,
- "Vee;":0x22c1, "Verbar;":0x2016,
- "Vert;":0x2016, "VerticalBar;":0x2223,
- "VerticalLine;":0x7c, "VerticalSeparator;":0x2758,
- "VerticalTilde;":0x2240, "VeryThinSpace;":0x200a,
- "Vfr;":[0xd835,0xdd19], "Vopf;":[0xd835,0xdd4d],
- "Vscr;":[0xd835,0xdcb1], "Vvdash;":0x22aa,
- "Wcirc;":0x174, "Wedge;":0x22c0,
- "Wfr;":[0xd835,0xdd1a], "Wopf;":[0xd835,0xdd4e],
- "Wscr;":[0xd835,0xdcb2], "Xfr;":[0xd835,0xdd1b],
- "Xi;":0x39e, "Xopf;":[0xd835,0xdd4f],
- "Xscr;":[0xd835,0xdcb3], "YAcy;":0x42f,
- "YIcy;":0x407, "YUcy;":0x42e,
- "Yacute":0xdd, "Yacute;":0xdd,
- "Ycirc;":0x176, "Ycy;":0x42b,
- "Yfr;":[0xd835,0xdd1c], "Yopf;":[0xd835,0xdd50],
- "Yscr;":[0xd835,0xdcb4], "Yuml;":0x178,
- "ZHcy;":0x416, "Zacute;":0x179,
- "Zcaron;":0x17d, "Zcy;":0x417,
- "Zdot;":0x17b, "ZeroWidthSpace;":0x200b,
- "Zeta;":0x396, "Zfr;":0x2128,
- "Zopf;":0x2124, "Zscr;":[0xd835,0xdcb5],
- "aacute":0xe1, "aacute;":0xe1,
- "abreve;":0x103, "ac;":0x223e,
- "acE;":[0x223e,0x333], "acd;":0x223f,
- "acirc":0xe2, "acirc;":0xe2,
- "acute":0xb4, "acute;":0xb4,
- "acy;":0x430, "aelig":0xe6,
- "aelig;":0xe6, "af;":0x2061,
- "afr;":[0xd835,0xdd1e], "agrave":0xe0,
- "agrave;":0xe0, "alefsym;":0x2135,
- "aleph;":0x2135, "alpha;":0x3b1,
- "amacr;":0x101, "amalg;":0x2a3f,
- "amp":0x26, "amp;":0x26,
- "and;":0x2227, "andand;":0x2a55,
- "andd;":0x2a5c, "andslope;":0x2a58,
- "andv;":0x2a5a, "ang;":0x2220,
- "ange;":0x29a4, "angle;":0x2220,
- "angmsd;":0x2221, "angmsdaa;":0x29a8,
- "angmsdab;":0x29a9, "angmsdac;":0x29aa,
- "angmsdad;":0x29ab, "angmsdae;":0x29ac,
- "angmsdaf;":0x29ad, "angmsdag;":0x29ae,
- "angmsdah;":0x29af, "angrt;":0x221f,
- "angrtvb;":0x22be, "angrtvbd;":0x299d,
- "angsph;":0x2222, "angst;":0xc5,
- "angzarr;":0x237c, "aogon;":0x105,
- "aopf;":[0xd835,0xdd52], "ap;":0x2248,
- "apE;":0x2a70, "apacir;":0x2a6f,
- "ape;":0x224a, "apid;":0x224b,
- "apos;":0x27, "approx;":0x2248,
- "approxeq;":0x224a, "aring":0xe5,
- "aring;":0xe5, "ascr;":[0xd835,0xdcb6],
- "ast;":0x2a, "asymp;":0x2248,
- "asympeq;":0x224d, "atilde":0xe3,
- "atilde;":0xe3, "auml":0xe4,
- "auml;":0xe4, "awconint;":0x2233,
- "awint;":0x2a11, "bNot;":0x2aed,
- "backcong;":0x224c, "backepsilon;":0x3f6,
- "backprime;":0x2035, "backsim;":0x223d,
- "backsimeq;":0x22cd, "barvee;":0x22bd,
- "barwed;":0x2305, "barwedge;":0x2305,
- "bbrk;":0x23b5, "bbrktbrk;":0x23b6,
- "bcong;":0x224c, "bcy;":0x431,
- "bdquo;":0x201e, "becaus;":0x2235,
- "because;":0x2235, "bemptyv;":0x29b0,
- "bepsi;":0x3f6, "bernou;":0x212c,
- "beta;":0x3b2, "beth;":0x2136,
- "between;":0x226c, "bfr;":[0xd835,0xdd1f],
- "bigcap;":0x22c2, "bigcirc;":0x25ef,
- "bigcup;":0x22c3, "bigodot;":0x2a00,
- "bigoplus;":0x2a01, "bigotimes;":0x2a02,
- "bigsqcup;":0x2a06, "bigstar;":0x2605,
- "bigtriangledown;":0x25bd, "bigtriangleup;":0x25b3,
- "biguplus;":0x2a04, "bigvee;":0x22c1,
- "bigwedge;":0x22c0, "bkarow;":0x290d,
- "blacklozenge;":0x29eb, "blacksquare;":0x25aa,
- "blacktriangle;":0x25b4, "blacktriangledown;":0x25be,
- "blacktriangleleft;":0x25c2, "blacktriangleright;":0x25b8,
- "blank;":0x2423, "blk12;":0x2592,
- "blk14;":0x2591, "blk34;":0x2593,
- "block;":0x2588, "bne;":[0x3d,0x20e5],
- "bnequiv;":[0x2261,0x20e5], "bnot;":0x2310,
- "bopf;":[0xd835,0xdd53], "bot;":0x22a5,
- "bottom;":0x22a5, "bowtie;":0x22c8,
- "boxDL;":0x2557, "boxDR;":0x2554,
- "boxDl;":0x2556, "boxDr;":0x2553,
- "boxH;":0x2550, "boxHD;":0x2566,
- "boxHU;":0x2569, "boxHd;":0x2564,
- "boxHu;":0x2567, "boxUL;":0x255d,
- "boxUR;":0x255a, "boxUl;":0x255c,
- "boxUr;":0x2559, "boxV;":0x2551,
- "boxVH;":0x256c, "boxVL;":0x2563,
- "boxVR;":0x2560, "boxVh;":0x256b,
- "boxVl;":0x2562, "boxVr;":0x255f,
- "boxbox;":0x29c9, "boxdL;":0x2555,
- "boxdR;":0x2552, "boxdl;":0x2510,
- "boxdr;":0x250c, "boxh;":0x2500,
- "boxhD;":0x2565, "boxhU;":0x2568,
- "boxhd;":0x252c, "boxhu;":0x2534,
- "boxminus;":0x229f, "boxplus;":0x229e,
- "boxtimes;":0x22a0, "boxuL;":0x255b,
- "boxuR;":0x2558, "boxul;":0x2518,
- "boxur;":0x2514, "boxv;":0x2502,
- "boxvH;":0x256a, "boxvL;":0x2561,
- "boxvR;":0x255e, "boxvh;":0x253c,
- "boxvl;":0x2524, "boxvr;":0x251c,
- "bprime;":0x2035, "breve;":0x2d8,
- "brvbar":0xa6, "brvbar;":0xa6,
- "bscr;":[0xd835,0xdcb7], "bsemi;":0x204f,
- "bsim;":0x223d, "bsime;":0x22cd,
- "bsol;":0x5c, "bsolb;":0x29c5,
- "bsolhsub;":0x27c8, "bull;":0x2022,
- "bullet;":0x2022, "bump;":0x224e,
- "bumpE;":0x2aae, "bumpe;":0x224f,
- "bumpeq;":0x224f, "cacute;":0x107,
- "cap;":0x2229, "capand;":0x2a44,
- "capbrcup;":0x2a49, "capcap;":0x2a4b,
- "capcup;":0x2a47, "capdot;":0x2a40,
- "caps;":[0x2229,0xfe00], "caret;":0x2041,
- "caron;":0x2c7, "ccaps;":0x2a4d,
- "ccaron;":0x10d, "ccedil":0xe7,
- "ccedil;":0xe7, "ccirc;":0x109,
- "ccups;":0x2a4c, "ccupssm;":0x2a50,
- "cdot;":0x10b, "cedil":0xb8,
- "cedil;":0xb8, "cemptyv;":0x29b2,
- "cent":0xa2, "cent;":0xa2,
- "centerdot;":0xb7, "cfr;":[0xd835,0xdd20],
- "chcy;":0x447, "check;":0x2713,
- "checkmark;":0x2713, "chi;":0x3c7,
- "cir;":0x25cb, "cirE;":0x29c3,
- "circ;":0x2c6, "circeq;":0x2257,
- "circlearrowleft;":0x21ba, "circlearrowright;":0x21bb,
- "circledR;":0xae, "circledS;":0x24c8,
- "circledast;":0x229b, "circledcirc;":0x229a,
- "circleddash;":0x229d, "cire;":0x2257,
- "cirfnint;":0x2a10, "cirmid;":0x2aef,
- "cirscir;":0x29c2, "clubs;":0x2663,
- "clubsuit;":0x2663, "colon;":0x3a,
- "colone;":0x2254, "coloneq;":0x2254,
- "comma;":0x2c, "commat;":0x40,
- "comp;":0x2201, "compfn;":0x2218,
- "complement;":0x2201, "complexes;":0x2102,
- "cong;":0x2245, "congdot;":0x2a6d,
- "conint;":0x222e, "copf;":[0xd835,0xdd54],
- "coprod;":0x2210, "copy":0xa9,
- "copy;":0xa9, "copysr;":0x2117,
- "crarr;":0x21b5, "cross;":0x2717,
- "cscr;":[0xd835,0xdcb8], "csub;":0x2acf,
- "csube;":0x2ad1, "csup;":0x2ad0,
- "csupe;":0x2ad2, "ctdot;":0x22ef,
- "cudarrl;":0x2938, "cudarrr;":0x2935,
- "cuepr;":0x22de, "cuesc;":0x22df,
- "cularr;":0x21b6, "cularrp;":0x293d,
- "cup;":0x222a, "cupbrcap;":0x2a48,
- "cupcap;":0x2a46, "cupcup;":0x2a4a,
- "cupdot;":0x228d, "cupor;":0x2a45,
- "cups;":[0x222a,0xfe00], "curarr;":0x21b7,
- "curarrm;":0x293c, "curlyeqprec;":0x22de,
- "curlyeqsucc;":0x22df, "curlyvee;":0x22ce,
- "curlywedge;":0x22cf, "curren":0xa4,
- "curren;":0xa4, "curvearrowleft;":0x21b6,
- "curvearrowright;":0x21b7, "cuvee;":0x22ce,
- "cuwed;":0x22cf, "cwconint;":0x2232,
- "cwint;":0x2231, "cylcty;":0x232d,
- "dArr;":0x21d3, "dHar;":0x2965,
- "dagger;":0x2020, "daleth;":0x2138,
- "darr;":0x2193, "dash;":0x2010,
- "dashv;":0x22a3, "dbkarow;":0x290f,
- "dblac;":0x2dd, "dcaron;":0x10f,
- "dcy;":0x434, "dd;":0x2146,
- "ddagger;":0x2021, "ddarr;":0x21ca,
- "ddotseq;":0x2a77, "deg":0xb0,
- "deg;":0xb0, "delta;":0x3b4,
- "demptyv;":0x29b1, "dfisht;":0x297f,
- "dfr;":[0xd835,0xdd21], "dharl;":0x21c3,
- "dharr;":0x21c2, "diam;":0x22c4,
- "diamond;":0x22c4, "diamondsuit;":0x2666,
- "diams;":0x2666, "die;":0xa8,
- "digamma;":0x3dd, "disin;":0x22f2,
- "div;":0xf7, "divide":0xf7,
- "divide;":0xf7, "divideontimes;":0x22c7,
- "divonx;":0x22c7, "djcy;":0x452,
- "dlcorn;":0x231e, "dlcrop;":0x230d,
- "dollar;":0x24, "dopf;":[0xd835,0xdd55],
- "dot;":0x2d9, "doteq;":0x2250,
- "doteqdot;":0x2251, "dotminus;":0x2238,
- "dotplus;":0x2214, "dotsquare;":0x22a1,
- "doublebarwedge;":0x2306, "downarrow;":0x2193,
- "downdownarrows;":0x21ca, "downharpoonleft;":0x21c3,
- "downharpoonright;":0x21c2, "drbkarow;":0x2910,
- "drcorn;":0x231f, "drcrop;":0x230c,
- "dscr;":[0xd835,0xdcb9], "dscy;":0x455,
- "dsol;":0x29f6, "dstrok;":0x111,
- "dtdot;":0x22f1, "dtri;":0x25bf,
- "dtrif;":0x25be, "duarr;":0x21f5,
- "duhar;":0x296f, "dwangle;":0x29a6,
- "dzcy;":0x45f, "dzigrarr;":0x27ff,
- "eDDot;":0x2a77, "eDot;":0x2251,
- "eacute":0xe9, "eacute;":0xe9,
- "easter;":0x2a6e, "ecaron;":0x11b,
- "ecir;":0x2256, "ecirc":0xea,
- "ecirc;":0xea, "ecolon;":0x2255,
- "ecy;":0x44d, "edot;":0x117,
- "ee;":0x2147, "efDot;":0x2252,
- "efr;":[0xd835,0xdd22], "eg;":0x2a9a,
- "egrave":0xe8, "egrave;":0xe8,
- "egs;":0x2a96, "egsdot;":0x2a98,
- "el;":0x2a99, "elinters;":0x23e7,
- "ell;":0x2113, "els;":0x2a95,
- "elsdot;":0x2a97, "emacr;":0x113,
- "empty;":0x2205, "emptyset;":0x2205,
- "emptyv;":0x2205, "emsp13;":0x2004,
- "emsp14;":0x2005, "emsp;":0x2003,
- "eng;":0x14b, "ensp;":0x2002,
- "eogon;":0x119, "eopf;":[0xd835,0xdd56],
- "epar;":0x22d5, "eparsl;":0x29e3,
- "eplus;":0x2a71, "epsi;":0x3b5,
- "epsilon;":0x3b5, "epsiv;":0x3f5,
- "eqcirc;":0x2256, "eqcolon;":0x2255,
- "eqsim;":0x2242, "eqslantgtr;":0x2a96,
- "eqslantless;":0x2a95, "equals;":0x3d,
- "equest;":0x225f, "equiv;":0x2261,
- "equivDD;":0x2a78, "eqvparsl;":0x29e5,
- "erDot;":0x2253, "erarr;":0x2971,
- "escr;":0x212f, "esdot;":0x2250,
- "esim;":0x2242, "eta;":0x3b7,
- "eth":0xf0, "eth;":0xf0,
- "euml":0xeb, "euml;":0xeb,
- "euro;":0x20ac, "excl;":0x21,
- "exist;":0x2203, "expectation;":0x2130,
- "exponentiale;":0x2147, "fallingdotseq;":0x2252,
- "fcy;":0x444, "female;":0x2640,
- "ffilig;":0xfb03, "fflig;":0xfb00,
- "ffllig;":0xfb04, "ffr;":[0xd835,0xdd23],
- "filig;":0xfb01, "fjlig;":[0x66,0x6a],
- "flat;":0x266d, "fllig;":0xfb02,
- "fltns;":0x25b1, "fnof;":0x192,
- "fopf;":[0xd835,0xdd57], "forall;":0x2200,
- "fork;":0x22d4, "forkv;":0x2ad9,
- "fpartint;":0x2a0d, "frac12":0xbd,
- "frac12;":0xbd, "frac13;":0x2153,
- "frac14":0xbc, "frac14;":0xbc,
- "frac15;":0x2155, "frac16;":0x2159,
- "frac18;":0x215b, "frac23;":0x2154,
- "frac25;":0x2156, "frac34":0xbe,
- "frac34;":0xbe, "frac35;":0x2157,
- "frac38;":0x215c, "frac45;":0x2158,
- "frac56;":0x215a, "frac58;":0x215d,
- "frac78;":0x215e, "frasl;":0x2044,
- "frown;":0x2322, "fscr;":[0xd835,0xdcbb],
- "gE;":0x2267, "gEl;":0x2a8c,
- "gacute;":0x1f5, "gamma;":0x3b3,
- "gammad;":0x3dd, "gap;":0x2a86,
- "gbreve;":0x11f, "gcirc;":0x11d,
- "gcy;":0x433, "gdot;":0x121,
- "ge;":0x2265, "gel;":0x22db,
- "geq;":0x2265, "geqq;":0x2267,
- "geqslant;":0x2a7e, "ges;":0x2a7e,
- "gescc;":0x2aa9, "gesdot;":0x2a80,
- "gesdoto;":0x2a82, "gesdotol;":0x2a84,
- "gesl;":[0x22db,0xfe00], "gesles;":0x2a94,
- "gfr;":[0xd835,0xdd24], "gg;":0x226b,
- "ggg;":0x22d9, "gimel;":0x2137,
- "gjcy;":0x453, "gl;":0x2277,
- "glE;":0x2a92, "gla;":0x2aa5,
- "glj;":0x2aa4, "gnE;":0x2269,
- "gnap;":0x2a8a, "gnapprox;":0x2a8a,
- "gne;":0x2a88, "gneq;":0x2a88,
- "gneqq;":0x2269, "gnsim;":0x22e7,
- "gopf;":[0xd835,0xdd58], "grave;":0x60,
- "gscr;":0x210a, "gsim;":0x2273,
- "gsime;":0x2a8e, "gsiml;":0x2a90,
- "gt":0x3e, "gt;":0x3e,
- "gtcc;":0x2aa7, "gtcir;":0x2a7a,
- "gtdot;":0x22d7, "gtlPar;":0x2995,
- "gtquest;":0x2a7c, "gtrapprox;":0x2a86,
- "gtrarr;":0x2978, "gtrdot;":0x22d7,
- "gtreqless;":0x22db, "gtreqqless;":0x2a8c,
- "gtrless;":0x2277, "gtrsim;":0x2273,
- "gvertneqq;":[0x2269,0xfe00], "gvnE;":[0x2269,0xfe00],
- "hArr;":0x21d4, "hairsp;":0x200a,
- "half;":0xbd, "hamilt;":0x210b,
- "hardcy;":0x44a, "harr;":0x2194,
- "harrcir;":0x2948, "harrw;":0x21ad,
- "hbar;":0x210f, "hcirc;":0x125,
- "hearts;":0x2665, "heartsuit;":0x2665,
- "hellip;":0x2026, "hercon;":0x22b9,
- "hfr;":[0xd835,0xdd25], "hksearow;":0x2925,
- "hkswarow;":0x2926, "hoarr;":0x21ff,
- "homtht;":0x223b, "hookleftarrow;":0x21a9,
- "hookrightarrow;":0x21aa, "hopf;":[0xd835,0xdd59],
- "horbar;":0x2015, "hscr;":[0xd835,0xdcbd],
- "hslash;":0x210f, "hstrok;":0x127,
- "hybull;":0x2043, "hyphen;":0x2010,
- "iacute":0xed, "iacute;":0xed,
- "ic;":0x2063, "icirc":0xee,
- "icirc;":0xee, "icy;":0x438,
- "iecy;":0x435, "iexcl":0xa1,
- "iexcl;":0xa1, "iff;":0x21d4,
- "ifr;":[0xd835,0xdd26], "igrave":0xec,
- "igrave;":0xec, "ii;":0x2148,
- "iiiint;":0x2a0c, "iiint;":0x222d,
- "iinfin;":0x29dc, "iiota;":0x2129,
- "ijlig;":0x133, "imacr;":0x12b,
- "image;":0x2111, "imagline;":0x2110,
- "imagpart;":0x2111, "imath;":0x131,
- "imof;":0x22b7, "imped;":0x1b5,
- "in;":0x2208, "incare;":0x2105,
- "infin;":0x221e, "infintie;":0x29dd,
- "inodot;":0x131, "int;":0x222b,
- "intcal;":0x22ba, "integers;":0x2124,
- "intercal;":0x22ba, "intlarhk;":0x2a17,
- "intprod;":0x2a3c, "iocy;":0x451,
- "iogon;":0x12f, "iopf;":[0xd835,0xdd5a],
- "iota;":0x3b9, "iprod;":0x2a3c,
- "iquest":0xbf, "iquest;":0xbf,
- "iscr;":[0xd835,0xdcbe], "isin;":0x2208,
- "isinE;":0x22f9, "isindot;":0x22f5,
- "isins;":0x22f4, "isinsv;":0x22f3,
- "isinv;":0x2208, "it;":0x2062,
- "itilde;":0x129, "iukcy;":0x456,
- "iuml":0xef, "iuml;":0xef,
- "jcirc;":0x135, "jcy;":0x439,
- "jfr;":[0xd835,0xdd27], "jmath;":0x237,
- "jopf;":[0xd835,0xdd5b], "jscr;":[0xd835,0xdcbf],
- "jsercy;":0x458, "jukcy;":0x454,
- "kappa;":0x3ba, "kappav;":0x3f0,
- "kcedil;":0x137, "kcy;":0x43a,
- "kfr;":[0xd835,0xdd28], "kgreen;":0x138,
- "khcy;":0x445, "kjcy;":0x45c,
- "kopf;":[0xd835,0xdd5c], "kscr;":[0xd835,0xdcc0],
- "lAarr;":0x21da, "lArr;":0x21d0,
- "lAtail;":0x291b, "lBarr;":0x290e,
- "lE;":0x2266, "lEg;":0x2a8b,
- "lHar;":0x2962, "lacute;":0x13a,
- "laemptyv;":0x29b4, "lagran;":0x2112,
- "lambda;":0x3bb, "lang;":0x27e8,
- "langd;":0x2991, "langle;":0x27e8,
- "lap;":0x2a85, "laquo":0xab,
- "laquo;":0xab, "larr;":0x2190,
- "larrb;":0x21e4, "larrbfs;":0x291f,
- "larrfs;":0x291d, "larrhk;":0x21a9,
- "larrlp;":0x21ab, "larrpl;":0x2939,
- "larrsim;":0x2973, "larrtl;":0x21a2,
- "lat;":0x2aab, "latail;":0x2919,
- "late;":0x2aad, "lates;":[0x2aad,0xfe00],
- "lbarr;":0x290c, "lbbrk;":0x2772,
- "lbrace;":0x7b, "lbrack;":0x5b,
- "lbrke;":0x298b, "lbrksld;":0x298f,
- "lbrkslu;":0x298d, "lcaron;":0x13e,
- "lcedil;":0x13c, "lceil;":0x2308,
- "lcub;":0x7b, "lcy;":0x43b,
- "ldca;":0x2936, "ldquo;":0x201c,
- "ldquor;":0x201e, "ldrdhar;":0x2967,
- "ldrushar;":0x294b, "ldsh;":0x21b2,
- "le;":0x2264, "leftarrow;":0x2190,
- "leftarrowtail;":0x21a2, "leftharpoondown;":0x21bd,
- "leftharpoonup;":0x21bc, "leftleftarrows;":0x21c7,
- "leftrightarrow;":0x2194, "leftrightarrows;":0x21c6,
- "leftrightharpoons;":0x21cb, "leftrightsquigarrow;":0x21ad,
- "leftthreetimes;":0x22cb, "leg;":0x22da,
- "leq;":0x2264, "leqq;":0x2266,
- "leqslant;":0x2a7d, "les;":0x2a7d,
- "lescc;":0x2aa8, "lesdot;":0x2a7f,
- "lesdoto;":0x2a81, "lesdotor;":0x2a83,
- "lesg;":[0x22da,0xfe00], "lesges;":0x2a93,
- "lessapprox;":0x2a85, "lessdot;":0x22d6,
- "lesseqgtr;":0x22da, "lesseqqgtr;":0x2a8b,
- "lessgtr;":0x2276, "lesssim;":0x2272,
- "lfisht;":0x297c, "lfloor;":0x230a,
- "lfr;":[0xd835,0xdd29], "lg;":0x2276,
- "lgE;":0x2a91, "lhard;":0x21bd,
- "lharu;":0x21bc, "lharul;":0x296a,
- "lhblk;":0x2584, "ljcy;":0x459,
- "ll;":0x226a, "llarr;":0x21c7,
- "llcorner;":0x231e, "llhard;":0x296b,
- "lltri;":0x25fa, "lmidot;":0x140,
- "lmoust;":0x23b0, "lmoustache;":0x23b0,
- "lnE;":0x2268, "lnap;":0x2a89,
- "lnapprox;":0x2a89, "lne;":0x2a87,
- "lneq;":0x2a87, "lneqq;":0x2268,
- "lnsim;":0x22e6, "loang;":0x27ec,
- "loarr;":0x21fd, "lobrk;":0x27e6,
- "longleftarrow;":0x27f5, "longleftrightarrow;":0x27f7,
- "longmapsto;":0x27fc, "longrightarrow;":0x27f6,
- "looparrowleft;":0x21ab, "looparrowright;":0x21ac,
- "lopar;":0x2985, "lopf;":[0xd835,0xdd5d],
- "loplus;":0x2a2d, "lotimes;":0x2a34,
- "lowast;":0x2217, "lowbar;":0x5f,
- "loz;":0x25ca, "lozenge;":0x25ca,
- "lozf;":0x29eb, "lpar;":0x28,
- "lparlt;":0x2993, "lrarr;":0x21c6,
- "lrcorner;":0x231f, "lrhar;":0x21cb,
- "lrhard;":0x296d, "lrm;":0x200e,
- "lrtri;":0x22bf, "lsaquo;":0x2039,
- "lscr;":[0xd835,0xdcc1], "lsh;":0x21b0,
- "lsim;":0x2272, "lsime;":0x2a8d,
- "lsimg;":0x2a8f, "lsqb;":0x5b,
- "lsquo;":0x2018, "lsquor;":0x201a,
- "lstrok;":0x142, "lt":0x3c,
- "lt;":0x3c, "ltcc;":0x2aa6,
- "ltcir;":0x2a79, "ltdot;":0x22d6,
- "lthree;":0x22cb, "ltimes;":0x22c9,
- "ltlarr;":0x2976, "ltquest;":0x2a7b,
- "ltrPar;":0x2996, "ltri;":0x25c3,
- "ltrie;":0x22b4, "ltrif;":0x25c2,
- "lurdshar;":0x294a, "luruhar;":0x2966,
- "lvertneqq;":[0x2268,0xfe00], "lvnE;":[0x2268,0xfe00],
- "mDDot;":0x223a, "macr":0xaf,
- "macr;":0xaf, "male;":0x2642,
- "malt;":0x2720, "maltese;":0x2720,
- "map;":0x21a6, "mapsto;":0x21a6,
- "mapstodown;":0x21a7, "mapstoleft;":0x21a4,
- "mapstoup;":0x21a5, "marker;":0x25ae,
- "mcomma;":0x2a29, "mcy;":0x43c,
- "mdash;":0x2014, "measuredangle;":0x2221,
- "mfr;":[0xd835,0xdd2a], "mho;":0x2127,
- "micro":0xb5, "micro;":0xb5,
- "mid;":0x2223, "midast;":0x2a,
- "midcir;":0x2af0, "middot":0xb7,
- "middot;":0xb7, "minus;":0x2212,
- "minusb;":0x229f, "minusd;":0x2238,
- "minusdu;":0x2a2a, "mlcp;":0x2adb,
- "mldr;":0x2026, "mnplus;":0x2213,
- "models;":0x22a7, "mopf;":[0xd835,0xdd5e],
- "mp;":0x2213, "mscr;":[0xd835,0xdcc2],
- "mstpos;":0x223e, "mu;":0x3bc,
- "multimap;":0x22b8, "mumap;":0x22b8,
- "nGg;":[0x22d9,0x338], "nGt;":[0x226b,0x20d2],
- "nGtv;":[0x226b,0x338], "nLeftarrow;":0x21cd,
- "nLeftrightarrow;":0x21ce, "nLl;":[0x22d8,0x338],
- "nLt;":[0x226a,0x20d2], "nLtv;":[0x226a,0x338],
- "nRightarrow;":0x21cf, "nVDash;":0x22af,
- "nVdash;":0x22ae, "nabla;":0x2207,
- "nacute;":0x144, "nang;":[0x2220,0x20d2],
- "nap;":0x2249, "napE;":[0x2a70,0x338],
- "napid;":[0x224b,0x338], "napos;":0x149,
- "napprox;":0x2249, "natur;":0x266e,
- "natural;":0x266e, "naturals;":0x2115,
- "nbsp":0xa0, "nbsp;":0xa0,
- "nbump;":[0x224e,0x338], "nbumpe;":[0x224f,0x338],
- "ncap;":0x2a43, "ncaron;":0x148,
- "ncedil;":0x146, "ncong;":0x2247,
- "ncongdot;":[0x2a6d,0x338], "ncup;":0x2a42,
- "ncy;":0x43d, "ndash;":0x2013,
- "ne;":0x2260, "neArr;":0x21d7,
- "nearhk;":0x2924, "nearr;":0x2197,
- "nearrow;":0x2197, "nedot;":[0x2250,0x338],
- "nequiv;":0x2262, "nesear;":0x2928,
- "nesim;":[0x2242,0x338], "nexist;":0x2204,
- "nexists;":0x2204, "nfr;":[0xd835,0xdd2b],
- "ngE;":[0x2267,0x338], "nge;":0x2271,
- "ngeq;":0x2271, "ngeqq;":[0x2267,0x338],
- "ngeqslant;":[0x2a7e,0x338], "nges;":[0x2a7e,0x338],
- "ngsim;":0x2275, "ngt;":0x226f,
- "ngtr;":0x226f, "nhArr;":0x21ce,
- "nharr;":0x21ae, "nhpar;":0x2af2,
- "ni;":0x220b, "nis;":0x22fc,
- "nisd;":0x22fa, "niv;":0x220b,
- "njcy;":0x45a, "nlArr;":0x21cd,
- "nlE;":[0x2266,0x338], "nlarr;":0x219a,
- "nldr;":0x2025, "nle;":0x2270,
- "nleftarrow;":0x219a, "nleftrightarrow;":0x21ae,
- "nleq;":0x2270, "nleqq;":[0x2266,0x338],
- "nleqslant;":[0x2a7d,0x338], "nles;":[0x2a7d,0x338],
- "nless;":0x226e, "nlsim;":0x2274,
- "nlt;":0x226e, "nltri;":0x22ea,
- "nltrie;":0x22ec, "nmid;":0x2224,
- "nopf;":[0xd835,0xdd5f], "not":0xac,
- "not;":0xac, "notin;":0x2209,
- "notinE;":[0x22f9,0x338], "notindot;":[0x22f5,0x338],
- "notinva;":0x2209, "notinvb;":0x22f7,
- "notinvc;":0x22f6, "notni;":0x220c,
- "notniva;":0x220c, "notnivb;":0x22fe,
- "notnivc;":0x22fd, "npar;":0x2226,
- "nparallel;":0x2226, "nparsl;":[0x2afd,0x20e5],
- "npart;":[0x2202,0x338], "npolint;":0x2a14,
- "npr;":0x2280, "nprcue;":0x22e0,
- "npre;":[0x2aaf,0x338], "nprec;":0x2280,
- "npreceq;":[0x2aaf,0x338], "nrArr;":0x21cf,
- "nrarr;":0x219b, "nrarrc;":[0x2933,0x338],
- "nrarrw;":[0x219d,0x338], "nrightarrow;":0x219b,
- "nrtri;":0x22eb, "nrtrie;":0x22ed,
- "nsc;":0x2281, "nsccue;":0x22e1,
- "nsce;":[0x2ab0,0x338], "nscr;":[0xd835,0xdcc3],
- "nshortmid;":0x2224, "nshortparallel;":0x2226,
- "nsim;":0x2241, "nsime;":0x2244,
- "nsimeq;":0x2244, "nsmid;":0x2224,
- "nspar;":0x2226, "nsqsube;":0x22e2,
- "nsqsupe;":0x22e3, "nsub;":0x2284,
- "nsubE;":[0x2ac5,0x338], "nsube;":0x2288,
- "nsubset;":[0x2282,0x20d2], "nsubseteq;":0x2288,
- "nsubseteqq;":[0x2ac5,0x338], "nsucc;":0x2281,
- "nsucceq;":[0x2ab0,0x338], "nsup;":0x2285,
- "nsupE;":[0x2ac6,0x338], "nsupe;":0x2289,
- "nsupset;":[0x2283,0x20d2], "nsupseteq;":0x2289,
- "nsupseteqq;":[0x2ac6,0x338], "ntgl;":0x2279,
- "ntilde":0xf1, "ntilde;":0xf1,
- "ntlg;":0x2278, "ntriangleleft;":0x22ea,
- "ntrianglelefteq;":0x22ec, "ntriangleright;":0x22eb,
- "ntrianglerighteq;":0x22ed, "nu;":0x3bd,
- "num;":0x23, "numero;":0x2116,
- "numsp;":0x2007, "nvDash;":0x22ad,
- "nvHarr;":0x2904, "nvap;":[0x224d,0x20d2],
- "nvdash;":0x22ac, "nvge;":[0x2265,0x20d2],
- "nvgt;":[0x3e,0x20d2], "nvinfin;":0x29de,
- "nvlArr;":0x2902, "nvle;":[0x2264,0x20d2],
- "nvlt;":[0x3c,0x20d2], "nvltrie;":[0x22b4,0x20d2],
- "nvrArr;":0x2903, "nvrtrie;":[0x22b5,0x20d2],
- "nvsim;":[0x223c,0x20d2], "nwArr;":0x21d6,
- "nwarhk;":0x2923, "nwarr;":0x2196,
- "nwarrow;":0x2196, "nwnear;":0x2927,
- "oS;":0x24c8, "oacute":0xf3,
- "oacute;":0xf3, "oast;":0x229b,
- "ocir;":0x229a, "ocirc":0xf4,
- "ocirc;":0xf4, "ocy;":0x43e,
- "odash;":0x229d, "odblac;":0x151,
- "odiv;":0x2a38, "odot;":0x2299,
- "odsold;":0x29bc, "oelig;":0x153,
- "ofcir;":0x29bf, "ofr;":[0xd835,0xdd2c],
- "ogon;":0x2db, "ograve":0xf2,
- "ograve;":0xf2, "ogt;":0x29c1,
- "ohbar;":0x29b5, "ohm;":0x3a9,
- "oint;":0x222e, "olarr;":0x21ba,
- "olcir;":0x29be, "olcross;":0x29bb,
- "oline;":0x203e, "olt;":0x29c0,
- "omacr;":0x14d, "omega;":0x3c9,
- "omicron;":0x3bf, "omid;":0x29b6,
- "ominus;":0x2296, "oopf;":[0xd835,0xdd60],
- "opar;":0x29b7, "operp;":0x29b9,
- "oplus;":0x2295, "or;":0x2228,
- "orarr;":0x21bb, "ord;":0x2a5d,
- "order;":0x2134, "orderof;":0x2134,
- "ordf":0xaa, "ordf;":0xaa,
- "ordm":0xba, "ordm;":0xba,
- "origof;":0x22b6, "oror;":0x2a56,
- "orslope;":0x2a57, "orv;":0x2a5b,
- "oscr;":0x2134, "oslash":0xf8,
- "oslash;":0xf8, "osol;":0x2298,
- "otilde":0xf5, "otilde;":0xf5,
- "otimes;":0x2297, "otimesas;":0x2a36,
- "ouml":0xf6, "ouml;":0xf6,
- "ovbar;":0x233d, "par;":0x2225,
- "para":0xb6, "para;":0xb6,
- "parallel;":0x2225, "parsim;":0x2af3,
- "parsl;":0x2afd, "part;":0x2202,
- "pcy;":0x43f, "percnt;":0x25,
- "period;":0x2e, "permil;":0x2030,
- "perp;":0x22a5, "pertenk;":0x2031,
- "pfr;":[0xd835,0xdd2d], "phi;":0x3c6,
- "phiv;":0x3d5, "phmmat;":0x2133,
- "phone;":0x260e, "pi;":0x3c0,
- "pitchfork;":0x22d4, "piv;":0x3d6,
- "planck;":0x210f, "planckh;":0x210e,
- "plankv;":0x210f, "plus;":0x2b,
- "plusacir;":0x2a23, "plusb;":0x229e,
- "pluscir;":0x2a22, "plusdo;":0x2214,
- "plusdu;":0x2a25, "pluse;":0x2a72,
- "plusmn":0xb1, "plusmn;":0xb1,
- "plussim;":0x2a26, "plustwo;":0x2a27,
- "pm;":0xb1, "pointint;":0x2a15,
- "popf;":[0xd835,0xdd61], "pound":0xa3,
- "pound;":0xa3, "pr;":0x227a,
- "prE;":0x2ab3, "prap;":0x2ab7,
- "prcue;":0x227c, "pre;":0x2aaf,
- "prec;":0x227a, "precapprox;":0x2ab7,
- "preccurlyeq;":0x227c, "preceq;":0x2aaf,
- "precnapprox;":0x2ab9, "precneqq;":0x2ab5,
- "precnsim;":0x22e8, "precsim;":0x227e,
- "prime;":0x2032, "primes;":0x2119,
- "prnE;":0x2ab5, "prnap;":0x2ab9,
- "prnsim;":0x22e8, "prod;":0x220f,
- "profalar;":0x232e, "profline;":0x2312,
- "profsurf;":0x2313, "prop;":0x221d,
- "propto;":0x221d, "prsim;":0x227e,
- "prurel;":0x22b0, "pscr;":[0xd835,0xdcc5],
- "psi;":0x3c8, "puncsp;":0x2008,
- "qfr;":[0xd835,0xdd2e], "qint;":0x2a0c,
- "qopf;":[0xd835,0xdd62], "qprime;":0x2057,
- "qscr;":[0xd835,0xdcc6], "quaternions;":0x210d,
- "quatint;":0x2a16, "quest;":0x3f,
- "questeq;":0x225f, "quot":0x22,
- "quot;":0x22, "rAarr;":0x21db,
- "rArr;":0x21d2, "rAtail;":0x291c,
- "rBarr;":0x290f, "rHar;":0x2964,
- "race;":[0x223d,0x331], "racute;":0x155,
- "radic;":0x221a, "raemptyv;":0x29b3,
- "rang;":0x27e9, "rangd;":0x2992,
- "range;":0x29a5, "rangle;":0x27e9,
- "raquo":0xbb, "raquo;":0xbb,
- "rarr;":0x2192, "rarrap;":0x2975,
- "rarrb;":0x21e5, "rarrbfs;":0x2920,
- "rarrc;":0x2933, "rarrfs;":0x291e,
- "rarrhk;":0x21aa, "rarrlp;":0x21ac,
- "rarrpl;":0x2945, "rarrsim;":0x2974,
- "rarrtl;":0x21a3, "rarrw;":0x219d,
- "ratail;":0x291a, "ratio;":0x2236,
- "rationals;":0x211a, "rbarr;":0x290d,
- "rbbrk;":0x2773, "rbrace;":0x7d,
- "rbrack;":0x5d, "rbrke;":0x298c,
- "rbrksld;":0x298e, "rbrkslu;":0x2990,
- "rcaron;":0x159, "rcedil;":0x157,
- "rceil;":0x2309, "rcub;":0x7d,
- "rcy;":0x440, "rdca;":0x2937,
- "rdldhar;":0x2969, "rdquo;":0x201d,
- "rdquor;":0x201d, "rdsh;":0x21b3,
- "real;":0x211c, "realine;":0x211b,
- "realpart;":0x211c, "reals;":0x211d,
- "rect;":0x25ad, "reg":0xae,
- "reg;":0xae, "rfisht;":0x297d,
- "rfloor;":0x230b, "rfr;":[0xd835,0xdd2f],
- "rhard;":0x21c1, "rharu;":0x21c0,
- "rharul;":0x296c, "rho;":0x3c1,
- "rhov;":0x3f1, "rightarrow;":0x2192,
- "rightarrowtail;":0x21a3, "rightharpoondown;":0x21c1,
- "rightharpoonup;":0x21c0, "rightleftarrows;":0x21c4,
- "rightleftharpoons;":0x21cc, "rightrightarrows;":0x21c9,
- "rightsquigarrow;":0x219d, "rightthreetimes;":0x22cc,
- "ring;":0x2da, "risingdotseq;":0x2253,
- "rlarr;":0x21c4, "rlhar;":0x21cc,
- "rlm;":0x200f, "rmoust;":0x23b1,
- "rmoustache;":0x23b1, "rnmid;":0x2aee,
- "roang;":0x27ed, "roarr;":0x21fe,
- "robrk;":0x27e7, "ropar;":0x2986,
- "ropf;":[0xd835,0xdd63], "roplus;":0x2a2e,
- "rotimes;":0x2a35, "rpar;":0x29,
- "rpargt;":0x2994, "rppolint;":0x2a12,
- "rrarr;":0x21c9, "rsaquo;":0x203a,
- "rscr;":[0xd835,0xdcc7], "rsh;":0x21b1,
- "rsqb;":0x5d, "rsquo;":0x2019,
- "rsquor;":0x2019, "rthree;":0x22cc,
- "rtimes;":0x22ca, "rtri;":0x25b9,
- "rtrie;":0x22b5, "rtrif;":0x25b8,
- "rtriltri;":0x29ce, "ruluhar;":0x2968,
- "rx;":0x211e, "sacute;":0x15b,
- "sbquo;":0x201a, "sc;":0x227b,
- "scE;":0x2ab4, "scap;":0x2ab8,
- "scaron;":0x161, "sccue;":0x227d,
- "sce;":0x2ab0, "scedil;":0x15f,
- "scirc;":0x15d, "scnE;":0x2ab6,
- "scnap;":0x2aba, "scnsim;":0x22e9,
- "scpolint;":0x2a13, "scsim;":0x227f,
- "scy;":0x441, "sdot;":0x22c5,
- "sdotb;":0x22a1, "sdote;":0x2a66,
- "seArr;":0x21d8, "searhk;":0x2925,
- "searr;":0x2198, "searrow;":0x2198,
- "sect":0xa7, "sect;":0xa7,
- "semi;":0x3b, "seswar;":0x2929,
- "setminus;":0x2216, "setmn;":0x2216,
- "sext;":0x2736, "sfr;":[0xd835,0xdd30],
- "sfrown;":0x2322, "sharp;":0x266f,
- "shchcy;":0x449, "shcy;":0x448,
- "shortmid;":0x2223, "shortparallel;":0x2225,
- "shy":0xad, "shy;":0xad,
- "sigma;":0x3c3, "sigmaf;":0x3c2,
- "sigmav;":0x3c2, "sim;":0x223c,
- "simdot;":0x2a6a, "sime;":0x2243,
- "simeq;":0x2243, "simg;":0x2a9e,
- "simgE;":0x2aa0, "siml;":0x2a9d,
- "simlE;":0x2a9f, "simne;":0x2246,
- "simplus;":0x2a24, "simrarr;":0x2972,
- "slarr;":0x2190, "smallsetminus;":0x2216,
- "smashp;":0x2a33, "smeparsl;":0x29e4,
- "smid;":0x2223, "smile;":0x2323,
- "smt;":0x2aaa, "smte;":0x2aac,
- "smtes;":[0x2aac,0xfe00], "softcy;":0x44c,
- "sol;":0x2f, "solb;":0x29c4,
- "solbar;":0x233f, "sopf;":[0xd835,0xdd64],
- "spades;":0x2660, "spadesuit;":0x2660,
- "spar;":0x2225, "sqcap;":0x2293,
- "sqcaps;":[0x2293,0xfe00], "sqcup;":0x2294,
- "sqcups;":[0x2294,0xfe00], "sqsub;":0x228f,
- "sqsube;":0x2291, "sqsubset;":0x228f,
- "sqsubseteq;":0x2291, "sqsup;":0x2290,
- "sqsupe;":0x2292, "sqsupset;":0x2290,
- "sqsupseteq;":0x2292, "squ;":0x25a1,
- "square;":0x25a1, "squarf;":0x25aa,
- "squf;":0x25aa, "srarr;":0x2192,
- "sscr;":[0xd835,0xdcc8], "ssetmn;":0x2216,
- "ssmile;":0x2323, "sstarf;":0x22c6,
- "star;":0x2606, "starf;":0x2605,
- "straightepsilon;":0x3f5, "straightphi;":0x3d5,
- "strns;":0xaf, "sub;":0x2282,
- "subE;":0x2ac5, "subdot;":0x2abd,
- "sube;":0x2286, "subedot;":0x2ac3,
- "submult;":0x2ac1, "subnE;":0x2acb,
- "subne;":0x228a, "subplus;":0x2abf,
- "subrarr;":0x2979, "subset;":0x2282,
- "subseteq;":0x2286, "subseteqq;":0x2ac5,
- "subsetneq;":0x228a, "subsetneqq;":0x2acb,
- "subsim;":0x2ac7, "subsub;":0x2ad5,
- "subsup;":0x2ad3, "succ;":0x227b,
- "succapprox;":0x2ab8, "succcurlyeq;":0x227d,
- "succeq;":0x2ab0, "succnapprox;":0x2aba,
- "succneqq;":0x2ab6, "succnsim;":0x22e9,
- "succsim;":0x227f, "sum;":0x2211,
- "sung;":0x266a, "sup1":0xb9,
- "sup1;":0xb9, "sup2":0xb2,
- "sup2;":0xb2, "sup3":0xb3,
- "sup3;":0xb3, "sup;":0x2283,
- "supE;":0x2ac6, "supdot;":0x2abe,
- "supdsub;":0x2ad8, "supe;":0x2287,
- "supedot;":0x2ac4, "suphsol;":0x27c9,
- "suphsub;":0x2ad7, "suplarr;":0x297b,
- "supmult;":0x2ac2, "supnE;":0x2acc,
- "supne;":0x228b, "supplus;":0x2ac0,
- "supset;":0x2283, "supseteq;":0x2287,
- "supseteqq;":0x2ac6, "supsetneq;":0x228b,
- "supsetneqq;":0x2acc, "supsim;":0x2ac8,
- "supsub;":0x2ad4, "supsup;":0x2ad6,
- "swArr;":0x21d9, "swarhk;":0x2926,
- "swarr;":0x2199, "swarrow;":0x2199,
- "swnwar;":0x292a, "szlig":0xdf,
- "szlig;":0xdf, "target;":0x2316,
- "tau;":0x3c4, "tbrk;":0x23b4,
- "tcaron;":0x165, "tcedil;":0x163,
- "tcy;":0x442, "tdot;":0x20db,
- "telrec;":0x2315, "tfr;":[0xd835,0xdd31],
- "there4;":0x2234, "therefore;":0x2234,
- "theta;":0x3b8, "thetasym;":0x3d1,
- "thetav;":0x3d1, "thickapprox;":0x2248,
- "thicksim;":0x223c, "thinsp;":0x2009,
- "thkap;":0x2248, "thksim;":0x223c,
- "thorn":0xfe, "thorn;":0xfe,
- "tilde;":0x2dc, "times":0xd7,
- "times;":0xd7, "timesb;":0x22a0,
- "timesbar;":0x2a31, "timesd;":0x2a30,
- "tint;":0x222d, "toea;":0x2928,
- "top;":0x22a4, "topbot;":0x2336,
- "topcir;":0x2af1, "topf;":[0xd835,0xdd65],
- "topfork;":0x2ada, "tosa;":0x2929,
- "tprime;":0x2034, "trade;":0x2122,
- "triangle;":0x25b5, "triangledown;":0x25bf,
- "triangleleft;":0x25c3, "trianglelefteq;":0x22b4,
- "triangleq;":0x225c, "triangleright;":0x25b9,
- "trianglerighteq;":0x22b5, "tridot;":0x25ec,
- "trie;":0x225c, "triminus;":0x2a3a,
- "triplus;":0x2a39, "trisb;":0x29cd,
- "tritime;":0x2a3b, "trpezium;":0x23e2,
- "tscr;":[0xd835,0xdcc9], "tscy;":0x446,
- "tshcy;":0x45b, "tstrok;":0x167,
- "twixt;":0x226c, "twoheadleftarrow;":0x219e,
- "twoheadrightarrow;":0x21a0, "uArr;":0x21d1,
- "uHar;":0x2963, "uacute":0xfa,
- "uacute;":0xfa, "uarr;":0x2191,
- "ubrcy;":0x45e, "ubreve;":0x16d,
- "ucirc":0xfb, "ucirc;":0xfb,
- "ucy;":0x443, "udarr;":0x21c5,
- "udblac;":0x171, "udhar;":0x296e,
- "ufisht;":0x297e, "ufr;":[0xd835,0xdd32],
- "ugrave":0xf9, "ugrave;":0xf9,
- "uharl;":0x21bf, "uharr;":0x21be,
- "uhblk;":0x2580, "ulcorn;":0x231c,
- "ulcorner;":0x231c, "ulcrop;":0x230f,
- "ultri;":0x25f8, "umacr;":0x16b,
- "uml":0xa8, "uml;":0xa8,
- "uogon;":0x173, "uopf;":[0xd835,0xdd66],
- "uparrow;":0x2191, "updownarrow;":0x2195,
- "upharpoonleft;":0x21bf, "upharpoonright;":0x21be,
- "uplus;":0x228e, "upsi;":0x3c5,
- "upsih;":0x3d2, "upsilon;":0x3c5,
- "upuparrows;":0x21c8, "urcorn;":0x231d,
- "urcorner;":0x231d, "urcrop;":0x230e,
- "uring;":0x16f, "urtri;":0x25f9,
- "uscr;":[0xd835,0xdcca], "utdot;":0x22f0,
- "utilde;":0x169, "utri;":0x25b5,
- "utrif;":0x25b4, "uuarr;":0x21c8,
- "uuml":0xfc, "uuml;":0xfc,
- "uwangle;":0x29a7, "vArr;":0x21d5,
- "vBar;":0x2ae8, "vBarv;":0x2ae9,
- "vDash;":0x22a8, "vangrt;":0x299c,
- "varepsilon;":0x3f5, "varkappa;":0x3f0,
- "varnothing;":0x2205, "varphi;":0x3d5,
- "varpi;":0x3d6, "varpropto;":0x221d,
- "varr;":0x2195, "varrho;":0x3f1,
- "varsigma;":0x3c2, "varsubsetneq;":[0x228a,0xfe00],
- "varsubsetneqq;":[0x2acb,0xfe00], "varsupsetneq;":[0x228b,0xfe00],
- "varsupsetneqq;":[0x2acc,0xfe00], "vartheta;":0x3d1,
- "vartriangleleft;":0x22b2, "vartriangleright;":0x22b3,
- "vcy;":0x432, "vdash;":0x22a2,
- "vee;":0x2228, "veebar;":0x22bb,
- "veeeq;":0x225a, "vellip;":0x22ee,
- "verbar;":0x7c, "vert;":0x7c,
- "vfr;":[0xd835,0xdd33], "vltri;":0x22b2,
- "vnsub;":[0x2282,0x20d2], "vnsup;":[0x2283,0x20d2],
- "vopf;":[0xd835,0xdd67], "vprop;":0x221d,
- "vrtri;":0x22b3, "vscr;":[0xd835,0xdccb],
- "vsubnE;":[0x2acb,0xfe00], "vsubne;":[0x228a,0xfe00],
- "vsupnE;":[0x2acc,0xfe00], "vsupne;":[0x228b,0xfe00],
- "vzigzag;":0x299a, "wcirc;":0x175,
- "wedbar;":0x2a5f, "wedge;":0x2227,
- "wedgeq;":0x2259, "weierp;":0x2118,
- "wfr;":[0xd835,0xdd34], "wopf;":[0xd835,0xdd68],
- "wp;":0x2118, "wr;":0x2240,
- "wreath;":0x2240, "wscr;":[0xd835,0xdccc],
- "xcap;":0x22c2, "xcirc;":0x25ef,
- "xcup;":0x22c3, "xdtri;":0x25bd,
- "xfr;":[0xd835,0xdd35], "xhArr;":0x27fa,
- "xharr;":0x27f7, "xi;":0x3be,
- "xlArr;":0x27f8, "xlarr;":0x27f5,
- "xmap;":0x27fc, "xnis;":0x22fb,
- "xodot;":0x2a00, "xopf;":[0xd835,0xdd69],
- "xoplus;":0x2a01, "xotime;":0x2a02,
- "xrArr;":0x27f9, "xrarr;":0x27f6,
- "xscr;":[0xd835,0xdccd], "xsqcup;":0x2a06,
- "xuplus;":0x2a04, "xutri;":0x25b3,
- "xvee;":0x22c1, "xwedge;":0x22c0,
- "yacute":0xfd, "yacute;":0xfd,
- "yacy;":0x44f, "ycirc;":0x177,
- "ycy;":0x44b, "yen":0xa5,
- "yen;":0xa5, "yfr;":[0xd835,0xdd36],
- "yicy;":0x457, "yopf;":[0xd835,0xdd6a],
- "yscr;":[0xd835,0xdcce], "yucy;":0x44e,
- "yuml":0xff, "yuml;":0xff,
- "zacute;":0x17a, "zcaron;":0x17e,
- "zcy;":0x437, "zdot;":0x17c,
- "zeetrf;":0x2128, "zeta;":0x3b6,
- "zfr;":[0xd835,0xdd37], "zhcy;":0x436,
- "zigrarr;":0x21dd, "zopf;":[0xd835,0xdd6b],
- "zscr;":[0xd835,0xdccf], "zwj;":0x200d,
- "zwnj;":0x200c,
-};
-/*
- * This regexp is generated with test/tools/update-entities.js
- * It will always match at least one character -- but note that there
- * are no entities whose names are a single character long.
- */
-var NAMEDCHARREF = /(A(?:Elig;?|MP;?|acute;?|breve;|c(?:irc;?|y;)|fr;|grave;?|lpha;|macr;|nd;|o(?:gon;|pf;)|pplyFunction;|ring;?|s(?:cr;|sign;)|tilde;?|uml;?)|B(?:a(?:ckslash;|r(?:v;|wed;))|cy;|e(?:cause;|rnoullis;|ta;)|fr;|opf;|reve;|scr;|umpeq;)|C(?:Hcy;|OPY;?|a(?:cute;|p(?:;|italDifferentialD;)|yleys;)|c(?:aron;|edil;?|irc;|onint;)|dot;|e(?:dilla;|nterDot;)|fr;|hi;|ircle(?:Dot;|Minus;|Plus;|Times;)|lo(?:ckwiseContourIntegral;|seCurly(?:DoubleQuote;|Quote;))|o(?:lon(?:;|e;)|n(?:gruent;|int;|tourIntegral;)|p(?:f;|roduct;)|unterClockwiseContourIntegral;)|ross;|scr;|up(?:;|Cap;))|D(?:D(?:;|otrahd;)|Jcy;|Scy;|Zcy;|a(?:gger;|rr;|shv;)|c(?:aron;|y;)|el(?:;|ta;)|fr;|i(?:a(?:critical(?:Acute;|Do(?:t;|ubleAcute;)|Grave;|Tilde;)|mond;)|fferentialD;)|o(?:pf;|t(?:;|Dot;|Equal;)|uble(?:ContourIntegral;|Do(?:t;|wnArrow;)|L(?:eft(?:Arrow;|RightArrow;|Tee;)|ong(?:Left(?:Arrow;|RightArrow;)|RightArrow;))|Right(?:Arrow;|Tee;)|Up(?:Arrow;|DownArrow;)|VerticalBar;)|wn(?:Arrow(?:;|Bar;|UpArrow;)|Breve;|Left(?:RightVector;|TeeVector;|Vector(?:;|Bar;))|Right(?:TeeVector;|Vector(?:;|Bar;))|Tee(?:;|Arrow;)|arrow;))|s(?:cr;|trok;))|E(?:NG;|TH;?|acute;?|c(?:aron;|irc;?|y;)|dot;|fr;|grave;?|lement;|m(?:acr;|pty(?:SmallSquare;|VerySmallSquare;))|o(?:gon;|pf;)|psilon;|qu(?:al(?:;|Tilde;)|ilibrium;)|s(?:cr;|im;)|ta;|uml;?|x(?:ists;|ponentialE;))|F(?:cy;|fr;|illed(?:SmallSquare;|VerySmallSquare;)|o(?:pf;|rAll;|uriertrf;)|scr;)|G(?:Jcy;|T;?|amma(?:;|d;)|breve;|c(?:edil;|irc;|y;)|dot;|fr;|g;|opf;|reater(?:Equal(?:;|Less;)|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|scr;|t;)|H(?:ARDcy;|a(?:cek;|t;)|circ;|fr;|ilbertSpace;|o(?:pf;|rizontalLine;)|s(?:cr;|trok;)|ump(?:DownHump;|Equal;))|I(?:Ecy;|Jlig;|Ocy;|acute;?|c(?:irc;?|y;)|dot;|fr;|grave;?|m(?:;|a(?:cr;|ginaryI;)|plies;)|n(?:t(?:;|e(?:gral;|rsection;))|visible(?:Comma;|Times;))|o(?:gon;|pf;|ta;)|scr;|tilde;|u(?:kcy;|ml;?))|J(?:c(?:irc;|y;)|fr;|opf;|s(?:cr;|ercy;)|ukcy;)|K(?:Hcy;|Jcy;|appa;|c(?:edil;|y;)|fr;|opf;|scr;)|L(?:Jcy;|T;?|a(?:cute;|mbda;|ng;|placetrf;|rr;)|c(?:aron;|edil;|y;)|e(?:ft(?:A(?:ngleBracket;|rrow(?:;|Bar;|RightArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|Right(?:Arrow;|Vector;)|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;|rightarrow;)|ss(?:EqualGreater;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;))|fr;|l(?:;|eftarrow;)|midot;|o(?:ng(?:Left(?:Arrow;|RightArrow;)|RightArrow;|left(?:arrow;|rightarrow;)|rightarrow;)|pf;|wer(?:LeftArrow;|RightArrow;))|s(?:cr;|h;|trok;)|t;)|M(?:ap;|cy;|e(?:diumSpace;|llintrf;)|fr;|inusPlus;|opf;|scr;|u;)|N(?:Jcy;|acute;|c(?:aron;|edil;|y;)|e(?:gative(?:MediumSpace;|Thi(?:ckSpace;|nSpace;)|VeryThinSpace;)|sted(?:GreaterGreater;|LessLess;)|wLine;)|fr;|o(?:Break;|nBreakingSpace;|pf;|t(?:;|C(?:ongruent;|upCap;)|DoubleVerticalBar;|E(?:lement;|qual(?:;|Tilde;)|xists;)|Greater(?:;|Equal;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|Hump(?:DownHump;|Equal;)|Le(?:ftTriangle(?:;|Bar;|Equal;)|ss(?:;|Equal;|Greater;|Less;|SlantEqual;|Tilde;))|Nested(?:GreaterGreater;|LessLess;)|Precedes(?:;|Equal;|SlantEqual;)|R(?:everseElement;|ightTriangle(?:;|Bar;|Equal;))|S(?:quareSu(?:bset(?:;|Equal;)|perset(?:;|Equal;))|u(?:bset(?:;|Equal;)|cceeds(?:;|Equal;|SlantEqual;|Tilde;)|perset(?:;|Equal;)))|Tilde(?:;|Equal;|FullEqual;|Tilde;)|VerticalBar;))|scr;|tilde;?|u;)|O(?:Elig;|acute;?|c(?:irc;?|y;)|dblac;|fr;|grave;?|m(?:acr;|ega;|icron;)|opf;|penCurly(?:DoubleQuote;|Quote;)|r;|s(?:cr;|lash;?)|ti(?:lde;?|mes;)|uml;?|ver(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;))|P(?:artialD;|cy;|fr;|hi;|i;|lusMinus;|o(?:incareplane;|pf;)|r(?:;|ecedes(?:;|Equal;|SlantEqual;|Tilde;)|ime;|o(?:duct;|portion(?:;|al;)))|s(?:cr;|i;))|Q(?:UOT;?|fr;|opf;|scr;)|R(?:Barr;|EG;?|a(?:cute;|ng;|rr(?:;|tl;))|c(?:aron;|edil;|y;)|e(?:;|verse(?:E(?:lement;|quilibrium;)|UpEquilibrium;))|fr;|ho;|ight(?:A(?:ngleBracket;|rrow(?:;|Bar;|LeftArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Ba
\ No newline at end of file
-
-var NAMEDCHARREF_MAXLEN = 32;
-
-// Regular expression constants used by the tokenizer and parser
-
-// Note that \r is included in all of these regexps because it will need
-// to be converted to LF by the scanChars() function.
-var DBLQUOTEATTRVAL = /[^\r"&\u0000]+/g;
-var SINGLEQUOTEATTRVAL = /[^\r'&\u0000]+/g;
-var UNQUOTEDATTRVAL = /[^\r\t\n\f &>\u0000]+/g;
-var TAGNAME = /[^\r\t\n\f \/>A-Z\u0000]+/g;
-var ATTRNAME = /[^\r\t\n\f \/=>A-Z\u0000]+/g;
-
-var CDATATEXT = /[^\]\r\u0000\uffff]*/g;
-var DATATEXT = /[^&<\r\u0000\uffff]*/g;
-var RAWTEXT = /[^<\r\u0000\uffff]*/g;
-var PLAINTEXT = /[^\r\u0000\uffff]*/g;
-// Since we don't have the 'sticky tag', add '|.' to the end of SIMPLETAG
-// and SIMPLEATTR so that we are guaranteed to always match. This prevents
-// us from scanning past the lastIndex set. (Note that the desired matches
-// are always greater than 1 char long, so longest-match will ensure that .
-// is not matched unless the desired match fails.)
-var SIMPLETAG = /(?:(\/)?([a-z]+)>)|[\s\S]/g;
-var SIMPLEATTR = /(?:([-a-z]+)[ \t\n\f]*=[ \t\n\f]*('[^'&\r\u0000]*'|"[^"&\r\u0000]*"|[^\t\n\r\f "&'\u0000>][^&> \t\n\r\f\u0000]*[ \t\n\f]))|[\s\S]/g;
-
-var NONWS = /[^\x09\x0A\x0C\x0D\x20]/;
-var ALLNONWS = /[^\x09\x0A\x0C\x0D\x20]/g; // like above, with g flag
-var NONWSNONNUL = /[^\x00\x09\x0A\x0C\x0D\x20]/; // don't allow NUL either
-var LEADINGWS = /^[\x09\x0A\x0C\x0D\x20]+/;
-var NULCHARS = /\x00/g;
-
-/***
- * These are utility functions that don't use any of the parser's
- * internal state.
- */
-function buf2str(buf) {
- var CHUNKSIZE=16384;
- if (buf.length < CHUNKSIZE) {
- return String.fromCharCode.apply(String, buf);
- }
- // special case for large strings, to avoid busting the stack.
- var result = '';
- for (var i = 0; i < buf.length; i += CHUNKSIZE) {
- result += String.fromCharCode.apply(String, buf.slice(i, i+CHUNKSIZE));
- }
- return result;
-}
-
-function str2buf(s) {
- var result = [];
- for (var i=0; i<s.length; i++) {
- result[i] = s.charCodeAt(i);
- }
- return result;
-}
-
-// Determine whether the element is a member of the set.
-// The set is an object that maps namespaces to objects. The objects
-// then map local tagnames to the value true if that tag is part of the set
-function isA(elt, set) {
- if (typeof set === 'string') {
- // convenience case for testing a particular HTML element
- return elt.namespaceURI === NAMESPACE.HTML &&
- elt.localName === set;
- }
- var tagnames = set[elt.namespaceURI];
- return tagnames && tagnames[elt.localName];
-}
-
-function isMathmlTextIntegrationPoint(n) {
- return isA(n, mathmlTextIntegrationPointSet);
-}
-
-function isHTMLIntegrationPoint(n) {
- if (isA(n, htmlIntegrationPointSet)) return true;
- if (n.namespaceURI === NAMESPACE.MATHML &&
- n.localName === "annotation-xml") {
- var encoding = n.getAttribute("encoding");
- if (encoding) encoding = encoding.toLowerCase();
- if (encoding === "text/html" ||
- encoding === "application/xhtml+xml")
- return true;
- }
- return false;
-}
-
-function adjustSVGTagName(name) {
- if (name in svgTagNameAdjustments)
- return svgTagNameAdjustments[name];
- else
- return name;
-}
-
-function adjustSVGAttributes(attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- if (attrs[i][0] in svgAttrAdjustments) {
- attrs[i][0] = svgAttrAdjustments[attrs[i][0]];
- }
- }
-}
-
-function adjustMathMLAttributes(attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- if (attrs[i][0] === "definitionurl") {
- attrs[i][0] = "definitionURL";
- break;
- }
- }
-}
-
-function adjustForeignAttributes(attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- if (attrs[i][0] in foreignAttributes) {
- // Attributes with namespaces get a 3rd element:
- // [Qname, value, namespace]
- attrs[i].push(foreignAttributes[attrs[i][0]]);
- }
- }
-}
-
-// For each attribute in attrs, if elt doesn't have an attribute
-// by that name, add the attribute to elt
-// XXX: I'm ignoring namespaces for now
-function transferAttributes(attrs, elt) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- var name = attrs[i][0], value = attrs[i][1];
- if (elt.hasAttribute(name)) continue;
- elt._setAttribute(name, value);
- }
-}
-
-/***
- * The ElementStack class
- */
-HTMLParser.ElementStack = function ElementStack() {
- this.elements = [];
- this.top = null; // stack.top is the "current node" in the spec
-};
-
-/*
-// This is for debugging only
-HTMLParser.ElementStack.prototype.toString = function(e) {
- return "STACK: " +
- this.elements.map(function(e) {return e.localName;}).join("-");
-}
-*/
-
-HTMLParser.ElementStack.prototype.push = function(e) {
- this.elements.push(e);
- this.top = e;
-};
-
-HTMLParser.ElementStack.prototype.pop = function(e) {
- this.elements.pop();
- this.top = this.elements[this.elements.length-1];
-};
-
-// Pop elements off the stack up to and including the first
-// element with the specified (HTML) tagname
-HTMLParser.ElementStack.prototype.popTag = function(tag) {
- for(var i = this.elements.length-1; i > 0; i--) {
- var e = this.elements[i];
- if (isA(e, tag)) break;
- }
- this.elements.length = i;
- this.top = this.elements[i-1];
-};
-
-// Pop elements off the stack up to and including the first
-// element that is an instance of the specified type
-HTMLParser.ElementStack.prototype.popElementType = function(type) {
- for(var i = this.elements.length-1; i > 0; i--) {
- if (this.elements[i] instanceof type) break;
- }
- this.elements.length = i;
- this.top = this.elements[i-1];
-};
-
-// Pop elements off the stack up to and including the element e.
-// Note that this is very different from removeElement()
-// This requires that e is on the stack.
-HTMLParser.ElementStack.prototype.popElement = function(e) {
- for(var i = this.elements.length-1; i > 0; i--) {
- if (this.elements[i] === e) break;
- }
- this.elements.length = i;
- this.top = this.elements[i-1];
-};
-
-// Remove a specific element from the stack.
-// Do nothing if the element is not on the stack
-HTMLParser.ElementStack.prototype.removeElement = function(e) {
- if (this.top === e) this.pop();
- else {
- var idx = this.elements.lastIndexOf(e);
- if (idx !== -1)
- this.elements.splice(idx, 1);
- }
-};
-
-HTMLParser.ElementStack.prototype.clearToContext = function(set) {
- // Note that we don't loop to 0. Never pop the <html> elt off.
- for(var i = this.elements.length-1; i > 0; i--) {
- if (isA(this.elements[i], set)) break;
- }
- this.elements.length = i+1;
- this.top = this.elements[i];
-};
-
-HTMLParser.ElementStack.prototype.contains = function(tag) {
- return this.inSpecificScope(tag, Object.create(null));
-};
-
-HTMLParser.ElementStack.prototype.inSpecificScope = function(tag, set) {
- for(var i = this.elements.length-1; i >= 0; i--) {
- var elt = this.elements[i];
- if (isA(elt, tag)) return true;
- if (isA(elt, set)) return false;
- }
- return false;
-};
-
-// Like the above, but for a specific element, not a tagname
-HTMLParser.ElementStack.prototype.elementInSpecificScope = function(target, set) {
- for(var i = this.elements.length-1; i >= 0; i--) {
- var elt = this.elements[i];
- if (elt === target) return true;
- if (isA(elt, set)) return false;
- }
- return false;
-};
-
-// Like the above, but for an element interface, not a tagname
-HTMLParser.ElementStack.prototype.elementTypeInSpecificScope = function(target, set) {
- for(var i = this.elements.length-1; i >= 0; i--) {
- var elt = this.elements[i];
- if (elt instanceof target) return true;
- if (isA(elt, set)) return false;
- }
- return false;
-};
-
-HTMLParser.ElementStack.prototype.inScope = function(tag) {
- return this.inSpecificScope(tag, inScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.elementInScope = function(e) {
- return this.elementInSpecificScope(e, inScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.elementTypeInScope = function(type) {
- return this.elementTypeInSpecificScope(type, inScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.inButtonScope = function(tag) {
- return this.inSpecificScope(tag, inButtonScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.inListItemScope = function(tag) {
- return this.inSpecificScope(tag, inListItemScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.inTableScope = function(tag) {
- return this.inSpecificScope(tag, inTableScopeSet);
-};
-
-HTMLParser.ElementStack.prototype.inSelectScope = function(tag) {
- // Can't implement this one with inSpecificScope, since it involves
- // a set defined by inverting another set. So implement manually.
- for(var i = this.elements.length-1; i >= 0; i--) {
- var elt = this.elements[i];
- if (elt.namespaceURI !== NAMESPACE.HTML) return false;
- var localname = elt.localName;
- if (localname === tag) return true;
- if (localname !== "optgroup" && localname !== "option")
- return false;
- }
- return false;
-};
-
-HTMLParser.ElementStack.prototype.generateImpliedEndTags = function(butnot, thorough) {
- var endTagSet = thorough ? thoroughImpliedEndTagsSet : impliedEndTagsSet;
- for(var i = this.elements.length-1; i >= 0; i--) {
- var e = this.elements[i];
- if (butnot && isA(e, butnot)) break;
- if (!isA(this.elements[i], endTagSet)) break;
- }
-
- this.elements.length = i+1;
- this.top = this.elements[i];
-};
-
-/***
- * The ActiveFormattingElements class
- */
-HTMLParser.ActiveFormattingElements = function AFE() {
- this.list = []; // elements
- this.attrs = []; // attribute tokens for cloning
-};
-
-HTMLParser.ActiveFormattingElements.prototype.MARKER = { localName: "|" };
-
-/*
-// For debugging
-HTMLParser.ActiveFormattingElements.prototype.toString = function() {
- return "AFE: " +
- this.list.map(function(e) { return e.localName; }).join("-");
-}
-*/
-
-HTMLParser.ActiveFormattingElements.prototype.insertMarker = function() {
- this.list.push(this.MARKER);
- this.attrs.push(this.MARKER);
-};
-
-HTMLParser.ActiveFormattingElements.prototype.push = function(elt, attrs) {
- // Scan backwards: if there are already 3 copies of this element
- // before we encounter a marker, then drop the last one
- var count = 0;
- for(var i = this.list.length-1; i >= 0; i--) {
- if (this.list[i] === this.MARKER) break;
- // equal() is defined below
- if (equal(elt, this.list[i], this.attrs[i])) {
- count++;
- if (count === 3) {
- this.list.splice(i, 1);
- this.attrs.splice(i, 1);
- break;
- }
- }
- }
-
-
- // Now push the element onto the list
- this.list.push(elt);
-
- // Copy the attributes and push those on, too
- var attrcopy = [];
- for(var ii = 0; ii < attrs.length; ii++) {
- attrcopy[ii] = attrs[ii];
- }
-
- this.attrs.push(attrcopy);
-
- // This function defines equality of two elements for the purposes
- // of the AFE list. Note that it compares the new elements
- // attributes to the saved array of attributes associated with
- // the old element because a script could have changed the
- // old element's set of attributes
- function equal(newelt, oldelt, oldattrs) {
- if (newelt.localName !== oldelt.localName) return false;
- if (newelt._numattrs !== oldattrs.length) return false;
- for(var i = 0, n = oldattrs.length; i < n; i++) {
- var oldname = oldattrs[i][0];
- var oldval = oldattrs[i][1];
- if (!newelt.hasAttribute(oldname)) return false;
- if (newelt.getAttribute(oldname) !== oldval) return false;
- }
- return true;
- }
-};
-
-HTMLParser.ActiveFormattingElements.prototype.clearToMarker = function() {
- for(var i = this.list.length-1; i >= 0; i--) {
- if (this.list[i] === this.MARKER) break;
- }
- if (i < 0) i = 0;
- this.list.length = i;
- this.attrs.length = i;
-};
-
-// Find and return the last element with the specified tag between the
-// end of the list and the last marker on the list.
-// Used when parsing <a> in_body_mode()
-HTMLParser.ActiveFormattingElements.prototype.findElementByTag = function(tag) {
- for(var i = this.list.length-1; i >= 0; i--) {
- var elt = this.list[i];
- if (elt === this.MARKER) break;
- if (elt.localName === tag) return elt;
- }
- return null;
-};
-
-HTMLParser.ActiveFormattingElements.prototype.indexOf = function(e) {
- return this.list.lastIndexOf(e);
-};
-
-// Find the element e in the list and remove it
-// Used when parsing <a> in_body()
-HTMLParser.ActiveFormattingElements.prototype.remove = function(e) {
- var idx = this.list.lastIndexOf(e);
- if (idx !== -1) {
- this.list.splice(idx, 1);
- this.attrs.splice(idx, 1);
- }
-};
-
-// Find element a in the list and replace it with element b
-// XXX: Do I need to handle attributes here?
-HTMLParser.ActiveFormattingElements.prototype.replace = function(a, b, attrs) {
- var idx = this.list.lastIndexOf(a);
- if (idx !== -1) {
- this.list[idx] = b;
- this.attrs[idx] = attrs;
- }
-};
-
-// Find a in the list and insert b after it
-// This is only used for insert a bookmark object, so the
-// attrs array doesn't really matter
-HTMLParser.ActiveFormattingElements.prototype.insertAfter = function(a,b) {
- var idx = this.list.lastIndexOf(a);
- if (idx !== -1) {
- this.list.splice(idx, 0, b);
- this.attrs.splice(idx, 0, b);
- }
-};
-
-
-
-
-/***
- * This is the parser factory function. It is the return value of
- * the outer closure that it is defined within. Most of the parser
- * implementation details are inside this function.
- */
-function HTMLParser(address, fragmentContext, options) {
- /***
- * These are the parser's state variables
- */
- // Scanner state
- var chars = null;
- var numchars = 0; // Length of chars
- var nextchar = 0; // Index of next char
- var input_complete = false; // Becomes true when end() called.
- var scanner_skip_newline = false; // If previous char was CR
- var reentrant_invocations = 0;
- var saved_scanner_state = [];
- var leftovers = "";
- var first_batch = true;
- var paused = 0; // Becomes non-zero while loading scripts
-
-
- // Tokenizer state
- var tokenizer = data_state; // Current tokenizer state
- var return_state;
- var character_reference_code;
- var tagnamebuf = "";
- var lasttagname = ""; // holds the target end tag for text states
- var tempbuf = [];
- var attrnamebuf = "";
- var attrvaluebuf = "";
- var commentbuf = [];
- var doctypenamebuf = [];
- var doctypepublicbuf = [];
- var doctypesystembuf = [];
- var attributes = [];
- var is_end_tag = false;
-
- // Tree builder state
- var parser = initial_mode; // Current insertion mode
- var originalInsertionMode = null; // A saved insertion mode
- var templateInsertionModes = []; // Stack of template insertion modes.
- var stack = new HTMLParser.ElementStack(); // Stack of open elements
- var afe = new HTMLParser.ActiveFormattingElements(); // mis-nested tags
- var fragment = (fragmentContext!==undefined); // For innerHTML, etc.
- var head_element_pointer = null;
- var form_element_pointer = null;
- var scripting_enabled = true;
- if (fragmentContext) {
- scripting_enabled = fragmentContext.ownerDocument._scripting_enabled;
- }
- if (options && options.scripting_enabled === false)
- scripting_enabled = false;
- var frameset_ok = true;
- var force_quirks = false;
- var pending_table_text;
- var text_integration_mode; // XXX a spec bug workaround?
-
- // A single run of characters, buffered up to be sent to
- // the parser as a single string.
- var textrun = [];
- var textIncludesNUL = false;
- var ignore_linefeed = false;
-
- /***
- * This is the parser object that will be the return value of this
- * factory function, which is some 5000 lines below.
- * Note that the variable "parser" is the current state of the
- * parser's state machine. This variable "htmlparser" is the
- * return value and defines the public API of the parser
- */
- var htmlparser = {
- document: function() {
- return doc;
- },
-
- // Convenience function for internal use. Can only be called once,
- // as it removes the nodes from `doc` to add them to fragment.
- _asDocumentFragment: function() {
- var frag = doc.createDocumentFragment();
- var root = doc.firstChild;
- while(root.hasChildNodes()) {
- frag.appendChild(root.firstChild);
- }
- return frag;
- },
-
- // Internal function used from HTMLScriptElement to pause the
- // parser while a script is being loaded from the network
- pause: function() {
- // print("pausing parser");
- paused++;
- },
-
- // Called when a script finishes loading
- resume: function() {
- // print("resuming parser");
- paused--;
- // XXX: added this to force a resumption.
- // Is this the right thing to do?
- this.parse("");
- },
-
- // Parse the HTML text s.
- // The second argument should be true if there is no more
- // text to be parsed, and should be false or omitted otherwise.
- // The second argument must not be set for recursive invocations
- // from document.write()
- parse: function(s, end, shouldPauseFunc) {
- var moreToDo;
-
- // If we're paused, remember the text to parse, but
- // don't parse it now.
- // (Don't invoke shouldPauseFunc because we haven't handled 'end' yet.)
- if (paused > 0) {
- leftovers += s;
- return true; // more to do
- }
-
-
- if (reentrant_invocations === 0) {
- // A normal, top-level invocation
- if (leftovers) {
- s = leftovers + s;
- leftovers = "";
- }
-
- // Add a special marker character to the end of
- // the buffer. If the scanner is at the end of
- // the buffer and input_complete is set, then this
- // character will transform into an EOF token.
- // Having an actual character that represents EOF
- // in the character buffer makes lookahead regexp
- // matching work more easily, and this is
- // important for character references.
- if (end) {
- s += "\uFFFF";
- input_complete = true; // Makes scanChars() send EOF
- }
-
- chars = s;
- numchars = s.length;
- nextchar = 0;
-
- if (first_batch) {
- // We skip a leading Byte Order Mark (\uFEFF)
- // on first batch of text we're given
- first_batch = false;
- if (chars.charCodeAt(0) === 0xFEFF) nextchar = 1;
- }
-
- reentrant_invocations++;
- moreToDo = scanChars(shouldPauseFunc);
- leftovers = chars.substring(nextchar, numchars);
- reentrant_invocations--;
- }
- else {
- // This is the re-entrant case, which we have to
- // handle a little differently.
- reentrant_invocations++;
-
- // Save current scanner state
- saved_scanner_state.push(chars, numchars, nextchar);
-
- // Set new scanner state
- chars = s;
- numchars = s.length;
- nextchar = 0;
-
- // Now scan as many of these new chars as we can
- scanChars();
- moreToDo = false;
-
- leftovers = chars.substring(nextchar, numchars);
-
- // restore old scanner state
- nextchar = saved_scanner_state.pop();
- numchars = saved_scanner_state.pop();
- chars = saved_scanner_state.pop();
-
- // If there were leftover chars from this invocation
- // insert them into the pending invocation's buffer
- // and trim already processed chars at the same time
- if (leftovers) {
- chars = leftovers + chars.substring(nextchar);
- numchars = chars.length;
- nextchar = 0;
- leftovers = "";
- }
-
- // Decrement the counter
- reentrant_invocations--;
- }
- return moreToDo;
- }
- };
-
-
- // This is the document we'll be building up
- var doc = new Document(true, address);
-
- // The document needs to know about the parser, for document.write().
- // This _parser property will be deleted when we're done parsing.
- doc._parser = htmlparser;
-
- // XXX I think that any document we use this parser on should support
- // scripts. But I may need to configure that through a parser parameter
- // Only documents with windows ("browsing contexts" to be precise)
- // allow scripting.
- doc._scripting_enabled = scripting_enabled;
-
-
- /***
- * The actual code of the HTMLParser() factory function begins here.
- */
-
- if (fragmentContext) { // for innerHTML parsing
- if (fragmentContext.ownerDocument._quirks)
- doc._quirks = true;
- if (fragmentContext.ownerDocument._limitedQuirks)
- doc._limitedQuirks = true;
-
- // Set the initial tokenizer state
- if (fragmentContext.namespaceURI === NAMESPACE.HTML) {
- switch(fragmentContext.localName) {
- case "title":
- case "textarea":
- tokenizer = rcdata_state;
- break;
- case "style":
- case "xmp":
- case "iframe":
- case "noembed":
- case "noframes":
- case "script":
- case "plaintext":
- tokenizer = plaintext_state;
- break;
- case "noscript":
- if (scripting_enabled)
- tokenizer = plaintext_state;
- }
- }
-
- var root = doc.createElement("html");
- doc._appendChild(root);
- stack.push(root);
- if (fragmentContext instanceof impl.HTMLTemplateElement) {
- templateInsertionModes.push(in_template_mode);
- }
- resetInsertionMode();
-
- for(var e = fragmentContext; e !== null; e = e.parentElement) {
- if (e instanceof impl.HTMLFormElement) {
- form_element_pointer = e;
- break;
- }
- }
- }
-
- /***
- * Scanner functions
- */
- // Loop through the characters in chars, and pass them one at a time
- // to the tokenizer FSM. Return when no more characters can be processed
- // (This may leave 1 or more characters in the buffer: like a CR
- // waiting to see if the next char is LF, or for states that require
- // lookahead...)
- function scanChars(shouldPauseFunc) {
- var codepoint, s, pattern, eof;
-
- while(nextchar < numchars) {
-
- // If we just tokenized a </script> tag, then the paused flag
- // may have been set to tell us to stop tokenizing while
- // the script is loading
- if (paused > 0 || (shouldPauseFunc && shouldPauseFunc())) {
- return true;
- }
-
-
- switch(typeof tokenizer.lookahead) {
- case 'undefined':
- codepoint = chars.charCodeAt(nextchar++);
- if (scanner_skip_newline) {
- scanner_skip_newline = false;
- if (codepoint === 0x000A) {
- nextchar++;
- continue;
- }
- }
- switch(codepoint) {
- case 0x000D:
- // CR always turns into LF, but if the next character
- // is LF, then that second LF is skipped.
- if (nextchar < numchars) {
- if (chars.charCodeAt(nextchar) === 0x000A)
- nextchar++;
- }
- else {
- // We don't know the next char right now, so we
- // can't check if it is a LF. So set a flag
- scanner_skip_newline = true;
- }
-
- // In either case, emit a LF
- tokenizer(0x000A);
-
- break;
- case 0xFFFF:
- if (input_complete && nextchar === numchars) {
- tokenizer(EOF); // codepoint will be 0xFFFF here
- break;
- }
- /* falls through */
- default:
- tokenizer(codepoint);
- break;
- }
- break;
-
- case 'number':
- codepoint = chars.charCodeAt(nextchar);
-
- // The only tokenizer states that require fixed lookahead
- // only consume alphanum characters, so we don't have
- // to worry about CR and LF in this case
-
- // tokenizer wants n chars of lookahead
- var n = tokenizer.lookahead;
- var needsString = true;
- if (n < 0) {
- needsString = false;
- n = -n;
- }
-
- if (n < numchars - nextchar) {
- // If we can look ahead that far
- s = needsString ? chars.substring(nextchar, nextchar+n) : null;
- eof = false;
- }
- else { // if we don't have that many characters
- if (input_complete) { // If no more are coming
- // Just return what we have
- s = needsString ? chars.substring(nextchar, numchars) : null;
- eof = true;
- if (codepoint === 0xFFFF && nextchar === numchars-1)
- codepoint = EOF;
- }
- else {
- // Return now and wait for more chars later
- return true;
- }
- }
- tokenizer(codepoint, s, eof);
- break;
- case 'string':
- codepoint = chars.charCodeAt(nextchar);
-
- // tokenizer wants characters up to a matching string
- pattern = tokenizer.lookahead;
- var pos = chars.indexOf(pattern, nextchar);
- if (pos !== -1) {
- s = chars.substring(nextchar, pos + pattern.length);
- eof = false;
- }
- else { // No match
- // If more characters coming, wait for them
- if (!input_complete) return true;
-
- // Otherwise, we've got to return what we've got
- s = chars.substring(nextchar, numchars);
- if (codepoint === 0xFFFF && nextchar === numchars-1)
- codepoint = EOF;
- eof = true;
- }
-
- // The tokenizer states that require this kind of
- // lookahead have to be careful to handle CR characters
- // correctly
- tokenizer(codepoint, s, eof);
- break;
- }
- }
- return false; // no more characters to scan!
- }
-
-
- /***
- * Tokenizer utility functions
- */
- function addAttribute(name,value) {
- // Make sure there isn't already an attribute with this name
- // If there is, ignore this one.
- for(var i = 0; i < attributes.length; i++) {
- if (attributes[i][0] === name) return;
- }
-
- if (value !== undefined) {
- attributes.push([name, value]);
- }
- else {
- attributes.push([name]);
- }
- }
-
- // Shortcut for simple attributes
- function handleSimpleAttribute() {
- SIMPLEATTR.lastIndex = nextchar-1;
- var matched = SIMPLEATTR.exec(chars);
- if (!matched) throw new Error("should never happen");
- var name = matched[1];
- if (!name) return false;
- var value = matched[2];
- var len = value.length;
- switch(value[0]) {
- case '"':
- case "'":
- value = value.substring(1, len-1);
- nextchar += (matched[0].length-1);
- tokenizer = after_attribute_value_quoted_state;
- break;
- default:
- tokenizer = before_attribute_name_state;
- nextchar += (matched[0].length-1);
- value = value.substring(0, len-1);
- break;
- }
-
- // Make sure there isn't already an attribute with this name
- // If there is, ignore this one.
- for(var i = 0; i < attributes.length; i++) {
- if (attributes[i][0] === name) return true;
- }
-
- attributes.push([name, value]);
- return true;
- }
-
- function beginTagName() {
- is_end_tag = false;
- tagnamebuf = "";
- attributes.length = 0;
- }
- function beginEndTagName() {
- is_end_tag = true;
- tagnamebuf = "";
- attributes.length = 0;
- }
-
- function beginTempBuf() { tempbuf.length = 0; }
- function beginAttrName() { attrnamebuf = ""; }
- function beginAttrValue() { attrvaluebuf = ""; }
- function beginComment() { commentbuf.length = 0; }
- function beginDoctype() {
- doctypenamebuf.length = 0;
- doctypepublicbuf = null;
- doctypesystembuf = null;
- }
- function beginDoctypePublicId() { doctypepublicbuf = []; }
- function beginDoctypeSystemId() { doctypesystembuf = []; }
- function forcequirks() { force_quirks = true; }
- function cdataAllowed() {
- return stack.top &&
- stack.top.namespaceURI !== "http://www.w3.org/1999/xhtml";
- }
-
- // Return true if the codepoints in the specified buffer match the
- // characters of lasttagname
- function appropriateEndTag(buf) {
- return lasttagname === buf;
- }
-
- function flushText() {
- if (textrun.length > 0) {
- var s = buf2str(textrun);
- textrun.length = 0;
-
- if (ignore_linefeed) {
- ignore_linefeed = false;
- if (s[0] === "\n") s = s.substring(1);
- if (s.length === 0) return;
- }
-
- insertToken(TEXT, s);
- textIncludesNUL = false;
- }
- ignore_linefeed = false;
- }
-
- // Consume chars matched by the pattern and return them as a string. Starts
- // matching at the current position, so users should drop the current char
- // otherwise.
- function getMatchingChars(pattern) {
- pattern.lastIndex = nextchar - 1;
- var match = pattern.exec(chars);
- if (match && match.index === nextchar - 1) {
- match = match[0];
- nextchar += match.length - 1;
- /* Careful! Make sure we haven't matched the EOF character! */
- if (input_complete && nextchar === numchars) {
- // Oops, backup one.
- match = match.slice(0, -1);
- nextchar--;
- }
- return match;
- } else {
- throw new Error("should never happen");
- }
- }
-
- // emit a string of chars that match a regexp
- // Returns false if no chars matched.
- function emitCharsWhile(pattern) {
- pattern.lastIndex = nextchar-1;
- var match = pattern.exec(chars)[0];
- if (!match) return false;
- emitCharString(match);
- nextchar += match.length - 1;
- return true;
- }
-
- // This is used by CDATA sections
- function emitCharString(s) {
- if (textrun.length > 0) flushText();
-
- if (ignore_linefeed) {
- ignore_linefeed = false;
- if (s[0] === "\n") s = s.substring(1);
- if (s.length === 0) return;
- }
-
- insertToken(TEXT, s);
- }
-
- function emitTag() {
- if (is_end_tag) insertToken(ENDTAG, tagnamebuf);
- else {
- // Remember the last open tag we emitted
- var tagname = tagnamebuf;
- tagnamebuf = "";
- lasttagname = tagname;
- insertToken(TAG, tagname, attributes);
- }
- }
-
-
- // A shortcut: look ahead and if this is a open or close tag
- // in lowercase with no spaces and no attributes, just emit it now.
- function emitSimpleTag() {
- if (nextchar === numchars) { return false; /* not even 1 char left */ }
- SIMPLETAG.lastIndex = nextchar;
- var matched = SIMPLETAG.exec(chars);
- if (!matched) throw new Error("should never happen");
- var tagname = matched[2];
- if (!tagname) return false;
- var endtag = matched[1];
- if (endtag) {
- nextchar += (tagname.length+2);
- insertToken(ENDTAG, tagname);
- }
- else {
- nextchar += (tagname.length+1);
- lasttagname = tagname;
- insertToken(TAG, tagname, NOATTRS);
- }
- return true;
- }
-
- function emitSelfClosingTag() {
- if (is_end_tag) insertToken(ENDTAG, tagnamebuf, null, true);
- else {
- insertToken(TAG, tagnamebuf, attributes, true);
- }
- }
-
- function emitDoctype() {
- insertToken(DOCTYPE,
- buf2str(doctypenamebuf),
- doctypepublicbuf ? buf2str(doctypepublicbuf) : undefined,
- doctypesystembuf ? buf2str(doctypesystembuf) : undefined);
- }
-
- function emitEOF() {
- flushText();
- parser(EOF); // EOF never goes to insertForeignContent()
- doc.modclock = 1; // Start tracking modifications
- }
-
- // Insert a token, either using the current parser insertion mode
- // (for HTML stuff) or using the insertForeignToken() method.
- var insertToken = htmlparser.insertToken = function insertToken(t, value, arg3, arg4) {
- flushText();
- var current = stack.top;
-
- if (!current || current.namespaceURI === NAMESPACE.HTML) {
- // This is the common case
- parser(t, value, arg3, arg4);
- }
- else {
- // Otherwise we may need to insert this token as foreign content
- if (t !== TAG && t !== TEXT) {
- insertForeignToken(t, value, arg3, arg4);
- }
- else {
- // But in some cases we treat it as regular content
- if ((isMathmlTextIntegrationPoint(current) &&
- (t === TEXT ||
- (t === TAG &&
- value !== "mglyph" && value !== "malignmark"))) ||
- (t === TAG &&
- value === "svg" &&
- current.namespaceURI === NAMESPACE.MATHML &&
- current.localName === "annotation-xml") ||
- isHTMLIntegrationPoint(current)) {
-
- // XXX: the text_integration_mode stuff is an
- // attempted bug workaround of mine
- text_integration_mode = true;
- parser(t, value, arg3, arg4);
- text_integration_mode = false;
- }
- // Otherwise it is foreign content
- else {
- insertForeignToken(t, value, arg3, arg4);
- }
- }
- }
- };
-
-
- /***
- * Tree building utility functions
- */
- function insertComment(data) {
- var parent = stack.top;
- if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
- fosterParent(function(doc) { return doc.createComment(data); });
- } else {
- // "If the adjusted insertion location is inside a template element,
- // let it instead be inside the template element's template contents"
- if (parent instanceof impl.HTMLTemplateElement) {
- parent = parent.content;
- }
- parent._appendChild(parent.ownerDocument.createComment(data));
- }
- }
-
- function insertText(s) {
- var parent = stack.top;
- if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
- fosterParent(function(doc) { return doc.createTextNode(s); });
- } else {
- // "If the adjusted insertion location is inside a template element,
- // let it instead be inside the template element's template contents"
- if (parent instanceof impl.HTMLTemplateElement) {
- parent = parent.content;
- }
- // "If there is a Text node immediately before the adjusted insertion
- // location, then append data to that Text node's data."
- var lastChild = parent.lastChild;
- if (lastChild && lastChild.nodeType === Node.TEXT_NODE) {
- lastChild.appendData(s);
- } else {
- parent._appendChild(parent.ownerDocument.createTextNode(s));
- }
- }
- }
-
- function createHTMLElt(doc, name, attrs) {
- // Create the element this way, rather than with
- // doc.createElement because createElement() does error
- // checking on the element name that we need to avoid here.
- var elt = html.createElement(doc, name, null);
-
- if (attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- // Use the _ version to avoid testing the validity
- // of the attribute name
- elt._setAttribute(attrs[i][0], attrs[i][1]);
- }
- }
- // XXX
- // If the element is a resettable form element,
- // run its reset algorithm now
- // XXX
- // handle case where form-element-pointer is not null
- return elt;
- }
-
- // The in_table insertion mode turns on this flag, and that makes
- // insertHTMLElement use the foster parenting algorithm for elements
- // tags inside a table
- var foster_parent_mode = false;
-
- function insertHTMLElement(name, attrs) {
- var elt = insertElement(function(doc) {
- return createHTMLElt(doc, name, attrs);
- });
-
- // XXX
- // If this is a form element, set its form attribute property here
- if (isA(elt, formassociatedSet)) {
- elt._form = form_element_pointer;
- }
-
- return elt;
- }
-
- // Insert the element into the open element or foster parent it
- function insertElement(eltFunc) {
- var elt;
- if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) {
- elt = fosterParent(eltFunc);
- }
- else if (stack.top instanceof impl.HTMLTemplateElement) {
- // "If the adjusted insertion location is inside a template element,
- // let it instead be inside the template element's template contents"
- elt = eltFunc(stack.top.content.ownerDocument);
- stack.top.content._appendChild(elt);
- } else {
- elt = eltFunc(stack.top.ownerDocument);
- stack.top._appendChild(elt);
- }
-
- stack.push(elt);
- return elt;
- }
-
- function insertForeignElement(name, attrs, ns) {
- return insertElement(function(doc) {
- // We need to prevent createElementNS from trying to parse `name` as a
- // `qname`, so use an internal Document#_createElementNS() interface.
- var elt = doc._createElementNS(name, ns, null);
- if (attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- var attr = attrs[i];
- if (attr.length === 2)
- elt._setAttribute(attr[0], attr[1]);
- else {
- elt._setAttributeNS(attr[2], attr[0], attr[1]);
- }
- }
- }
- return elt;
- });
- }
-
- function lastElementOfType(type) {
- for(var i = stack.elements.length-1; i >= 0; i--) {
- if (stack.elements[i] instanceof type) {
- return i;
- }
- }
- return -1;
- }
-
- function fosterParent(eltFunc) {
- var parent, before, lastTable = -1, lastTemplate = -1, elt;
-
- lastTable = lastElementOfType(impl.HTMLTableElement);
- lastTemplate = lastElementOfType(impl.HTMLTemplateElement);
-
- if (lastTemplate >= 0 && (lastTable < 0 || lastTemplate > lastTable)) {
- parent = stack.elements[lastTemplate];
- } else if (lastTable >= 0) {
- parent = stack.elements[lastTable].parentNode;
- if (parent) {
- before = stack.elements[lastTable];
- } else {
- parent = stack.elements[lastTable - 1];
- }
- }
- if (!parent) parent = stack.elements[0]; // the `html` element.
-
- // "If the adjusted insertion location is inside a template element,
- // let it instead be inside the template element's template contents"
- if (parent instanceof impl.HTMLTemplateElement) {
- parent = parent.content;
- }
- // Create element in the appropriate document.
- elt = eltFunc(parent.ownerDocument);
-
- if (elt.nodeType === Node.TEXT_NODE) {
- var prev;
- if (before) prev = before.previousSibling;
- else prev = parent.lastChild;
- if (prev && prev.nodeType === Node.TEXT_NODE) {
- prev.appendData(elt.data);
- return elt;
- }
- }
- if (before)
- parent.insertBefore(elt, before);
- else
- parent._appendChild(elt);
- return elt;
- }
-
-
- function resetInsertionMode() {
- var last = false;
- for(var i = stack.elements.length-1; i >= 0; i--) {
- var node = stack.elements[i];
- if (i === 0) {
- last = true;
- if (fragment) {
- node = fragmentContext;
- }
- }
- if (node.namespaceURI === NAMESPACE.HTML) {
- var tag = node.localName;
- switch(tag) {
- case "select":
- for(var j = i; j > 0; ) {
- var ancestor = stack.elements[--j];
- if (ancestor instanceof impl.HTMLTemplateElement) {
- break;
- } else if (ancestor instanceof impl.HTMLTableElement) {
- parser = in_select_in_table_mode;
- return;
- }
- }
- parser = in_select_mode;
- return;
- case "tr":
- parser = in_row_mode;
- return;
- case "tbody":
- case "tfoot":
- case "thead":
- parser = in_table_body_mode;
- return;
- case "caption":
- parser = in_caption_mode;
- return;
- case "colgroup":
- parser = in_column_group_mode;
- return;
- case "table":
- parser = in_table_mode;
- return;
- case "template":
- parser = templateInsertionModes[templateInsertionModes.length-1];
- return;
- case "body":
- parser = in_body_mode;
- return;
- case "frameset":
- parser = in_frameset_mode;
- return;
- case "html":
- if (head_element_pointer === null) {
- parser = before_head_mode;
- } else {
- parser = after_head_mode;
- }
- return;
- default:
- if (!last) {
- if (tag === "head") {
- parser = in_head_mode;
- return;
- }
- if (tag === "td" || tag === "th") {
- parser = in_cell_mode;
- return;
- }
- }
- }
- }
- if (last) {
- parser = in_body_mode;
- return;
- }
- }
- }
-
-
- function parseRawText(name, attrs) {
- insertHTMLElement(name, attrs);
- tokenizer = rawtext_state;
- originalInsertionMode = parser;
- parser = text_mode;
- }
-
- function parseRCDATA(name, attrs) {
- insertHTMLElement(name, attrs);
- tokenizer = rcdata_state;
- originalInsertionMode = parser;
- parser = text_mode;
- }
-
- // Make a copy of element i on the list of active formatting
- // elements, using its original attributes, not current
- // attributes (which may have been modified by a script)
- function afeclone(doc, i) {
- return {
- elt: createHTMLElt(doc, afe.list[i].localName, afe.attrs[i]),
- attrs: afe.attrs[i],
- };
- }
-
-
- function afereconstruct() {
- if (afe.list.length === 0) return;
- var entry = afe.list[afe.list.length-1];
- // If the last is a marker , do nothing
- if (entry === afe.MARKER) return;
- // Or if it is an open element, do nothing
- if (stack.elements.lastIndexOf(entry) !== -1) return;
-
- // Loop backward through the list until we find a marker or an
- // open element, and then move forward one from there.
- for(var i = afe.list.length-2; i >= 0; i--) {
- entry = afe.list[i];
- if (entry === afe.MARKER) break;
- if (stack.elements.lastIndexOf(entry) !== -1) break;
- }
-
- // Now loop forward, starting from the element after the current
- // one, recreating formatting elements and pushing them back onto
- // the list of open elements
- for(i = i+1; i < afe.list.length; i++) {
- var newelt = insertElement(function(doc) { return afeclone(doc, i).elt; });
- afe.list[i] = newelt;
- }
- }
-
- // Used by the adoptionAgency() function
- var BOOKMARK = {localName:"BM"};
-
- function adoptionAgency(tag) {
- // If the current node is an HTML element whose tag name is subject,
- // and the current node is not in the list of active formatting
- // elements, then pop the current node off the stack of open
- // elements and abort these steps.
- if (isA(stack.top, tag) && afe.indexOf(stack.top) === -1) {
- stack.pop();
- return true; // no more handling required
- }
-
- // Let outer loop counter be zero.
- var outer = 0;
-
- // Outer loop: If outer loop counter is greater than or
- // equal to eight, then abort these steps.
- while(outer < 8) {
- // Increment outer loop counter by one.
- outer++;
-
- // Let the formatting element be the last element in the list
- // of active formatting elements that: is between the end of
- // the list and the last scope marker in the list, if any, or
- // the start of the list otherwise, and has the same tag name
- // as the token.
- var fmtelt = afe.findElementByTag(tag);
-
- // If there is no such node, then abort these steps and instead
- // act as described in the "any other end tag" entry below.
- if (!fmtelt) {
- return false; // false means handle by the default case
- }
-
- // Otherwise, if there is such a node, but that node is not in
- // the stack of open elements, then this is a parse error;
- // remove the element from the list, and abort these steps.
- var index = stack.elements.lastIndexOf(fmtelt);
- if (index === -1) {
- afe.remove(fmtelt);
- return true; // true means no more handling required
- }
-
- // Otherwise, if there is such a node, and that node is also in
- // the stack of open elements, but the element is not in scope,
- // then this is a parse error; ignore the token, and abort
- // these steps.
- if (!stack.elementInScope(fmtelt)) {
- return true;
- }
-
- // Let the furthest block be the topmost node in the stack of
- // open elements that is lower in the stack than the formatting
- // element, and is an element in the special category. There
- // might not be one.
- var furthestblock = null, furthestblockindex;
- for(var i = index+1; i < stack.elements.length; i++) {
- if (isA(stack.elements[i], specialSet)) {
- furthestblock = stack.elements[i];
- furthestblockindex = i;
- break;
- }
- }
-
- // If there is no furthest block, then the UA must skip the
- // subsequent steps and instead just pop all the nodes from the
- // bottom of the stack of open elements, from the current node
- // up to and including the formatting element, and remove the
- // formatting element from the list of active formatting
- // elements.
- if (!furthestblock) {
- stack.popElement(fmtelt);
- afe.remove(fmtelt);
- return true;
- }
- else {
- // Let the common ancestor be the element immediately above
- // the formatting element in the stack of open elements.
- var ancestor = stack.elements[index-1];
-
- // Let a bookmark note the position of the formatting
- // element in the list of active formatting elements
- // relative to the elements on either side of it in the
- // list.
- afe.insertAfter(fmtelt, BOOKMARK);
-
- // Let node and last node be the furthest block.
- var node = furthestblock;
- var lastnode = furthestblock;
- var nodeindex = furthestblockindex;
- var nodeafeindex;
-
- // Let inner loop counter be zero.
- var inner = 0;
-
- while (true) {
-
- // Increment inner loop counter by one.
- inner++;
-
- // Let node be the element immediately above node in
- // the stack of open elements, or if node is no longer
- // in the stack of open elements (e.g. because it got
- // removed by this algorithm), the element that was
- // immediately above node in the stack of open elements
- // before node was removed.
- node = stack.elements[--nodeindex];
-
- // If node is the formatting element, then go
- // to the next step in the overall algorithm.
- if (node === fmtelt) break;
-
- // If the inner loop counter is greater than three and node
- // is in the list of active formatting elements, then remove
- // node from the list of active formatting elements.
- nodeafeindex = afe.indexOf(node);
- if (inner > 3 && nodeafeindex !== -1) {
- afe.remove(node);
- nodeafeindex = -1;
- }
-
- // If node is not in the list of active formatting
- // elements, then remove node from the stack of open
- // elements and then go back to the step labeled inner
- // loop.
- if (nodeafeindex === -1) {
- stack.removeElement(node);
- continue;
- }
-
- // Create an element for the token for which the
- // element node was created with common ancestor as
- // the intended parent, replace the entry for node
- // in the list of active formatting elements with an
- // entry for the new element, replace the entry for
- // node in the stack of open elements with an entry for
- // the new element, and let node be the new element.
- var newelt = afeclone(ancestor.ownerDocument, nodeafeindex);
- afe.replace(node, newelt.elt, newelt.attrs);
- stack.elements[nodeindex] = newelt.elt;
- node = newelt.elt;
-
- // If last node is the furthest block, then move the
- // aforementioned bookmark to be immediately after the
- // new node in the list of active formatting elements.
- if (lastnode === furthestblock) {
- afe.remove(BOOKMARK);
- afe.insertAfter(newelt.elt, BOOKMARK);
- }
-
- // Insert last node into node, first removing it from
- // its previous parent node if any.
- node._appendChild(lastnode);
-
- // Let last node be node.
- lastnode = node;
- }
-
- // If the common ancestor node is a table, tbody, tfoot,
- // thead, or tr element, then, foster parent whatever last
- // node ended up being in the previous step, first removing
- // it from its previous parent node if any.
- if (foster_parent_mode && isA(ancestor, tablesectionrowSet)) {
- fosterParent(function() { return lastnode; });
- }
- // Otherwise, append whatever last node ended up being in
- // the previous step to the common ancestor node, first
- // removing it from its previous parent node if any.
- else if (ancestor instanceof impl.HTMLTemplateElement) {
- ancestor.content._appendChild(lastnode);
- } else {
- ancestor._appendChild(lastnode);
- }
-
- // Create an element for the token for which the
- // formatting element was created, with furthest block
- // as the intended parent.
- var newelt2 = afeclone(furthestblock.ownerDocument, afe.indexOf(fmtelt));
-
- // Take all of the child nodes of the furthest block and
- // append them to the element created in the last step.
- while(furthestblock.hasChildNodes()) {
- newelt2.elt._appendChild(furthestblock.firstChild);
- }
-
- // Append that new element to the furthest block.
- furthestblock._appendChild(newelt2.elt);
-
- // Remove the formatting element from the list of active
- // formatting elements, and insert the new element into the
- // list of active formatting elements at the position of
- // the aforementioned bookmark.
- afe.remove(fmtelt);
- afe.replace(BOOKMARK, newelt2.elt, newelt2.attrs);
-
- // Remove the formatting element from the stack of open
- // elements, and insert the new element into the stack of
- // open elements immediately below the position of the
- // furthest block in that stack.
- stack.removeElement(fmtelt);
- var pos = stack.elements.lastIndexOf(furthestblock);
- stack.elements.splice(pos+1, 0, newelt2.elt);
- }
- }
-
- return true;
- }
-
- // We do this when we get /script in in_text_mode
- function handleScriptEnd() {
- // XXX:
- // This is just a stub implementation right now and doesn't run scripts.
- // Getting this method right involves the event loop, URL resolution
- // script fetching etc. For now I just want to be able to parse
- // documents and test the parser.
-
- //var script = stack.top;
- stack.pop();
- parser = originalInsertionMode;
- //script._prepare();
- return;
-
- // XXX: here is what this method is supposed to do
-
- // Provide a stable state.
-
- // Let script be the current node (which will be a script
- // element).
-
- // Pop the current node off the stack of open elements.
-
- // Switch the insertion mode to the original insertion mode.
-
- // Let the old insertion point have the same value as the current
- // insertion point. Let the insertion point be just before the
- // next input character.
-
- // Increment the parser's script nesting level by one.
-
- // Prepare the script. This might cause some script to execute,
- // which might cause new characters to be inserted into the
- // tokenizer, and might cause the tokenizer to output more tokens,
- // resulting in a reentrant invocation of the parser.
-
- // Decrement the parser's script nesting level by one. If the
- // parser's script nesting level is zero, then set the parser
- // pause flag to false.
-
- // Let the insertion point have the value of the old insertion
- // point. (In other words, restore the insertion point to its
- // previous value. This value might be the "undefined" value.)
-
- // At this stage, if there is a pending parsing-blocking script,
- // then:
-
- // If the script nesting level is not zero:
-
- // Set the parser pause flag to true, and abort the processing
- // of any nested invocations of the tokenizer, yielding
- // control back to the caller. (Tokenization will resume when
- // the caller returns to the "outer" tree construction stage.)
-
- // The tree construction stage of this particular parser is
- // being called reentrantly, say from a call to
- // document.write().
-
- // Otherwise:
-
- // Run these steps:
-
- // Let the script be the pending parsing-blocking
- // script. There is no longer a pending
- // parsing-blocking script.
-
- // Block the tokenizer for this instance of the HTML
- // parser, such that the event loop will not run tasks
- // that invoke the tokenizer.
-
- // If the parser's Document has a style sheet that is
- // blocking scripts or the script's "ready to be
- // parser-executed" flag is not set: spin the event
- // loop until the parser's Document has no style sheet
- // that is blocking scripts and the script's "ready to
- // be parser-executed" flag is set.
-
- // Unblock the tokenizer for this instance of the HTML
- // parser, such that tasks that invoke the tokenizer
- // can again be run.
-
- // Let the insertion point be just before the next
- // input character.
-
- // Increment the parser's script nesting level by one
- // (it should be zero before this step, so this sets
- // it to one).
-
- // Execute the script.
-
- // Decrement the parser's script nesting level by
- // one. If the parser's script nesting level is zero
- // (which it always should be at this point), then set
- // the parser pause flag to false.
-
- // Let the insertion point be undefined again.
-
- // If there is once again a pending parsing-blocking
- // script, then repeat these steps from step 1.
-
-
- }
-
- function stopParsing() {
- // XXX This is just a temporary implementation to get the parser working.
- // A full implementation involves scripts and events and the event loop.
-
- // Remove the link from document to parser.
- // This is instead of "set the insertion point to undefined".
- // It means that document.write() can't write into the doc anymore.
- delete doc._parser;
-
- stack.elements.length = 0; // pop everything off
-
- // If there is a window object associated with the document
- // then trigger an load event on it
- if (doc.defaultView) {
- doc.defaultView.dispatchEvent(new impl.Event("load",{}));
- }
-
- }
-
- /****
- * Tokenizer states
- */
-
- /**
- * This file was partially mechanically generated from
- * http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
- *
- * After mechanical conversion, it was further converted from
- * prose to JS by hand, but the intent is that it is a very
- * faithful rendering of the HTML tokenization spec in
- * JavaScript.
- *
- * It is not a goal of this tokenizer to detect or report
- * parse errors.
- *
- * XXX The tokenizer is supposed to work with straight UTF32
- * codepoints. But I don't think it has any dependencies on
- * any character outside of the BMP so I think it is safe to
- * pass it UTF16 characters. I don't think it will ever change
- * state in the middle of a surrogate pair.
- */
-
- /*
- * Each state is represented by a function. For most states, the
- * scanner simply passes the next character (as an integer
- * codepoint) to the current state function and automatically
- * consumes the character. If the state function can't process
- * the character it can call pushback() to push it back to the
- * scanner.
- *
- * Some states require lookahead, though. If a state function has
- * a lookahead property, then it is invoked differently. In this
- * case, the scanner invokes the function with 3 arguments: 1) the
- * next codepoint 2) a string of lookahead text 3) a boolean that
- * is true if the lookahead goes all the way to the EOF. (XXX
- * actually maybe this third is not necessary... the lookahead
- * could just include \uFFFF?)
- *
- * If the lookahead property of a state function is an integer, it
- * specifies the number of characters required. If it is a string,
- * then the scanner will scan for that string and return all
- * characters up to and including that sequence, or up to EOF. If
- * the lookahead property is a regexp, then the scanner will match
- * the regexp at the current point and return the matching string.
- *
- * States that require lookahead are responsible for explicitly
- * consuming the characters they process. They do this by
- * incrementing nextchar by the number of processed characters.
- */
- function reconsume(c, new_state) {
- tokenizer = new_state;
- nextchar--; // pushback
- }
-
- function data_state(c) {
- switch(c) {
- case 0x0026: // AMPERSAND
- return_state = data_state;
- tokenizer = character_reference_state;
- break;
- case 0x003C: // LESS-THAN SIGN
- if (emitSimpleTag()) // Shortcut for <p>, <dl>, </div> etc.
- break;
- tokenizer = tag_open_state;
- break;
- case 0x0000: // NULL
- // Usually null characters emitted by the tokenizer will be
- // ignored by the tree builder, but sometimes they'll be
- // converted to \uFFFD. I don't want to have the search every
- // string emitted to replace NULs, so I'll set a flag
- // if I've emitted a NUL.
- textrun.push(c);
- textIncludesNUL = true;
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- // Instead of just pushing a single character and then
- // coming back to the very same place, lookahead and
- // emit everything we can at once.
- /*jshint -W030 */
- emitCharsWhile(DATATEXT) || textrun.push(c);
- break;
- }
- }
-
- function rcdata_state(c) {
- // Save the open tag so we can find a matching close tag
- switch(c) {
- case 0x0026: // AMPERSAND
- return_state = rcdata_state;
- tokenizer = character_reference_state;
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = rcdata_less_than_sign_state;
- break;
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- textIncludesNUL = true;
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- textrun.push(c);
- break;
- }
- }
-
- function rawtext_state(c) {
- switch(c) {
- case 0x003C: // LESS-THAN SIGN
- tokenizer = rawtext_less_than_sign_state;
- break;
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- /*jshint -W030 */
- emitCharsWhile(RAWTEXT) || textrun.push(c);
- break;
- }
- }
-
- function script_data_state(c) {
- switch(c) {
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_less_than_sign_state;
- break;
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- /*jshint -W030 */
- emitCharsWhile(RAWTEXT) || textrun.push(c);
- break;
- }
- }
-
- function plaintext_state(c) {
- switch(c) {
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- /*jshint -W030 */
- emitCharsWhile(PLAINTEXT) || textrun.push(c);
- break;
- }
- }
-
- function tag_open_state(c) {
- switch(c) {
- case 0x0021: // EXCLAMATION MARK
- tokenizer = markup_declaration_open_state;
- break;
- case 0x002F: // SOLIDUS
- tokenizer = end_tag_open_state;
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginTagName();
- reconsume(c, tag_name_state);
- break;
- case 0x003F: // QUESTION MARK
- reconsume(c, bogus_comment_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, data_state);
- break;
- }
- }
-
- function end_tag_open_state(c) {
- switch(c) {
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginEndTagName();
- reconsume(c, tag_name_state);
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- break;
- case -1: // EOF
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- emitEOF();
- break;
- default:
- reconsume(c, bogus_comment_state);
- break;
- }
- }
-
- function tag_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = before_attribute_name_state;
- break;
- case 0x002F: // SOLIDUS
- tokenizer = self_closing_start_tag_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitTag();
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- tagnamebuf += String.fromCharCode(c + 0x0020);
- break;
- case 0x0000: // NULL
- tagnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- tagnamebuf += getMatchingChars(TAGNAME);
- break;
- }
- }
-
- function rcdata_less_than_sign_state(c) {
- /* identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g */
- if (c === 0x002F) { // SOLIDUS
- beginTempBuf();
- tokenizer = rcdata_end_tag_open_state;
- }
- else {
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, rcdata_state);
- }
- }
-
- function rcdata_end_tag_open_state(c) {
- /* identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g */
- switch(c) {
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginEndTagName();
- reconsume(c, rcdata_end_tag_name_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- reconsume(c, rcdata_state);
- break;
- }
- }
-
- function rcdata_end_tag_name_state(c) {
- /* identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g */
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = before_attribute_name_state;
- return;
- }
- break;
- case 0x002F: // SOLIDUS
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = self_closing_start_tag_state;
- return;
- }
- break;
- case 0x003E: // GREATER-THAN SIGN
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = data_state;
- emitTag();
- return;
- }
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
-
- tagnamebuf += String.fromCharCode(c + 0x0020);
- tempbuf.push(c);
- return;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
-
- tagnamebuf += String.fromCharCode(c);
- tempbuf.push(c);
- return;
- default:
- break;
- }
-
- // If we don't return in one of the cases above, then this was not
- // an appropriately matching close tag, so back out by emitting all
- // the characters as text
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- pushAll(textrun, tempbuf);
- reconsume(c, rcdata_state);
- }
-
- function rawtext_less_than_sign_state(c) {
- /* identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g
- */
- if (c === 0x002F) { // SOLIDUS
- beginTempBuf();
- tokenizer = rawtext_end_tag_open_state;
- }
- else {
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, rawtext_state);
- }
- }
-
- function rawtext_end_tag_open_state(c) {
- /* identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g */
- switch(c) {
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginEndTagName();
- reconsume(c, rawtext_end_tag_name_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- reconsume(c, rawtext_state);
- break;
- }
- }
-
- function rawtext_end_tag_name_state(c) {
- /* identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g */
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = before_attribute_name_state;
- return;
- }
- break;
- case 0x002F: // SOLIDUS
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = self_closing_start_tag_state;
- return;
- }
- break;
- case 0x003E: // GREATER-THAN SIGN
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = data_state;
- emitTag();
- return;
- }
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- tagnamebuf += String.fromCharCode(c + 0x0020);
- tempbuf.push(c);
- return;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- tagnamebuf += String.fromCharCode(c);
- tempbuf.push(c);
- return;
- default:
- break;
- }
-
- // If we don't return in one of the cases above, then this was not
- // an appropriately matching close tag, so back out by emitting all
- // the characters as text
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- pushAll(textrun,tempbuf);
- reconsume(c, rawtext_state);
- }
-
- function script_data_less_than_sign_state(c) {
- switch(c) {
- case 0x002F: // SOLIDUS
- beginTempBuf();
- tokenizer = script_data_end_tag_open_state;
- break;
- case 0x0021: // EXCLAMATION MARK
- tokenizer = script_data_escape_start_state;
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x0021); // EXCLAMATION MARK
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, script_data_state);
- break;
- }
- }
-
- function script_data_end_tag_open_state(c) {
- /* identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g */
- switch(c) {
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginEndTagName();
- reconsume(c, script_data_end_tag_name_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- reconsume(c, script_data_state);
- break;
- }
- }
-
- function script_data_end_tag_name_state(c) {
- /* identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g */
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = before_attribute_name_state;
- return;
- }
- break;
- case 0x002F: // SOLIDUS
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = self_closing_start_tag_state;
- return;
- }
- break;
- case 0x003E: // GREATER-THAN SIGN
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = data_state;
- emitTag();
- return;
- }
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
-
- tagnamebuf += String.fromCharCode(c + 0x0020);
- tempbuf.push(c);
- return;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
-
- tagnamebuf += String.fromCharCode(c);
- tempbuf.push(c);
- return;
- default:
- break;
- }
-
- // If we don't return in one of the cases above, then this was not
- // an appropriately matching close tag, so back out by emitting all
- // the characters as text
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- pushAll(textrun,tempbuf);
- reconsume(c, script_data_state);
- }
-
- function script_data_escape_start_state(c) {
- if (c === 0x002D) { // HYPHEN-MINUS
- tokenizer = script_data_escape_start_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- }
- else {
- reconsume(c, script_data_state);
- }
- }
-
- function script_data_escape_start_dash_state(c) {
- if (c === 0x002D) { // HYPHEN-MINUS
- tokenizer = script_data_escaped_dash_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- }
- else {
- reconsume(c, script_data_state);
- }
- }
-
- function script_data_escaped_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = script_data_escaped_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_escaped_less_than_sign_state;
- break;
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- textrun.push(c);
- break;
- }
- }
-
- function script_data_escaped_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = script_data_escaped_dash_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_escaped_less_than_sign_state;
- break;
- case 0x0000: // NULL
- tokenizer = script_data_escaped_state;
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- tokenizer = script_data_escaped_state;
- textrun.push(c);
- break;
- }
- }
-
- function script_data_escaped_dash_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_escaped_less_than_sign_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = script_data_state;
- textrun.push(0x003E); // GREATER-THAN SIGN
- break;
- case 0x0000: // NULL
- tokenizer = script_data_escaped_state;
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- tokenizer = script_data_escaped_state;
- textrun.push(c);
- break;
- }
- }
-
- function script_data_escaped_less_than_sign_state(c) {
- switch(c) {
- case 0x002F: // SOLIDUS
- beginTempBuf();
- tokenizer = script_data_escaped_end_tag_open_state;
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginTempBuf();
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, script_data_double_escape_start_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- reconsume(c, script_data_escaped_state);
- break;
- }
- }
-
- function script_data_escaped_end_tag_open_state(c) {
- switch(c) {
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- beginEndTagName();
- reconsume(c, script_data_escaped_end_tag_name_state);
- break;
- default:
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- reconsume(c, script_data_escaped_state);
- break;
- }
- }
-
- function script_data_escaped_end_tag_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = before_attribute_name_state;
- return;
- }
- break;
- case 0x002F: // SOLIDUS
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = self_closing_start_tag_state;
- return;
- }
- break;
- case 0x003E: // GREATER-THAN SIGN
- if (appropriateEndTag(tagnamebuf)) {
- tokenizer = data_state;
- emitTag();
- return;
- }
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- tagnamebuf += String.fromCharCode(c + 0x0020);
- tempbuf.push(c);
- return;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- tagnamebuf += String.fromCharCode(c);
- tempbuf.push(c);
- return;
- default:
- break;
- }
-
- // We get here in the default case, and if the closing tagname
- // is not an appropriate tagname.
- textrun.push(0x003C); // LESS-THAN SIGN
- textrun.push(0x002F); // SOLIDUS
- pushAll(textrun,tempbuf);
- reconsume(c, script_data_escaped_state);
- }
-
- function script_data_double_escape_start_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- case 0x002F: // SOLIDUS
- case 0x003E: // GREATER-THAN SIGN
- if (buf2str(tempbuf) === "script") {
- tokenizer = script_data_double_escaped_state;
- }
- else {
- tokenizer = script_data_escaped_state;
- }
- textrun.push(c);
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- tempbuf.push(c + 0x0020);
- textrun.push(c);
- break;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- tempbuf.push(c);
- textrun.push(c);
- break;
- default:
- reconsume(c, script_data_escaped_state);
- break;
- }
- }
-
- function script_data_double_escaped_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = script_data_double_escaped_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_double_escaped_less_than_sign_state;
- textrun.push(0x003C); // LESS-THAN SIGN
- break;
- case 0x0000: // NULL
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- textrun.push(c);
- break;
- }
- }
-
- function script_data_double_escaped_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = script_data_double_escaped_dash_dash_state;
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_double_escaped_less_than_sign_state;
- textrun.push(0x003C); // LESS-THAN SIGN
- break;
- case 0x0000: // NULL
- tokenizer = script_data_double_escaped_state;
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- tokenizer = script_data_double_escaped_state;
- textrun.push(c);
- break;
- }
- }
-
- function script_data_double_escaped_dash_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- textrun.push(0x002D); // HYPHEN-MINUS
- break;
- case 0x003C: // LESS-THAN SIGN
- tokenizer = script_data_double_escaped_less_than_sign_state;
- textrun.push(0x003C); // LESS-THAN SIGN
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = script_data_state;
- textrun.push(0x003E); // GREATER-THAN SIGN
- break;
- case 0x0000: // NULL
- tokenizer = script_data_double_escaped_state;
- textrun.push(0xFFFD); // REPLACEMENT CHARACTER
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- tokenizer = script_data_double_escaped_state;
- textrun.push(c);
- break;
- }
- }
-
- function script_data_double_escaped_less_than_sign_state(c) {
- if (c === 0x002F) { // SOLIDUS
- beginTempBuf();
- tokenizer = script_data_double_escape_end_state;
- textrun.push(0x002F); // SOLIDUS
- }
- else {
- reconsume(c, script_data_double_escaped_state);
- }
- }
-
- function script_data_double_escape_end_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- case 0x002F: // SOLIDUS
- case 0x003E: // GREATER-THAN SIGN
- if (buf2str(tempbuf) === "script") {
- tokenizer = script_data_escaped_state;
- }
- else {
- tokenizer = script_data_double_escaped_state;
- }
- textrun.push(c);
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- tempbuf.push(c + 0x0020);
- textrun.push(c);
- break;
- case 0x0061: // [a-z]
- case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
- case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
- case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
- case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
- case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
- tempbuf.push(c);
- textrun.push(c);
- break;
- default:
- reconsume(c, script_data_double_escaped_state);
- break;
- }
- }
-
- function before_attribute_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- // For SOLIDUS, GREATER-THAN SIGN, and EOF, spec says "reconsume in
- // the after attribute name state", but in our implementation that
- // state always has an active attribute in attrnamebuf. Just clone
- // the rules here, without the addAttribute business.
- case 0x002F: // SOLIDUS
- tokenizer = self_closing_start_tag_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitTag();
- break;
- case -1: // EOF
- emitEOF();
- break;
- case 0x003D: // EQUALS SIGN
- beginAttrName();
- attrnamebuf += String.fromCharCode(c);
- tokenizer = attribute_name_state;
- break;
- default:
- if (handleSimpleAttribute()) break;
- beginAttrName();
- reconsume(c, attribute_name_state);
- break;
- }
- }
-
- // beginAttrName() must have been called before this point
- // There is an active attribute in attrnamebuf (but not attrvaluebuf)
- function attribute_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- case 0x002F: // SOLIDUS
- case 0x003E: // GREATER-THAN SIGN
- case -1: // EOF
- reconsume(c, after_attribute_name_state);
- break;
- case 0x003D: // EQUALS SIGN
- tokenizer = before_attribute_value_state;
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- attrnamebuf += String.fromCharCode(c + 0x0020);
- break;
- case 0x0000: // NULL
- attrnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case 0x0022: // QUOTATION MARK
- case 0x0027: // APOSTROPHE
- case 0x003C: // LESS-THAN SIGN
- /* falls through */
- default:
- attrnamebuf += getMatchingChars(ATTRNAME);
- break;
- }
- }
-
- // There is an active attribute in attrnamebuf, but not yet in attrvaluebuf.
- function after_attribute_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- case 0x002F: // SOLIDUS
- // Keep in sync with before_attribute_name_state.
- addAttribute(attrnamebuf);
- tokenizer = self_closing_start_tag_state;
- break;
- case 0x003D: // EQUALS SIGN
- tokenizer = before_attribute_value_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- // Keep in sync with before_attribute_name_state.
- tokenizer = data_state;
- addAttribute(attrnamebuf);
- emitTag();
- break;
- case -1: // EOF
- // Keep in sync with before_attribute_name_state.
- addAttribute(attrnamebuf);
- emitEOF();
- break;
- default:
- addAttribute(attrnamebuf);
- beginAttrName();
- reconsume(c, attribute_name_state);
- break;
- }
- }
-
- function before_attribute_value_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- case 0x0022: // QUOTATION MARK
- beginAttrValue();
- tokenizer = attribute_value_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginAttrValue();
- tokenizer = attribute_value_single_quoted_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- /* falls through */
- default:
- beginAttrValue();
- reconsume(c, attribute_value_unquoted_state);
- break;
- }
- }
-
- function attribute_value_double_quoted_state(c) {
- switch(c) {
- case 0x0022: // QUOTATION MARK
- addAttribute(attrnamebuf, attrvaluebuf);
- tokenizer = after_attribute_value_quoted_state;
- break;
- case 0x0026: // AMPERSAND
- return_state = attribute_value_double_quoted_state;
- tokenizer = character_reference_state;
- break;
- case 0x0000: // NULL
- attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- emitEOF();
- break;
- case 0x000A: // LF
- // this could be a converted \r, so don't use getMatchingChars
- attrvaluebuf += String.fromCharCode(c);
- break;
- default:
- attrvaluebuf += getMatchingChars(DBLQUOTEATTRVAL);
- break;
- }
- }
-
- function attribute_value_single_quoted_state(c) {
- switch(c) {
- case 0x0027: // APOSTROPHE
- addAttribute(attrnamebuf, attrvaluebuf);
- tokenizer = after_attribute_value_quoted_state;
- break;
- case 0x0026: // AMPERSAND
- return_state = attribute_value_single_quoted_state;
- tokenizer = character_reference_state;
- break;
- case 0x0000: // NULL
- attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- emitEOF();
- break;
- case 0x000A: // LF
- // this could be a converted \r, so don't use getMatchingChars
- attrvaluebuf += String.fromCharCode(c);
- break;
- default:
- attrvaluebuf += getMatchingChars(SINGLEQUOTEATTRVAL);
- break;
- }
- }
-
- function attribute_value_unquoted_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- addAttribute(attrnamebuf, attrvaluebuf);
- tokenizer = before_attribute_name_state;
- break;
- case 0x0026: // AMPERSAND
- return_state = attribute_value_unquoted_state;
- tokenizer = character_reference_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- addAttribute(attrnamebuf, attrvaluebuf);
- tokenizer = data_state;
- emitTag();
- break;
- case 0x0000: // NULL
- attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- nextchar--; // pushback
- tokenizer = data_state;
- break;
- case 0x0022: // QUOTATION MARK
- case 0x0027: // APOSTROPHE
- case 0x003C: // LESS-THAN SIGN
- case 0x003D: // EQUALS SIGN
- case 0x0060: // GRAVE ACCENT
- /* falls through */
- default:
- attrvaluebuf += getMatchingChars(UNQUOTEDATTRVAL);
- break;
- }
- }
-
- function after_attribute_value_quoted_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = before_attribute_name_state;
- break;
- case 0x002F: // SOLIDUS
- tokenizer = self_closing_start_tag_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitTag();
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- reconsume(c, before_attribute_name_state);
- break;
- }
- }
-
- function self_closing_start_tag_state(c) {
- switch(c) {
- case 0x003E: // GREATER-THAN SIGN
- // Set the <i>self-closing flag</i> of the current tag token.
- tokenizer = data_state;
- emitSelfClosingTag(true);
- break;
- case -1: // EOF
- emitEOF();
- break;
- default:
- reconsume(c, before_attribute_name_state);
- break;
- }
- }
-
- function bogus_comment_state(c, lookahead, eof) {
- var len = lookahead.length;
-
- if (eof) {
- nextchar += len-1; // don't consume the eof
- }
- else {
- nextchar += len;
- }
-
- var comment = lookahead.substring(0, len-1);
-
- comment = comment.replace(/\u0000/g,"\uFFFD");
- comment = comment.replace(/\u000D\u000A/g,"\u000A");
- comment = comment.replace(/\u000D/g,"\u000A");
-
- insertToken(COMMENT, comment);
- tokenizer = data_state;
- }
- bogus_comment_state.lookahead = ">";
-
- function markup_declaration_open_state(c, lookahead, eof) {
- if (lookahead[0] === "-" && lookahead[1] === "-") {
- nextchar += 2;
- beginComment();
- tokenizer = comment_start_state;
- return;
- }
-
- if (lookahead.toUpperCase() === "DOCTYPE") {
- nextchar += 7;
- tokenizer = doctype_state;
- }
- else if (lookahead === "[CDATA[" && cdataAllowed()) {
- nextchar += 7;
- tokenizer = cdata_section_state;
- }
- else {
- tokenizer = bogus_comment_state;
- }
- }
- markup_declaration_open_state.lookahead = 7;
-
- function comment_start_state(c) {
- beginComment();
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_start_dash_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- insertToken(COMMENT, buf2str(commentbuf));
- break; /* see comment in comment end state */
- default:
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_start_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_end_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- insertToken(COMMENT, buf2str(commentbuf));
- break;
- case -1: // EOF
- insertToken(COMMENT, buf2str(commentbuf));
- emitEOF();
- break; /* see comment in comment end state */
- default:
- commentbuf.push(0x002D /* HYPHEN-MINUS */);
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_state(c) {
- switch(c) {
- case 0x003C: // LESS-THAN SIGN
- commentbuf.push(c);
- tokenizer = comment_less_than_sign_state;
- break;
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_end_dash_state;
- break;
- case 0x0000: // NULL
- commentbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- insertToken(COMMENT, buf2str(commentbuf));
- emitEOF();
- break; /* see comment in comment end state */
- default:
- commentbuf.push(c);
- break;
- }
- }
-
- function comment_less_than_sign_state(c) {
- switch(c) {
- case 0x0021: // EXCLAMATION MARK
- commentbuf.push(c);
- tokenizer = comment_less_than_sign_bang_state;
- break;
- case 0x003C: // LESS-THAN SIGN
- commentbuf.push(c);
- break;
- default:
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_less_than_sign_bang_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_less_than_sign_bang_dash_state;
- break;
- default:
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_less_than_sign_bang_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_less_than_sign_bang_dash_dash_state;
- break;
- default:
- reconsume(c, comment_end_dash_state);
- break;
- }
- }
-
- function comment_less_than_sign_bang_dash_dash_state(c) {
- switch(c) {
- case 0x003E: // GREATER-THAN SIGN
- case -1: // EOF
- reconsume(c, comment_end_state);
- break;
- default:
- // parse error
- reconsume(c, comment_end_state);
- break;
- }
- }
-
- function comment_end_dash_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- tokenizer = comment_end_state;
- break;
- case -1: // EOF
- insertToken(COMMENT, buf2str(commentbuf));
- emitEOF();
- break; /* see comment in comment end state */
- default:
- commentbuf.push(0x002D /* HYPHEN-MINUS */);
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_end_state(c) {
- switch(c) {
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- insertToken(COMMENT, buf2str(commentbuf));
- break;
- case 0x0021: // EXCLAMATION MARK
- tokenizer = comment_end_bang_state;
- break;
- case 0x002D: // HYPHEN-MINUS
- commentbuf.push(0x002D);
- break;
- case -1: // EOF
- insertToken(COMMENT, buf2str(commentbuf));
- emitEOF();
- break; /* For security reasons: otherwise, hostile user could put a script in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't read, and then the commented script tag would be treated as live code */
- default:
- commentbuf.push(0x002D);
- commentbuf.push(0x002D);
- reconsume(c, comment_state);
- break;
- }
- }
-
- function comment_end_bang_state(c) {
- switch(c) {
- case 0x002D: // HYPHEN-MINUS
- commentbuf.push(0x002D);
- commentbuf.push(0x002D);
- commentbuf.push(0x0021);
- tokenizer = comment_end_dash_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- insertToken(COMMENT, buf2str(commentbuf));
- break;
- case -1: // EOF
- insertToken(COMMENT, buf2str(commentbuf));
- emitEOF();
- break; /* see comment in comment end state */
- default:
- commentbuf.push(0x002D);
- commentbuf.push(0x002D);
- commentbuf.push(0x0021);
- reconsume(c, comment_state);
- break;
- }
- }
-
- function doctype_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = before_doctype_name_state;
- break;
- case -1: // EOF
- beginDoctype();
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- reconsume(c, before_doctype_name_state);
- break;
- }
- }
-
- function before_doctype_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- beginDoctype();
- doctypenamebuf.push(c + 0x0020);
- tokenizer = doctype_name_state;
- break;
- case 0x0000: // NULL
- beginDoctype();
- doctypenamebuf.push(0xFFFD);
- tokenizer = doctype_name_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- beginDoctype();
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- beginDoctype();
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- beginDoctype();
- doctypenamebuf.push(c);
- tokenizer = doctype_name_state;
- break;
- }
- }
-
- function doctype_name_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = after_doctype_name_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitDoctype();
- break;
- case 0x0041: // [A-Z]
- case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
- case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
- case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
- case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
- case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
- doctypenamebuf.push(c + 0x0020);
- break;
- case 0x0000: // NULL
- doctypenamebuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- doctypenamebuf.push(c);
- break;
- }
- }
-
- function after_doctype_name_state(c, lookahead, eof) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- nextchar += 1;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- nextchar += 1;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- lookahead = lookahead.toUpperCase();
- if (lookahead === "PUBLIC") {
- nextchar += 6;
- tokenizer = after_doctype_public_keyword_state;
- }
- else if (lookahead === "SYSTEM") {
- nextchar += 6;
- tokenizer = after_doctype_system_keyword_state;
- }
- else {
- forcequirks();
- tokenizer = bogus_doctype_state;
- }
- break;
- }
- }
- after_doctype_name_state.lookahead = 6;
-
- function after_doctype_public_keyword_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = before_doctype_public_identifier_state;
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypePublicId();
- tokenizer = doctype_public_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypePublicId();
- tokenizer = doctype_public_identifier_single_quoted_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function before_doctype_public_identifier_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypePublicId();
- tokenizer = doctype_public_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypePublicId();
- tokenizer = doctype_public_identifier_single_quoted_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function doctype_public_identifier_double_quoted_state(c) {
- switch(c) {
- case 0x0022: // QUOTATION MARK
- tokenizer = after_doctype_public_identifier_state;
- break;
- case 0x0000: // NULL
- doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- doctypepublicbuf.push(c);
- break;
- }
- }
-
- function doctype_public_identifier_single_quoted_state(c) {
- switch(c) {
- case 0x0027: // APOSTROPHE
- tokenizer = after_doctype_public_identifier_state;
- break;
- case 0x0000: // NULL
- doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- doctypepublicbuf.push(c);
- break;
- }
- }
-
- function after_doctype_public_identifier_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = between_doctype_public_and_system_identifiers_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitDoctype();
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_single_quoted_state;
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function between_doctype_public_and_system_identifiers_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE Ignore the character.
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitDoctype();
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_single_quoted_state;
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function after_doctype_system_keyword_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- tokenizer = before_doctype_system_identifier_state;
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_single_quoted_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function before_doctype_system_identifier_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE Ignore the character.
- break;
- case 0x0022: // QUOTATION MARK
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_double_quoted_state;
- break;
- case 0x0027: // APOSTROPHE
- beginDoctypeSystemId();
- tokenizer = doctype_system_identifier_single_quoted_state;
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- forcequirks();
- tokenizer = bogus_doctype_state;
- break;
- }
- }
-
- function doctype_system_identifier_double_quoted_state(c) {
- switch(c) {
- case 0x0022: // QUOTATION MARK
- tokenizer = after_doctype_system_identifier_state;
- break;
- case 0x0000: // NULL
- doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- doctypesystembuf.push(c);
- break;
- }
- }
-
- function doctype_system_identifier_single_quoted_state(c) {
- switch(c) {
- case 0x0027: // APOSTROPHE
- tokenizer = after_doctype_system_identifier_state;
- break;
- case 0x0000: // NULL
- doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
- break;
- case 0x003E: // GREATER-THAN SIGN
- forcequirks();
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- doctypesystembuf.push(c);
- break;
- }
- }
-
- function after_doctype_system_identifier_state(c) {
- switch(c) {
- case 0x0009: // CHARACTER TABULATION (tab)
- case 0x000A: // LINE FEED (LF)
- case 0x000C: // FORM FEED (FF)
- case 0x0020: // SPACE
- /* Ignore the character. */
- break;
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- forcequirks();
- emitDoctype();
- emitEOF();
- break;
- default:
- tokenizer = bogus_doctype_state;
- /* This does *not* set the DOCTYPE token's force-quirks flag. */
- break;
- }
- }
-
- function bogus_doctype_state(c) {
- switch(c) {
- case 0x003E: // GREATER-THAN SIGN
- tokenizer = data_state;
- emitDoctype();
- break;
- case -1: // EOF
- emitDoctype();
- emitEOF();
- break;
- default:
- /* Ignore the character. */
- break;
- }
- }
-
- function cdata_section_state(c) {
- switch(c) {
- case 0x005D: // RIGHT SQUARE BRACKET
- tokenizer = cdata_section_bracket_state;
- break;
- case -1: // EOF
- emitEOF();
- break;
- case 0x0000: // NULL
- textIncludesNUL = true;
- /* fall through */
- default:
- // Instead of just pushing a single character and then
- // coming back to the very same place, lookahead and
- // emit everything we can at once.
- /*jshint -W030 */
- emitCharsWhile(CDATATEXT) || textrun.push(c);
- break;
- }
- }
-
- function cdata_section_bracket_state(c) {
- switch(c) {
- case 0x005D: // RIGHT SQUARE BRACKET
- tokenizer = cdata_section_end_state;
- break;
- default:
- textrun.push(0x005D);
- reconsume(c, cdata_section_state);
- break;
- }
- }
-
- function cdata_section_end_state(c) {
- switch(c) {
- case 0x005D: // RIGHT SQUARE BRACKET
- textrun.push(0x005D);
- break;
- case 0x003E: // GREATER-THAN SIGN
- flushText();
- tokenizer = data_state;
- break;
- default:
- textrun.push(0x005D);
- textrun.push(0x005D);
- reconsume(c, cdata_section_state);
- break;
- }
- }
-
- function character_reference_state(c) {
- beginTempBuf();
- tempbuf.push(0x0026);
- switch(c) {
- case 0x0009: // TAB
- case 0x000A: // LINE FEED
- case 0x000C: // FORM FEED
- case 0x0020: // SPACE
- case 0x003C: // LESS-THAN SIGN
- case 0x0026: // AMPERSAND
- case -1: // EOF
- reconsume(c, character_reference_end_state);
- break;
- case 0x0023: // NUMBER SIGN
- tempbuf.push(c);
- tokenizer = numeric_character_reference_state;
- break;
- default:
- reconsume(c, named_character_reference_state);
- break;
- }
- }
-
- function named_character_reference_state(c) {
- NAMEDCHARREF.lastIndex = nextchar; // w/ lookahead no char has been consumed
- var matched = NAMEDCHARREF.exec(chars);
- if (!matched) throw new Error("should never happen");
- var name = matched[1];
- if (!name) {
- // If no match can be made, switch to the character reference end state
- tokenizer = character_reference_end_state;
- return;
- }
-
- // Consume the matched characters and append them to temporary buffer
- nextchar += name.length;
- pushAll(tempbuf, str2buf(name));
-
- switch(return_state) {
- case attribute_value_double_quoted_state:
- case attribute_value_single_quoted_state:
- case attribute_value_unquoted_state:
- // If the character reference was consumed as part of an attribute...
- if (name[name.length-1] !== ';') { // ...and the last char is not ;
- if (/[=A-Za-z0-9]/.test(chars[nextchar])) {
- tokenizer = character_reference_end_state;
- return;
- }
- }
- break;
- default:
- break;
- }
-
- beginTempBuf();
- var rv = namedCharRefs[name];
- if (typeof rv === 'number') {
- tempbuf.push(rv);
- } else {
- pushAll(tempbuf, rv);
- }
- tokenizer = character_reference_end_state;
- }
- // We might need to pause tokenization until we have enough characters
- // in the buffer for longest possible character reference.
- named_character_reference_state.lookahead = -NAMEDCHARREF_MAXLEN;
-
- function numeric_character_reference_state(c) {
- character_reference_code = 0;
- switch(c) {
- case 0x0078: // x
- case 0x0058: // X
- tempbuf.push(c);
- tokenizer = hexadecimal_character_reference_start_state;
- break;
- default:
- reconsume(c, decimal_character_reference_start_state);
- break;
- }
- }
-
- function hexadecimal_character_reference_start_state(c) {
- switch(c) {
- case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
- case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
- case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
- case 0x0046: // [A-F]
- case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
- case 0x0066: // [a-f]
- reconsume(c, hexadecimal_character_reference_state);
- break;
- default:
- reconsume(c, character_reference_end_state);
- break;
- }
- }
-
- function decimal_character_reference_start_state(c) {
- switch(c) {
- case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
- case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
- reconsume(c, decimal_character_reference_state);
- break;
- default:
- reconsume(c, character_reference_end_state);
- break;
- }
- }
-
- function hexadecimal_character_reference_state(c) {
- switch(c) {
- case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
- case 0x0046: // [A-F]
- character_reference_code *= 16;
- character_reference_code += (c - 0x0037);
- break;
- case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
- case 0x0066: // [a-f]
- character_reference_code *= 16;
- character_reference_code += (c - 0x0057);
- break;
- case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
- case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
- character_reference_code *= 16;
- character_reference_code += (c - 0x0030);
- break;
- case 0x003B: // SEMICOLON
- tokenizer = numeric_character_reference_end_state;
- break;
- default:
- reconsume(c, numeric_character_reference_end_state);
- break;
- }
- }
-
- function decimal_character_reference_state(c) {
- switch(c) {
- case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
- case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
- character_reference_code *= 10;
- character_reference_code += (c - 0x0030);
- break;
- case 0x003B: // SEMICOLON
- tokenizer = numeric_character_reference_end_state;
- break;
- default:
- reconsume(c, numeric_character_reference_end_state);
- break;
- }
- }
-
- function numeric_character_reference_end_state(c) {
- if (character_reference_code in numericCharRefReplacements) {
- character_reference_code = numericCharRefReplacements[character_reference_code];
- } else if (character_reference_code > 0x10FFFF || (character_reference_code >= 0xD800 && character_reference_code < 0xE000)) {
- character_reference_code = 0xFFFD;
- }
-
- beginTempBuf();
- if (character_reference_code <= 0xFFFF) {
- tempbuf.push(character_reference_code);
- } else {
- character_reference_code = character_reference_code - 0x10000;
- /* jshint bitwise: false */
- tempbuf.push(0xD800 + (character_reference_code >> 10));
- tempbuf.push(0xDC00 + (character_reference_code & 0x03FF));
- }
- reconsume(c, character_reference_end_state);
- }
-
- function character_reference_end_state(c) {
- switch(return_state) {
- case attribute_value_double_quoted_state:
- case attribute_value_single_quoted_state:
- case attribute_value_unquoted_state:
- // append each character to the current attribute's value
- attrvaluebuf += buf2str(tempbuf);
- break;
- default:
- pushAll(textrun, tempbuf);
- break;
- }
- reconsume(c, return_state);
- }
-
- /***
- * The tree builder insertion modes
- */
-
- // 11.2.5.4.1 The "initial" insertion mode
- function initial_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- value = value.replace(LEADINGWS, ""); // Ignore spaces
- if (value.length === 0) return; // Are we done?
- break; // Handle anything non-space text below
- case 4: // COMMENT
- doc._appendChild(doc.createComment(value));
- return;
- case 5: // DOCTYPE
- var name = value;
- var publicid = arg3;
- var systemid = arg4;
- // Use the constructor directly instead of
- // implementation.createDocumentType because the create
- // function throws errors on invalid characters, and
- // we don't want the parser to throw them.
- doc.appendChild(new DocumentType(doc, name, publicid, systemid));
-
- // Note that there is no public API for setting quirks mode We can
- // do this here because we have access to implementation details
- if (force_quirks ||
- name.toLowerCase() !== "html" ||
- quirkyPublicIds.test(publicid) ||
- (systemid && systemid.toLowerCase() === quirkySystemId) ||
- (systemid === undefined &&
- conditionallyQuirkyPublicIds.test(publicid)))
- doc._quirks = true;
- else if (limitedQuirkyPublicIds.test(publicid) ||
- (systemid !== undefined &&
- conditionallyQuirkyPublicIds.test(publicid)))
- doc._limitedQuirks = true;
- parser = before_html_mode;
- return;
- }
-
- // tags or non-whitespace text
- doc._quirks = true;
- parser = before_html_mode;
- parser(t,value,arg3,arg4);
- }
-
- // 11.2.5.4.2 The "before html" insertion mode
- function before_html_mode(t,value,arg3,arg4) {
- var elt;
- switch(t) {
- case 1: // TEXT
- value = value.replace(LEADINGWS, ""); // Ignore spaces
- if (value.length === 0) return; // Are we done?
- break; // Handle anything non-space text below
- case 5: // DOCTYPE
- /* ignore the token */
- return;
- case 4: // COMMENT
- doc._appendChild(doc.createComment(value));
- return;
- case 2: // TAG
- if (value === "html") {
- elt = createHTMLElt(doc, value, arg3);
- stack.push(elt);
- doc.appendChild(elt);
- // XXX: handle application cache here
- parser = before_head_mode;
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "html":
- case "head":
- case "body":
- case "br":
- break; // fall through on these
- default:
- return; // ignore most end tags
- }
- }
-
- // Anything that didn't get handled above is handled like this:
- elt = createHTMLElt(doc, "html", null);
- stack.push(elt);
- doc.appendChild(elt);
- // XXX: handle application cache here
- parser = before_head_mode;
- parser(t,value,arg3,arg4);
- }
-
- // 11.2.5.4.3 The "before head" insertion mode
- function before_head_mode(t,value,arg3,arg4) {
- switch(t) {
- case 1: // TEXT
- value = value.replace(LEADINGWS, ""); // Ignore spaces
- if (value.length === 0) return; // Are we done?
- break; // Handle anything non-space text below
- case 5: // DOCTYPE
- /* ignore the token */
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t,value,arg3,arg4);
- return;
- case "head":
- var elt = insertHTMLElement(value, arg3);
- head_element_pointer = elt;
- parser = in_head_mode;
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "html":
- case "head":
- case "body":
- case "br":
- break;
- default:
- return; // ignore most end tags
- }
- }
-
- // If not handled explicitly above
- before_head_mode(TAG, "head", null); // create a head tag
- parser(t, value, arg3, arg4); // then try again with this token
- }
-
- function in_head_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- var ws = value.match(LEADINGWS);
- if (ws) {
- insertText(ws[0]);
- value = value.substring(ws[0].length);
- }
- if (value.length === 0) return;
- break; // Handle non-whitespace below
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "meta":
- // XXX:
- // May need to change the encoding based on this tag
- /* falls through */
- case "base":
- case "basefont":
- case "bgsound":
- case "link":
- insertHTMLElement(value, arg3);
- stack.pop();
- return;
- case "title":
- parseRCDATA(value, arg3);
- return;
- case "noscript":
- if (!scripting_enabled) {
- insertHTMLElement(value, arg3);
- parser = in_head_noscript_mode;
- return;
- }
- // Otherwise, if scripting is enabled...
- /* falls through */
- case "noframes":
- case "style":
- parseRawText(value,arg3);
- return;
- case "script":
- insertElement(function(doc) {
- var elt = createHTMLElt(doc, value, arg3);
- elt._parser_inserted = true;
- elt._force_async = false;
- if (fragment) elt._already_started = true;
- flushText();
- return elt;
- });
- tokenizer = script_data_state;
- originalInsertionMode = parser;
- parser = text_mode;
- return;
- case "template":
- insertHTMLElement(value, arg3);
- afe.insertMarker();
- frameset_ok = false;
- parser = in_template_mode;
- templateInsertionModes.push(parser);
- return;
- case "head":
- return; // ignore it
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "head":
- stack.pop();
- parser = after_head_mode;
- return;
- case "body":
- case "html":
- case "br":
- break; // handle these at the bottom of the function
- case "template":
- if (!stack.contains("template")) {
- return;
- }
- stack.generateImpliedEndTags(null, "thorough");
- stack.popTag("template");
- afe.clearToMarker();
- templateInsertionModes.pop();
- resetInsertionMode();
- return;
- default:
- // ignore any other end tag
- return;
- }
- break;
- }
-
- // If not handled above
- in_head_mode(ENDTAG, "head", null); // synthetic </head>
- parser(t, value, arg3, arg4); // Then redo this one
- }
-
- // 13.2.5.4.5 The "in head noscript" insertion mode
- function in_head_noscript_mode(t, value, arg3, arg4) {
- switch(t) {
- case 5: // DOCTYPE
- return;
- case 4: // COMMENT
- in_head_mode(t, value);
- return;
- case 1: // TEXT
- var ws = value.match(LEADINGWS);
- if (ws) {
- in_head_mode(t, ws[0]);
- value = value.substring(ws[0].length);
- }
- if (value.length === 0) return; // no more text
- break; // Handle non-whitespace below
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "basefont":
- case "bgsound":
- case "link":
- case "meta":
- case "noframes":
- case "style":
- in_head_mode(t, value, arg3);
- return;
- case "head":
- case "noscript":
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "noscript":
- stack.pop();
- parser = in_head_mode;
- return;
- case "br":
- break; // goes to the outer default
- default:
- return; // ignore other end tags
- }
- break;
- }
-
- // If not handled above
- in_head_noscript_mode(ENDTAG, "noscript", null);
- parser(t, value, arg3, arg4);
- }
-
- function after_head_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- var ws = value.match(LEADINGWS);
- if (ws) {
- insertText(ws[0]);
- value = value.substring(ws[0].length);
- }
- if (value.length === 0) return;
- break; // Handle non-whitespace below
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "body":
- insertHTMLElement(value, arg3);
- frameset_ok = false;
- parser = in_body_mode;
- return;
- case "frameset":
- insertHTMLElement(value, arg3);
- parser = in_frameset_mode;
- return;
- case "base":
- case "basefont":
- case "bgsound":
- case "link":
- case "meta":
- case "noframes":
- case "script":
- case "style":
- case "template":
- case "title":
- stack.push(head_element_pointer);
- in_head_mode(TAG, value, arg3);
- stack.removeElement(head_element_pointer);
- return;
- case "head":
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "template":
- return in_head_mode(t, value, arg3, arg4);
- case "body":
- case "html":
- case "br":
- break;
- default:
- return; // ignore any other end tag
- }
- break;
- }
-
- after_head_mode(TAG, "body", null);
- frameset_ok = true;
- parser(t, value, arg3, arg4);
- }
-
- // 13.2.5.4.7 The "in body" insertion mode
- function in_body_mode(t,value,arg3,arg4) {
- var body, i, node, elt;
- switch(t) {
- case 1: // TEXT
- if (textIncludesNUL) {
- value = value.replace(NULCHARS, "");
- if (value.length === 0) return;
- }
- // If any non-space characters
- if (frameset_ok && NONWS.test(value))
- frameset_ok = false;
- afereconstruct();
- insertText(value);
- return;
- case 5: // DOCTYPE
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case -1: // EOF
- if (templateInsertionModes.length) {
- return in_template_mode(t);
- }
- stopParsing();
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- if (stack.contains("template")) {
- return;
- }
- transferAttributes(arg3, stack.elements[0]);
- return;
- case "base":
- case "basefont":
- case "bgsound":
- case "link":
- case "meta":
- case "noframes":
- case "script":
- case "style":
- case "template":
- case "title":
- in_head_mode(TAG, value, arg3);
- return;
- case "body":
- body = stack.elements[1];
- if (!body || !(body instanceof impl.HTMLBodyElement) ||
- stack.contains("template"))
- return;
- frameset_ok = false;
- transferAttributes(arg3, body);
- return;
- case "frameset":
- if (!frameset_ok) return;
- body = stack.elements[1];
- if (!body || !(body instanceof impl.HTMLBodyElement))
- return;
- if (body.parentNode) body.parentNode.removeChild(body);
- while(!(stack.top instanceof impl.HTMLHtmlElement))
- stack.pop();
- insertHTMLElement(value, arg3);
- parser = in_frameset_mode;
- return;
-
- case "address":
- case "article":
- case "aside":
- case "blockquote":
- case "center":
- case "details":
- case "dialog":
- case "dir":
- case "div":
- case "dl":
- case "fieldset":
- case "figcaption":
- case "figure":
- case "footer":
- case "header":
- case "hgroup":
- case "main":
- case "nav":
- case "ol":
- case "p":
- case "section":
- case "summary":
- case "ul":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- insertHTMLElement(value, arg3);
- return;
-
- case "menu":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- if (isA(stack.top, 'menuitem')) {
- stack.pop();
- }
- insertHTMLElement(value, arg3);
- return;
-
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- if (stack.top instanceof impl.HTMLHeadingElement)
- stack.pop();
- insertHTMLElement(value, arg3);
- return;
-
- case "pre":
- case "listing":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- insertHTMLElement(value, arg3);
- ignore_linefeed = true;
- frameset_ok = false;
- return;
-
- case "form":
- if (form_element_pointer && !stack.contains("template")) return;
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- elt = insertHTMLElement(value, arg3);
- if (!stack.contains("template"))
- form_element_pointer = elt;
- return;
-
- case "li":
- frameset_ok = false;
- for(i = stack.elements.length-1; i >= 0; i--) {
- node = stack.elements[i];
- if (node instanceof impl.HTMLLIElement) {
- in_body_mode(ENDTAG, "li");
- break;
- }
- if (isA(node, specialSet) && !isA(node, addressdivpSet))
- break;
- }
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- insertHTMLElement(value, arg3);
- return;
-
- case "dd":
- case "dt":
- frameset_ok = false;
- for(i = stack.elements.length-1; i >= 0; i--) {
- node = stack.elements[i];
- if (isA(node, dddtSet)) {
- in_body_mode(ENDTAG, node.localName);
- break;
- }
- if (isA(node, specialSet) && !isA(node, addressdivpSet))
- break;
- }
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- insertHTMLElement(value, arg3);
- return;
-
- case "plaintext":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- insertHTMLElement(value, arg3);
- tokenizer = plaintext_state;
- return;
-
- case "button":
- if (stack.inScope("button")) {
- in_body_mode(ENDTAG, "button");
- parser(t, value, arg3, arg4);
- }
- else {
- afereconstruct();
- insertHTMLElement(value, arg3);
- frameset_ok = false;
- }
- return;
-
- case "a":
- var activeElement = afe.findElementByTag("a");
- if (activeElement) {
- in_body_mode(ENDTAG, value);
- afe.remove(activeElement);
- stack.removeElement(activeElement);
- }
- /* falls through */
- case "b":
- case "big":
- case "code":
- case "em":
- case "font":
- case "i":
- case "s":
- case "small":
- case "strike":
- case "strong":
- case "tt":
- case "u":
- afereconstruct();
- afe.push(insertHTMLElement(value,arg3), arg3);
- return;
-
- case "nobr":
- afereconstruct();
-
- if (stack.inScope(value)) {
- in_body_mode(ENDTAG, value);
- afereconstruct();
- }
- afe.push(insertHTMLElement(value,arg3), arg3);
- return;
-
- case "applet":
- case "marquee":
- case "object":
- afereconstruct();
- insertHTMLElement(value,arg3);
- afe.insertMarker();
- frameset_ok = false;
- return;
-
- case "table":
- if (!doc._quirks && stack.inButtonScope("p")) {
- in_body_mode(ENDTAG, "p");
- }
- insertHTMLElement(value,arg3);
- frameset_ok = false;
- parser = in_table_mode;
- return;
-
- case "area":
- case "br":
- case "embed":
- case "img":
- case "keygen":
- case "wbr":
- afereconstruct();
- insertHTMLElement(value,arg3);
- stack.pop();
- frameset_ok = false;
- return;
-
- case "input":
- afereconstruct();
- elt = insertHTMLElement(value,arg3);
- stack.pop();
- var type = elt.getAttribute("type");
- if (!type || type.toLowerCase() !== "hidden")
- frameset_ok = false;
- return;
-
- case "param":
- case "source":
- case "track":
- insertHTMLElement(value,arg3);
- stack.pop();
- return;
-
- case "hr":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- if (isA(stack.top, 'menuitem')) {
- stack.pop();
- }
- insertHTMLElement(value,arg3);
- stack.pop();
- frameset_ok = false;
- return;
-
- case "image":
- in_body_mode(TAG, "img", arg3, arg4);
- return;
-
- case "textarea":
- insertHTMLElement(value,arg3);
- ignore_linefeed = true;
- frameset_ok = false;
- tokenizer = rcdata_state;
- originalInsertionMode = parser;
- parser = text_mode;
- return;
-
- case "xmp":
- if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
- afereconstruct();
- frameset_ok = false;
- parseRawText(value, arg3);
- return;
-
- case "iframe":
- frameset_ok = false;
- parseRawText(value, arg3);
- return;
-
- case "noembed":
- parseRawText(value,arg3);
- return;
-
- case "noscript":
- if (scripting_enabled) {
- parseRawText(value,arg3);
- return;
- }
- break; // XXX Otherwise treat it as any other open tag?
-
- case "select":
- afereconstruct();
- insertHTMLElement(value,arg3);
- frameset_ok = false;
- if (parser === in_table_mode ||
- parser === in_caption_mode ||
- parser === in_table_body_mode ||
- parser === in_row_mode ||
- parser === in_cell_mode)
- parser = in_select_in_table_mode;
- else
- parser = in_select_mode;
- return;
-
- case "optgroup":
- case "option":
- if (stack.top instanceof impl.HTMLOptionElement) {
- in_body_mode(ENDTAG, "option");
- }
- afereconstruct();
- insertHTMLElement(value,arg3);
- return;
-
- case "menuitem":
- if (isA(stack.top, 'menuitem')) {
- stack.pop();
- }
- afereconstruct();
- insertHTMLElement(value, arg3);
- return;
-
- case "rb":
- case "rtc":
- if (stack.inScope("ruby")) {
- stack.generateImpliedEndTags();
- }
- insertHTMLElement(value,arg3);
- return;
-
- case "rp":
- case "rt":
- if (stack.inScope("ruby")) {
- stack.generateImpliedEndTags("rtc");
- }
- insertHTMLElement(value,arg3);
- return;
-
- case "math":
- afereconstruct();
- adjustMathMLAttributes(arg3);
- adjustForeignAttributes(arg3);
- insertForeignElement(value, arg3, NAMESPACE.MATHML);
- if (arg4) // self-closing flag
- stack.pop();
- return;
-
- case "svg":
- afereconstruct();
- adjustSVGAttributes(arg3);
- adjustForeignAttributes(arg3);
- insertForeignElement(value, arg3, NAMESPACE.SVG);
- if (arg4) // self-closing flag
- stack.pop();
- return;
-
- case "caption":
- case "col":
- case "colgroup":
- case "frame":
- case "head":
- case "tbody":
- case "td":
- case "tfoot":
- case "th":
- case "thead":
- case "tr":
- // Ignore table tags if we're not in_table mode
- return;
- }
-
- // Handle any other start tag here
- // (and also noscript tags when scripting is disabled)
- afereconstruct();
- insertHTMLElement(value,arg3);
- return;
-
- case 3: // ENDTAG
- switch(value) {
- case "template":
- in_head_mode(ENDTAG, value, arg3);
- return;
- case "body":
- if (!stack.inScope("body")) return;
- parser = after_body_mode;
- return;
- case "html":
- if (!stack.inScope("body")) return;
- parser = after_body_mode;
- parser(t, value, arg3);
- return;
-
- case "address":
- case "article":
- case "aside":
- case "blockquote":
- case "button":
- case "center":
- case "details":
- case "dialog":
- case "dir":
- case "div":
- case "dl":
- case "fieldset":
- case "figcaption":
- case "figure":
- case "footer":
- case "header":
- case "hgroup":
- case "listing":
- case "main":
- case "menu":
- case "nav":
- case "ol":
- case "pre":
- case "section":
- case "summary":
- case "ul":
- // Ignore if there is not a matching open tag
- if (!stack.inScope(value)) return;
- stack.generateImpliedEndTags();
- stack.popTag(value);
- return;
-
- case "form":
- if (!stack.contains("template")) {
- var openform = form_element_pointer;
- form_element_pointer = null;
- if (!openform || !stack.elementInScope(openform)) return;
- stack.generateImpliedEndTags();
- stack.removeElement(openform);
- } else {
- if (!stack.inScope("form")) return;
- stack.generateImpliedEndTags();
- stack.popTag("form");
- }
- return;
-
- case "p":
- if (!stack.inButtonScope(value)) {
- in_body_mode(TAG, value, null);
- parser(t, value, arg3, arg4);
- }
- else {
- stack.generateImpliedEndTags(value);
- stack.popTag(value);
- }
- return;
-
- case "li":
- if (!stack.inListItemScope(value)) return;
- stack.generateImpliedEndTags(value);
- stack.popTag(value);
- return;
-
- case "dd":
- case "dt":
- if (!stack.inScope(value)) return;
- stack.generateImpliedEndTags(value);
- stack.popTag(value);
- return;
-
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- if (!stack.elementTypeInScope(impl.HTMLHeadingElement)) return;
- stack.generateImpliedEndTags();
- stack.popElementType(impl.HTMLHeadingElement);
- return;
-
- case "sarcasm":
- // Take a deep breath, and then:
- break;
-
- case "a":
- case "b":
- case "big":
- case "code":
- case "em":
- case "font":
- case "i":
- case "nobr":
- case "s":
- case "small":
- case "strike":
- case "strong":
- case "tt":
- case "u":
- var result = adoptionAgency(value);
- if (result) return; // If we did something we're done
- break; // Go to the "any other end tag" case
-
- case "applet":
- case "marquee":
- case "object":
- if (!stack.inScope(value)) return;
- stack.generateImpliedEndTags();
- stack.popTag(value);
- afe.clearToMarker();
- return;
-
- case "br":
- in_body_mode(TAG, value, null); // Turn </br> into <br>
- return;
- }
-
- // Any other end tag goes here
- for(i = stack.elements.length-1; i >= 0; i--) {
- node = stack.elements[i];
- if (isA(node, value)) {
- stack.generateImpliedEndTags(value);
- stack.popElement(node);
- break;
- }
- else if (isA(node, specialSet)) {
- return;
- }
- }
-
- return;
- }
- }
-
- function text_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- insertText(value);
- return;
- case -1: // EOF
- if (stack.top instanceof impl.HTMLScriptElement)
- stack.top._already_started = true;
- stack.pop();
- parser = originalInsertionMode;
- parser(t);
- return;
- case 3: // ENDTAG
- if (value === "script") {
- handleScriptEnd();
- }
- else {
- stack.pop();
- parser = originalInsertionMode;
- }
- return;
- default:
- // We should never get any other token types
- return;
- }
- }
-
- function in_table_mode(t, value, arg3, arg4) {
- function getTypeAttr(attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- if (attrs[i][0] === "type")
- return attrs[i][1].toLowerCase();
- }
- return null;
- }
-
- switch(t) {
- case 1: // TEXT
- // XXX the text_integration_mode stuff is
- // just a hack I made up
- if (text_integration_mode) {
- in_body_mode(t, value, arg3, arg4);
- return;
- }
- else if (isA(stack.top, tablesectionrowSet)) {
- pending_table_text = [];
- originalInsertionMode = parser;
- parser = in_table_text_mode;
- parser(t, value, arg3, arg4);
- return;
- }
- break;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case 2: // TAG
- switch(value) {
- case "caption":
- stack.clearToContext(tableContextSet);
- afe.insertMarker();
- insertHTMLElement(value,arg3);
- parser = in_caption_mode;
- return;
- case "colgroup":
- stack.clearToContext(tableContextSet);
- insertHTMLElement(value,arg3);
- parser = in_column_group_mode;
- return;
- case "col":
- in_table_mode(TAG, "colgroup", null);
- parser(t, value, arg3, arg4);
- return;
- case "tbody":
- case "tfoot":
- case "thead":
- stack.clearToContext(tableContextSet);
- insertHTMLElement(value,arg3);
- parser = in_table_body_mode;
- return;
- case "td":
- case "th":
- case "tr":
- in_table_mode(TAG, "tbody", null);
- parser(t, value, arg3, arg4);
- return;
-
- case "table":
- if (!stack.inTableScope(value)) {
- return; // Ignore the token
- }
- in_table_mode(ENDTAG, value);
- parser(t, value, arg3, arg4);
- return;
-
- case "style":
- case "script":
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
-
- case "input":
- var type = getTypeAttr(arg3);
- if (type !== "hidden") break; // to the anything else case
- insertHTMLElement(value,arg3);
- stack.pop();
- return;
-
- case "form":
- if (form_element_pointer || stack.contains("template")) return;
- form_element_pointer = insertHTMLElement(value, arg3);
- stack.popElement(form_element_pointer);
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "table":
- if (!stack.inTableScope(value)) return;
- stack.popTag(value);
- resetInsertionMode();
- return;
- case "body":
- case "caption":
- case "col":
- case "colgroup":
- case "html":
- case "tbody":
- case "td":
- case "tfoot":
- case "th":
- case "thead":
- case "tr":
- return;
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
-
- break;
- case -1: // EOF
- in_body_mode(t, value, arg3, arg4);
- return;
- }
-
- // This is the anything else case
- foster_parent_mode = true;
- in_body_mode(t, value, arg3, arg4);
- foster_parent_mode = false;
- }
-
- function in_table_text_mode(t, value, arg3, arg4) {
- if (t === TEXT) {
- if (textIncludesNUL) {
- value = value.replace(NULCHARS, "");
- if (value.length === 0) return;
- }
- pending_table_text.push(value);
- }
- else {
- var s = pending_table_text.join("");
- pending_table_text.length = 0;
- if (NONWS.test(s)) { // If any non-whitespace characters
- // This must be the same code as the "anything else"
- // case of the in_table mode above.
- foster_parent_mode = true;
- in_body_mode(TEXT, s);
- foster_parent_mode = false;
- }
- else {
- insertText(s);
- }
- parser = originalInsertionMode;
- parser(t, value, arg3, arg4);
- }
- }
-
-
- function in_caption_mode(t, value, arg3, arg4) {
- function end_caption() {
- if (!stack.inTableScope("caption")) return false;
- stack.generateImpliedEndTags();
- stack.popTag("caption");
- afe.clearToMarker();
- parser = in_table_mode;
- return true;
- }
-
- switch(t) {
- case 2: // TAG
- switch(value) {
- case "caption":
- case "col":
- case "colgroup":
- case "tbody":
- case "td":
- case "tfoot":
- case "th":
- case "thead":
- case "tr":
- if (end_caption()) parser(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "caption":
- end_caption();
- return;
- case "table":
- if (end_caption()) parser(t, value, arg3, arg4);
- return;
- case "body":
- case "col":
- case "colgroup":
- case "html":
- case "tbody":
- case "td":
- case "tfoot":
- case "th":
- case "thead":
- case "tr":
- return;
- }
- break;
- }
-
- // The Anything Else case
- in_body_mode(t, value, arg3, arg4);
- }
-
- function in_column_group_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- var ws = value.match(LEADINGWS);
- if (ws) {
- insertText(ws[0]);
- value = value.substring(ws[0].length);
- }
- if (value.length === 0) return;
- break; // Handle non-whitespace below
-
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "col":
- insertHTMLElement(value, arg3);
- stack.pop();
- return;
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "colgroup":
- if (!isA(stack.top, 'colgroup')) {
- return; // Ignore the token.
- }
- stack.pop();
- parser = in_table_mode;
- return;
- case "col":
- return;
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- case -1: // EOF
- in_body_mode(t, value, arg3, arg4);
- return;
- }
-
- // Anything else
- if (!isA(stack.top, 'colgroup')) {
- return; // Ignore the token.
- }
- in_column_group_mode(ENDTAG, "colgroup");
- parser(t, value, arg3, arg4);
- }
-
- function in_table_body_mode(t, value, arg3, arg4) {
- function endsect() {
- if (!stack.inTableScope("tbody") &&
- !stack.inTableScope("thead") &&
- !stack.inTableScope("tfoot"))
- return;
- stack.clearToContext(tableBodyContextSet);
- in_table_body_mode(ENDTAG, stack.top.localName, null);
- parser(t, value, arg3, arg4);
- }
-
- switch(t) {
- case 2: // TAG
- switch(value) {
- case "tr":
- stack.clearToContext(tableBodyContextSet);
- insertHTMLElement(value, arg3);
- parser = in_row_mode;
- return;
- case "th":
- case "td":
- in_table_body_mode(TAG, "tr", null);
- parser(t, value, arg3, arg4);
- return;
- case "caption":
- case "col":
- case "colgroup":
- case "tbody":
- case "tfoot":
- case "thead":
- endsect();
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "table":
- endsect();
- return;
- case "tbody":
- case "tfoot":
- case "thead":
- if (stack.inTableScope(value)) {
- stack.clearToContext(tableBodyContextSet);
- stack.pop();
- parser = in_table_mode;
- }
- return;
- case "body":
- case "caption":
- case "col":
- case "colgroup":
- case "html":
- case "td":
- case "th":
- case "tr":
- return;
- }
- break;
- }
-
- // Anything else:
- in_table_mode(t, value, arg3, arg4);
- }
-
- function in_row_mode(t, value, arg3, arg4) {
- function endrow() {
- if (!stack.inTableScope("tr")) return false;
- stack.clearToContext(tableRowContextSet);
- stack.pop();
- parser = in_table_body_mode;
- return true;
- }
-
- switch(t) {
- case 2: // TAG
- switch(value) {
- case "th":
- case "td":
- stack.clearToContext(tableRowContextSet);
- insertHTMLElement(value, arg3);
- parser = in_cell_mode;
- afe.insertMarker();
- return;
- case "caption":
- case "col":
- case "colgroup":
- case "tbody":
- case "tfoot":
- case "thead":
- case "tr":
- if (endrow()) parser(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "tr":
- endrow();
- return;
- case "table":
- if (endrow()) parser(t, value, arg3, arg4);
- return;
- case "tbody":
- case "tfoot":
- case "thead":
- if (stack.inTableScope(value)) {
- if (endrow()) parser(t, value, arg3, arg4);
- }
- return;
- case "body":
- case "caption":
- case "col":
- case "colgroup":
- case "html":
- case "td":
- case "th":
- return;
- }
- break;
- }
-
- // anything else
- in_table_mode(t, value, arg3, arg4);
- }
-
- function in_cell_mode(t, value, arg3, arg4) {
- switch(t) {
- case 2: // TAG
- switch(value) {
- case "caption":
- case "col":
- case "colgroup":
- case "tbody":
- case "td":
- case "tfoot":
- case "th":
- case "thead":
- case "tr":
- if (stack.inTableScope("td")) {
- in_cell_mode(ENDTAG, "td");
- parser(t, value, arg3, arg4);
- }
- else if (stack.inTableScope("th")) {
- in_cell_mode(ENDTAG, "th");
- parser(t, value, arg3, arg4);
- }
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "td":
- case "th":
- if (!stack.inTableScope(value)) return;
- stack.generateImpliedEndTags();
- stack.popTag(value);
- afe.clearToMarker();
- parser = in_row_mode;
- return;
-
- case "body":
- case "caption":
- case "col":
- case "colgroup":
- case "html":
- return;
-
- case "table":
- case "tbody":
- case "tfoot":
- case "thead":
- case "tr":
- if (!stack.inTableScope(value)) return;
- in_cell_mode(ENDTAG, stack.inTableScope("td") ? "td" : "th");
- parser(t, value, arg3, arg4);
- return;
- }
- break;
- }
-
- // anything else
- in_body_mode(t, value, arg3, arg4);
- }
-
- function in_select_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- if (textIncludesNUL) {
- value = value.replace(NULCHARS, "");
- if (value.length === 0) return;
- }
- insertText(value);
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case -1: // EOF
- in_body_mode(t, value, arg3, arg4);
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "option":
- if (stack.top instanceof impl.HTMLOptionElement)
- in_select_mode(ENDTAG, value);
- insertHTMLElement(value, arg3);
- return;
- case "optgroup":
- if (stack.top instanceof impl.HTMLOptionElement)
- in_select_mode(ENDTAG, "option");
- if (stack.top instanceof impl.HTMLOptGroupElement)
- in_select_mode(ENDTAG, value);
- insertHTMLElement(value, arg3);
- return;
- case "select":
- in_select_mode(ENDTAG, value); // treat it as a close tag
- return;
-
- case "input":
- case "keygen":
- case "textarea":
- if (!stack.inSelectScope("select")) return;
- in_select_mode(ENDTAG, "select");
- parser(t, value, arg3, arg4);
- return;
-
- case "script":
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- switch(value) {
- case "optgroup":
- if (stack.top instanceof impl.HTMLOptionElement &&
- stack.elements[stack.elements.length-2] instanceof
- impl.HTMLOptGroupElement) {
- in_select_mode(ENDTAG, "option");
- }
- if (stack.top instanceof impl.HTMLOptGroupElement)
- stack.pop();
-
- return;
-
- case "option":
- if (stack.top instanceof impl.HTMLOptionElement)
- stack.pop();
- return;
-
- case "select":
- if (!stack.inSelectScope(value)) return;
- stack.popTag(value);
- resetInsertionMode();
- return;
-
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
-
- break;
- }
-
- // anything else: just ignore the token
- }
-
- function in_select_in_table_mode(t, value, arg3, arg4) {
- switch(value) {
- case "caption":
- case "table":
- case "tbody":
- case "tfoot":
- case "thead":
- case "tr":
- case "td":
- case "th":
- switch(t) {
- case 2: // TAG
- in_select_in_table_mode(ENDTAG, "select");
- parser(t, value, arg3, arg4);
- return;
- case 3: // ENDTAG
- if (stack.inTableScope(value)) {
- in_select_in_table_mode(ENDTAG, "select");
- parser(t, value, arg3, arg4);
- }
- return;
- }
- }
-
- // anything else
- in_select_mode(t, value, arg3, arg4);
- }
-
- function in_template_mode(t, value, arg3, arg4) {
- function switchModeAndReprocess(mode) {
- parser = mode;
- templateInsertionModes[templateInsertionModes.length-1] = parser;
- parser(t, value, arg3, arg4);
- }
- switch(t) {
- case 1: // TEXT
- case 4: // COMMENT
- case 5: // DOCTYPE
- in_body_mode(t, value, arg3, arg4);
- return;
- case -1: // EOF
- if (!stack.contains("template")) {
- stopParsing();
- } else {
- stack.popTag("template");
- afe.clearToMarker();
- templateInsertionModes.pop();
- resetInsertionMode();
- parser(t, value, arg3, arg4);
- }
- return;
- case 2: // TAG
- switch(value) {
- case "base":
- case "basefont":
- case "bgsound":
- case "link":
- case "meta":
- case "noframes":
- case "script":
- case "style":
- case "template":
- case "title":
- in_head_mode(t, value, arg3, arg4);
- return;
- case "caption":
- case "colgroup":
- case "tbody":
- case "tfoot":
- case "thead":
- switchModeAndReprocess(in_table_mode);
- return;
- case "col":
- switchModeAndReprocess(in_column_group_mode);
- return;
- case "tr":
- switchModeAndReprocess(in_table_body_mode);
- return;
- case "td":
- case "th":
- switchModeAndReprocess(in_row_mode);
- return;
- }
- switchModeAndReprocess(in_body_mode);
- return;
- case 3: // ENDTAG
- switch(value) {
- case "template":
- in_head_mode(t, value, arg3, arg4);
- return;
- default:
- return;
- }
- }
- }
-
- function after_body_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- // If any non-space chars, handle below
- if (NONWS.test(value)) break;
- in_body_mode(t, value);
- return;
- case 4: // COMMENT
- // Append it to the <html> element
- stack.elements[0]._appendChild(doc.createComment(value));
- return;
- case 5: // DOCTYPE
- return;
- case -1: // EOF
- stopParsing();
- return;
- case 2: // TAG
- if (value === "html") {
- in_body_mode(t, value, arg3, arg4);
- return;
- }
- break; // for any other tags
- case 3: // ENDTAG
- if (value === "html") {
- if (fragment) return;
- parser = after_after_body_mode;
- return;
- }
- break; // for any other tags
- }
-
- // anything else
- parser = in_body_mode;
- parser(t, value, arg3, arg4);
- }
-
- function in_frameset_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- // Ignore any non-space characters
- value = value.replace(ALLNONWS, "");
- if (value.length > 0) insertText(value);
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case -1: // EOF
- stopParsing();
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "frameset":
- insertHTMLElement(value, arg3);
- return;
- case "frame":
- insertHTMLElement(value, arg3);
- stack.pop();
- return;
- case "noframes":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- if (value === "frameset") {
- if (fragment && stack.top instanceof impl.HTMLHtmlElement)
- return;
- stack.pop();
- if (!fragment &&
- !(stack.top instanceof impl.HTMLFrameSetElement))
- parser = after_frameset_mode;
- return;
- }
- break;
- }
-
- // ignore anything else
- }
-
- function after_frameset_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- // Ignore any non-space characters
- value = value.replace(ALLNONWS, "");
- if (value.length > 0) insertText(value);
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- return;
- case -1: // EOF
- stopParsing();
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "noframes":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- case 3: // ENDTAG
- if (value === "html") {
- parser = after_after_frameset_mode;
- return;
- }
- break;
- }
-
- // ignore anything else
- }
-
- function after_after_body_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- // If any non-space chars, handle below
- if (NONWS.test(value)) break;
- in_body_mode(t, value, arg3, arg4);
- return;
- case 4: // COMMENT
- doc._appendChild(doc.createComment(value));
- return;
- case 5: // DOCTYPE
- in_body_mode(t, value, arg3, arg4);
- return;
- case -1: // EOF
- stopParsing();
- return;
- case 2: // TAG
- if (value === "html") {
- in_body_mode(t, value, arg3, arg4);
- return;
- }
- break;
- }
-
- // anything else
- parser = in_body_mode;
- parser(t, value, arg3, arg4);
- }
-
- function after_after_frameset_mode(t, value, arg3, arg4) {
- switch(t) {
- case 1: // TEXT
- // Ignore any non-space characters
- value = value.replace(ALLNONWS, "");
- if (value.length > 0)
- in_body_mode(t, value, arg3, arg4);
- return;
- case 4: // COMMENT
- doc._appendChild(doc.createComment(value));
- return;
- case 5: // DOCTYPE
- in_body_mode(t, value, arg3, arg4);
- return;
- case -1: // EOF
- stopParsing();
- return;
- case 2: // TAG
- switch(value) {
- case "html":
- in_body_mode(t, value, arg3, arg4);
- return;
- case "noframes":
- in_head_mode(t, value, arg3, arg4);
- return;
- }
- break;
- }
-
- // ignore anything else
- }
-
-
- // 13.2.5.5 The rules for parsing tokens in foreign content
- //
- // This is like one of the insertion modes above, but is
- // invoked somewhat differently when the current token is not HTML.
- // See the insertToken() function.
- function insertForeignToken(t, value, arg3, arg4) {
- // A <font> tag is an HTML font tag if it has a color, font, or size
- // attribute. Otherwise we assume it is foreign content
- function isHTMLFont(attrs) {
- for(var i = 0, n = attrs.length; i < n; i++) {
- switch(attrs[i][0]) {
- case "color":
- case "face":
- case "size":
- return true;
- }
- }
- return false;
- }
-
- var current;
-
- switch(t) {
- case 1: // TEXT
- // If any non-space, non-nul characters
- if (frameset_ok && NONWSNONNUL.test(value))
- frameset_ok = false;
- if (textIncludesNUL) {
- value = value.replace(NULCHARS, "\uFFFD");
- }
- insertText(value);
- return;
- case 4: // COMMENT
- insertComment(value);
- return;
- case 5: // DOCTYPE
- // ignore it
- return;
- case 2: // TAG
- switch(value) {
- case "font":
- if (!isHTMLFont(arg3)) break;
- /* falls through */
- case "b":
- case "big":
- case "blockquote":
- case "body":
- case "br":
- case "center":
- case "code":
- case "dd":
- case "div":
- case "dl":
- case "dt":
- case "em":
- case "embed":
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- case "head":
- case "hr":
- case "i":
- case "img":
- case "li":
- case "listing":
- case "menu":
- case "meta":
- case "nobr":
- case "ol":
- case "p":
- case "pre":
- case "ruby":
- case "s":
- case "small":
- case "span":
- case "strong":
- case "strike":
- case "sub":
- case "sup":
- case "table":
- case "tt":
- case "u":
- case "ul":
- case "var":
- if (fragment) {
- break;
- }
- do {
- stack.pop();
- current = stack.top;
- } while(current.namespaceURI !== NAMESPACE.HTML &&
- !isMathmlTextIntegrationPoint(current) &&
- !isHTMLIntegrationPoint(current));
-
- insertToken(t, value, arg3, arg4); // reprocess
- return;
- }
-
- // Any other start tag case goes here
- current = (stack.elements.length===1 && fragment) ? fragmentContext :
- stack.top;
- if (current.namespaceURI === NAMESPACE.MATHML) {
- adjustMathMLAttributes(arg3);
- }
- else if (current.namespaceURI === NAMESPACE.SVG) {
- value = adjustSVGTagName(value);
- adjustSVGAttributes(arg3);
- }
- adjustForeignAttributes(arg3);
-
- insertForeignElement(value, arg3, current.namespaceURI);
- if (arg4) { // the self-closing flag
- if (value === 'script' && current.namespaceURI === NAMESPACE.SVG) {
- // XXX deal with SVG scripts here
- }
- stack.pop();
- }
- return;
-
- case 3: // ENDTAG
- current = stack.top;
- if (value === "script" &&
- current.namespaceURI === NAMESPACE.SVG &&
- current.localName === "script") {
-
- stack.pop();
-
- // XXX
- // Deal with SVG scripts here
- }
- else {
- // The any other end tag case
- var i = stack.elements.length-1;
- var node = stack.elements[i];
- for(;;) {
- if (node.localName.toLowerCase() === value) {
- stack.popElement(node);
- break;
- }
- node = stack.elements[--i];
- // If non-html, keep looping
- if (node.namespaceURI !== NAMESPACE.HTML)
- continue;
- // Otherwise process the end tag as html
- parser(t, value, arg3, arg4);
- break;
- }
- }
- return;
- }
- }
-
- /***
- * Finally, this is the end of the HTMLParser() factory function.
- * It returns the htmlparser object with the append() and end() methods.
- */
-
- // Sneak another method into the htmlparser object to allow us to run
- // tokenizer tests. This can be commented out in production code.
- // This is a hook for testing the tokenizer. It has to be here
- // because the tokenizer details are all hidden away within the closure.
- // It should return an array of tokens generated while parsing the
- // input string.
- htmlparser.testTokenizer = function(input, initialState, lastStartTag, charbychar) {
- var tokens = [];
-
- switch(initialState) {
- case "PCDATA state":
- tokenizer = data_state;
- break;
- case "RCDATA state":
- tokenizer = rcdata_state;
- break;
- case "RAWTEXT state":
- tokenizer = rawtext_state;
- break;
- case "PLAINTEXT state":
- tokenizer = plaintext_state;
- break;
- }
-
- if (lastStartTag) {
- lasttagname = lastStartTag;
- }
-
- insertToken = function(t, value, arg3, arg4) {
- flushText();
- switch(t) {
- case 1: // TEXT
- if (tokens.length > 0 &&
- tokens[tokens.length-1][0] === "Character") {
- tokens[tokens.length-1][1] += value;
- }
- else tokens.push(["Character", value]);
- break;
- case 4: // COMMENT
- tokens.push(["Comment", value]);
- break;
- case 5: // DOCTYPE
- tokens.push(["DOCTYPE", value,
- arg3 === undefined ? null : arg3,
- arg4 === undefined ? null : arg4,
- !force_quirks]);
- break;
- case 2: // TAG
- var attrs = Object.create(null);
- for(var i = 0; i < arg3.length; i++) {
- // XXX: does attribute order matter?
- var a = arg3[i];
- if (a.length === 1) {
- attrs[a[0]] = "";
- }
- else {
- attrs[a[0]] = a[1];
- }
- }
- var token = ["StartTag", value, attrs];
- if (arg4) token.push(true);
- tokens.push(token);
- break;
- case 3: // ENDTAG
- tokens.push(["EndTag", value]);
- break;
- case -1: // EOF
- break;
- }
- };
-
- if (!charbychar) {
- this.parse(input, true);
- }
- else {
- for(var i = 0; i < input.length; i++) {
- this.parse(input[i]);
- }
- this.parse("", true);
- }
- return tokens;
- };
-
- // Return the parser object from the HTMLParser() factory function
- return htmlparser;
-}
--- a/domino/domino-lib/LICENSE
+++ /dev/null
@@ -1,25 +1,0 @@
-Copyright (c) 2011 The Mozilla Foundation.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/domino/domino-lib/Leaf.js
+++ /dev/null
@@ -1,37 +1,0 @@
-"use strict";
-module.exports = Leaf;
-
-var Node = require('./Node');
-var NodeList = require('./NodeList');
-var utils = require('./utils');
-var HierarchyRequestError = utils.HierarchyRequestError;
-var NotFoundError = utils.NotFoundError;
-
-// This class defines common functionality for node subtypes that
-// can never have children
-function Leaf() {
- Node.call(this);
-}
-
-Leaf.prototype = Object.create(Node.prototype, {
- hasChildNodes: { value: function() { return false; }},
- firstChild: { value: null },
- lastChild: { value: null },
- insertBefore: { value: function(node, child) {
- if (!node.nodeType) throw new TypeError('not a node');
- HierarchyRequestError();
- }},
- replaceChild: { value: function(node, child) {
- if (!node.nodeType) throw new TypeError('not a node');
- HierarchyRequestError();
- }},
- removeChild: { value: function(node) {
- if (!node.nodeType) throw new TypeError('not a node');
- NotFoundError();
- }},
- removeChildren: { value: function() { /* no op */ }},
- childNodes: { get: function() {
- if (!this._childNodes) this._childNodes = new NodeList();
- return this._childNodes;
- }}
-});
--- a/domino/domino-lib/LinkedList.js
+++ /dev/null
@@ -1,44 +1,0 @@
-"use strict";
-var utils = require('./utils');
-
-var LinkedList = module.exports = {
- // basic validity tests on a circular linked list a
- valid: function(a) {
- utils.assert(a, "list falsy");
- utils.assert(a._previousSibling, "previous falsy");
- utils.assert(a._nextSibling, "next falsy");
- // xxx check that list is actually circular
- return true;
- },
- // insert a before b
- insertBefore: function(a, b) {
- utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
- var a_first = a, a_last = a._previousSibling;
- var b_first = b, b_last = b._previousSibling;
- a_first._previousSibling = b_last;
- a_last._nextSibling = b_first;
- b_last._nextSibling = a_first;
- b_first._previousSibling = a_last;
- utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
- },
- // replace a single node a with a list b (which could be null)
- replace: function(a, b) {
- utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
- if (b!==null) {
- LinkedList.insertBefore(b, a);
- }
- LinkedList.remove(a);
- utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
- },
- // remove single node a from its list
- remove: function(a) {
- utils.assert(LinkedList.valid(a));
- var prev = a._previousSibling;
- if (prev === a) { return; }
- var next = a._nextSibling;
- prev._nextSibling = next;
- next._previousSibling = prev;
- a._previousSibling = a._nextSibling = a;
- utils.assert(LinkedList.valid(a));
- }
-};
--- a/domino/domino-lib/Location.js
+++ /dev/null
@@ -1,56 +1,0 @@
-"use strict";
-var URL = require('./URL');
-var URLUtils = require('./URLUtils');
-
-module.exports = Location;
-
-function Location(window, href) {
- this._window = window;
- this._href = href;
-}
-
-Location.prototype = Object.create(URLUtils.prototype, {
- constructor: { value: Location },
-
- // Special behavior when href is set
- href: {
- get: function() { return this._href; },
- set: function(v) { this.assign(v); }
- },
-
- assign: { value: function(url) {
- // Resolve the new url against the current one
- // XXX:
- // This is not actually correct. It should be resolved against
- // the URL of the document of the script. For now, though, I only
- // support a single window and there is only one base url.
- // So this is good enough for now.
- var current = new URL(this._href);
- var newurl = current.resolve(url);
-
- // Save the new url
- this._href = newurl;
-
- // Start loading the new document!
- // XXX
- // This is just something hacked together.
- // The real algorithm is: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#navigate
- }},
-
- replace: { value: function(url) {
- // XXX
- // Since we aren't tracking history yet, replace is the same as assign
- this.assign(url);
- }},
-
- reload: { value: function() {
- // XXX:
- // Actually, the spec is a lot more complicated than this
- this.assign(this.href);
- }},
-
- toString: { value: function() {
- return this.href;
- }}
-
-});
--- a/domino/domino-lib/MouseEvent.js
+++ /dev/null
@@ -1,52 +1,0 @@
-"use strict";
-var UIEvent = require('./UIEvent');
-
-module.exports = MouseEvent;
-
-function MouseEvent() {
- // Just use the superclass constructor to initialize
- UIEvent.call(this);
-
- this.screenX = this.screenY = this.clientX = this.clientY = 0;
- this.ctrlKey = this.altKey = this.shiftKey = this.metaKey = false;
- this.button = 0;
- this.buttons = 1;
- this.relatedTarget = null;
-}
-MouseEvent.prototype = Object.create(UIEvent.prototype, {
- constructor: { value: MouseEvent },
- initMouseEvent: { value: function(type, bubbles, cancelable,
- view, detail,
- screenX, screenY, clientX, clientY,
- ctrlKey, altKey, shiftKey, metaKey,
- button, relatedTarget) {
-
- this.initEvent(type, bubbles, cancelable, view, detail);
- this.screenX = screenX;
- this.screenY = screenY;
- this.clientX = clientX;
- this.clientY = clientY;
- this.ctrlKey = ctrlKey;
- this.altKey = altKey;
- this.shiftKey = shiftKey;
- this.metaKey = metaKey;
- this.button = button;
- switch(button) {
- case 0: this.buttons = 1; break;
- case 1: this.buttons = 4; break;
- case 2: this.buttons = 2; break;
- default: this.buttons = 0; break;
- }
- this.relatedTarget = relatedTarget;
- }},
-
- getModifierState: { value: function(key) {
- switch(key) {
- case "Alt": return this.altKey;
- case "Control": return this.ctrlKey;
- case "Shift": return this.shiftKey;
- case "Meta": return this.metaKey;
- default: return false;
- }
- }}
-});
--- a/domino/domino-lib/MutationConstants.js
+++ /dev/null
@@ -1,9 +1,0 @@
-"use strict";
-module.exports = {
- VALUE: 1, // The value of a Text, Comment or PI node changed
- ATTR: 2, // A new attribute was added or an attribute value and/or prefix changed
- REMOVE_ATTR: 3, // An attribute was removed
- REMOVE: 4, // A node was removed
- MOVE: 5, // A node was moved
- INSERT: 6 // A node (or a subtree of nodes) was inserted
-};
\ No newline at end of file
--- a/domino/domino-lib/NamedNodeMap.js
+++ /dev/null
@@ -1,41 +1,0 @@
-"use strict";
-module.exports = NamedNodeMap;
-
-var utils = require('./utils');
-
-/* This is a hacky implementation of NamedNodeMap, intended primarily to
- * satisfy clients (like dompurify and the web-platform-tests) which check
- * to ensure that Node#attributes instanceof NamedNodeMap. */
-
-function NamedNodeMap(element) {
- this.element = element;
-}
-Object.defineProperties(NamedNodeMap.prototype, {
- length: { get: utils.shouldOverride },
- item: { value: utils.shouldOverride },
-
- getNamedItem: { value: function getNamedItem(qualifiedName) {
- return this.element.getAttributeNode(qualifiedName);
- } },
- getNamedItemNS: { value: function getNamedItemNS(namespace, localName) {
- return this.element.getAttributeNodeNS(namespace, localName);
- } },
- setNamedItem: { value: utils.nyi },
- setNamedItemNS: { value: utils.nyi },
- removeNamedItem: { value: function removeNamedItem(qualifiedName) {
- var attr = this.element.getAttributeNode(qualifiedName);
- if (attr) {
- this.element.removeAttribute(qualifiedName);
- return attr;
- }
- utils.NotFoundError();
- } },
- removeNamedItemNS: { value: function removeNamedItemNS(ns, lname) {
- var attr = this.element.getAttributeNodeNS(ns, lname);
- if (attr) {
- this.element.removeAttributeNS(ns, lname);
- return attr;
- }
- utils.NotFoundError();
- } },
-});
--- a/domino/domino-lib/NavigatorID.js
+++ /dev/null
@@ -1,17 +1,0 @@
-"use strict";
-
-// https://html.spec.whatwg.org/multipage/webappapis.html#navigatorid
-var NavigatorID = Object.create(null, {
- appCodeName: { value: "Mozilla" },
- appName: { value: "Netscape" },
- appVersion: { value: "4.0" },
- platform: { value: "" },
- product: { value: "Gecko" },
- productSub: { value: "20100101" },
- userAgent: { value: "" },
- vendor: { value: "" },
- vendorSub: { value: "" },
- taintEnabled: { value: function() { return false; } }
-});
-
-module.exports = NavigatorID;
--- a/domino/domino-lib/Node.js
+++ /dev/null
@@ -1,738 +1,0 @@
-"use strict";
-module.exports = Node;
-
-var EventTarget = require('./EventTarget');
-var LinkedList = require('./LinkedList');
-var NodeUtils = require('./NodeUtils');
-var utils = require('./utils');
-
-// All nodes have a nodeType and an ownerDocument.
-// Once inserted, they also have a parentNode.
-// This is an abstract class; all nodes in a document are instances
-// of a subtype, so all the properties are defined by more specific
-// constructors.
-function Node() {
- EventTarget.call(this);
- this.parentNode = null;
- this._nextSibling = this._previousSibling = this;
- this._index = undefined;
-}
-
-var ELEMENT_NODE = Node.ELEMENT_NODE = 1;
-var ATTRIBUTE_NODE = Node.ATTRIBUTE_NODE = 2;
-var TEXT_NODE = Node.TEXT_NODE = 3;
-var CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE = 4;
-var ENTITY_REFERENCE_NODE = Node.ENTITY_REFERENCE_NODE = 5;
-var ENTITY_NODE = Node.ENTITY_NODE = 6;
-var PROCESSING_INSTRUCTION_NODE = Node.PROCESSING_INSTRUCTION_NODE = 7;
-var COMMENT_NODE = Node.COMMENT_NODE = 8;
-var DOCUMENT_NODE = Node.DOCUMENT_NODE = 9;
-var DOCUMENT_TYPE_NODE = Node.DOCUMENT_TYPE_NODE = 10;
-var DOCUMENT_FRAGMENT_NODE = Node.DOCUMENT_FRAGMENT_NODE = 11;
-var NOTATION_NODE = Node.NOTATION_NODE = 12;
-
-var DOCUMENT_POSITION_DISCONNECTED = Node.DOCUMENT_POSITION_DISCONNECTED = 0x01;
-var DOCUMENT_POSITION_PRECEDING = Node.DOCUMENT_POSITION_PRECEDING = 0x02;
-var DOCUMENT_POSITION_FOLLOWING = Node.DOCUMENT_POSITION_FOLLOWING = 0x04;
-var DOCUMENT_POSITION_CONTAINS = Node.DOCUMENT_POSITION_CONTAINS = 0x08;
-var DOCUMENT_POSITION_CONTAINED_BY = Node.DOCUMENT_POSITION_CONTAINED_BY = 0x10;
-var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
-
-Node.prototype = Object.create(EventTarget.prototype, {
-
- // Node that are not inserted into the tree inherit a null parent
-
- // XXX: the baseURI attribute is defined by dom core, but
- // a correct implementation of it requires HTML features, so
- // we'll come back to this later.
- baseURI: { get: utils.nyi },
-
- parentElement: { get: function() {
- return (this.parentNode && this.parentNode.nodeType===ELEMENT_NODE) ? this.parentNode : null;
- }},
-
- hasChildNodes: { value: utils.shouldOverride },
-
- firstChild: { get: utils.shouldOverride },
-
- lastChild: { get: utils.shouldOverride },
-
- previousSibling: { get: function() {
- var parent = this.parentNode;
- if (!parent) return null;
- if (this === parent.firstChild) return null;
- return this._previousSibling;
- }},
-
- nextSibling: { get: function() {
- var parent = this.parentNode, next = this._nextSibling;
- if (!parent) return null;
- if (next === parent.firstChild) return null;
- return next;
- }},
-
- textContent: {
- // Should override for DocumentFragment/Element/Attr/Text/PI/Comment
- get: function() { return null; },
- set: function(v) { /* do nothing */ },
- },
-
- _countChildrenOfType: { value: function(type) {
- var sum = 0;
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === type) sum++;
- }
- return sum;
- }},
-
- _ensureInsertValid: { value: function _ensureInsertValid(node, child, isPreinsert) {
- var parent = this, i, kid;
- if (!node.nodeType) throw new TypeError('not a node');
- // 1. If parent is not a Document, DocumentFragment, or Element
- // node, throw a HierarchyRequestError.
- switch (parent.nodeType) {
- case DOCUMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- case ELEMENT_NODE:
- break;
- default: utils.HierarchyRequestError();
- }
- // 2. If node is a host-including inclusive ancestor of parent,
- // throw a HierarchyRequestError.
- if (node.isAncestor(parent)) utils.HierarchyRequestError();
- // 3. If child is not null and its parent is not parent, then
- // throw a NotFoundError. (replaceChild omits the 'child is not null'
- // and throws a TypeError here if child is null.)
- if (child !== null || !isPreinsert) {
- if (child.parentNode !== parent) utils.NotFoundError();
- }
- // 4. If node is not a DocumentFragment, DocumentType, Element,
- // Text, ProcessingInstruction, or Comment node, throw a
- // HierarchyRequestError.
- switch (node.nodeType) {
- case DOCUMENT_FRAGMENT_NODE:
- case DOCUMENT_TYPE_NODE:
- case ELEMENT_NODE:
- case TEXT_NODE:
- case PROCESSING_INSTRUCTION_NODE:
- case COMMENT_NODE:
- break;
- default: utils.HierarchyRequestError();
- }
- // 5. If either node is a Text node and parent is a document, or
- // node is a doctype and parent is not a document, throw a
- // HierarchyRequestError.
- // 6. If parent is a document, and any of the statements below, switched
- // on node, are true, throw a HierarchyRequestError.
- if (parent.nodeType === DOCUMENT_NODE) {
- switch (node.nodeType) {
- case TEXT_NODE:
- utils.HierarchyRequestError();
- break;
- case DOCUMENT_FRAGMENT_NODE:
- // 6a1. If node has more than one element child or has a Text
- // node child.
- if (node._countChildrenOfType(TEXT_NODE) > 0)
- utils.HierarchyRequestError();
- switch (node._countChildrenOfType(ELEMENT_NODE)) {
- case 0:
- break;
- case 1:
- // 6a2. Otherwise, if node has one element child and either
- // parent has an element child, child is a doctype, or child
- // is not null and a doctype is following child. [preinsert]
- // 6a2. Otherwise, if node has one element child and either
- // parent has an element child that is not child or a
- // doctype is following child. [replaceWith]
- if (child !== null /* always true here for replaceWith */) {
- if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE)
- utils.HierarchyRequestError();
- for (kid = child.nextSibling; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === DOCUMENT_TYPE_NODE)
- utils.HierarchyRequestError();
- }
- }
- i = parent._countChildrenOfType(ELEMENT_NODE);
- if (isPreinsert) {
- // "parent has an element child"
- if (i > 0)
- utils.HierarchyRequestError();
- } else {
- // "parent has an element child that is not child"
- if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE))
- utils.HierarchyRequestError();
- }
- break;
- default: // 6a1, continued. (more than one Element child)
- utils.HierarchyRequestError();
- }
- break;
- case ELEMENT_NODE:
- // 6b. parent has an element child, child is a doctype, or
- // child is not null and a doctype is following child. [preinsert]
- // 6b. parent has an element child that is not child or a
- // doctype is following child. [replaceWith]
- if (child !== null /* always true here for replaceWith */) {
- if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE)
- utils.HierarchyRequestError();
- for (kid = child.nextSibling; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === DOCUMENT_TYPE_NODE)
- utils.HierarchyRequestError();
- }
- }
- i = parent._countChildrenOfType(ELEMENT_NODE);
- if (isPreinsert) {
- // "parent has an element child"
- if (i > 0)
- utils.HierarchyRequestError();
- } else {
- // "parent has an element child that is not child"
- if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE))
- utils.HierarchyRequestError();
- }
- break;
- case DOCUMENT_TYPE_NODE:
- // 6c. parent has a doctype child, child is non-null and an
- // element is preceding child, or child is null and parent has
- // an element child. [preinsert]
- // 6c. parent has a doctype child that is not child, or an
- // element is preceding child. [replaceWith]
- if (child === null) {
- if (parent._countChildrenOfType(ELEMENT_NODE))
- utils.HierarchyRequestError();
- } else {
- // child is always non-null for [replaceWith] case
- for (kid = parent.firstChild; kid !== null; kid = kid.nextSibling) {
- if (kid === child) break;
- if (kid.nodeType === ELEMENT_NODE)
- utils.HierarchyRequestError();
- }
- }
- i = parent._countChildrenOfType(DOCUMENT_TYPE_NODE);
- if (isPreinsert) {
- // "parent has an doctype child"
- if (i > 0)
- utils.HierarchyRequestError();
- } else {
- // "parent has an doctype child that is not child"
- if (i > 1 || (i === 1 && child.nodeType !== DOCUMENT_TYPE_NODE))
- utils.HierarchyRequestError();
- }
- break;
- }
- } else {
- // 5, continued: (parent is not a document)
- if (node.nodeType === DOCUMENT_TYPE_NODE) utils.HierarchyRequestError();
- }
- }},
-
- insertBefore: { value: function insertBefore(node, child) {
- var parent = this;
- // 1. Ensure pre-insertion validity
- parent._ensureInsertValid(node, child, true);
- // 2. Let reference child be child.
- var refChild = child;
- // 3. If reference child is node, set it to node's next sibling
- if (refChild === node) { refChild = node.nextSibling; }
- // 4. Adopt node into parent's node document.
- parent.doc.adoptNode(node);
- // 5. Insert node into parent before reference child.
- node._insertOrReplace(parent, refChild, false);
- // 6. Return node
- return node;
- }},
-
-
- appendChild: { value: function(child) {
- // This invokes _appendChild after doing validity checks.
- return this.insertBefore(child, null);
- }},
-
- _appendChild: { value: function(child) {
- child._insertOrReplace(this, null, false);
- }},
-
- removeChild: { value: function removeChild(child) {
- var parent = this;
- if (!child.nodeType) throw new TypeError('not a node');
- if (child.parentNode !== parent) utils.NotFoundError();
- child.remove();
- return child;
- }},
-
- // To replace a `child` with `node` within a `parent` (this)
- replaceChild: { value: function replaceChild(node, child) {
- var parent = this;
- // Ensure validity (slight differences from pre-insertion check)
- parent._ensureInsertValid(node, child, false);
- // Adopt node into parent's node document.
- if (node.doc !== parent.doc) {
- // XXX adoptNode has side-effect of removing node from its parent
- // and generating a mutation event, thus causing the _insertOrReplace
- // to generate two deletes and an insert instead of a 'move'
- // event. It looks like the new MutationObserver stuff avoids
- // this problem, but for now let's only adopt (ie, remove `node`
- // from its parent) here if we need to.
- parent.doc.adoptNode(node);
- }
- // Do the replace.
- node._insertOrReplace(parent, child, true);
- return child;
- }},
-
- // See: http://ejohn.org/blog/comparing-document-position/
- contains: { value: function contains(node) {
- if (node === null) { return false; }
- if (this === node) { return true; /* inclusive descendant */ }
- /* jshint bitwise: false */
- return (this.compareDocumentPosition(node) &
- DOCUMENT_POSITION_CONTAINED_BY) !== 0;
- }},
-
- compareDocumentPosition: { value: function compareDocumentPosition(that){
- // Basic algorithm for finding the relative position of two nodes.
- // Make a list the ancestors of each node, starting with the
- // document element and proceeding down to the nodes themselves.
- // Then, loop through the lists, looking for the first element
- // that differs. The order of those two elements give the
- // order of their descendant nodes. Or, if one list is a prefix
- // of the other one, then that node contains the other.
-
- if (this === that) return 0;
-
- // If they're not owned by the same document or if one is rooted
- // and one is not, then they're disconnected.
- if (this.doc !== that.doc ||
- this.rooted !== that.rooted)
- return (DOCUMENT_POSITION_DISCONNECTED +
- DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
-
- // Get arrays of ancestors for this and that
- var these = [], those = [];
- for(var n = this; n !== null; n = n.parentNode) these.push(n);
- for(n = that; n !== null; n = n.parentNode) those.push(n);
- these.reverse(); // So we start with the outermost
- those.reverse();
-
- if (these[0] !== those[0]) // No common ancestor
- return (DOCUMENT_POSITION_DISCONNECTED +
- DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
-
- n = Math.min(these.length, those.length);
- for(var i = 1; i < n; i++) {
- if (these[i] !== those[i]) {
- // We found two different ancestors, so compare
- // their positions
- if (these[i].index < those[i].index)
- return DOCUMENT_POSITION_FOLLOWING;
- else
- return DOCUMENT_POSITION_PRECEDING;
- }
- }
-
- // If we get to here, then one of the nodes (the one with the
- // shorter list of ancestors) contains the other one.
- if (these.length < those.length)
- return (DOCUMENT_POSITION_FOLLOWING +
- DOCUMENT_POSITION_CONTAINED_BY);
- else
- return (DOCUMENT_POSITION_PRECEDING +
- DOCUMENT_POSITION_CONTAINS);
- }},
-
- isSameNode: {value : function isSameNode(node) {
- return this === node;
- }},
-
-
- // This method implements the generic parts of node equality testing
- // and defers to the (non-recursive) type-specific isEqual() method
- // defined by subclasses
- isEqualNode: { value: function isEqualNode(node) {
- if (!node) return false;
- if (node.nodeType !== this.nodeType) return false;
-
- // Check type-specific properties for equality
- if (!this.isEqual(node)) return false;
-
- // Now check children for number and equality
- for (var c1 = this.firstChild, c2 = node.firstChild;
- c1 && c2;
- c1 = c1.nextSibling, c2 = c2.nextSibling) {
- if (!c1.isEqualNode(c2)) return false;
- }
- return c1 === null && c2 === null;
- }},
-
- // This method delegates shallow cloning to a clone() method
- // that each concrete subclass must implement
- cloneNode: { value: function(deep) {
- // Clone this node
- var clone = this.clone();
-
- // Handle the recursive case if necessary
- if (deep) {
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- clone._appendChild(kid.cloneNode(true));
- }
- }
-
- return clone;
- }},
-
- lookupPrefix: { value: function lookupPrefix(ns) {
- var e;
- if (ns === '' || ns === null || ns === undefined) return null;
- switch(this.nodeType) {
- case ELEMENT_NODE:
- return this._lookupNamespacePrefix(ns, this);
- case DOCUMENT_NODE:
- e = this.documentElement;
- return e ? e.lookupPrefix(ns) : null;
- case ENTITY_NODE:
- case NOTATION_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- case DOCUMENT_TYPE_NODE:
- return null;
- case ATTRIBUTE_NODE:
- e = this.ownerElement;
- return e ? e.lookupPrefix(ns) : null;
- default:
- e = this.parentElement;
- return e ? e.lookupPrefix(ns) : null;
- }
- }},
-
-
- lookupNamespaceURI: {value: function lookupNamespaceURI(prefix) {
- if (prefix === '' || prefix === undefined) { prefix = null; }
- var e;
- switch(this.nodeType) {
- case ELEMENT_NODE:
- return utils.shouldOverride();
- case DOCUMENT_NODE:
- e = this.documentElement;
- return e ? e.lookupNamespaceURI(prefix) : null;
- case ENTITY_NODE:
- case NOTATION_NODE:
- case DOCUMENT_TYPE_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- return null;
- case ATTRIBUTE_NODE:
- e = this.ownerElement;
- return e ? e.lookupNamespaceURI(prefix) : null;
- default:
- e = this.parentElement;
- return e ? e.lookupNamespaceURI(prefix) : null;
- }
- }},
-
- isDefaultNamespace: { value: function isDefaultNamespace(ns) {
- if (ns === '' || ns === undefined) { ns = null; }
- var defaultNamespace = this.lookupNamespaceURI(null);
- return (defaultNamespace === ns);
- }},
-
- // Utility methods for nodes. Not part of the DOM
-
- // Return the index of this node in its parent.
- // Throw if no parent, or if this node is not a child of its parent
- index: { get: function() {
- var parent = this.parentNode;
- if (this === parent.firstChild) return 0; // fast case
- var kids = parent.childNodes;
- if (this._index === undefined || kids[this._index] !== this) {
- // Ensure that we don't have an O(N^2) blowup if none of the
- // kids have defined indices yet and we're traversing via
- // nextSibling or previousSibling
- for (var i=0; i<kids.length; i++) {
- kids[i]._index = i;
- }
- utils.assert(kids[this._index] === this);
- }
- return this._index;
- }},
-
- // Return true if this node is equal to or is an ancestor of that node
- // Note that nodes are considered to be ancestors of themselves
- isAncestor: { value: function(that) {
- // If they belong to different documents, then they're unrelated.
- if (this.doc !== that.doc) return false;
- // If one is rooted and one isn't then they're not related
- if (this.rooted !== that.rooted) return false;
-
- // Otherwise check by traversing the parentNode chain
- for(var e = that; e; e = e.parentNode) {
- if (e === this) return true;
- }
- return false;
- }},
-
- // DOMINO Changed the behavior to conform with the specs. See:
- // https://groups.google.com/d/topic/mozilla.dev.platform/77sIYcpdDmc/discussion
- ensureSameDoc: { value: function(that) {
- if (that.ownerDocument === null) {
- that.ownerDocument = this.doc;
- }
- else if(that.ownerDocument !== this.doc) {
- utils.WrongDocumentError();
- }
- }},
-
- removeChildren: { value: utils.shouldOverride },
-
- // Insert this node as a child of parent before the specified child,
- // or insert as the last child of parent if specified child is null,
- // or replace the specified child with this node, firing mutation events as
- // necessary
- _insertOrReplace: { value: function _insertOrReplace(parent, before, isReplace) {
- var child = this, before_index, i;
-
- if (child.nodeType === DOCUMENT_FRAGMENT_NODE && child.rooted) {
- utils.HierarchyRequestError();
- }
-
- /* Ensure index of `before` is cached before we (possibly) remove it. */
- if (parent._childNodes) {
- before_index = (before === null) ? parent._childNodes.length :
- before.index; /* ensure _index is cached */
-
- // If we are already a child of the specified parent, then
- // the index may have to be adjusted.
- if (child.parentNode === parent) {
- var child_index = child.index;
- // If the child is before the spot it is to be inserted at,
- // then when it is removed, the index of that spot will be
- // reduced.
- if (child_index < before_index) {
- before_index--;
- }
- }
- }
-
- // Delete the old child
- if (isReplace) {
- if (before.rooted) before.doc.mutateRemove(before);
- before.parentNode = null;
- }
-
- var n = before;
- if (n === null) { n = parent.firstChild; }
-
- // If both the child and the parent are rooted, then we want to
- // transplant the child without uprooting and rerooting it.
- var bothRooted = child.rooted && parent.rooted;
- if (child.nodeType === DOCUMENT_FRAGMENT_NODE) {
- var spliceArgs = [0, isReplace ? 1 : 0], next;
- for (var kid = child.firstChild; kid !== null; kid = next) {
- next = kid.nextSibling;
- spliceArgs.push(kid);
- kid.parentNode = parent;
- }
- var len = spliceArgs.length;
- // Add all nodes to the new parent, overwriting the old child
- if (isReplace) {
- LinkedList.replace(n, len > 2 ? spliceArgs[2] : null);
- } else if (len > 2 && n !== null) {
- LinkedList.insertBefore(spliceArgs[2], n);
- }
- if (parent._childNodes) {
- spliceArgs[0] = (before === null) ?
- parent._childNodes.length : before._index;
- parent._childNodes.splice.apply(parent._childNodes, spliceArgs);
- for (i=2; i<len; i++) {
- spliceArgs[i]._index = spliceArgs[0] + (i - 2);
- }
- } else if (parent._firstChild === before) {
- if (len > 2) {
- parent._firstChild = spliceArgs[2];
- } else if (isReplace) {
- parent._firstChild = null;
- }
- }
- // Remove all nodes from the document fragment
- if (child._childNodes) {
- child._childNodes.length = 0;
- } else {
- child._firstChild = null;
- }
- // Call the mutation handlers
- // Use spliceArgs since the original array has been destroyed. The
- // liveness guarantee requires us to clone the array so that
- // references to the childNodes of the DocumentFragment will be empty
- // when the insertion handlers are called.
- if (parent.rooted) {
- parent.modify();
- for (i = 2; i < len; i++) {
- parent.doc.mutateInsert(spliceArgs[i]);
- }
- }
- } else {
- if (before === child) { return; }
- if (bothRooted) {
- // Remove the child from its current position in the tree
- // without calling remove(), since we don't want to uproot it.
- child._remove();
- } else if (child.parentNode) {
- child.remove();
- }
-
- // Insert it as a child of its new parent
- child.parentNode = parent;
- if (isReplace) {
- LinkedList.replace(n, child);
- if (parent._childNodes) {
- child._index = before_index;
- parent._childNodes[before_index] = child;
- } else if (parent._firstChild === before) {
- parent._firstChild = child;
- }
- } else {
- if (n !== null) {
- LinkedList.insertBefore(child, n);
- }
- if (parent._childNodes) {
- child._index = before_index;
- parent._childNodes.splice(before_index, 0, child);
- } else if (parent._firstChild === before) {
- parent._firstChild = child;
- }
- }
- if (bothRooted) {
- parent.modify();
- // Generate a move mutation event
- parent.doc.mutateMove(child);
- } else if (parent.rooted) {
- parent.modify();
- parent.doc.mutateInsert(child);
- }
- }
- }},
-
-
- // Return the lastModTime value for this node. (For use as a
- // cache invalidation mechanism. If the node does not already
- // have one, initialize it from the owner document's modclock
- // property. (Note that modclock does not return the actual
- // time; it is simply a counter incremented on each document
- // modification)
- lastModTime: { get: function() {
- if (!this._lastModTime) {
- this._lastModTime = this.doc.modclock;
- }
- return this._lastModTime;
- }},
-
- // Increment the owner document's modclock and use the new
- // value to update the lastModTime value for this node and
- // all of its ancestors. Nodes that have never had their
- // lastModTime value queried do not need to have a
- // lastModTime property set on them since there is no
- // previously queried value to ever compare the new value
- // against, so only update nodes that already have a
- // _lastModTime property.
- modify: { value: function() {
- if (this.doc.modclock) { // Skip while doc.modclock == 0
- var time = ++this.doc.modclock;
- for(var n = this; n; n = n.parentElement) {
- if (n._lastModTime) {
- n._lastModTime = time;
- }
- }
- }
- }},
-
- // This attribute is not part of the DOM but is quite helpful.
- // It returns the document with which a node is associated. Usually
- // this is the ownerDocument. But ownerDocument is null for the
- // document object itself, so this is a handy way to get the document
- // regardless of the node type
- doc: { get: function() {
- return this.ownerDocument || this;
- }},
-
-
- // If the node has a nid (node id), then it is rooted in a document
- rooted: { get: function() {
- return !!this._nid;
- }},
-
- normalize: { value: function() {
- var next;
- for (var child=this.firstChild; child !== null; child=next) {
- next = child.nextSibling;
-
- if (child.normalize) {
- child.normalize();
- }
-
- if (child.nodeType !== Node.TEXT_NODE) {
- continue;
- }
-
- if (child.nodeValue === "") {
- this.removeChild(child);
- continue;
- }
-
- var prevChild = child.previousSibling;
- if (prevChild === null) {
- continue;
- } else if (prevChild.nodeType === Node.TEXT_NODE) {
- // merge this with previous and remove the child
- prevChild.appendData(child.nodeValue);
- this.removeChild(child);
- }
- }
- }},
-
- // Convert the children of a node to an HTML string.
- // This is used by the innerHTML getter
- // The serialization spec is at:
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments
- //
- // The serialization logic is intentionally implemented in a separate
- // `NodeUtils` helper instead of the more obvious choice of a private
- // `_serializeOne()` method on the `Node.prototype` in order to avoid
- // the megamorphic `this._serializeOne` property access, which reduces
- // performance unnecessarily. If you need specialized behavior for a
- // certain subclass, you'll need to implement that in `NodeUtils`.
- // See https://github.com/fgnass/domino/pull/142 for more information.
- serialize: { value: function() {
- var s = '';
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
- s += NodeUtils.serializeOne(kid, this);
- }
- return s;
- }},
-
- // Non-standard, but often useful for debugging.
- outerHTML: {
- get: function() {
- return NodeUtils.serializeOne(this, { nodeType: 0 });
- },
- set: utils.nyi,
- },
-
- // mirror node type properties in the prototype, so they are present
- // in instances of Node (and subclasses)
- ELEMENT_NODE: { value: ELEMENT_NODE },
- ATTRIBUTE_NODE: { value: ATTRIBUTE_NODE },
- TEXT_NODE: { value: TEXT_NODE },
- CDATA_SECTION_NODE: { value: CDATA_SECTION_NODE },
- ENTITY_REFERENCE_NODE: { value: ENTITY_REFERENCE_NODE },
- ENTITY_NODE: { value: ENTITY_NODE },
- PROCESSING_INSTRUCTION_NODE: { value: PROCESSING_INSTRUCTION_NODE },
- COMMENT_NODE: { value: COMMENT_NODE },
- DOCUMENT_NODE: { value: DOCUMENT_NODE },
- DOCUMENT_TYPE_NODE: { value: DOCUMENT_TYPE_NODE },
- DOCUMENT_FRAGMENT_NODE: { value: DOCUMENT_FRAGMENT_NODE },
- NOTATION_NODE: { value: NOTATION_NODE },
-
- DOCUMENT_POSITION_DISCONNECTED: { value: DOCUMENT_POSITION_DISCONNECTED },
- DOCUMENT_POSITION_PRECEDING: { value: DOCUMENT_POSITION_PRECEDING },
- DOCUMENT_POSITION_FOLLOWING: { value: DOCUMENT_POSITION_FOLLOWING },
- DOCUMENT_POSITION_CONTAINS: { value: DOCUMENT_POSITION_CONTAINS },
- DOCUMENT_POSITION_CONTAINED_BY: { value: DOCUMENT_POSITION_CONTAINED_BY },
- DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: { value: DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC },
-});
--- a/domino/domino-lib/NodeFilter.js
+++ /dev/null
@@ -1,24 +1,0 @@
-"use strict";
-var NodeFilter = {
- // Constants for acceptNode()
- FILTER_ACCEPT: 1,
- FILTER_REJECT: 2,
- FILTER_SKIP: 3,
-
- // Constants for whatToShow
- SHOW_ALL: 0xFFFFFFFF,
- SHOW_ELEMENT: 0x1,
- SHOW_ATTRIBUTE: 0x2, // historical
- SHOW_TEXT: 0x4,
- SHOW_CDATA_SECTION: 0x8, // historical
- SHOW_ENTITY_REFERENCE: 0x10, // historical
- SHOW_ENTITY: 0x20, // historical
- SHOW_PROCESSING_INSTRUCTION: 0x40,
- SHOW_COMMENT: 0x80,
- SHOW_DOCUMENT: 0x100,
- SHOW_DOCUMENT_TYPE: 0x200,
- SHOW_DOCUMENT_FRAGMENT: 0x400,
- SHOW_NOTATION: 0x800 // historical
-};
-
-module.exports = (NodeFilter.constructor = NodeFilter.prototype = NodeFilter);
--- a/domino/domino-lib/NodeIterator.js
+++ /dev/null
@@ -1,217 +1,0 @@
-"use strict";
-module.exports = NodeIterator;
-
-var NodeFilter = require('./NodeFilter');
-var NodeTraversal = require('./NodeTraversal');
-var utils = require('./utils');
-
-/* Private methods and helpers */
-
-/**
- * @based on WebKit's NodeIterator::moveToNext and NodeIterator::moveToPrevious
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeIterator.cpp?rev=186279#L51
- */
-function move(node, stayWithin, directionIsNext) {
- if (directionIsNext) {
- return NodeTraversal.next(node, stayWithin);
- } else {
- if (node === stayWithin) {
- return null;
- }
- return NodeTraversal.previous(node, null);
- }
-}
-
-function isInclusiveAncestor(node, possibleChild) {
- for ( ; possibleChild; possibleChild = possibleChild.parentNode) {
- if (node === possibleChild) { return true; }
- }
- return false;
-}
-
-/**
- * @spec http://www.w3.org/TR/dom/#concept-nodeiterator-traverse
- * @method
- * @access private
- * @param {NodeIterator} ni
- * @param {string} direction One of 'next' or 'previous'.
- * @return {Node|null}
- */
-function traverse(ni, directionIsNext) {
- var node, beforeNode;
- node = ni._referenceNode;
- beforeNode = ni._pointerBeforeReferenceNode;
- while (true) {
- if (beforeNode === directionIsNext) {
- beforeNode = !beforeNode;
- } else {
- node = move(node, ni._root, directionIsNext);
- if (node === null) {
- return null;
- }
- }
- var result = ni._internalFilter(node);
- if (result === NodeFilter.FILTER_ACCEPT) {
- break;
- }
- }
- ni._referenceNode = node;
- ni._pointerBeforeReferenceNode = beforeNode;
- return node;
-}
-
-/* Public API */
-
-/**
- * Implemented version: http://www.w3.org/TR/2015/WD-dom-20150618/#nodeiterator
- * Latest version: http://www.w3.org/TR/dom/#nodeiterator
- *
- * @constructor
- * @param {Node} root
- * @param {number} whatToShow [optional]
- * @param {Function|NodeFilter} filter [optional]
- * @throws Error
- */
-function NodeIterator(root, whatToShow, filter) {
- if (!root || !root.nodeType) {
- utils.NotSupportedError();
- }
-
- // Read-only properties
- this._root = root;
- this._referenceNode = root;
- this._pointerBeforeReferenceNode = true;
- this._whatToShow = Number(whatToShow) || 0;
- this._filter = filter || null;
- this._active = false;
- // Record active node iterators in the document, in order to perform
- // "node iterator pre-removal steps".
- root.doc._attachNodeIterator(this);
-}
-
-Object.defineProperties(NodeIterator.prototype, {
- root: { get: function root() {
- return this._root;
- } },
- referenceNode: { get: function referenceNode() {
- return this._referenceNode;
- } },
- pointerBeforeReferenceNode: { get: function pointerBeforeReferenceNode() {
- return this._pointerBeforeReferenceNode;
- } },
- whatToShow: { get: function whatToShow() {
- return this._whatToShow;
- } },
- filter: { get: function filter() {
- return this._filter;
- } },
-
- /**
- * @method
- * @param {Node} node
- * @return {Number} Constant NodeFilter.FILTER_ACCEPT,
- * NodeFilter.FILTER_REJECT or NodeFilter.FILTER_SKIP.
- */
- _internalFilter: { value: function _internalFilter(node) {
- /* jshint bitwise: false */
- var result, filter;
- if (this._active) {
- utils.InvalidStateError();
- }
-
- // Maps nodeType to whatToShow
- if (!(((1 << (node.nodeType - 1)) & this._whatToShow))) {
- return NodeFilter.FILTER_SKIP;
- }
-
- filter = this._filter;
- if (filter === null) {
- result = NodeFilter.FILTER_ACCEPT;
- } else {
- this._active = true;
- try {
- if (typeof filter === 'function') {
- result = filter(node);
- } else {
- result = filter.acceptNode(node);
- }
- } finally {
- this._active = false;
- }
- }
-
- // Note that coercing to a number means that
- // `true` becomes `1` (which is NodeFilter.FILTER_ACCEPT)
- // `false` becomes `0` (neither accept, reject, or skip)
- return (+result);
- } },
-
- /**
- * @spec https://dom.spec.whatwg.org/#nodeiterator-pre-removing-steps
- * @method
- * @return void
- */
- _preremove: { value: function _preremove(toBeRemovedNode) {
- if (isInclusiveAncestor(toBeRemovedNode, this._root)) { return; }
- if (!isInclusiveAncestor(toBeRemovedNode, this._referenceNode)) { return; }
- if (this._pointerBeforeReferenceNode) {
- var next = toBeRemovedNode;
- while (next.lastChild) {
- next = next.lastChild;
- }
- next = NodeTraversal.next(next, this.root);
- if (next) {
- this._referenceNode = next;
- return;
- }
- this._pointerBeforeReferenceNode = false;
- // fall through
- }
- if (toBeRemovedNode.previousSibling === null) {
- this._referenceNode = toBeRemovedNode.parentNode;
- } else {
- this._referenceNode = toBeRemovedNode.previousSibling;
- var lastChild;
- for (lastChild = this._referenceNode.lastChild;
- lastChild;
- lastChild = this._referenceNode.lastChild) {
- this._referenceNode = lastChild;
- }
- }
- } },
-
- /**
- * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-nextnode
- * @method
- * @return {Node|null}
- */
- nextNode: { value: function nextNode() {
- return traverse(this, true);
- } },
-
- /**
- * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-previousnode
- * @method
- * @return {Node|null}
- */
- previousNode: { value: function previousNode() {
- return traverse(this, false);
- } },
-
- /**
- * @spec http://www.w3.org/TR/dom/#dom-nodeiterator-detach
- * @method
- * @return void
- */
- detach: { value: function detach() {
- /* "The detach() method must do nothing.
- * Its functionality (disabling a NodeIterator object) was removed,
- * but the method itself is preserved for compatibility.
- */
- } },
-
- /** For compatibility with web-platform-tests. */
- toString: { value: function toString() {
- return "[object NodeIterator]";
- } },
-});
--- a/domino/domino-lib/NodeList.es5.js
+++ /dev/null
@@ -1,15 +1,0 @@
-"use strict";
-
-// No support for subclassing array, return an actual Array object.
-function item(i) {
- /* jshint validthis: true */
- return this[i] || null;
-}
-
-function NodeList(a) {
- if (!a) a = [];
- a.item = item;
- return a;
-}
-
-module.exports = NodeList;
--- a/domino/domino-lib/NodeList.es6.js
+++ /dev/null
@@ -1,12 +1,0 @@
-/* jshint esversion: 6 */
-"use strict";
-
-module.exports = class NodeList extends Array {
- constructor(a) {
- super((a && a.length) || 0);
- if (a) {
- for (var idx in a) { this[idx] = a[idx]; }
- }
- }
- item(i) { return this[i] || null; }
-};
--- a/domino/domino-lib/NodeList.js
+++ /dev/null
@@ -1,13 +1,0 @@
-"use strict";
-
-var NodeList;
-
-try {
- // Attempt to use ES6-style Array subclass if possible.
- NodeList = require('./NodeList.es6.js');
-} catch (e) {
- // No support for subclassing array, return an actual Array object.
- NodeList = require('./NodeList.es5.js');
-}
-
-module.exports = NodeList;
--- a/domino/domino-lib/NodeTraversal.js
+++ /dev/null
@@ -1,87 +1,0 @@
-"use strict";
-/* exported NodeTraversal */
-var NodeTraversal = module.exports = {
- nextSkippingChildren: nextSkippingChildren,
- nextAncestorSibling: nextAncestorSibling,
- next: next,
- previous: previous,
- deepLastChild: deepLastChild
-};
-
-/**
- * @based on WebKit's NodeTraversal::nextSkippingChildren
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L109
- */
-function nextSkippingChildren(node, stayWithin) {
- if (node === stayWithin) {
- return null;
- }
- if (node.nextSibling !== null) {
- return node.nextSibling;
- }
- return nextAncestorSibling(node, stayWithin);
-}
-
-/**
- * @based on WebKit's NodeTraversal::nextAncestorSibling
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L93
- */
-function nextAncestorSibling(node, stayWithin) {
- for (node = node.parentNode; node !== null; node = node.parentNode) {
- if (node === stayWithin) {
- return null;
- }
- if (node.nextSibling !== null) {
- return node.nextSibling;
- }
- }
- return null;
-}
-
-/**
- * @based on WebKit's NodeTraversal::next
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L99
- */
-function next(node, stayWithin) {
- var n;
- n = node.firstChild;
- if (n !== null) {
- return n;
- }
- if (node === stayWithin) {
- return null;
- }
- n = node.nextSibling;
- if (n !== null) {
- return n;
- }
- return nextAncestorSibling(node, stayWithin);
-}
-
-/**
- * @based on WebKit's NodeTraversal::deepLastChild
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L116
- */
-function deepLastChild(node) {
- while (node.lastChild) {
- node = node.lastChild;
- }
- return node;
-}
-
-/**
- * @based on WebKit's NodeTraversal::previous
- * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L121
- */
-function previous(node, stayWithin) {
- var p;
- p = node.previousSibling;
- if (p !== null) {
- return deepLastChild(p);
- }
- p = node.parentNode;
- if (p === stayWithin) {
- return null;
- }
- return p;
-}
--- a/domino/domino-lib/NodeUtils.js
+++ /dev/null
@@ -1,168 +1,0 @@
-"use strict";
-module.exports = {
- // NOTE: The `serializeOne()` function used to live on the `Node.prototype`
- // as a private method `Node#_serializeOne(child)`, however that requires
- // a megamorphic property access `this._serializeOne` just to get to the
- // method, and this is being done on lots of different `Node` subclasses,
- // which puts a lot of pressure on V8's megamorphic stub cache. So by
- // moving the helper off of the `Node.prototype` and into a separate
- // function in this helper module, we get a monomorphic property access
- // `NodeUtils.serializeOne` to get to the function and reduce pressure
- // on the megamorphic stub cache.
- // See https://github.com/fgnass/domino/pull/142 for more information.
- serializeOne: serializeOne
-};
-
-var utils = require('./utils');
-var NAMESPACE = utils.NAMESPACE;
-
-var hasRawContent = {
- STYLE: true,
- SCRIPT: true,
- XMP: true,
- IFRAME: true,
- NOEMBED: true,
- NOFRAMES: true,
- PLAINTEXT: true
-};
-
-var emptyElements = {
- area: true,
- base: true,
- basefont: true,
- bgsound: true,
- br: true,
- col: true,
- embed: true,
- frame: true,
- hr: true,
- img: true,
- input: true,
- keygen: true,
- link: true,
- meta: true,
- param: true,
- source: true,
- track: true,
- wbr: true
-};
-
-var extraNewLine = {
- /* Removed in https://github.com/whatwg/html/issues/944
- pre: true,
- textarea: true,
- listing: true
- */
-};
-
-function escape(s) {
- return s.replace(/[&<>\u00A0]/g, function(c) {
- switch(c) {
- case '&': return '&';
- case '<': return '<';
- case '>': return '>';
- case '\u00A0': return ' ';
- }
- });
-}
-
-function escapeAttr(s) {
- var toEscape = /[&"\u00A0]/g;
- if (!toEscape.test(s)) {
- // nothing to do, fast path
- return s;
- } else {
- return s.replace(toEscape, function(c) {
- switch(c) {
- case '&': return '&';
- case '"': return '"';
- case '\u00A0': return ' ';
- }
- });
- }
-}
-
-function attrname(a) {
- var ns = a.namespaceURI;
- if (!ns)
- return a.localName;
- if (ns === NAMESPACE.XML)
- return 'xml:' + a.localName;
- if (ns === NAMESPACE.XLINK)
- return 'xlink:' + a.localName;
-
- if (ns === NAMESPACE.XMLNS) {
- if (a.localName === 'xmlns') return 'xmlns';
- else return 'xmlns:' + a.localName;
- }
- return a.name;
-}
-
-function serializeOne(kid, parent) {
- var s = '';
- switch(kid.nodeType) {
- case 1: //ELEMENT_NODE
- var ns = kid.namespaceURI;
- var html = ns === NAMESPACE.HTML;
- var tagname = (html || ns === NAMESPACE.SVG || ns === NAMESPACE.MATHML) ? kid.localName : kid.tagName;
-
- s += '<' + tagname;
-
- for(var j = 0, k = kid._numattrs; j < k; j++) {
- var a = kid._attr(j);
- s += ' ' + attrname(a);
- if (a.value !== undefined) s += '="' + escapeAttr(a.value) + '"';
- }
- s += '>';
-
- if (!(html && emptyElements[tagname])) {
- var ss = kid.serialize();
- if (html && extraNewLine[tagname] && ss.charAt(0)==='\n') s += '\n';
- // Serialize children and add end tag for all others
- s += ss;
- s += '</' + tagname + '>';
- }
- break;
- case 3: //TEXT_NODE
- case 4: //CDATA_SECTION_NODE
- var parenttag;
- if (parent.nodeType === 1 /*ELEMENT_NODE*/ &&
- parent.namespaceURI === NAMESPACE.HTML)
- parenttag = parent.tagName;
- else
- parenttag = '';
-
- if (hasRawContent[parenttag] ||
- (parenttag==='NOSCRIPT' && parent.ownerDocument._scripting_enabled)) {
- s += kid.data;
- } else {
- s += escape(kid.data);
- }
- break;
- case 8: //COMMENT_NODE
- s += '<!--' + kid.data + '-->';
- break;
- case 7: //PROCESSING_INSTRUCTION_NODE
- s += '<?' + kid.target + ' ' + kid.data + '?>';
- break;
- case 10: //DOCUMENT_TYPE_NODE
- s += '<!DOCTYPE ' + kid.name;
-
- if (false) {
- // Latest HTML serialization spec omits the public/system ID
- if (kid.publicID) {
- s += ' PUBLIC "' + kid.publicId + '"';
- }
-
- if (kid.systemId) {
- s += ' "' + kid.systemId + '"';
- }
- }
-
- s += '>';
- break;
- default:
- utils.InvalidStateError();
- }
- return s;
-}
--- a/domino/domino-lib/NonDocumentTypeChildNode.js
+++ /dev/null
@@ -1,26 +1,0 @@
-"use strict";
-var Node = require('./Node');
-
-var NonDocumentTypeChildNode = {
-
- nextElementSibling: { get: function() {
- if (this.parentNode) {
- for (var kid = this.nextSibling; kid !== null; kid = kid.nextSibling) {
- if (kid.nodeType === Node.ELEMENT_NODE) return kid;
- }
- }
- return null;
- }},
-
- previousElementSibling: { get: function() {
- if (this.parentNode) {
- for (var kid = this.previousSibling; kid !== null; kid = kid.previousSibling) {
- if (kid.nodeType === Node.ELEMENT_NODE) return kid;
- }
- }
- return null;
- }}
-
-};
-
-module.exports = NonDocumentTypeChildNode;
--- a/domino/domino-lib/ProcessingInstruction.js
+++ /dev/null
@@ -1,43 +1,0 @@
-"use strict";
-module.exports = ProcessingInstruction;
-
-var Node = require('./Node');
-var CharacterData = require('./CharacterData');
-
-function ProcessingInstruction(doc, target, data) {
- CharacterData.call(this);
- this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
- this.ownerDocument = doc;
- this.target = target;
- this._data = data;
-}
-
-var nodeValue = {
- get: function() { return this._data; },
- set: function(v) {
- if (v === null || v === undefined) { v = ''; } else { v = String(v); }
- this._data = v;
- if (this.rooted) this.ownerDocument.mutateValue(this);
- }
-};
-
-ProcessingInstruction.prototype = Object.create(CharacterData.prototype, {
- nodeName: { get: function() { return this.target; }},
- nodeValue: nodeValue,
- textContent: nodeValue,
- data: {
- get: nodeValue.get,
- set: function(v) {
- nodeValue.set.call(this, v===null ? '' : String(v));
- },
- },
-
- // Utility methods
- clone: { value: function clone() {
- return new ProcessingInstruction(this.ownerDocument, this.target, this._data);
- }},
- isEqual: { value: function isEqual(n) {
- return this.target === n.target && this._data === n._data;
- }}
-
-});
--- a/domino/domino-lib/Text.js
+++ /dev/null
@@ -1,74 +1,0 @@
-"use strict";
-module.exports = Text;
-
-var utils = require('./utils');
-var Node = require('./Node');
-var CharacterData = require('./CharacterData');
-
-function Text(doc, data) {
- CharacterData.call(this);
- this.nodeType = Node.TEXT_NODE;
- this.ownerDocument = doc;
- this._data = data;
- this._index = undefined;
-}
-
-var nodeValue = {
- get: function() { return this._data; },
- set: function(v) {
- if (v === null || v === undefined) { v = ''; } else { v = String(v); }
- if (v === this._data) return;
- this._data = v;
- if (this.rooted)
- this.ownerDocument.mutateValue(this);
- if (this.parentNode &&
- this.parentNode._textchangehook)
- this.parentNode._textchangehook(this);
- }
-};
-
-Text.prototype = Object.create(CharacterData.prototype, {
- nodeName: { value: "#text" },
- // These three attributes are all the same.
- // The data attribute has a [TreatNullAs=EmptyString] but we'll
- // implement that at the interface level
- nodeValue: nodeValue,
- textContent: nodeValue,
- data: {
- get: nodeValue.get,
- set: function(v) {
- nodeValue.set.call(this, v===null ? '' : String(v));
- },
- },
-
- splitText: { value: function splitText(offset) {
- if (offset > this._data.length || offset < 0) utils.IndexSizeError();
-
- var newdata = this._data.substring(offset),
- newnode = this.ownerDocument.createTextNode(newdata);
- this.data = this.data.substring(0, offset);
-
- var parent = this.parentNode;
- if (parent !== null)
- parent.insertBefore(newnode, this.nextSibling);
-
- return newnode;
- }},
-
- wholeText: { get: function wholeText() {
- var result = this.textContent;
- for (var next = this.nextSibling; next; next = next.nextSibling) {
- if (next.nodeType !== Node.TEXT_NODE) { break; }
- result += next.textContent;
- }
- return result;
- }},
- // Obsolete, removed from spec.
- replaceWholeText: { value: utils.nyi },
-
- // Utility methods
- clone: { value: function clone() {
- return new Text(this.ownerDocument, this._data);
- }},
-
-});
--- a/domino/domino-lib/TreeWalker.js
+++ /dev/null
@@ -1,336 +1,0 @@
-"use strict";
-module.exports = TreeWalker;
-
-var Node = require('./Node');
-var NodeFilter = require('./NodeFilter');
-var NodeTraversal = require('./NodeTraversal');
-var utils = require('./utils');
-
-var mapChild = {
- first: 'firstChild',
- last: 'lastChild',
- next: 'firstChild',
- previous: 'lastChild'
-};
-
-var mapSibling = {
- first: 'nextSibling',
- last: 'previousSibling',
- next: 'nextSibling',
- previous: 'previousSibling'
-};
-
-/* Private methods and helpers */
-
-/**
- * @spec https://dom.spec.whatwg.org/#concept-traverse-children
- * @method
- * @access private
- * @param {TreeWalker} tw
- * @param {string} type One of 'first' or 'last'.
- * @return {Node|null}
- */
-function traverseChildren(tw, type) {
- var child, node, parent, result, sibling;
- node = tw._currentNode[mapChild[type]];
- while (node !== null) {
- result = tw._internalFilter(node);
- if (result === NodeFilter.FILTER_ACCEPT) {
- tw._currentNode = node;
- return node;
- }
- if (result === NodeFilter.FILTER_SKIP) {
- child = node[mapChild[type]];
- if (child !== null) {
- node = child;
- continue;
- }
- }
- while (node !== null) {
- sibling = node[mapSibling[type]];
- if (sibling !== null) {
- node = sibling;
- break;
- }
- parent = node.parentNode;
- if (parent === null || parent === tw.root || parent === tw._currentNode) {
- return null;
- } else {
- node = parent;
- }
- }
- }
- return null;
-}
-
-/**
- * @spec https://dom.spec.whatwg.org/#concept-traverse-siblings
- * @method
- * @access private
- * @param {TreeWalker} tw
- * @param {TreeWalker} type One of 'next' or 'previous'.
- * @return {Node|nul}
- */
-function traverseSiblings(tw, type) {
- var node, result, sibling;
- node = tw._currentNode;
- if (node === tw.root) {
- return null;
- }
- while (true) {
- sibling = node[mapSibling[type]];
- while (sibling !== null) {
- node = sibling;
- result = tw._internalFilter(node);
- if (result === NodeFilter.FILTER_ACCEPT) {
- tw._currentNode = node;
- return node;
- }
- sibling = node[mapChild[type]];
- if (result === NodeFilter.FILTER_REJECT || sibling === null) {
- sibling = node[mapSibling[type]];
- }
- }
- node = node.parentNode;
- if (node === null || node === tw.root) {
- return null;
- }
- if (tw._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
- return null;
- }
- }
-}
-
-
-/* Public API */
-
-/**
- * Latest version: https://dom.spec.whatwg.org/#treewalker
- *
- * @constructor
- * @param {Node} root
- * @param {number} whatToShow [optional]
- * @param {Function|NodeFilter} filter [optional]
- * @throws Error
- */
-function TreeWalker(root, whatToShow, filter) {
- if (!root || !root.nodeType) {
- utils.NotSupportedError();
- }
-
- // Read-only properties
- this._root = root;
- this._whatToShow = Number(whatToShow) || 0;
- this._filter = filter || null;
- this._active = false;
- // Read-write property
- this._currentNode = root;
-}
-
-Object.defineProperties(TreeWalker.prototype, {
- root: { get: function() { return this._root; } },
- whatToShow: { get: function() { return this._whatToShow; } },
- filter: { get: function() { return this._filter; } },
-
- currentNode: {
- get: function currentNode() {
- return this._currentNode;
- },
- set: function setCurrentNode(v) {
- if (!(v instanceof Node)) {
- throw new TypeError("Not a Node"); // `null` is also not a node
- }
- this._currentNode = v;
- },
- },
-
- /**
- * @method
- * @param {Node} node
- * @return {Number} Constant NodeFilter.FILTER_ACCEPT,
- * NodeFilter.FILTER_REJECT or NodeFilter.FILTER_SKIP.
- */
- _internalFilter: { value: function _internalFilter(node) {
- /* jshint bitwise: false */
- var result, filter;
- if (this._active) {
- utils.InvalidStateError();
- }
-
- // Maps nodeType to whatToShow
- if (!(((1 << (node.nodeType - 1)) & this._whatToShow))) {
- return NodeFilter.FILTER_SKIP;
- }
-
- filter = this._filter;
- if (filter === null) {
- result = NodeFilter.FILTER_ACCEPT;
- } else {
- this._active = true;
- try {
- if (typeof filter === 'function') {
- result = filter(node);
- } else {
- result = filter.acceptNode(node);
- }
- } finally {
- this._active = false;
- }
- }
-
- // Note that coercing to a number means that
- // `true` becomes `1` (which is NodeFilter.FILTER_ACCEPT)
- // `false` becomes `0` (neither accept, reject, or skip)
- return (+result);
- }},
-
- /**
- * @spec https://dom.spec.whatwg.org/#dom-treewalker-parentnode
- * @based on WebKit's TreeWalker::parentNode
- * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L50
- * @method
- * @return {Node|null}
- */
- parentNode: { value: function parentNode() {
- var node = this._currentNode;
- while (node !== this.root) {
- node = node.parentNode;
- if (node === null) {
- return null;
- }
- if (this._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
- this._currentNode = node;
- return node;
- }
- }
- return null;
- }},
-
- /**
- * @spec https://dom.spec.whatwg.org/#dom-treewalker-firstchild
- * @method
- * @return {Node|null}
- */
- firstChild: { value: function firstChild() {
- return traverseChildren(this, 'first');
- }},
-
- /**
- * @spec https://dom.spec.whatwg.org/#dom-treewalker-lastchild
- * @method
- * @return {Node|null}
- */
- lastChild: { value: function lastChild() {
- return traverseChildren(this, 'last');
- }},
-
- /**
- * @spec http://www.w3.org/TR/dom/#dom-treewalker-previoussibling
- * @method
- * @return {Node|null}
- */
- previousSibling: { value: function previousSibling() {
- return traverseSiblings(this, 'previous');
- }},
-
- /**
- * @spec http://www.w3.org/TR/dom/#dom-treewalker-nextsibling
- * @method
- * @return {Node|null}
- */
- nextSibling: { value: function nextSibling() {
- return traverseSiblings(this, 'next');
- }},
-
- /**
- * @spec https://dom.spec.whatwg.org/#dom-treewalker-previousnode
- * @based on WebKit's TreeWalker::previousNode
- * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L181
- * @method
- * @return {Node|null}
- */
- previousNode: { value: function previousNode() {
- var node, result, previousSibling, lastChild;
- node = this._currentNode;
- while (node !== this._root) {
- for (previousSibling = node.previousSibling;
- previousSibling;
- previousSibling = node.previousSibling) {
- node = previousSibling;
- result = this._internalFilter(node);
- if (result === NodeFilter.FILTER_REJECT) {
- continue;
- }
- for (lastChild = node.lastChild;
- lastChild;
- lastChild = node.lastChild) {
- node = lastChild;
- result = this._internalFilter(node);
- if (result === NodeFilter.FILTER_REJECT) {
- break;
- }
- }
- if (result === NodeFilter.FILTER_ACCEPT) {
- this._currentNode = node;
- return node;
- }
- }
- if (node === this.root || node.parentNode === null) {
- return null;
- }
- node = node.parentNode;
- if (this._internalFilter(node) === NodeFilter.FILTER_ACCEPT) {
- this._currentNode = node;
- return node;
- }
- }
- return null;
- }},
-
- /**
- * @spec https://dom.spec.whatwg.org/#dom-treewalker-nextnode
- * @based on WebKit's TreeWalker::nextNode
- * https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/TreeWalker.cpp?rev=220453#L228
- * @method
- * @return {Node|null}
- */
- nextNode: { value: function nextNode() {
- var node, result, firstChild, nextSibling;
- node = this._currentNode;
- result = NodeFilter.FILTER_ACCEPT;
-
- CHILDREN:
- while (true) {
- for (firstChild = node.firstChild;
- firstChild;
- firstChild = node.firstChild) {
- node = firstChild;
- result = this._internalFilter(node);
- if (result === NodeFilter.FILTER_ACCEPT) {
- this._currentNode = node;
- return node;
- } else if (result === NodeFilter.FILTER_REJECT) {
- break;
- }
- }
- for (nextSibling = NodeTraversal.nextSkippingChildren(node, this.root);
- nextSibling;
- nextSibling = NodeTraversal.nextSkippingChildren(node, this.root)) {
- node = nextSibling;
- result = this._internalFilter(node);
- if (result === NodeFilter.FILTER_ACCEPT) {
- this._currentNode = node;
- return node;
- } else if (result === NodeFilter.FILTER_SKIP) {
- continue CHILDREN;
- }
- }
- return null;
- }
- }},
-
- /** For compatibility with web-platform-tests. */
- toString: { value: function toString() {
- return "[object TreeWalker]";
- }},
-});
--- a/domino/domino-lib/UIEvent.js
+++ /dev/null
@@ -1,19 +1,0 @@
-"use strict";
-var Event = require('./Event');
-
-module.exports = UIEvent;
-
-function UIEvent() {
- // Just use the superclass constructor to initialize
- Event.call(this);
- this.view = null; // FF uses the current window
- this.detail = 0;
-}
-UIEvent.prototype = Object.create(Event.prototype, {
- constructor: { value: UIEvent },
- initUIEvent: { value: function(type, bubbles, cancelable, view, detail) {
- this.initEvent(type, bubbles, cancelable);
- this.view = view;
- this.detail = detail;
- }}
-});
--- a/domino/domino-lib/URL.js
+++ /dev/null
@@ -1,194 +1,0 @@
-"use strict";
-module.exports = URL;
-
-function URL(url) {
- if (!url) return Object.create(URL.prototype);
- // Can't use String.trim() since it defines whitespace differently than HTML
- this.url = url.replace(/^[ \t\n\r\f]+|[ \t\n\r\f]+$/g, "");
-
- // See http://tools.ietf.org/html/rfc3986#appendix-B
- // and https://url.spec.whatwg.org/#parsing
- var match = URL.pattern.exec(this.url);
- if (match) {
- if (match[2]) this.scheme = match[2];
- if (match[4]) {
- // parse username/password
- var userinfo = match[4].match(URL.userinfoPattern);
- if (userinfo) {
- this.username = userinfo[1];
- this.password = userinfo[3];
- match[4] = match[4].substring(userinfo[0].length);
- }
- if (match[4].match(URL.portPattern)) {
- var pos = match[4].lastIndexOf(':');
- this.host = match[4].substring(0, pos);
- this.port = match[4].substring(pos+1);
- }
- else {
- this.host = match[4];
- }
- }
- if (match[5]) this.path = match[5];
- if (match[6]) this.query = match[7];
- if (match[8]) this.fragment = match[9];
- }
-}
-
-URL.pattern = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/;
-URL.userinfoPattern = /^([^@:]*)(:([^@]*))?@/;
-URL.portPattern = /:\d+$/;
-URL.authorityPattern = /^[^:\/?#]+:\/\//;
-URL.hierarchyPattern = /^[^:\/?#]+:\//;
-
-// Return a percentEncoded version of s.
-// S should be a single-character string
-// XXX: needs to do utf-8 encoding?
-URL.percentEncode = function percentEncode(s) {
- var c = s.charCodeAt(0);
- if (c < 256) return "%" + c.toString(16);
- else throw Error("can't percent-encode codepoints > 255 yet");
-};
-
-URL.prototype = {
- constructor: URL,
-
- // XXX: not sure if this is the precise definition of absolute
- isAbsolute: function() { return !!this.scheme; },
- isAuthorityBased: function() {
- return URL.authorityPattern.test(this.url);
- },
- isHierarchical: function() {
- return URL.hierarchyPattern.test(this.url);
- },
-
- toString: function() {
- var s = "";
- if (this.scheme !== undefined) s += this.scheme + ":";
- if (this.isAbsolute()) {
- s += '//';
- if (this.username || this.password) {
- s += this.username || '';
- if (this.password) {
- s += ':' + this.password;
- }
- s += '@';
- }
- if (this.host) {
- s += this.host;
- }
- }
- if (this.port !== undefined) s += ":" + this.port;
- if (this.path !== undefined) s += this.path;
- if (this.query !== undefined) s += "?" + this.query;
- if (this.fragment !== undefined) s += "#" + this.fragment;
- return s;
- },
-
- // See: http://tools.ietf.org/html/rfc3986#section-5.2
- // and https://url.spec.whatwg.org/#constructors
- resolve: function(relative) {
- var base = this; // The base url we're resolving against
- var r = new URL(relative); // The relative reference url to resolve
- var t = new URL(); // The absolute target url we will return
-
- if (r.scheme !== undefined) {
- t.scheme = r.scheme;
- t.username = r.username;
- t.password = r.password;
- t.host = r.host;
- t.port = r.port;
- t.path = remove_dot_segments(r.path);
- t.query = r.query;
- }
- else {
- t.scheme = base.scheme;
- if (r.host !== undefined) {
- t.username = r.username;
- t.password = r.password;
- t.host = r.host;
- t.port = r.port;
- t.path = remove_dot_segments(r.path);
- t.query = r.query;
- }
- else {
- t.username = base.username;
- t.password = base.password;
- t.host = base.host;
- t.port = base.port;
- if (!r.path) { // undefined or empty
- t.path = base.path;
- if (r.query !== undefined)
- t.query = r.query;
- else
- t.query = base.query;
- }
- else {
- if (r.path.charAt(0) === "/") {
- t.path = remove_dot_segments(r.path);
- }
- else {
- t.path = merge(base.path, r.path);
- t.path = remove_dot_segments(t.path);
- }
- t.query = r.query;
- }
- }
- }
- t.fragment = r.fragment;
-
- return t.toString();
-
-
- function merge(basepath, refpath) {
- if (base.host !== undefined && !base.path)
- return "/" + refpath;
-
- var lastslash = basepath.lastIndexOf("/");
- if (lastslash === -1)
- return refpath;
- else
- return basepath.substring(0, lastslash+1) + refpath;
- }
-
- function remove_dot_segments(path) {
- if (!path) return path; // For "" or undefined
-
- var output = "";
- while(path.length > 0) {
- if (path === "." || path === "..") {
- path = "";
- break;
- }
-
- var twochars = path.substring(0,2);
- var threechars = path.substring(0,3);
- var fourchars = path.substring(0,4);
- if (threechars === "../") {
- path = path.substring(3);
- }
- else if (twochars === "./") {
- path = path.substring(2);
- }
- else if (threechars === "/./") {
- path = "/" + path.substring(3);
- }
- else if (twochars === "/." && path.length === 2) {
- path = "/";
- }
- else if (fourchars === "/../" ||
- (threechars === "/.." && path.length === 3)) {
- path = "/" + path.substring(4);
-
- output = output.replace(/\/?[^\/]*$/, "");
- }
- else {
- var segment = path.match(/(\/?([^\/]*))/)[0];
- output += segment;
- path = path.substring(segment.length);
- }
- }
-
- return output;
- }
- },
-};
--- a/domino/domino-lib/URLUtils.js
+++ /dev/null
@@ -1,270 +1,0 @@
-"use strict";
-var URL = require('./URL');
-
-module.exports = URLUtils;
-
-// Allow the `x == null` pattern. This is eslint's "null: 'ignore'" option,
-// but jshint doesn't support this.
-/* jshint eqeqeq: false */
-
-// This is an abstract superclass for Location, HTMLAnchorElement and
-// other types that have the standard complement of "URL decomposition
-// IDL attributes". This is now standardized as URLUtils, see:
-// https://url.spec.whatwg.org/#urlutils
-// Subclasses must define a getter/setter on href.
-// The getter and setter methods parse and rebuild the URL on each
-// invocation; there is no attempt to cache the value and be more efficient
-function URLUtils() {}
-URLUtils.prototype = Object.create(Object.prototype, {
-
- _url: { get: function() {
- // XXX: this should do the "Reinitialize url" steps, and "null" should
- // be a valid return value.
- return new URL(this.href);
- } },
-
- protocol: {
- get: function() {
- var url = this._url;
- if (url && url.scheme) return url.scheme + ":";
- else return ":";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute()) {
- v = v.replace(/:+$/, "");
- v = v.replace(/[^-+\.a-zA-Z0-9]/g, URL.percentEncode);
- if (v.length > 0) {
- url.scheme = v;
- output = url.toString();
- }
- }
- this.href = output;
- },
- },
-
- host: {
- get: function() {
- var url = this._url;
- if (url.isAbsolute() && url.isAuthorityBased())
- return url.host + (url.port ? (":" + url.port) : "");
- else
- return "";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute() && url.isAuthorityBased()) {
- v = v.replace(/[^-+\._~!$&'()*,;:=a-zA-Z0-9]/g, URL.percentEncode);
- if (v.length > 0) {
- url.host = v;
- delete url.port;
- output = url.toString();
- }
- }
- this.href = output;
- },
- },
-
- hostname: {
- get: function() {
- var url = this._url;
- if (url.isAbsolute() && url.isAuthorityBased())
- return url.host;
- else
- return "";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute() && url.isAuthorityBased()) {
- v = v.replace(/^\/+/, "");
- v = v.replace(/[^-+\._~!$&'()*,;:=a-zA-Z0-9]/g, URL.percentEncode);
- if (v.length > 0) {
- url.host = v;
- output = url.toString();
- }
- }
- this.href = output;
- },
- },
-
- port: {
- get: function() {
- var url = this._url;
- if (url.isAbsolute() && url.isAuthorityBased() && url.port!==undefined)
- return url.port;
- else
- return "";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute() && url.isAuthorityBased()) {
- v = '' + v;
- v = v.replace(/[^0-9].*$/, "");
- v = v.replace(/^0+/, "");
- if (v.length === 0) v = "0";
- if (parseInt(v, 10) <= 65535) {
- url.port = v;
- output = url.toString();
- }
- }
- this.href = output;
- },
- },
-
- pathname: {
- get: function() {
- var url = this._url;
- if (url.isAbsolute() && url.isHierarchical())
- return url.path;
- else
- return "";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute() && url.isHierarchical()) {
- if (v.charAt(0) !== "/")
- v = "/" + v;
- v = v.replace(/[^-+\._~!$&'()*,;:=@\/a-zA-Z0-9]/g, URL.percentEncode);
- url.path = v;
- output = url.toString();
- }
- this.href = output;
- },
- },
-
- search: {
- get: function() {
- var url = this._url;
- if (url.isAbsolute() && url.isHierarchical() && url.query!==undefined)
- return "?" + url.query;
- else
- return "";
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute() && url.isHierarchical()) {
- if (v.charAt(0) === "?") v = v.substring(1);
- v = v.replace(/[^-+\._~!$&'()*,;:=@\/?a-zA-Z0-9]/g, URL.percentEncode);
- url.query = v;
- output = url.toString();
- }
- this.href = output;
- },
- },
-
- hash: {
- get: function() {
- var url = this._url;
- if (url == null || url.fragment == null || url.fragment === '') {
- return "";
- } else {
- return "#" + url.fragment;
- }
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
-
- if (v.charAt(0) === "#") v = v.substring(1);
- v = v.replace(/[^-+\._~!$&'()*,;:=@\/?a-zA-Z0-9]/g, URL.percentEncode);
- url.fragment = v;
- output = url.toString();
-
- this.href = output;
- },
- },
-
- username: {
- get: function() {
- var url = this._url;
- return url.username || '';
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute()) {
- v = v.replace(/[\x00-\x1F\x7F-\uFFFF "#<>?`\/@\\:]/g, URL.percentEncode);
- url.username = v;
- output = url.toString();
- }
- this.href = output;
- },
- },
-
- password: {
- get: function() {
- var url = this._url;
- return url.password || '';
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- if (url.isAbsolute()) {
- if (v==='') {
- url.password = null;
- } else {
- v = v.replace(/[\x00-\x1F\x7F-\uFFFF "#<>?`\/@\\]/g, URL.percentEncode);
- url.password = v;
- }
- output = url.toString();
- }
- this.href = output;
- },
- },
-
- origin: { get: function() {
- var url = this._url;
- if (url == null) { return ''; }
- var originForPort = function(defaultPort) {
- var origin = [url.scheme, url.host, +url.port || defaultPort];
- // XXX should be "unicode serialization"
- return origin[0] + '://' + origin[1] +
- (origin[2] === defaultPort ? '' : (':' + origin[2]));
- };
- switch (url.scheme) {
- case 'ftp':
- return originForPort(21);
- case 'gopher':
- return originForPort(70);
- case 'http':
- case 'ws':
- return originForPort(80);
- case 'https':
- case 'wss':
- return originForPort(443);
- default:
- // this is what chrome does
- return url.scheme + '://';
- }
- } },
-
- /*
- searchParams: {
- get: function() {
- var url = this._url;
- // XXX
- },
- set: function(v) {
- var output = this.href;
- var url = new URL(output);
- // XXX
- this.href = output;
- },
- },
- */
-});
-
-URLUtils._inherit = function(proto) {
- // copy getters/setters from URLUtils to o.
- Object.getOwnPropertyNames(URLUtils.prototype).forEach(function(p) {
- if (p==='constructor' || p==='href') { return; }
- var desc = Object.getOwnPropertyDescriptor(URLUtils.prototype, p);
- Object.defineProperty(proto, p, desc);
- });
-};
--- a/domino/domino-lib/Window.js
+++ /dev/null
@@ -1,62 +1,0 @@
-"use strict";
-var DOMImplementation = require('./DOMImplementation');
-var EventTarget = require('./EventTarget');
-var Location = require('./Location');
-var sloppy = require('./sloppy');
-var utils = require('./utils');
-
-module.exports = Window;
-
-function Window(document) {
- this.document = document || new DOMImplementation(null).createHTMLDocument("");
- this.document._scripting_enabled = true;
- this.document.defaultView = this;
- this.location = new Location(this, this.document._address || 'about:blank');
-}
-
-Window.prototype = Object.create(EventTarget.prototype, {
- _run: { value: sloppy.Window_run },
- console: { value: console },
- history: { value: {
- back: utils.nyi,
- forward: utils.nyi,
- go: utils.nyi
- }},
- navigator: { value: require("./NavigatorID") },
-
- // Self-referential properties
- window: { get: function() { return this; }},
- self: { get: function() { return this; }},
- frames: { get: function() { return this; }},
-
- // Self-referential properties for a top-level window
- parent: { get: function() { return this; }},
- top: { get: function() { return this; }},
-
- // We don't support any other windows for now
- length: { value: 0 }, // no frames
- frameElement: { value: null }, // not part of a frame
- opener: { value: null }, // not opened by another window
-
- // The onload event handler.
- // XXX: need to support a bunch of other event types, too,
- // and have them interoperate with document.body.
-
- onload: {
- get: function() {
- return this._getEventHandler("load");
- },
- set: function(v) {
- this._setEventHandler("load", v);
- }
- },
-
- // XXX This is a completely broken implementation
- getComputedStyle: { value: function getComputedStyle(elt) {
- return elt.style;
- }}
-
-});
-
-utils.expose(require('./WindowTimers'), Window);
-utils.expose(require('./impl'), Window);
--- a/domino/domino-lib/WindowTimers.js
+++ /dev/null
@@ -1,11 +1,0 @@
-"use strict";
-
-// https://html.spec.whatwg.org/multipage/webappapis.html#windowtimers
-var WindowTimers = {
- setTimeout: setTimeout,
- clearTimeout: clearTimeout,
- setInterval: setInterval,
- clearInterval: clearInterval
-};
-
-module.exports = WindowTimers;
--- a/domino/domino-lib/attributes.js
+++ /dev/null
@@ -1,152 +1,0 @@
-"use strict";
-var utils = require('./utils');
-
-exports.property = function(attr) {
- if (Array.isArray(attr.type)) {
- var valid = Object.create(null);
- attr.type.forEach(function(val) {
- valid[val.value || val] = val.alias || val;
- });
- var missingValueDefault = attr.missing;
- if (missingValueDefault===undefined) { missingValueDefault = null; }
- var invalidValueDefault = attr.invalid;
- if (invalidValueDefault===undefined) { invalidValueDefault = missingValueDefault; }
- return {
- get: function() {
- var v = this._getattr(attr.name);
- if (v === null) return missingValueDefault;
-
- v = valid[v.toLowerCase()];
- if (v !== undefined) return v;
- if (invalidValueDefault !== null) return invalidValueDefault;
- return v;
- },
- set: function(v) {
- this._setattr(attr.name, v);
- }
- };
- }
- else if (attr.type === Boolean) {
- return {
- get: function() {
- return this.hasAttribute(attr.name);
- },
- set: function(v) {
- if (v) {
- this._setattr(attr.name, '');
- }
- else {
- this.removeAttribute(attr.name);
- }
- }
- };
- }
- else if (attr.type === Number ||
- attr.type === "long" ||
- attr.type === "unsigned long" ||
- attr.type === "limited unsigned long with fallback") {
- return numberPropDesc(attr);
- }
- else if (!attr.type || attr.type === String) {
- return {
- get: function() { return this._getattr(attr.name) || ''; },
- set: function(v) {
- if (attr.treatNullAsEmptyString && v === null) { v = ''; }
- this._setattr(attr.name, v);
- }
- };
- }
- else if (typeof attr.type === 'function') {
- return attr.type(attr.name, attr);
- }
- throw new Error('Invalid attribute definition');
-};
-
-// See http://www.whatwg.org/specs/web-apps/current-work/#reflect
-//
-// defval is the default value. If it is a function, then that function
-// will be invoked as a method of the element to obtain the default.
-// If no default is specified for a given attribute, then the default
-// depends on the type of the attribute, but since this function handles
-// 4 integer cases, you must specify the default value in each call
-//
-// min and max define a valid range for getting the attribute.
-//
-// setmin defines a minimum value when setting. If the value is less
-// than that, then throw INDEX_SIZE_ERR.
-//
-// Conveniently, JavaScript's parseInt function appears to be
-// compatible with HTML's 'rules for parsing integers'
-function numberPropDesc(a) {
- var def;
- if(typeof a.default === 'function') {
- def = a.default;
- }
- else if(typeof a.default === 'number') {
- def = function() { return a.default; };
- }
- else {
- def = function() { utils.assert(false, typeof a.default); };
- }
- var unsigned_long = (a.type === 'unsigned long');
- var signed_long = (a.type === 'long');
- var unsigned_fallback = (a.type === 'limited unsigned long with fallback');
- var min = a.min, max = a.max, setmin = a.setmin;
- if (min === undefined) {
- if (unsigned_long) min = 0;
- if (signed_long) min = -0x80000000;
- if (unsigned_fallback) min = 1;
- }
- if (max === undefined) {
- if (unsigned_long || signed_long || unsigned_fallback) max = 0x7FFFFFFF;
- }
-
- return {
- get: function() {
- var v = this._getattr(a.name);
- var n = a.float ? parseFloat(v) : parseInt(v, 10);
- if (v === null || !isFinite(n) || (min !== undefined && n < min) || (max !== undefined && n > max)) {
- return def.call(this);
- }
- if (unsigned_long || signed_long || unsigned_fallback) {
- if (!/^[ \t\n\f\r]*[-+]?[0-9]/.test(v)) { return def.call(this); }
- n = n|0; // jshint ignore:line
- }
- return n;
- },
- set: function(v) {
- if (!a.float) { v = Math.floor(v); }
- if (setmin !== undefined && v < setmin) {
- utils.IndexSizeError(a.name + ' set to ' + v);
- }
- if (unsigned_long) {
- v = (v < 0 || v > 0x7FFFFFFF) ? def.call(this) :
- (v|0); // jshint ignore:line
- } else if (unsigned_fallback) {
- v = (v < 1 || v > 0x7FFFFFFF) ? def.call(this) :
- (v|0); // jshint ignore:line
- } else if (signed_long) {
- v = (v < -0x80000000 || v > 0x7FFFFFFF) ? def.call(this) :
- (v|0); // jshint ignore:line
- }
- this._setattr(a.name, String(v));
- }
- };
-}
-
-// This is a utility function for setting up change handler functions
-// for attributes like 'id' that require special handling when they change.
-exports.registerChangeHandler = function(c, name, handler) {
- var p = c.prototype;
-
- // If p does not already have its own _attributeChangeHandlers
- // then create one for it, inheriting from the inherited
- // _attributeChangeHandlers. At the top (for the Element class) the
- // _attributeChangeHandlers object will be created with a null prototype.
- if (!Object.prototype.hasOwnProperty.call(p, '_attributeChangeHandlers')) {
- p._attributeChangeHandlers =
- Object.create(p._attributeChangeHandlers || null);
- }
-
- p._attributeChangeHandlers[name] = handler;
-};
--- a/domino/domino-lib/config.js
+++ /dev/null
@@ -1,7 +1,0 @@
-/*
- * This file defines Domino behaviour that can be externally configured.
- * To change these settings, set the relevant global property *before*
- * you call `require("domino")`.
- */
-
-exports.isApiWritable = !global.__domino_frozen__;
--- a/domino/domino-lib/cssparser.js
+++ /dev/null
@@ -1,6654 +1,0 @@
-/* jshint node:true, latedef:false */
-"use strict"; // jshint ignore:line
-/*!
-Parser-Lib
-Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-*/
-/* Version v0.2.5+domino1, Build time: 30-January-2016 05:13:03 */
-var parserlib = Object.create(null);
-(function(){
-
-/**
- * A generic base to inherit from for any object
- * that needs event handling.
- * @class EventTarget
- * @constructor
- */
-function EventTarget(){
-
- /**
- * The array of listeners for various events.
- * @type Object
- * @property _listeners
- * @private
- */
- this._listeners = Object.create(null);
-}
-
-EventTarget.prototype = {
-
- //restore constructor
- constructor: EventTarget,
-
- /**
- * Adds a listener for a given event type.
- * @param {String} type The type of event to add a listener for.
- * @param {Function} listener The function to call when the event occurs.
- * @return {void}
- * @method addListener
- */
- addListener: function(type, listener){
- if (!this._listeners[type]){
- this._listeners[type] = [];
- }
-
- this._listeners[type].push(listener);
- },
-
- /**
- * Fires an event based on the passed-in object.
- * @param {Object|String} event An object with at least a 'type' attribute
- * or a string indicating the event name.
- * @return {void}
- * @method fire
- */
- fire: function(event){
- if (typeof event === "string"){
- event = { type: event };
- }
- if (typeof event.target !== "undefined"){
- event.target = this;
- }
-
- if (typeof event.type === "undefined"){
- throw new Error("Event object missing 'type' property.");
- }
-
- if (this._listeners[event.type]){
-
- //create a copy of the array and use that so listeners can't chane
- var listeners = this._listeners[event.type].concat();
- for (var i=0, len=listeners.length; i < len; i++){
- listeners[i].call(this, event);
- }
- }
- },
-
- /**
- * Removes a listener for a given event type.
- * @param {String} type The type of event to remove a listener from.
- * @param {Function} listener The function to remove from the event.
- * @return {void}
- * @method removeListener
- */
- removeListener: function(type, listener){
- if (this._listeners[type]){
- var listeners = this._listeners[type];
- for (var i=0, len=listeners.length; i < len; i++){
- if (listeners[i] === listener){
- listeners.splice(i, 1);
- break;
- }
- }
-
-
- }
- }
-};
-/**
- * Convenient way to read through strings.
- * @namespace parserlib.util
- * @class StringReader
- * @constructor
- * @param {String} text The text to read.
- */
-function StringReader(text){
-
- /**
- * The input text with line endings normalized.
- * @property _input
- * @type String
- * @private
- */
- this._input = text.replace(/(\r|\n){1,2}/g, "\n");
-
-
- /**
- * The row for the character to be read next.
- * @property _line
- * @type int
- * @private
- */
- this._line = 1;
-
-
- /**
- * The column for the character to be read next.
- * @property _col
- * @type int
- * @private
- */
- this._col = 1;
-
- /**
- * The index of the character in the input to be read next.
- * @property _cursor
- * @type int
- * @private
- */
- this._cursor = 0;
-}
-
-StringReader.prototype = {
-
- //restore constructor
- constructor: StringReader,
-
- //-------------------------------------------------------------------------
- // Position info
- //-------------------------------------------------------------------------
-
- /**
- * Returns the column of the character to be read next.
- * @return {int} The column of the character to be read next.
- * @method getCol
- */
- getCol: function(){
- return this._col;
- },
-
- /**
- * Returns the row of the character to be read next.
- * @return {int} The row of the character to be read next.
- * @method getLine
- */
- getLine: function(){
- return this._line ;
- },
-
- /**
- * Determines if you're at the end of the input.
- * @return {Boolean} True if there's no more input, false otherwise.
- * @method eof
- */
- eof: function(){
- return (this._cursor === this._input.length);
- },
-
- //-------------------------------------------------------------------------
- // Basic reading
- //-------------------------------------------------------------------------
-
- /**
- * Reads the next character without advancing the cursor.
- * @param {int} count How many characters to look ahead (default is 1).
- * @return {String} The next character or null if there is no next character.
- * @method peek
- */
- peek: function(count){
- var c = null;
- count = (typeof count === "undefined" ? 1 : count);
-
- //if we're not at the end of the input...
- if (this._cursor < this._input.length){
-
- //get character and increment cursor and column
- c = this._input.charAt(this._cursor + count - 1);
- }
-
- return c;
- },
-
- /**
- * Reads the next character from the input and adjusts the row and column
- * accordingly.
- * @return {String} The next character or null if there is no next character.
- * @method read
- */
- read: function(){
- var c = null;
-
- //if we're not at the end of the input...
- if (this._cursor < this._input.length){
-
- //if the last character was a newline, increment row count
- //and reset column count
- if (this._input.charAt(this._cursor) === "\n"){
- this._line++;
- this._col=1;
- } else {
- this._col++;
- }
-
- //get character and increment cursor and column
- c = this._input.charAt(this._cursor++);
- }
-
- return c;
- },
-
- //-------------------------------------------------------------------------
- // Misc
- //-------------------------------------------------------------------------
-
- /**
- * Saves the current location so it can be returned to later.
- * @method mark
- * @return {void}
- */
- mark: function(){
- this._bookmark = {
- cursor: this._cursor,
- line: this._line,
- col: this._col
- };
- },
-
- reset: function(){
- if (this._bookmark){
- this._cursor = this._bookmark.cursor;
- this._line = this._bookmark.line;
- this._col = this._bookmark.col;
- delete this._bookmark;
- }
- },
-
- //-------------------------------------------------------------------------
- // Advanced reading
- //-------------------------------------------------------------------------
-
- /**
- * Reads up to and including the given string. Throws an error if that
- * string is not found.
- * @param {String} pattern The string to read.
- * @return {String} The string when it is found.
- * @throws Error when the string pattern is not found.
- * @method readTo
- */
- readTo: function(pattern){
-
- var buffer = "",
- c;
-
- /*
- * First, buffer must be the same length as the pattern.
- * Then, buffer must end with the pattern or else reach the
- * end of the input.
- */
- while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length){
- c = this.read();
- if (c){
- buffer += c;
- } else {
- throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
- }
- }
-
- return buffer;
-
- },
-
- /**
- * Reads characters while each character causes the given
- * filter function to return true. The function is passed
- * in each character and either returns true to continue
- * reading or false to stop.
- * @param {Function} filter The function to read on each character.
- * @return {String} The string made up of all characters that passed the
- * filter check.
- * @method readWhile
- */
- readWhile: function(filter){
-
- var buffer = "",
- c = this.read();
-
- while(c !== null && filter(c)){
- buffer += c;
- c = this.read();
- }
-
- return buffer;
-
- },
-
- /**
- * Reads characters that match either text or a regular expression and
- * returns those characters. If a match is found, the row and column
- * are adjusted; if no match is found, the reader's state is unchanged.
- * reading or false to stop.
- * @param {String|RegExp} matchter If a string, then the literal string
- * value is searched for. If a regular expression, then any string
- * matching the pattern is search for.
- * @return {String} The string made up of all characters that matched or
- * null if there was no match.
- * @method readMatch
- */
- readMatch: function(matcher){
-
- var source = this._input.substring(this._cursor),
- value = null;
-
- //if it's a string, just do a straight match
- if (typeof matcher === "string"){
- if (source.indexOf(matcher) === 0){
- value = this.readCount(matcher.length);
- }
- } else if (matcher instanceof RegExp){
- if (matcher.test(source)){
- value = this.readCount(RegExp.lastMatch.length);
- }
- }
-
- return value;
- },
-
-
- /**
- * Reads a given number of characters. If the end of the input is reached,
- * it reads only the remaining characters and does not throw an error.
- * @param {int} count The number of characters to read.
- * @return {String} The string made up the read characters.
- * @method readCount
- */
- readCount: function(count){
- var buffer = "";
-
- while(count--){
- buffer += this.read();
- }
-
- return buffer;
- }
-
-};
-/**
- * Type to use when a syntax error occurs.
- * @class SyntaxError
- * @namespace parserlib.util
- * @constructor
- * @param {String} message The error message.
- * @param {int} line The line at which the error occurred.
- * @param {int} col The column at which the error occurred.
- */
-function SyntaxError(message, line, col){
- Error.call(this);
- this.name = this.constructor.name;
-
- /**
- * The column at which the error occurred.
- * @type int
- * @property col
- */
- this.col = col;
-
- /**
- * The line at which the error occurred.
- * @type int
- * @property line
- */
- this.line = line;
-
- /**
- * The text representation of the unit.
- * @type String
- * @property text
- */
- this.message = message;
-
-}
-
-//inherit from Error
-SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
-SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
-/**
- * Base type to represent a single syntactic unit.
- * @class SyntaxUnit
- * @namespace parserlib.util
- * @constructor
- * @param {String} text The text of the unit.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function SyntaxUnit(text, line, col, type){
-
-
- /**
- * The column of text on which the unit resides.
- * @type int
- * @property col
- */
- this.col = col;
-
- /**
- * The line of text on which the unit resides.
- * @type int
- * @property line
- */
- this.line = line;
-
- /**
- * The text representation of the unit.
- * @type String
- * @property text
- */
- this.text = text;
-
- /**
- * The type of syntax unit.
- * @type int
- * @property type
- */
- this.type = type;
-}
-
-/**
- * Create a new syntax unit based solely on the given token.
- * Convenience method for creating a new syntax unit when
- * it represents a single token instead of multiple.
- * @param {Object} token The token object to represent.
- * @return {parserlib.util.SyntaxUnit} The object representing the token.
- * @static
- * @method fromToken
- */
-SyntaxUnit.fromToken = function(token){
- return new SyntaxUnit(token.value, token.startLine, token.startCol);
-};
-
-SyntaxUnit.prototype = {
-
- //restore constructor
- constructor: SyntaxUnit,
-
- /**
- * Returns the text representation of the unit.
- * @return {String} The text representation of the unit.
- * @method valueOf
- */
- valueOf: function(){
- return this.toString();
- },
-
- /**
- * Returns the text representation of the unit.
- * @return {String} The text representation of the unit.
- * @method toString
- */
- toString: function(){
- return this.text;
- }
-
-};
-
-/**
- * Generic TokenStream providing base functionality.
- * @class TokenStreamBase
- * @namespace parserlib.util
- * @constructor
- * @param {String|StringReader} input The text to tokenize or a reader from
- * which to read the input.
- */
-function TokenStreamBase(input, tokenData){
-
- /**
- * The string reader for easy access to the text.
- * @type StringReader
- * @property _reader
- * @private
- */
- this._reader = input ? new StringReader(input.toString()) : null;
-
- /**
- * Token object for the last consumed token.
- * @type Token
- * @property _token
- * @private
- */
- this._token = null;
-
- /**
- * The array of token information.
- * @type Array
- * @property _tokenData
- * @private
- */
- this._tokenData = tokenData;
-
- /**
- * Lookahead token buffer.
- * @type Array
- * @property _lt
- * @private
- */
- this._lt = [];
-
- /**
- * Lookahead token buffer index.
- * @type int
- * @property _ltIndex
- * @private
- */
- this._ltIndex = 0;
-
- this._ltIndexCache = [];
-}
-
-/**
- * Accepts an array of token information and outputs
- * an array of token data containing key-value mappings
- * and matching functions that the TokenStream needs.
- * @param {Array} tokens An array of token descriptors.
- * @return {Array} An array of processed token data.
- * @method createTokenData
- * @static
- */
-TokenStreamBase.createTokenData = function(tokens){
-
- var nameMap = [],
- typeMap = Object.create(null),
- tokenData = tokens.concat([]),
- i = 0,
- len = tokenData.length+1;
-
- tokenData.UNKNOWN = -1;
- tokenData.unshift({name:"EOF"});
-
- for (; i < len; i++){
- nameMap.push(tokenData[i].name);
- tokenData[tokenData[i].name] = i;
- if (tokenData[i].text){
- typeMap[tokenData[i].text] = i;
- }
- }
-
- tokenData.name = function(tt){
- return nameMap[tt];
- };
-
- tokenData.type = function(c){
- return typeMap[c];
- };
-
- return tokenData;
-};
-
-TokenStreamBase.prototype = {
-
- //restore constructor
- constructor: TokenStreamBase,
-
- //-------------------------------------------------------------------------
- // Matching methods
- //-------------------------------------------------------------------------
-
- /**
- * Determines if the next token matches the given token type.
- * If so, that token is consumed; if not, the token is placed
- * back onto the token stream. You can pass in any number of
- * token types and this will return true if any of the token
- * types is found.
- * @param {int|int[]} tokenTypes Either a single token type or an array of
- * token types that the next token might be. If an array is passed,
- * it's assumed that the token can be any of these.
- * @param {variant} channel (Optional) The channel to read from. If not
- * provided, reads from the default (unnamed) channel.
- * @return {Boolean} True if the token type matches, false if not.
- * @method match
- */
- match: function(tokenTypes, channel){
-
- //always convert to an array, makes things easier
- if (!(tokenTypes instanceof Array)){
- tokenTypes = [tokenTypes];
- }
-
- var tt = this.get(channel),
- i = 0,
- len = tokenTypes.length;
-
- while(i < len){
- if (tt === tokenTypes[i++]){
- return true;
- }
- }
-
- //no match found, put the token back
- this.unget();
- return false;
- },
-
- /**
- * Determines if the next token matches the given token type.
- * If so, that token is consumed; if not, an error is thrown.
- * @param {int|int[]} tokenTypes Either a single token type or an array of
- * token types that the next token should be. If an array is passed,
- * it's assumed that the token must be one of these.
- * @param {variant} channel (Optional) The channel to read from. If not
- * provided, reads from the default (unnamed) channel.
- * @return {void}
- * @method mustMatch
- */
- mustMatch: function(tokenTypes, channel){
-
- var token;
-
- //always convert to an array, makes things easier
- if (!(tokenTypes instanceof Array)){
- tokenTypes = [tokenTypes];
- }
-
- if (!this.match.apply(this, arguments)){
- token = this.LT(1);
- throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
- " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
- }
- },
-
- //-------------------------------------------------------------------------
- // Consuming methods
- //-------------------------------------------------------------------------
-
- /**
- * Keeps reading from the token stream until either one of the specified
- * token types is found or until the end of the input is reached.
- * @param {int|int[]} tokenTypes Either a single token type or an array of
- * token types that the next token should be. If an array is passed,
- * it's assumed that the token must be one of these.
- * @param {variant} channel (Optional) The channel to read from. If not
- * provided, reads from the default (unnamed) channel.
- * @return {void}
- * @method advance
- */
- advance: function(tokenTypes, channel){
-
- while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){
- this.get();
- }
-
- return this.LA(0);
- },
-
- /**
- * Consumes the next token from the token stream.
- * @return {int} The token type of the token that was just consumed.
- * @method get
- */
- get: function(channel){
-
- var tokenInfo = this._tokenData,
- i =0,
- token,
- info;
-
- //check the lookahead buffer first
- if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){
-
- i++;
- this._token = this._lt[this._ltIndex++];
- info = tokenInfo[this._token.type];
-
- //obey channels logic
- while((info.channel !== undefined && channel !== info.channel) &&
- this._ltIndex < this._lt.length){
- this._token = this._lt[this._ltIndex++];
- info = tokenInfo[this._token.type];
- i++;
- }
-
- //here be dragons
- if ((info.channel === undefined || channel === info.channel) &&
- this._ltIndex <= this._lt.length){
- this._ltIndexCache.push(i);
- return this._token.type;
- }
- }
-
- //call token retriever method
- token = this._getToken();
-
- //if it should be hidden, don't save a token
- if (token.type > -1 && !tokenInfo[token.type].hide){
-
- //apply token channel
- token.channel = tokenInfo[token.type].channel;
-
- //save for later
- this._token = token;
- this._lt.push(token);
-
- //save space that will be moved (must be done before array is truncated)
- this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
-
- //keep the buffer under 5 items
- if (this._lt.length > 5){
- this._lt.shift();
- }
-
- //also keep the shift buffer under 5 items
- if (this._ltIndexCache.length > 5){
- this._ltIndexCache.shift();
- }
-
- //update lookahead index
- this._ltIndex = this._lt.length;
- }
-
- /*
- * Skip to the next token if:
- * 1. The token type is marked as hidden.
- * 2. The token type has a channel specified and it isn't the current channel.
- */
- info = tokenInfo[token.type];
- if (info &&
- (info.hide ||
- (info.channel !== undefined && channel !== info.channel))){
- return this.get(channel);
- } else {
- //return just the type
- return token.type;
- }
- },
-
- /**
- * Looks ahead a certain number of tokens and returns the token type at
- * that position. This will throw an error if you lookahead past the
- * end of input, past the size of the lookahead buffer, or back past
- * the first token in the lookahead buffer.
- * @param {int} The index of the token type to retrieve. 0 for the
- * current token, 1 for the next, -1 for the previous, etc.
- * @return {int} The token type of the token in the given position.
- * @method LA
- */
- LA: function(index){
- var total = index,
- tt;
- if (index > 0){
- //TODO: Store 5 somewhere
- if (index > 5){
- throw new Error("Too much lookahead.");
- }
-
- //get all those tokens
- while(total){
- tt = this.get();
- total--;
- }
-
- //unget all those tokens
- while(total < index){
- this.unget();
- total++;
- }
- } else if (index < 0){
-
- if(this._lt[this._ltIndex+index]){
- tt = this._lt[this._ltIndex+index].type;
- } else {
- throw new Error("Too much lookbehind.");
- }
-
- } else {
- tt = this._token.type;
- }
-
- return tt;
-
- },
-
- /**
- * Looks ahead a certain number of tokens and returns the token at
- * that position. This will throw an error if you lookahead past the
- * end of input, past the size of the lookahead buffer, or back past
- * the first token in the lookahead buffer.
- * @param {int} The index of the token type to retrieve. 0 for the
- * current token, 1 for the next, -1 for the previous, etc.
- * @return {Object} The token of the token in the given position.
- * @method LA
- */
- LT: function(index){
-
- //lookahead first to prime the token buffer
- this.LA(index);
-
- //now find the token, subtract one because _ltIndex is already at the next index
- return this._lt[this._ltIndex+index-1];
- },
-
- /**
- * Returns the token type for the next token in the stream without
- * consuming it.
- * @return {int} The token type of the next token in the stream.
- * @method peek
- */
- peek: function(){
- return this.LA(1);
- },
-
- /**
- * Returns the actual token object for the last consumed token.
- * @return {Token} The token object for the last consumed token.
- * @method token
- */
- token: function(){
- return this._token;
- },
-
- /**
- * Returns the name of the token for the given token type.
- * @param {int} tokenType The type of token to get the name of.
- * @return {String} The name of the token or "UNKNOWN_TOKEN" for any
- * invalid token type.
- * @method tokenName
- */
- tokenName: function(tokenType){
- if (tokenType < 0 || tokenType > this._tokenData.length){
- return "UNKNOWN_TOKEN";
- } else {
- return this._tokenData[tokenType].name;
- }
- },
-
- /**
- * Returns the token type value for the given token name.
- * @param {String} tokenName The name of the token whose value should be returned.
- * @return {int} The token type value for the given token name or -1
- * for an unknown token.
- * @method tokenName
- */
- tokenType: function(tokenName){
- return this._tokenData[tokenName] || -1;
- },
-
- /**
- * Returns the last consumed token to the token stream.
- * @method unget
- */
- unget: function(){
- //if (this._ltIndex > -1){
- if (this._ltIndexCache.length){
- this._ltIndex -= this._ltIndexCache.pop();//--;
- this._token = this._lt[this._ltIndex - 1];
- } else {
- throw new Error("Too much lookahead.");
- }
- }
-
-};
-
-
-parserlib.util = {
-__proto__ : null,
-StringReader: StringReader,
-SyntaxError : SyntaxError,
-SyntaxUnit : SyntaxUnit,
-EventTarget : EventTarget,
-TokenStreamBase : TokenStreamBase
-};
-})();
-/*
-Parser-Lib
-Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-*/
-/* Version v0.2.5+domino1, Build time: 30-January-2016 05:13:03 */
-(function(){
-var EventTarget = parserlib.util.EventTarget,
-TokenStreamBase = parserlib.util.TokenStreamBase,
-StringReader = parserlib.util.StringReader, // jshint ignore:line
-SyntaxError = parserlib.util.SyntaxError,
-SyntaxUnit = parserlib.util.SyntaxUnit;
-
-var Colors = {
- __proto__ :null,
- aliceblue :"#f0f8ff",
- antiquewhite :"#faebd7",
- aqua :"#00ffff",
- aquamarine :"#7fffd4",
- azure :"#f0ffff",
- beige :"#f5f5dc",
- bisque :"#ffe4c4",
- black :"#000000",
- blanchedalmond :"#ffebcd",
- blue :"#0000ff",
- blueviolet :"#8a2be2",
- brown :"#a52a2a",
- burlywood :"#deb887",
- cadetblue :"#5f9ea0",
- chartreuse :"#7fff00",
- chocolate :"#d2691e",
- coral :"#ff7f50",
- cornflowerblue :"#6495ed",
- cornsilk :"#fff8dc",
- crimson :"#dc143c",
- cyan :"#00ffff",
- darkblue :"#00008b",
- darkcyan :"#008b8b",
- darkgoldenrod :"#b8860b",
- darkgray :"#a9a9a9",
- darkgrey :"#a9a9a9",
- darkgreen :"#006400",
- darkkhaki :"#bdb76b",
- darkmagenta :"#8b008b",
- darkolivegreen :"#556b2f",
- darkorange :"#ff8c00",
- darkorchid :"#9932cc",
- darkred :"#8b0000",
- darksalmon :"#e9967a",
- darkseagreen :"#8fbc8f",
- darkslateblue :"#483d8b",
- darkslategray :"#2f4f4f",
- darkslategrey :"#2f4f4f",
- darkturquoise :"#00ced1",
- darkviolet :"#9400d3",
- deeppink :"#ff1493",
- deepskyblue :"#00bfff",
- dimgray :"#696969",
- dimgrey :"#696969",
- dodgerblue :"#1e90ff",
- firebrick :"#b22222",
- floralwhite :"#fffaf0",
- forestgreen :"#228b22",
- fuchsia :"#ff00ff",
- gainsboro :"#dcdcdc",
- ghostwhite :"#f8f8ff",
- gold :"#ffd700",
- goldenrod :"#daa520",
- gray :"#808080",
- grey :"#808080",
- green :"#008000",
- greenyellow :"#adff2f",
- honeydew :"#f0fff0",
- hotpink :"#ff69b4",
- indianred :"#cd5c5c",
- indigo :"#4b0082",
- ivory :"#fffff0",
- khaki :"#f0e68c",
- lavender :"#e6e6fa",
- lavenderblush :"#fff0f5",
- lawngreen :"#7cfc00",
- lemonchiffon :"#fffacd",
- lightblue :"#add8e6",
- lightcoral :"#f08080",
- lightcyan :"#e0ffff",
- lightgoldenrodyellow :"#fafad2",
- lightgray :"#d3d3d3",
- lightgrey :"#d3d3d3",
- lightgreen :"#90ee90",
- lightpink :"#ffb6c1",
- lightsalmon :"#ffa07a",
- lightseagreen :"#20b2aa",
- lightskyblue :"#87cefa",
- lightslategray :"#778899",
- lightslategrey :"#778899",
- lightsteelblue :"#b0c4de",
- lightyellow :"#ffffe0",
- lime :"#00ff00",
- limegreen :"#32cd32",
- linen :"#faf0e6",
- magenta :"#ff00ff",
- maroon :"#800000",
- mediumaquamarine:"#66cdaa",
- mediumblue :"#0000cd",
- mediumorchid :"#ba55d3",
- mediumpurple :"#9370d8",
- mediumseagreen :"#3cb371",
- mediumslateblue :"#7b68ee",
- mediumspringgreen :"#00fa9a",
- mediumturquoise :"#48d1cc",
- mediumvioletred :"#c71585",
- midnightblue :"#191970",
- mintcream :"#f5fffa",
- mistyrose :"#ffe4e1",
- moccasin :"#ffe4b5",
- navajowhite :"#ffdead",
- navy :"#000080",
- oldlace :"#fdf5e6",
- olive :"#808000",
- olivedrab :"#6b8e23",
- orange :"#ffa500",
- orangered :"#ff4500",
- orchid :"#da70d6",
- palegoldenrod :"#eee8aa",
- palegreen :"#98fb98",
- paleturquoise :"#afeeee",
- palevioletred :"#d87093",
- papayawhip :"#ffefd5",
- peachpuff :"#ffdab9",
- peru :"#cd853f",
- pink :"#ffc0cb",
- plum :"#dda0dd",
- powderblue :"#b0e0e6",
- purple :"#800080",
- red :"#ff0000",
- rosybrown :"#bc8f8f",
- royalblue :"#4169e1",
- saddlebrown :"#8b4513",
- salmon :"#fa8072",
- sandybrown :"#f4a460",
- seagreen :"#2e8b57",
- seashell :"#fff5ee",
- sienna :"#a0522d",
- silver :"#c0c0c0",
- skyblue :"#87ceeb",
- slateblue :"#6a5acd",
- slategray :"#708090",
- slategrey :"#708090",
- snow :"#fffafa",
- springgreen :"#00ff7f",
- steelblue :"#4682b4",
- tan :"#d2b48c",
- teal :"#008080",
- thistle :"#d8bfd8",
- tomato :"#ff6347",
- turquoise :"#40e0d0",
- violet :"#ee82ee",
- wheat :"#f5deb3",
- white :"#ffffff",
- whitesmoke :"#f5f5f5",
- yellow :"#ffff00",
- yellowgreen :"#9acd32",
- //'currentColor' color keyword http://www.w3.org/TR/css3-color/#currentcolor
- currentColor :"The value of the 'color' property.",
- //CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system
- activeBorder :"Active window border.",
- activecaption :"Active window caption.",
- appworkspace :"Background color of multiple document interface.",
- background :"Desktop background.",
- buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
- buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
- buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
- buttontext :"Text on push buttons.",
- captiontext :"Text in caption, size box, and scrollbar arrow box.",
- graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
- greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
- highlight :"Item(s) selected in a control.",
- highlighttext :"Text of item(s) selected in a control.",
- inactiveborder :"Inactive window border.",
- inactivecaption :"Inactive window caption.",
- inactivecaptiontext :"Color of text in an inactive caption.",
- infobackground :"Background color for tooltip controls.",
- infotext :"Text color for tooltip controls.",
- menu :"Menu background.",
- menutext :"Text in menus.",
- scrollbar :"Scroll bar gray area.",
- threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
- threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
- threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
- threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
- threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
- window :"Window background.",
- windowframe :"Window frame.",
- windowtext :"Text in windows."
-};
-/**
- * Represents a selector combinator (whitespace, +, >).
- * @namespace parserlib.css
- * @class Combinator
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {String} text The text representation of the unit.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function Combinator(text, line, col){
-
- SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
-
- /**
- * The type of modifier.
- * @type String
- * @property type
- */
- this.type = "unknown";
-
- //pretty simple
- if (/^\s+$/.test(text)){
- this.type = "descendant";
- } else if (text === ">"){
- this.type = "child";
- } else if (text === "+"){
- this.type = "adjacent-sibling";
- } else if (text === "~"){
- this.type = "sibling";
- }
-
-}
-
-Combinator.prototype = new SyntaxUnit();
-Combinator.prototype.constructor = Combinator;
-
-/**
- * Represents a media feature, such as max-width:500.
- * @namespace parserlib.css
- * @class MediaFeature
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {SyntaxUnit} name The name of the feature.
- * @param {SyntaxUnit} value The value of the feature or null if none.
- */
-function MediaFeature(name, value){
-
- SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
-
- /**
- * The name of the media feature
- * @type String
- * @property name
- */
- this.name = name;
-
- /**
- * The value for the feature or null if there is none.
- * @type SyntaxUnit
- * @property value
- */
- this.value = value;
-}
-
-MediaFeature.prototype = new SyntaxUnit();
-MediaFeature.prototype.constructor = MediaFeature;
-
-/**
- * Represents an individual media query.
- * @namespace parserlib.css
- * @class MediaQuery
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {String} modifier The modifier "not" or "only" (or null).
- * @param {String} mediaType The type of media (i.e., "print").
- * @param {Array} parts Array of selectors parts making up this selector.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function MediaQuery(modifier, mediaType, features, line, col){
-
- SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
-
- /**
- * The media modifier ("not" or "only")
- * @type String
- * @property modifier
- */
- this.modifier = modifier;
-
- /**
- * The mediaType (i.e., "print")
- * @type String
- * @property mediaType
- */
- this.mediaType = mediaType;
-
- /**
- * The parts that make up the selector.
- * @type Array
- * @property features
- */
- this.features = features;
-
-}
-
-MediaQuery.prototype = new SyntaxUnit();
-MediaQuery.prototype.constructor = MediaQuery;
-
-
-/**
- * A CSS3 parser.
- * @namespace parserlib.css
- * @class Parser
- * @constructor
- * @param {Object} options (Optional) Various options for the parser:
- * starHack (true|false) to allow IE6 star hack as valid,
- * underscoreHack (true|false) to interpret leading underscores
- * as IE6-7 targeting for known properties, ieFilters (true|false)
- * to indicate that IE < 8 filters should be accepted and not throw
- * syntax errors.
- */
-function Parser(options){
-
- //inherit event functionality
- EventTarget.call(this);
-
-
- this.options = options || {};
-
- this._tokenStream = null;
-}
-
-//Static constants
-Parser.DEFAULT_TYPE = 0;
-Parser.COMBINATOR_TYPE = 1;
-Parser.MEDIA_FEATURE_TYPE = 2;
-Parser.MEDIA_QUERY_TYPE = 3;
-Parser.PROPERTY_NAME_TYPE = 4;
-Parser.PROPERTY_VALUE_TYPE = 5;
-Parser.PROPERTY_VALUE_PART_TYPE = 6;
-Parser.SELECTOR_TYPE = 7;
-Parser.SELECTOR_PART_TYPE = 8;
-Parser.SELECTOR_SUB_PART_TYPE = 9;
-
-Parser.prototype = function(){
-
- var proto = new EventTarget(), //new prototype
- prop,
- additions = {
- __proto__: null,
-
- //restore constructor
- constructor: Parser,
-
- //instance constants - yuck
- DEFAULT_TYPE : 0,
- COMBINATOR_TYPE : 1,
- MEDIA_FEATURE_TYPE : 2,
- MEDIA_QUERY_TYPE : 3,
- PROPERTY_NAME_TYPE : 4,
- PROPERTY_VALUE_TYPE : 5,
- PROPERTY_VALUE_PART_TYPE : 6,
- SELECTOR_TYPE : 7,
- SELECTOR_PART_TYPE : 8,
- SELECTOR_SUB_PART_TYPE : 9,
-
- //-----------------------------------------------------------------
- // Grammar
- //-----------------------------------------------------------------
-
- _stylesheet: function(){
-
- /*
- * stylesheet
- * : [ CHARSET_SYM S* STRING S* ';' ]?
- * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
- * [ namespace [S|CDO|CDC]* ]*
- * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- count,
- token,
- tt;
-
- this.fire("startstylesheet");
-
- //try to read character set
- this._charset();
-
- this._skipCruft();
-
- //try to read imports - may be more than one
- while (tokenStream.peek() === Tokens.IMPORT_SYM){
- this._import();
- this._skipCruft();
- }
-
- //try to read namespaces - may be more than one
- while (tokenStream.peek() === Tokens.NAMESPACE_SYM){
- this._namespace();
- this._skipCruft();
- }
-
- //get the next token
- tt = tokenStream.peek();
-
- //try to read the rest
- while(tt > Tokens.EOF){
-
- try {
-
- switch(tt){
- case Tokens.MEDIA_SYM:
- this._media();
- this._skipCruft();
- break;
- case Tokens.PAGE_SYM:
- this._page();
- this._skipCruft();
- break;
- case Tokens.FONT_FACE_SYM:
- this._font_face();
- this._skipCruft();
- break;
- case Tokens.KEYFRAMES_SYM:
- this._keyframes();
- this._skipCruft();
- break;
- case Tokens.VIEWPORT_SYM:
- this._viewport();
- this._skipCruft();
- break;
- case Tokens.DOCUMENT_SYM:
- this._document();
- this._skipCruft();
- break;
- case Tokens.UNKNOWN_SYM: //unknown @ rule
- tokenStream.get();
- if (!this.options.strict){
-
- //fire error event
- this.fire({
- type: "error",
- error: null,
- message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
- line: tokenStream.LT(0).startLine,
- col: tokenStream.LT(0).startCol
- });
-
- //skip braces
- count=0;
- while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE){
- count++; //keep track of nesting depth
- }
-
- while(count){
- tokenStream.advance([Tokens.RBRACE]);
- count--;
- }
-
- } else {
- //not a syntax error, rethrow it
- throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
- }
- break;
- case Tokens.S:
- this._readWhitespace();
- break;
- default:
- if(!this._ruleset()){
-
- //error handling for known issues
- switch(tt){
- case Tokens.CHARSET_SYM:
- token = tokenStream.LT(1);
- this._charset(false);
- throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
- case Tokens.IMPORT_SYM:
- token = tokenStream.LT(1);
- this._import(false);
- throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
- case Tokens.NAMESPACE_SYM:
- token = tokenStream.LT(1);
- this._namespace(false);
- throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
- default:
- tokenStream.get(); //get the last token
- this._unexpectedToken(tokenStream.token());
- }
-
- }
- }
- } catch(ex) {
- if (ex instanceof SyntaxError && !this.options.strict){
- this.fire({
- type: "error",
- error: ex,
- message: ex.message,
- line: ex.line,
- col: ex.col
- });
- } else {
- throw ex;
- }
- }
-
- tt = tokenStream.peek();
- }
-
- if (tt !== Tokens.EOF){
- this._unexpectedToken(tokenStream.token());
- }
-
- this.fire("endstylesheet");
- },
-
- _charset: function(emit){
- var tokenStream = this._tokenStream,
- charset,
- token,
- line,
- col;
-
- if (tokenStream.match(Tokens.CHARSET_SYM)){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this._readWhitespace();
- tokenStream.mustMatch(Tokens.STRING);
-
- token = tokenStream.token();
- charset = token.value;
-
- this._readWhitespace();
- tokenStream.mustMatch(Tokens.SEMICOLON);
-
- if (emit !== false){
- this.fire({
- type: "charset",
- charset:charset,
- line: line,
- col: col
- });
- }
- }
- },
-
- _import: function(emit){
- /*
- * import
- * : IMPORT_SYM S*
- * [STRING|URI] S* media_query_list? ';' S*
- */
-
- var tokenStream = this._tokenStream,
- uri,
- importToken,
- mediaList = [];
-
- //read import symbol
- tokenStream.mustMatch(Tokens.IMPORT_SYM);
- importToken = tokenStream.token();
- this._readWhitespace();
-
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
-
- //grab the URI value
- uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
-
- this._readWhitespace();
-
- mediaList = this._media_query_list();
-
- //must end with a semicolon
- tokenStream.mustMatch(Tokens.SEMICOLON);
- this._readWhitespace();
-
- if (emit !== false){
- this.fire({
- type: "import",
- uri: uri,
- media: mediaList,
- line: importToken.startLine,
- col: importToken.startCol
- });
- }
-
- },
-
- _namespace: function(emit){
- /*
- * namespace
- * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S*
- */
-
- var tokenStream = this._tokenStream,
- line,
- col,
- prefix,
- uri;
-
- //read import symbol
- tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- this._readWhitespace();
-
- //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT
- if (tokenStream.match(Tokens.IDENT)){
- prefix = tokenStream.token().value;
- this._readWhitespace();
- }
-
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
- /*if (!tokenStream.match(Tokens.STRING)){
- tokenStream.mustMatch(Tokens.URI);
- }*/
-
- //grab the URI value
- uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
-
- this._readWhitespace();
-
- //must end with a semicolon
- tokenStream.mustMatch(Tokens.SEMICOLON);
- this._readWhitespace();
-
- if (emit !== false){
- this.fire({
- type: "namespace",
- prefix: prefix,
- uri: uri,
- line: line,
- col: col
- });
- }
-
- },
-
- _media: function(){
- /*
- * media
- * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- line,
- col,
- mediaList;// = [];
-
- //look for @media
- tokenStream.mustMatch(Tokens.MEDIA_SYM);
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this._readWhitespace();
-
- mediaList = this._media_query_list();
-
- tokenStream.mustMatch(Tokens.LBRACE);
- this._readWhitespace();
-
- this.fire({
- type: "startmedia",
- media: mediaList,
- line: line,
- col: col
- });
-
- while(true) {
- if (tokenStream.peek() === Tokens.PAGE_SYM){
- this._page();
- } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
- this._font_face();
- } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
- this._viewport();
- } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM){
- this._document();
- } else if (!this._ruleset()){
- break;
- }
- }
-
- tokenStream.mustMatch(Tokens.RBRACE);
- this._readWhitespace();
-
- this.fire({
- type: "endmedia",
- media: mediaList,
- line: line,
- col: col
- });
- },
-
-
- //CSS3 Media Queries
- _media_query_list: function(){
- /*
- * media_query_list
- * : S* [media_query [ ',' S* media_query ]* ]?
- * ;
- */
- var tokenStream = this._tokenStream,
- mediaList = [];
-
-
- this._readWhitespace();
-
- if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN){
- mediaList.push(this._media_query());
- }
-
- while(tokenStream.match(Tokens.COMMA)){
- this._readWhitespace();
- mediaList.push(this._media_query());
- }
-
- return mediaList;
- },
-
- /*
- * Note: "expression" in the grammar maps to the _media_expression
- * method.
-
- */
- _media_query: function(){
- /*
- * media_query
- * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
- * | expression [ AND S* expression ]*
- * ;
- */
- var tokenStream = this._tokenStream,
- type = null,
- ident = null,
- token = null,
- expressions = [];
-
- if (tokenStream.match(Tokens.IDENT)){
- ident = tokenStream.token().value.toLowerCase();
-
- //since there's no custom tokens for these, need to manually check
- if (ident !== "only" && ident !== "not"){
- tokenStream.unget();
- ident = null;
- } else {
- token = tokenStream.token();
- }
- }
-
- this._readWhitespace();
-
- if (tokenStream.peek() === Tokens.IDENT){
- type = this._media_type();
- if (token === null){
- token = tokenStream.token();
- }
- } else if (tokenStream.peek() === Tokens.LPAREN){
- if (token === null){
- token = tokenStream.LT(1);
- }
- expressions.push(this._media_expression());
- }
-
- if (type === null && expressions.length === 0){
- return null;
- } else {
- this._readWhitespace();
- while (tokenStream.match(Tokens.IDENT)){
- if (tokenStream.token().value.toLowerCase() !== "and"){
- this._unexpectedToken(tokenStream.token());
- }
-
- this._readWhitespace();
- expressions.push(this._media_expression());
- }
- }
-
- return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
- },
-
- //CSS3 Media Queries
- _media_type: function(){
- /*
- * media_type
- * : IDENT
- * ;
- */
- return this._media_feature();
- },
-
- /**
- * Note: in CSS3 Media Queries, this is called "expression".
- * Renamed here to avoid conflict with CSS3 Selectors
- * definition of "expression". Also note that "expr" in the
- * grammar now maps to "expression" from CSS3 selectors.
- * @method _media_expression
- * @private
- */
- _media_expression: function(){
- /*
- * expression
- * : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- feature = null,
- token,
- expression = null;
-
- tokenStream.mustMatch(Tokens.LPAREN);
-
- feature = this._media_feature();
- this._readWhitespace();
-
- if (tokenStream.match(Tokens.COLON)){
- this._readWhitespace();
- token = tokenStream.LT(1);
- expression = this._expression();
- }
-
- tokenStream.mustMatch(Tokens.RPAREN);
- this._readWhitespace();
-
- return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null));
- },
-
- //CSS3 Media Queries
- _media_feature: function(){
- /*
- * media_feature
- * : IDENT
- * ;
- */
- var tokenStream = this._tokenStream;
-
- this._readWhitespace();
-
- tokenStream.mustMatch(Tokens.IDENT);
-
- return SyntaxUnit.fromToken(tokenStream.token());
- },
-
- //CSS3 Paged Media
- _page: function(){
- /*
- * page:
- * PAGE_SYM S* IDENT? pseudo_page? S*
- * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- line,
- col,
- identifier = null,
- pseudoPage = null;
-
- //look for @page
- tokenStream.mustMatch(Tokens.PAGE_SYM);
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this._readWhitespace();
-
- if (tokenStream.match(Tokens.IDENT)){
- identifier = tokenStream.token().value;
-
- //The value 'auto' may not be used as a page name and MUST be treated as a syntax error.
- if (identifier.toLowerCase() === "auto"){
- this._unexpectedToken(tokenStream.token());
- }
- }
-
- //see if there's a colon upcoming
- if (tokenStream.peek() === Tokens.COLON){
- pseudoPage = this._pseudo_page();
- }
-
- this._readWhitespace();
-
- this.fire({
- type: "startpage",
- id: identifier,
- pseudo: pseudoPage,
- line: line,
- col: col
- });
-
- this._readDeclarations(true, true);
-
- this.fire({
- type: "endpage",
- id: identifier,
- pseudo: pseudoPage,
- line: line,
- col: col
- });
-
- },
-
- //CSS3 Paged Media
- _margin: function(){
- /*
- * margin :
- * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- line,
- col,
- marginSym = this._margin_sym();
-
- if (marginSym){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this.fire({
- type: "startpagemargin",
- margin: marginSym,
- line: line,
- col: col
- });
-
- this._readDeclarations(true);
-
- this.fire({
- type: "endpagemargin",
- margin: marginSym,
- line: line,
- col: col
- });
- return true;
- } else {
- return false;
- }
- },
-
- //CSS3 Paged Media
- _margin_sym: function(){
-
- /*
- * margin_sym :
- * TOPLEFTCORNER_SYM |
- * TOPLEFT_SYM |
- * TOPCENTER_SYM |
- * TOPRIGHT_SYM |
- * TOPRIGHTCORNER_SYM |
- * BOTTOMLEFTCORNER_SYM |
- * BOTTOMLEFT_SYM |
- * BOTTOMCENTER_SYM |
- * BOTTOMRIGHT_SYM |
- * BOTTOMRIGHTCORNER_SYM |
- * LEFTTOP_SYM |
- * LEFTMIDDLE_SYM |
- * LEFTBOTTOM_SYM |
- * RIGHTTOP_SYM |
- * RIGHTMIDDLE_SYM |
- * RIGHTBOTTOM_SYM
- * ;
- */
-
- var tokenStream = this._tokenStream;
-
- if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
- Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
- Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
- Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
- Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
- Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
- Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM]))
- {
- return SyntaxUnit.fromToken(tokenStream.token());
- } else {
- return null;
- }
-
- },
-
- _pseudo_page: function(){
- /*
- * pseudo_page
- * : ':' IDENT
- * ;
- */
-
- var tokenStream = this._tokenStream;
-
- tokenStream.mustMatch(Tokens.COLON);
- tokenStream.mustMatch(Tokens.IDENT);
-
- //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed
-
- return tokenStream.token().value;
- },
-
- _font_face: function(){
- /*
- * font_face
- * : FONT_FACE_SYM S*
- * '{' S* declaration [ ';' S* declaration ]* '}' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- line,
- col;
-
- //look for @page
- tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this._readWhitespace();
-
- this.fire({
- type: "startfontface",
- line: line,
- col: col
- });
-
- this._readDeclarations(true);
-
- this.fire({
- type: "endfontface",
- line: line,
- col: col
- });
- },
-
- _viewport: function(){
- /*
- * viewport
- * : VIEWPORT_SYM S*
- * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
- * ;
- */
- var tokenStream = this._tokenStream,
- line,
- col;
-
- tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
-
- this._readWhitespace();
-
- this.fire({
- type: "startviewport",
- line: line,
- col: col
- });
-
- this._readDeclarations(true);
-
- this.fire({
- type: "endviewport",
- line: line,
- col: col
- });
-
- },
-
- _document: function(){
- /*
- * document
- * : DOCUMENT_SYM S*
- * _document_function [ ',' S* _document_function ]* S*
- * '{' S* ruleset* '}'
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token,
- functions = [],
- prefix = "";
-
- tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
- token = tokenStream.token();
- if (/^@\-([^\-]+)\-/.test(token.value)) {
- prefix = RegExp.$1;
- }
-
- this._readWhitespace();
- functions.push(this._document_function());
-
- while(tokenStream.match(Tokens.COMMA)) {
- this._readWhitespace();
- functions.push(this._document_function());
- }
-
- tokenStream.mustMatch(Tokens.LBRACE);
- this._readWhitespace();
-
- this.fire({
- type: "startdocument",
- functions: functions,
- prefix: prefix,
- line: token.startLine,
- col: token.startCol
- });
-
- while(true) {
- if (tokenStream.peek() === Tokens.PAGE_SYM){
- this._page();
- } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
- this._font_face();
- } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
- this._viewport();
- } else if (tokenStream.peek() === Tokens.MEDIA_SYM){
- this._media();
- } else if (!this._ruleset()){
- break;
- }
- }
-
- tokenStream.mustMatch(Tokens.RBRACE);
- this._readWhitespace();
-
- this.fire({
- type: "enddocument",
- functions: functions,
- prefix: prefix,
- line: token.startLine,
- col: token.startCol
- });
- },
-
- _document_function: function(){
- /*
- * document_function
- * : function | URI S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value;
-
- if (tokenStream.match(Tokens.URI)) {
- value = tokenStream.token().value;
- this._readWhitespace();
- } else {
- value = this._function();
- }
-
- return value;
- },
-
- _operator: function(inFunction){
-
- /*
- * operator (outside function)
- * : '/' S* | ',' S* | /( empty )/
- * operator (inside function)
- * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token = null;
-
- if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
- (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
- token = tokenStream.token();
- this._readWhitespace();
- }
- return token ? PropertyValuePart.fromToken(token) : null;
-
- },
-
- _combinator: function(){
-
- /*
- * combinator
- * : PLUS S* | GREATER S* | TILDE S* | S+
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value = null,
- token;
-
- if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){
- token = tokenStream.token();
- value = new Combinator(token.value, token.startLine, token.startCol);
- this._readWhitespace();
- }
-
- return value;
- },
-
- _unary_operator: function(){
-
- /*
- * unary_operator
- * : '-' | '+'
- * ;
- */
-
- var tokenStream = this._tokenStream;
-
- if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){
- return tokenStream.token().value;
- } else {
- return null;
- }
- },
-
- _property: function(){
-
- /*
- * property
- * : IDENT S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value = null,
- hack = null,
- tokenValue,
- token,
- line,
- col;
-
- //check for star hack - throws error if not allowed
- if (tokenStream.peek() === Tokens.STAR && this.options.starHack){
- tokenStream.get();
- token = tokenStream.token();
- hack = token.value;
- line = token.startLine;
- col = token.startCol;
- }
-
- if(tokenStream.match(Tokens.IDENT)){
- token = tokenStream.token();
- tokenValue = token.value;
-
- //check for underscore hack - no error if not allowed because it's valid CSS syntax
- if (tokenValue.charAt(0) === "_" && this.options.underscoreHack){
- hack = "_";
- tokenValue = tokenValue.substring(1);
- }
-
- value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol));
- this._readWhitespace();
- }
-
- return value;
- },
-
- //Augmented with CSS3 Selectors
- _ruleset: function(){
- /*
- * ruleset
- * : selectors_group
- * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- tt,
- selectors;
-
-
- /*
- * Error Recovery: If even a single selector fails to parse,
- * then the entire ruleset should be thrown away.
- */
- try {
- selectors = this._selectors_group();
- } catch (ex){
- if (ex instanceof SyntaxError && !this.options.strict){
-
- //fire error event
- this.fire({
- type: "error",
- error: ex,
- message: ex.message,
- line: ex.line,
- col: ex.col
- });
-
- //skip over everything until closing brace
- tt = tokenStream.advance([Tokens.RBRACE]);
- if (tt === Tokens.RBRACE){
- //if there's a right brace, the rule is finished so don't do anything
- } else {
- //otherwise, rethrow the error because it wasn't handled properly
- throw ex;
- }
-
- } else {
- //not a syntax error, rethrow it
- throw ex;
- }
-
- //trigger parser to continue
- return true;
- }
-
- //if it got here, all selectors parsed
- if (selectors){
-
- this.fire({
- type: "startrule",
- selectors: selectors,
- line: selectors[0].line,
- col: selectors[0].col
- });
-
- this._readDeclarations(true);
-
- this.fire({
- type: "endrule",
- selectors: selectors,
- line: selectors[0].line,
- col: selectors[0].col
- });
-
- }
-
- return selectors;
-
- },
-
- //CSS3 Selectors
- _selectors_group: function(){
-
- /*
- * selectors_group
- * : selector [ COMMA S* selector ]*
- * ;
- */
- var tokenStream = this._tokenStream,
- selectors = [],
- selector;
-
- selector = this._selector();
- if (selector !== null){
-
- selectors.push(selector);
- while(tokenStream.match(Tokens.COMMA)){
- this._readWhitespace();
- selector = this._selector();
- if (selector !== null){
- selectors.push(selector);
- } else {
- this._unexpectedToken(tokenStream.LT(1));
- }
- }
- }
-
- return selectors.length ? selectors : null;
- },
-
- //CSS3 Selectors
- _selector: function(){
- /*
- * selector
- * : simple_selector_sequence [ combinator simple_selector_sequence ]*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- selector = [],
- nextSelector = null,
- combinator = null,
- ws = null;
-
- //if there's no simple selector, then there's no selector
- nextSelector = this._simple_selector_sequence();
- if (nextSelector === null){
- return null;
- }
-
- selector.push(nextSelector);
-
- do {
-
- //look for a combinator
- combinator = this._combinator();
-
- if (combinator !== null){
- selector.push(combinator);
- nextSelector = this._simple_selector_sequence();
-
- //there must be a next selector
- if (nextSelector === null){
- this._unexpectedToken(tokenStream.LT(1));
- } else {
-
- //nextSelector is an instance of SelectorPart
- selector.push(nextSelector);
- }
- } else {
-
- //if there's not whitespace, we're done
- if (this._readWhitespace()){
-
- //add whitespace separator
- ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
-
- //combinator is not required
- combinator = this._combinator();
-
- //selector is required if there's a combinator
- nextSelector = this._simple_selector_sequence();
- if (nextSelector === null){
- if (combinator !== null){
- this._unexpectedToken(tokenStream.LT(1));
- }
- } else {
-
- if (combinator !== null){
- selector.push(combinator);
- } else {
- selector.push(ws);
- }
-
- selector.push(nextSelector);
- }
- } else {
- break;
- }
-
- }
- } while(true);
-
- return new Selector(selector, selector[0].line, selector[0].col);
- },
-
- //CSS3 Selectors
- _simple_selector_sequence: function(){
- /*
- * simple_selector_sequence
- * : [ type_selector | universal ]
- * [ HASH | class | attrib | pseudo | negation ]*
- * | [ HASH | class | attrib | pseudo | negation ]+
- * ;
- */
-
- var tokenStream = this._tokenStream,
-
- //parts of a simple selector
- elementName = null,
- modifiers = [],
-
- //complete selector text
- selectorText= "",
-
- //the different parts after the element name to search for
- components = [
- //HASH
- function(){
- return tokenStream.match(Tokens.HASH) ?
- new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
- null;
- },
- this._class,
- this._attrib,
- this._pseudo,
- this._negation
- ],
- i = 0,
- len = components.length,
- component = null,
- line,
- col;
-
-
- //get starting line and column for the selector
- line = tokenStream.LT(1).startLine;
- col = tokenStream.LT(1).startCol;
-
- elementName = this._type_selector();
- if (!elementName){
- elementName = this._universal();
- }
-
- if (elementName !== null){
- selectorText += elementName;
- }
-
- while(true){
-
- //whitespace means we're done
- if (tokenStream.peek() === Tokens.S){
- break;
- }
-
- //check for each component
- while(i < len && component === null){
- component = components[i++].call(this);
- }
-
- if (component === null){
-
- //we don't have a selector
- if (selectorText === ""){
- return null;
- } else {
- break;
- }
- } else {
- i = 0;
- modifiers.push(component);
- selectorText += component.toString();
- component = null;
- }
- }
-
-
- return selectorText !== "" ?
- new SelectorPart(elementName, modifiers, selectorText, line, col) :
- null;
- },
-
- //CSS3 Selectors
- _type_selector: function(){
- /*
- * type_selector
- * : [ namespace_prefix ]? element_name
- * ;
- */
-
- var tokenStream = this._tokenStream,
- ns = this._namespace_prefix(),
- elementName = this._element_name();
-
- if (!elementName){
- /*
- * Need to back out the namespace that was read due to both
- * type_selector and universal reading namespace_prefix
- * first. Kind of hacky, but only way I can figure out
- * right now how to not change the grammar.
- */
- if (ns){
- tokenStream.unget();
- if (ns.length > 1){
- tokenStream.unget();
- }
- }
-
- return null;
- } else {
- if (ns){
- elementName.text = ns + elementName.text;
- elementName.col -= ns.length;
- }
- return elementName;
- }
- },
-
- //CSS3 Selectors
- _class: function(){
- /*
- * class
- * : '.' IDENT
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token;
-
- if (tokenStream.match(Tokens.DOT)){
- tokenStream.mustMatch(Tokens.IDENT);
- token = tokenStream.token();
- return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
- } else {
- return null;
- }
-
- },
-
- //CSS3 Selectors
- _element_name: function(){
- /*
- * element_name
- * : IDENT
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token;
-
- if (tokenStream.match(Tokens.IDENT)){
- token = tokenStream.token();
- return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
-
- } else {
- return null;
- }
- },
-
- //CSS3 Selectors
- _namespace_prefix: function(){
- /*
- * namespace_prefix
- * : [ IDENT | '*' ]? '|'
- * ;
- */
- var tokenStream = this._tokenStream,
- value = "";
-
- //verify that this is a namespace prefix
- if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){
-
- if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){
- value += tokenStream.token().value;
- }
-
- tokenStream.mustMatch(Tokens.PIPE);
- value += "|";
-
- }
-
- return value.length ? value : null;
- },
-
- //CSS3 Selectors
- _universal: function(){
- /*
- * universal
- * : [ namespace_prefix ]? '*'
- * ;
- */
- var tokenStream = this._tokenStream,
- value = "",
- ns;
-
- ns = this._namespace_prefix();
- if(ns){
- value += ns;
- }
-
- if(tokenStream.match(Tokens.STAR)){
- value += "*";
- }
-
- return value.length ? value : null;
-
- },
-
- //CSS3 Selectors
- _attrib: function(){
- /*
- * attrib
- * : '[' S* [ namespace_prefix ]? IDENT S*
- * [ [ PREFIXMATCH |
- * SUFFIXMATCH |
- * SUBSTRINGMATCH |
- * '=' |
- * INCLUDES |
- * DASHMATCH ] S* [ IDENT | STRING ] S*
- * ]? ']'
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value = null,
- ns,
- token;
-
- if (tokenStream.match(Tokens.LBRACKET)){
- token = tokenStream.token();
- value = token.value;
- value += this._readWhitespace();
-
- ns = this._namespace_prefix();
-
- if (ns){
- value += ns;
- }
-
- tokenStream.mustMatch(Tokens.IDENT);
- value += tokenStream.token().value;
- value += this._readWhitespace();
-
- if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
- Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){
-
- value += tokenStream.token().value;
- value += this._readWhitespace();
-
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
- value += tokenStream.token().value;
- value += this._readWhitespace();
- }
-
- tokenStream.mustMatch(Tokens.RBRACKET);
-
- return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
- } else {
- return null;
- }
- },
-
- //CSS3 Selectors
- _pseudo: function(){
-
- /*
- * pseudo
- * : ':' ':'? [ IDENT | functional_pseudo ]
- * ;
- */
-
- var tokenStream = this._tokenStream,
- pseudo = null,
- colons = ":",
- line,
- col;
-
- if (tokenStream.match(Tokens.COLON)){
-
- if (tokenStream.match(Tokens.COLON)){
- colons += ":";
- }
-
- if (tokenStream.match(Tokens.IDENT)){
- pseudo = tokenStream.token().value;
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol - colons.length;
- } else if (tokenStream.peek() === Tokens.FUNCTION){
- line = tokenStream.LT(1).startLine;
- col = tokenStream.LT(1).startCol - colons.length;
- pseudo = this._functional_pseudo();
- }
-
- if (pseudo){
- pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
- }
- }
-
- return pseudo;
- },
-
- //CSS3 Selectors
- _functional_pseudo: function(){
- /*
- * functional_pseudo
- * : FUNCTION S* expression ')'
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value = null;
-
- if(tokenStream.match(Tokens.FUNCTION)){
- value = tokenStream.token().value;
- value += this._readWhitespace();
- value += this._expression();
- tokenStream.mustMatch(Tokens.RPAREN);
- value += ")";
- }
-
- return value;
- },
-
- //CSS3 Selectors
- _expression: function(){
- /*
- * expression
- * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
- * ;
- */
-
- var tokenStream = this._tokenStream,
- value = "";
-
- while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
- Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
- Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
- Tokens.RESOLUTION, Tokens.SLASH])){
-
- value += tokenStream.token().value;
- value += this._readWhitespace();
- }
-
- return value.length ? value : null;
-
- },
-
- //CSS3 Selectors
- _negation: function(){
- /*
- * negation
- * : NOT S* negation_arg S* ')'
- * ;
- */
-
- var tokenStream = this._tokenStream,
- line,
- col,
- value = "",
- arg,
- subpart = null;
-
- if (tokenStream.match(Tokens.NOT)){
- value = tokenStream.token().value;
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- value += this._readWhitespace();
- arg = this._negation_arg();
- value += arg;
- value += this._readWhitespace();
- tokenStream.match(Tokens.RPAREN);
- value += tokenStream.token().value;
-
- subpart = new SelectorSubPart(value, "not", line, col);
- subpart.args.push(arg);
- }
-
- return subpart;
- },
-
- //CSS3 Selectors
- _negation_arg: function(){
- /*
- * negation_arg
- * : type_selector | universal | HASH | class | attrib | pseudo
- * ;
- */
-
- var tokenStream = this._tokenStream,
- args = [
- this._type_selector,
- this._universal,
- function(){
- return tokenStream.match(Tokens.HASH) ?
- new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
- null;
- },
- this._class,
- this._attrib,
- this._pseudo
- ],
- arg = null,
- i = 0,
- len = args.length,
- line,
- col,
- part;
-
- line = tokenStream.LT(1).startLine;
- col = tokenStream.LT(1).startCol;
-
- while(i < len && arg === null){
-
- arg = args[i].call(this);
- i++;
- }
-
- //must be a negation arg
- if (arg === null){
- this._unexpectedToken(tokenStream.LT(1));
- }
-
- //it's an element name
- if (arg.type === "elementName"){
- part = new SelectorPart(arg, [], arg.toString(), line, col);
- } else {
- part = new SelectorPart(null, [arg], arg.toString(), line, col);
- }
-
- return part;
- },
-
- _declaration: function(){
-
- /*
- * declaration
- * : property ':' S* expr prio?
- * | /( empty )/
- * ;
- */
-
- var tokenStream = this._tokenStream,
- property = null,
- expr = null,
- prio = null,
- invalid = null,
- propertyName= "";
-
- property = this._property();
- if (property !== null){
-
- tokenStream.mustMatch(Tokens.COLON);
- this._readWhitespace();
-
- expr = this._expr();
-
- //if there's no parts for the value, it's an error
- if (!expr || expr.length === 0){
- this._unexpectedToken(tokenStream.LT(1));
- }
-
- prio = this._prio();
-
- /*
- * If hacks should be allowed, then only check the root
- * property. If hacks should not be allowed, treat
- * _property or *property as invalid properties.
- */
- propertyName = property.toString();
- if (this.options.starHack && property.hack === "*" ||
- this.options.underscoreHack && property.hack === "_") {
-
- propertyName = property.text;
- }
-
- try {
- this._validateProperty(propertyName, expr);
- } catch (ex) {
- invalid = ex;
- }
-
- this.fire({
- type: "property",
- property: property,
- value: expr,
- important: prio,
- line: property.line,
- col: property.col,
- invalid: invalid
- });
-
- return true;
- } else {
- return false;
- }
- },
-
- _prio: function(){
- /*
- * prio
- * : IMPORTANT_SYM S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- result = tokenStream.match(Tokens.IMPORTANT_SYM);
-
- this._readWhitespace();
- return result;
- },
-
- _expr: function(inFunction){
- /*
- * expr
- * : term [ operator term ]*
- * ;
- */
-
- var values = [],
- //valueParts = [],
- value = null,
- operator = null;
-
- value = this._term(inFunction);
- if (value !== null){
-
- values.push(value);
-
- do {
- operator = this._operator(inFunction);
-
- //if there's an operator, keep building up the value parts
- if (operator){
- values.push(operator);
- } /*else {
- //if there's not an operator, you have a full value
- values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
- valueParts = [];
- }*/
-
- value = this._term(inFunction);
-
- if (value === null){
- break;
- } else {
- values.push(value);
- }
- } while(true);
- }
-
- //cleanup
- /*if (valueParts.length){
- values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
- }*/
-
- return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
- },
-
- _term: function(inFunction){
-
- /*
- * term
- * : unary_operator?
- * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* |
- * TIME S* | FREQ S* | function | ie_function ]
- * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor
- * ;
- */
-
- var tokenStream = this._tokenStream,
- unary = null,
- value = null,
- endChar = null,
- token,
- line,
- col;
-
- //returns the operator or null
- unary = this._unary_operator();
- if (unary !== null){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- }
-
- //exception for IE filters
- if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters){
-
- value = this._ie_function();
- if (unary === null){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- }
-
- //see if it's a simple block
- } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){
-
- token = tokenStream.token();
- endChar = token.endChar;
- value = token.value + this._expr(inFunction).text;
- if (unary === null){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- }
- tokenStream.mustMatch(Tokens.type(endChar));
- value += endChar;
- this._readWhitespace();
-
- //see if there's a simple match
- } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
- Tokens.ANGLE, Tokens.TIME,
- Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){
-
- value = tokenStream.token().value;
- if (unary === null){
- line = tokenStream.token().startLine;
- col = tokenStream.token().startCol;
- }
- this._readWhitespace();
- } else {
-
- //see if it's a color
- token = this._hexcolor();
- if (token === null){
-
- //if there's no unary, get the start of the next token for line/col info
- if (unary === null){
- line = tokenStream.LT(1).startLine;
- col = tokenStream.LT(1).startCol;
- }
-
- //has to be a function
- if (value === null){
-
- /*
- * This checks for alpha(opacity=0) style of IE
- * functions. IE_FUNCTION only presents progid: style.
- */
- if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters){
- value = this._ie_function();
- } else {
- value = this._function();
- }
- }
-
- /*if (value === null){
- return null;
- //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
- }*/
-
- } else {
- value = token.value;
- if (unary === null){
- line = token.startLine;
- col = token.startCol;
- }
- }
-
- }
-
- return value !== null ?
- new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
- null;
-
- },
-
- _function: function(){
-
- /*
- * function
- * : FUNCTION S* expr ')' S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- functionText = null,
- expr = null,
- lt;
-
- if (tokenStream.match(Tokens.FUNCTION)){
- functionText = tokenStream.token().value;
- this._readWhitespace();
- expr = this._expr(true);
- functionText += expr;
-
- //START: Horrible hack in case it's an IE filter
- if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS){
- do {
-
- if (this._readWhitespace()){
- functionText += tokenStream.token().value;
- }
-
- //might be second time in the loop
- if (tokenStream.LA(0) === Tokens.COMMA){
- functionText += tokenStream.token().value;
- }
-
- tokenStream.match(Tokens.IDENT);
- functionText += tokenStream.token().value;
-
- tokenStream.match(Tokens.EQUALS);
- functionText += tokenStream.token().value;
-
- //functionText += this._term();
- lt = tokenStream.peek();
- while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
- tokenStream.get();
- functionText += tokenStream.token().value;
- lt = tokenStream.peek();
- }
- } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
- }
-
- //END: Horrible Hack
-
- tokenStream.match(Tokens.RPAREN);
- functionText += ")";
- this._readWhitespace();
- }
-
- return functionText;
- },
-
- _ie_function: function(){
-
- /* (My own extension)
- * ie_function
- * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- functionText = null,
- lt;
-
- //IE function can begin like a regular function, too
- if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){
- functionText = tokenStream.token().value;
-
- do {
-
- if (this._readWhitespace()){
- functionText += tokenStream.token().value;
- }
-
- //might be second time in the loop
- if (tokenStream.LA(0) === Tokens.COMMA){
- functionText += tokenStream.token().value;
- }
-
- tokenStream.match(Tokens.IDENT);
- functionText += tokenStream.token().value;
-
- tokenStream.match(Tokens.EQUALS);
- functionText += tokenStream.token().value;
-
- //functionText += this._term();
- lt = tokenStream.peek();
- while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
- tokenStream.get();
- functionText += tokenStream.token().value;
- lt = tokenStream.peek();
- }
- } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
-
- tokenStream.match(Tokens.RPAREN);
- functionText += ")";
- this._readWhitespace();
- }
-
- return functionText;
- },
-
- _hexcolor: function(){
- /*
- * There is a constraint on the color that it must
- * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
- * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
- *
- * hexcolor
- * : HASH S*
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token = null,
- color;
-
- if(tokenStream.match(Tokens.HASH)){
-
- //need to do some validation here
-
- token = tokenStream.token();
- color = token.value;
- if (!/#[a-f0-9]{3,6}/i.test(color)){
- throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
- }
- this._readWhitespace();
- }
-
- return token;
- },
-
- //-----------------------------------------------------------------
- // Animations methods
- //-----------------------------------------------------------------
-
- _keyframes: function(){
-
- /*
- * keyframes:
- * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
- * ;
- */
- var tokenStream = this._tokenStream,
- token,
- tt,
- name,
- prefix = "";
-
- tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
- token = tokenStream.token();
- if (/^@\-([^\-]+)\-/.test(token.value)) {
- prefix = RegExp.$1;
- }
-
- this._readWhitespace();
- name = this._keyframe_name();
-
- this._readWhitespace();
- tokenStream.mustMatch(Tokens.LBRACE);
-
- this.fire({
- type: "startkeyframes",
- name: name,
- prefix: prefix,
- line: token.startLine,
- col: token.startCol
- });
-
- this._readWhitespace();
- tt = tokenStream.peek();
-
- //check for key
- while(tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
- this._keyframe_rule();
- this._readWhitespace();
- tt = tokenStream.peek();
- }
-
- this.fire({
- type: "endkeyframes",
- name: name,
- prefix: prefix,
- line: token.startLine,
- col: token.startCol
- });
-
- this._readWhitespace();
- tokenStream.mustMatch(Tokens.RBRACE);
-
- },
-
- _keyframe_name: function(){
-
- /*
- * keyframe_name:
- * : IDENT
- * | STRING
- * ;
- */
- var tokenStream = this._tokenStream;
-
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
- return SyntaxUnit.fromToken(tokenStream.token());
- },
-
- _keyframe_rule: function(){
-
- /*
- * keyframe_rule:
- * : key_list S*
- * '{' S* declaration [ ';' S* declaration ]* '}' S*
- * ;
- */
- var keyList = this._key_list();
-
- this.fire({
- type: "startkeyframerule",
- keys: keyList,
- line: keyList[0].line,
- col: keyList[0].col
- });
-
- this._readDeclarations(true);
-
- this.fire({
- type: "endkeyframerule",
- keys: keyList,
- line: keyList[0].line,
- col: keyList[0].col
- });
-
- },
-
- _key_list: function(){
-
- /*
- * key_list:
- * : key [ S* ',' S* key]*
- * ;
- */
- var tokenStream = this._tokenStream,
- keyList = [];
-
- //must be least one key
- keyList.push(this._key());
-
- this._readWhitespace();
-
- while(tokenStream.match(Tokens.COMMA)){
- this._readWhitespace();
- keyList.push(this._key());
- this._readWhitespace();
- }
-
- return keyList;
- },
-
- _key: function(){
- /*
- * There is a restriction that IDENT can be only "from" or "to".
- *
- * key
- * : PERCENTAGE
- * | IDENT
- * ;
- */
-
- var tokenStream = this._tokenStream,
- token;
-
- if (tokenStream.match(Tokens.PERCENTAGE)){
- return SyntaxUnit.fromToken(tokenStream.token());
- } else if (tokenStream.match(Tokens.IDENT)){
- token = tokenStream.token();
-
- if (/from|to/i.test(token.value)){
- return SyntaxUnit.fromToken(token);
- }
-
- tokenStream.unget();
- }
-
- //if it gets here, there wasn't a valid token, so time to explode
- this._unexpectedToken(tokenStream.LT(1));
- },
-
- //-----------------------------------------------------------------
- // Helper methods
- //-----------------------------------------------------------------
-
- /**
- * Not part of CSS grammar, but useful for skipping over
- * combination of white space and HTML-style comments.
- * @return {void}
- * @method _skipCruft
- * @private
- */
- _skipCruft: function(){
- while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){
- //noop
- }
- },
-
- /**
- * Not part of CSS grammar, but this pattern occurs frequently
- * in the official CSS grammar. Split out here to eliminate
- * duplicate code.
- * @param {Boolean} checkStart Indicates if the rule should check
- * for the left brace at the beginning.
- * @param {Boolean} readMargins Indicates if the rule should check
- * for margin patterns.
- * @return {void}
- * @method _readDeclarations
- * @private
- */
- _readDeclarations: function(checkStart, readMargins){
- /*
- * Reads the pattern
- * S* '{' S* declaration [ ';' S* declaration ]* '}' S*
- * or
- * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
- * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
- * A semicolon is only necessary following a declaration if there's another declaration
- * or margin afterwards.
- */
- var tokenStream = this._tokenStream,
- tt;
-
-
- this._readWhitespace();
-
- if (checkStart){
- tokenStream.mustMatch(Tokens.LBRACE);
- }
-
- this._readWhitespace();
-
- try {
-
- while(true){
- if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
- //noop
- } else if (this._declaration()){
- if (!tokenStream.match(Tokens.SEMICOLON)){
- break;
- }
- } else {
- break;
- }
-
-
- //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
- // break;
- //}
- this._readWhitespace();
- }
-
- tokenStream.mustMatch(Tokens.RBRACE);
- this._readWhitespace();
-
- } catch (ex) {
- if (ex instanceof SyntaxError && !this.options.strict){
-
- //fire error event
- this.fire({
- type: "error",
- error: ex,
- message: ex.message,
- line: ex.line,
- col: ex.col
- });
-
- //see if there's another declaration
- tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
- if (tt === Tokens.SEMICOLON){
- //if there's a semicolon, then there might be another declaration
- this._readDeclarations(false, readMargins);
- } else if (tt !== Tokens.RBRACE){
- //if there's a right brace, the rule is finished so don't do anything
- //otherwise, rethrow the error because it wasn't handled properly
- throw ex;
- }
-
- } else {
- //not a syntax error, rethrow it
- throw ex;
- }
- }
-
- },
-
- /**
- * In some cases, you can end up with two white space tokens in a
- * row. Instead of making a change in every function that looks for
- * white space, this function is used to match as much white space
- * as necessary.
- * @method _readWhitespace
- * @return {String} The white space if found, empty string if not.
- * @private
- */
- _readWhitespace: function(){
-
- var tokenStream = this._tokenStream,
- ws = "";
-
- while(tokenStream.match(Tokens.S)){
- ws += tokenStream.token().value;
- }
-
- return ws;
- },
-
-
- /**
- * Throws an error when an unexpected token is found.
- * @param {Object} token The token that was found.
- * @method _unexpectedToken
- * @return {void}
- * @private
- */
- _unexpectedToken: function(token){
- throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
- },
-
- /**
- * Helper method used for parsing subparts of a style sheet.
- * @return {void}
- * @method _verifyEnd
- * @private
- */
- _verifyEnd: function(){
- if (this._tokenStream.LA(1) !== Tokens.EOF){
- this._unexpectedToken(this._tokenStream.LT(1));
- }
- },
-
- //-----------------------------------------------------------------
- // Validation methods
- //-----------------------------------------------------------------
- _validateProperty: function(property, value){
- Validation.validate(property, value);
- },
-
- //-----------------------------------------------------------------
- // Parsing methods
- //-----------------------------------------------------------------
-
- parse: function(input){
- this._tokenStream = new TokenStream(input, Tokens);
- this._stylesheet();
- },
-
- parseStyleSheet: function(input){
- //just passthrough
- return this.parse(input);
- },
-
- parseMediaQuery: function(input){
- this._tokenStream = new TokenStream(input, Tokens);
- var result = this._media_query();
-
- //if there's anything more, then it's an invalid selector
- this._verifyEnd();
-
- //otherwise return result
- return result;
- },
-
- /**
- * Parses a property value (everything after the semicolon).
- * @return {parserlib.css.PropertyValue} The property value.
- * @throws parserlib.util.SyntaxError If an unexpected token is found.
- * @method parserPropertyValue
- */
- parsePropertyValue: function(input){
-
- this._tokenStream = new TokenStream(input, Tokens);
- this._readWhitespace();
-
- var result = this._expr();
-
- //okay to have a trailing white space
- this._readWhitespace();
-
- //if there's anything more, then it's an invalid selector
- this._verifyEnd();
-
- //otherwise return result
- return result;
- },
-
- /**
- * Parses a complete CSS rule, including selectors and
- * properties.
- * @param {String} input The text to parser.
- * @return {Boolean} True if the parse completed successfully, false if not.
- * @method parseRule
- */
- parseRule: function(input){
- this._tokenStream = new TokenStream(input, Tokens);
-
- //skip any leading white space
- this._readWhitespace();
-
- var result = this._ruleset();
-
- //skip any trailing white space
- this._readWhitespace();
-
- //if there's anything more, then it's an invalid selector
- this._verifyEnd();
-
- //otherwise return result
- return result;
- },
-
- /**
- * Parses a single CSS selector (no comma)
- * @param {String} input The text to parse as a CSS selector.
- * @return {Selector} An object representing the selector.
- * @throws parserlib.util.SyntaxError If an unexpected token is found.
- * @method parseSelector
- */
- parseSelector: function(input){
-
- this._tokenStream = new TokenStream(input, Tokens);
-
- //skip any leading white space
- this._readWhitespace();
-
- var result = this._selector();
-
- //skip any trailing white space
- this._readWhitespace();
-
- //if there's anything more, then it's an invalid selector
- this._verifyEnd();
-
- //otherwise return result
- return result;
- },
-
- /**
- * Parses an HTML style attribute: a set of CSS declarations
- * separated by semicolons.
- * @param {String} input The text to parse as a style attribute
- * @return {void}
- * @method parseStyleAttribute
- */
- parseStyleAttribute: function(input){
- input += "}"; // for error recovery in _readDeclarations()
- this._tokenStream = new TokenStream(input, Tokens);
- this._readDeclarations();
- }
- };
-
- //copy over onto prototype
- for (prop in additions){
- if (Object.prototype.hasOwnProperty.call(additions, prop)){
- proto[prop] = additions[prop];
- }
- }
-
- return proto;
-}();
-
-
-/*
-nth
- : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
- ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
- ;
-*/
-var Properties = {
- __proto__: null,
-
- //A
- "align-items" : "flex-start | flex-end | center | baseline | stretch",
- "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
- "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
- "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
- "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
- "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
- "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
- "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
- "animation" : 1,
- "animation-delay" : { multi: "<time>", comma: true },
- "animation-direction" : { multi: "normal | alternate", comma: true },
- "animation-duration" : { multi: "<time>", comma: true },
- "animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
- "animation-iteration-count" : { multi: "<number> | infinite", comma: true },
- "animation-name" : { multi: "none | <ident>", comma: true },
- "animation-play-state" : { multi: "running | paused", comma: true },
- "animation-timing-function" : 1,
-
- //vendor prefixed
- "-moz-animation-delay" : { multi: "<time>", comma: true },
- "-moz-animation-direction" : { multi: "normal | alternate", comma: true },
- "-moz-animation-duration" : { multi: "<time>", comma: true },
- "-moz-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
- "-moz-animation-name" : { multi: "none | <ident>", comma: true },
- "-moz-animation-play-state" : { multi: "running | paused", comma: true },
-
- "-ms-animation-delay" : { multi: "<time>", comma: true },
- "-ms-animation-direction" : { multi: "normal | alternate", comma: true },
- "-ms-animation-duration" : { multi: "<time>", comma: true },
- "-ms-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
- "-ms-animation-name" : { multi: "none | <ident>", comma: true },
- "-ms-animation-play-state" : { multi: "running | paused", comma: true },
-
- "-webkit-animation-delay" : { multi: "<time>", comma: true },
- "-webkit-animation-direction" : { multi: "normal | alternate", comma: true },
- "-webkit-animation-duration" : { multi: "<time>", comma: true },
- "-webkit-animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
- "-webkit-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
- "-webkit-animation-name" : { multi: "none | <ident>", comma: true },
- "-webkit-animation-play-state" : { multi: "running | paused", comma: true },
-
- "-o-animation-delay" : { multi: "<time>", comma: true },
- "-o-animation-direction" : { multi: "normal | alternate", comma: true },
- "-o-animation-duration" : { multi: "<time>", comma: true },
- "-o-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
- "-o-animation-name" : { multi: "none | <ident>", comma: true },
- "-o-animation-play-state" : { multi: "running | paused", comma: true },
-
- "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",
- "azimuth" : function (expression) {
- var simple = "<angle> | leftwards | rightwards | inherit",
- direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",
- behind = false,
- valid = false,
- part;
-
- if (!ValidationTypes.isAny(expression, simple)) {
- if (ValidationTypes.isAny(expression, "behind")) {
- behind = true;
- valid = true;
- }
-
- if (ValidationTypes.isAny(expression, direction)) {
- valid = true;
- if (!behind) {
- ValidationTypes.isAny(expression, "behind");
- }
- }
- }
-
- if (expression.hasNext()) {
- part = expression.next();
- if (valid) {
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected (<'azimuth'>) but found '" + part + "'.", part.line, part.col);
- }
- }
- },
-
- //B
- "backface-visibility" : "visible | hidden",
- "background" : 1,
- "background-attachment" : { multi: "<attachment>", comma: true },
- "background-clip" : { multi: "<box>", comma: true },
- "background-color" : "<color> | inherit",
- "background-image" : { multi: "<bg-image>", comma: true },
- "background-origin" : { multi: "<box>", comma: true },
- "background-position" : { multi: "<bg-position>", comma: true },
- "background-repeat" : { multi: "<repeat-style>" },
- "background-size" : { multi: "<bg-size>", comma: true },
- "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
- "behavior" : 1,
- "binding" : 1,
- "bleed" : "<length>",
- "bookmark-label" : "<content> | <attr> | <string>",
- "bookmark-level" : "none | <integer>",
- "bookmark-state" : "open | closed",
- "bookmark-target" : "none | <uri> | <attr>",
- "border" : "<border-width> || <border-style> || <color>",
- "border-bottom" : "<border-width> || <border-style> || <color>",
- "border-bottom-color" : "<color> | inherit",
- "border-bottom-left-radius" : "<x-one-radius>",
- "border-bottom-right-radius" : "<x-one-radius>",
- "border-bottom-style" : "<border-style>",
- "border-bottom-width" : "<border-width>",
- "border-collapse" : "collapse | separate | inherit",
- "border-color" : { multi: "<color> | inherit", max: 4 },
- "border-image" : 1,
- "border-image-outset" : { multi: "<length> | <number>", max: 4 },
- "border-image-repeat" : { multi: "stretch | repeat | round", max: 2 },
- "border-image-slice" : function(expression) {
-
- var valid = false,
- numeric = "<number> | <percentage>",
- fill = false,
- count = 0,
- max = 4,
- part;
-
- if (ValidationTypes.isAny(expression, "fill")) {
- fill = true;
- valid = true;
- }
-
- while (expression.hasNext() && count < max) {
- valid = ValidationTypes.isAny(expression, numeric);
- if (!valid) {
- break;
- }
- count++;
- }
-
-
- if (!fill) {
- ValidationTypes.isAny(expression, "fill");
- } else {
- valid = true;
- }
-
- if (expression.hasNext()) {
- part = expression.next();
- if (valid) {
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '" + part + "'.", part.line, part.col);
- }
- }
- },
- "border-image-source" : "<image> | none",
- "border-image-width" : { multi: "<length> | <percentage> | <number> | auto", max: 4 },
- "border-left" : "<border-width> || <border-style> || <color>",
- "border-left-color" : "<color> | inherit",
- "border-left-style" : "<border-style>",
- "border-left-width" : "<border-width>",
- "border-radius" : function(expression) {
-
- var valid = false,
- simple = "<length> | <percentage> | inherit",
- slash = false,
- count = 0,
- max = 8,
- part;
-
- while (expression.hasNext() && count < max) {
- valid = ValidationTypes.isAny(expression, simple);
- if (!valid) {
-
- if (String(expression.peek()) === "/" && count > 0 && !slash) {
- slash = true;
- max = count + 5;
- expression.next();
- } else {
- break;
- }
- }
- count++;
- }
-
- if (expression.hasNext()) {
- part = expression.next();
- if (valid) {
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected (<'border-radius'>) but found '" + part + "'.", part.line, part.col);
- }
- }
- },
- "border-right" : "<border-width> || <border-style> || <color>",
- "border-right-color" : "<color> | inherit",
- "border-right-style" : "<border-style>",
- "border-right-width" : "<border-width>",
- "border-spacing" : { multi: "<length> | inherit", max: 2 },
- "border-style" : { multi: "<border-style>", max: 4 },
- "border-top" : "<border-width> || <border-style> || <color>",
- "border-top-color" : "<color> | inherit",
- "border-top-left-radius" : "<x-one-radius>",
- "border-top-right-radius" : "<x-one-radius>",
- "border-top-style" : "<border-style>",
- "border-top-width" : "<border-width>",
- "border-width" : { multi: "<border-width>", max: 4 },
- "bottom" : "<margin-width> | inherit",
- "-moz-box-align" : "start | end | center | baseline | stretch",
- "-moz-box-decoration-break" : "slice |clone",
- "-moz-box-direction" : "normal | reverse | inherit",
- "-moz-box-flex" : "<number>",
- "-moz-box-flex-group" : "<integer>",
- "-moz-box-lines" : "single | multiple",
- "-moz-box-ordinal-group" : "<integer>",
- "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
- "-moz-box-pack" : "start | end | center | justify",
- "-o-box-decoration-break" : "slice | clone",
- "-webkit-box-align" : "start | end | center | baseline | stretch",
- "-webkit-box-decoration-break" : "slice |clone",
- "-webkit-box-direction" : "normal | reverse | inherit",
- "-webkit-box-flex" : "<number>",
- "-webkit-box-flex-group" : "<integer>",
- "-webkit-box-lines" : "single | multiple",
- "-webkit-box-ordinal-group" : "<integer>",
- "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
- "-webkit-box-pack" : "start | end | center | justify",
- "box-decoration-break" : "slice | clone",
- "box-shadow" : function (expression) {
- var part;
-
- if (!ValidationTypes.isAny(expression, "none")) {
- Validation.multiProperty("<shadow>", expression, true, Infinity);
- } else {
- if (expression.hasNext()) {
- part = expression.next();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- }
- }
- },
- "box-sizing" : "content-box | border-box | inherit",
- "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
- "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
- "break-inside" : "auto | avoid | avoid-page | avoid-column",
-
- //C
- "caption-side" : "top | bottom | inherit",
- "clear" : "none | right | left | both | inherit",
- "clip" : 1,
- "color" : "<color> | inherit",
- "color-profile" : 1,
- "column-count" : "<integer> | auto", //http://www.w3.org/TR/css3-multicol/
- "column-fill" : "auto | balance",
- "column-gap" : "<length> | normal",
- "column-rule" : "<border-width> || <border-style> || <color>",
- "column-rule-color" : "<color>",
- "column-rule-style" : "<border-style>",
- "column-rule-width" : "<border-width>",
- "column-span" : "none | all",
- "column-width" : "<length> | auto",
- "columns" : 1,
- "content" : 1,
- "counter-increment" : 1,
- "counter-reset" : 1,
- "crop" : "<shape> | auto",
- "cue" : "cue-after | cue-before | inherit",
- "cue-after" : 1,
- "cue-before" : 1,
- "cursor" : 1,
-
- //D
- "direction" : "ltr | rtl | inherit",
- "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
- "dominant-baseline" : 1,
- "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
- "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
- "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
- "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
- "drop-initial-size" : "auto | line | <length> | <percentage>",
- "drop-initial-value" : "initial | <integer>",
-
- //E
- "elevation" : "<angle> | below | level | above | higher | lower | inherit",
- "empty-cells" : "show | hide | inherit",
-
- //F
- "filter" : 1,
- "fit" : "fill | hidden | meet | slice",
- "fit-position" : 1,
- "flex" : "<flex>",
- "flex-basis" : "<width>",
- "flex-direction" : "row | row-reverse | column | column-reverse",
- "flex-flow" : "<flex-direction> || <flex-wrap>",
- "flex-grow" : "<number>",
- "flex-shrink" : "<number>",
- "flex-wrap" : "nowrap | wrap | wrap-reverse",
- "-webkit-flex" : "<flex>",
- "-webkit-flex-basis" : "<width>",
- "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
- "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
- "-webkit-flex-grow" : "<number>",
- "-webkit-flex-shrink" : "<number>",
- "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
- "-ms-flex" : "<flex>",
- "-ms-flex-align" : "start | end | center | stretch | baseline",
- "-ms-flex-direction" : "row | row-reverse | column | column-reverse | inherit",
- "-ms-flex-order" : "<number>",
- "-ms-flex-pack" : "start | end | center | justify",
- "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
- "float" : "left | right | none | inherit",
- "float-offset" : 1,
- "font" : 1,
- "font-family" : 1,
- "font-feature-settings" : "<feature-tag-value> | normal | inherit",
- "font-kerning" : "auto | normal | none | initial | inherit | unset",
- "font-size" : "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
- "font-size-adjust" : "<number> | none | inherit",
- "font-stretch" : "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
- "font-style" : "normal | italic | oblique | inherit",
- "font-variant" : "normal | small-caps | inherit",
- "font-variant-caps" : "normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps",
- "font-variant-position" : "normal | sub | super | inherit | initial | unset",
- "font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
-
- //G
- "grid" : 1,
- "grid-area" : 1,
- "grid-auto-columns" : 1,
- "grid-auto-flow" : 1,
- "grid-auto-position" : 1,
- "grid-auto-rows" : 1,
- "grid-cell-stacking" : "columns | rows | layer",
- "grid-column" : 1,
- "grid-columns" : 1,
- "grid-column-align" : "start | end | center | stretch",
- "grid-column-sizing" : 1,
- "grid-column-start" : 1,
- "grid-column-end" : 1,
- "grid-column-span" : "<integer>",
- "grid-flow" : "none | rows | columns",
- "grid-layer" : "<integer>",
- "grid-row" : 1,
- "grid-rows" : 1,
- "grid-row-align" : "start | end | center | stretch",
- "grid-row-start" : 1,
- "grid-row-end" : 1,
- "grid-row-span" : "<integer>",
- "grid-row-sizing" : 1,
- "grid-template" : 1,
- "grid-template-areas" : 1,
- "grid-template-columns" : 1,
- "grid-template-rows" : 1,
-
- //H
- "hanging-punctuation" : 1,
- "height" : "<margin-width> | <content-sizing> | inherit",
- "hyphenate-after" : "<integer> | auto",
- "hyphenate-before" : "<integer> | auto",
- "hyphenate-character" : "<string> | auto",
- "hyphenate-lines" : "no-limit | <integer>",
- "hyphenate-resource" : 1,
- "hyphens" : "none | manual | auto",
-
- //I
- "icon" : 1,
- "image-orientation" : "angle | auto",
- "image-rendering" : 1,
- "image-resolution" : 1,
- "ime-mode" : "auto | normal | active | inactive | disabled | inherit",
- "inline-box-align" : "initial | last | <integer>",
-
- //J
- "justify-content" : "flex-start | flex-end | center | space-between | space-around",
- "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around",
-
- //L
- "left" : "<margin-width> | inherit",
- "letter-spacing" : "<length> | normal | inherit",
- "line-height" : "<number> | <length> | <percentage> | normal | inherit",
- "line-break" : "auto | loose | normal | strict",
- "line-stacking" : 1,
- "line-stacking-ruby" : "exclude-ruby | include-ruby",
- "line-stacking-shift" : "consider-shifts | disregard-shifts",
- "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
- "list-style" : 1,
- "list-style-image" : "<uri> | none | inherit",
- "list-style-position" : "inside | outside | inherit",
- "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",
-
- //M
- "margin" : { multi: "<margin-width> | inherit", max: 4 },
- "margin-bottom" : "<margin-width> | inherit",
- "margin-left" : "<margin-width> | inherit",
- "margin-right" : "<margin-width> | inherit",
- "margin-top" : "<margin-width> | inherit",
- "mark" : 1,
- "mark-after" : 1,
- "mark-before" : 1,
- "marks" : 1,
- "marquee-direction" : 1,
- "marquee-play-count" : 1,
- "marquee-speed" : 1,
- "marquee-style" : 1,
- "max-height" : "<length> | <percentage> | <content-sizing> | none | inherit",
- "max-width" : "<length> | <percentage> | <content-sizing> | none | inherit",
- "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
- "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
- "move-to" : 1,
-
- //N
- "nav-down" : 1,
- "nav-index" : 1,
- "nav-left" : 1,
- "nav-right" : 1,
- "nav-up" : 1,
-
- //O
- "object-fit" : "fill | contain | cover | none | scale-down",
- "object-position" : "<bg-position>",
- "opacity" : "<number> | inherit",
- "order" : "<integer>",
- "-webkit-order" : "<integer>",
- "orphans" : "<integer> | inherit",
- "outline" : 1,
- "outline-color" : "<color> | invert | inherit",
- "outline-offset" : 1,
- "outline-style" : "<border-style> | inherit",
- "outline-width" : "<border-width> | inherit",
- "overflow" : "visible | hidden | scroll | auto | inherit",
- "overflow-style" : 1,
- "overflow-wrap" : "normal | break-word",
- "overflow-x" : 1,
- "overflow-y" : 1,
-
- //P
- "padding" : { multi: "<padding-width> | inherit", max: 4 },
- "padding-bottom" : "<padding-width> | inherit",
- "padding-left" : "<padding-width> | inherit",
- "padding-right" : "<padding-width> | inherit",
- "padding-top" : "<padding-width> | inherit",
- "page" : 1,
- "page-break-after" : "auto | always | avoid | left | right | inherit",
- "page-break-before" : "auto | always | avoid | left | right | inherit",
- "page-break-inside" : "auto | avoid | inherit",
- "page-policy" : 1,
- "pause" : 1,
- "pause-after" : 1,
- "pause-before" : 1,
- "perspective" : 1,
- "perspective-origin" : 1,
- "phonemes" : 1,
- "pitch" : 1,
- "pitch-range" : 1,
- "play-during" : 1,
- "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",
- "position" : "static | relative | absolute | fixed | inherit",
- "presentation-level" : 1,
- "punctuation-trim" : 1,
-
- //Q
- "quotes" : 1,
-
- //R
- "rendering-intent" : 1,
- "resize" : 1,
- "rest" : 1,
- "rest-after" : 1,
- "rest-before" : 1,
- "richness" : 1,
- "right" : "<margin-width> | inherit",
- "rotation" : 1,
- "rotation-point" : 1,
- "ruby-align" : 1,
- "ruby-overhang" : 1,
- "ruby-position" : 1,
- "ruby-span" : 1,
-
- //S
- "size" : 1,
- "speak" : "normal | none | spell-out | inherit",
- "speak-header" : "once | always | inherit",
- "speak-numeral" : "digits | continuous | inherit",
- "speak-punctuation" : "code | none | inherit",
- "speech-rate" : 1,
- "src" : 1,
- "stress" : 1,
- "string-set" : 1,
-
- "table-layout" : "auto | fixed | inherit",
- "tab-size" : "<integer> | <length>",
- "target" : 1,
- "target-name" : 1,
- "target-new" : 1,
- "target-position" : 1,
- "text-align" : "left | right | center | justify | match-parent | start | end | inherit" ,
- "text-align-last" : 1,
- "text-decoration" : 1,
- "text-emphasis" : 1,
- "text-height" : 1,
- "text-indent" : "<length> | <percentage> | inherit",
- "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
- "text-outline" : 1,
- "text-overflow" : 1,
- "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
- "text-shadow" : 1,
- "text-transform" : "capitalize | uppercase | lowercase | none | inherit",
- "text-wrap" : "normal | none | avoid",
- "top" : "<margin-width> | inherit",
- "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
- "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
- "transform" : 1,
- "transform-origin" : 1,
- "transform-style" : 1,
- "transition" : 1,
- "transition-delay" : 1,
- "transition-duration" : 1,
- "transition-property" : 1,
- "transition-timing-function" : 1,
-
- //U
- "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext | inherit",
- "user-modify" : "read-only | read-write | write-only | inherit",
- "user-select" : "none | text | toggle | element | elements | all | inherit",
-
- //V
- "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> | inherit",
- "visibility" : "visible | hidden | collapse | inherit",
- "voice-balance" : 1,
- "voice-duration" : 1,
- "voice-family" : 1,
- "voice-pitch" : 1,
- "voice-pitch-range" : 1,
- "voice-rate" : 1,
- "voice-stress" : 1,
- "voice-volume" : 1,
- "volume" : 1,
-
- //W
- "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", //http://perishablepress.com/wrapping-content/
- "white-space-collapse" : 1,
- "widows" : "<integer> | inherit",
- "width" : "<length> | <percentage> | <content-sizing> | auto | inherit",
- "will-change" : { multi: "<ident>", comma: true },
- "word-break" : "normal | keep-all | break-all",
- "word-spacing" : "<length> | normal | inherit",
- "word-wrap" : "normal | break-word",
- "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb | inherit",
-
- //Z
- "z-index" : "<integer> | auto | inherit",
- "zoom" : "<number> | <percentage> | normal"
-};
-/**
- * Represents a selector combinator (whitespace, +, >).
- * @namespace parserlib.css
- * @class PropertyName
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {String} text The text representation of the unit.
- * @param {String} hack The type of IE hack applied ("*", "_", or null).
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function PropertyName(text, hack, line, col){
-
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
-
- /**
- * The type of IE hack applied ("*", "_", or null).
- * @type String
- * @property hack
- */
- this.hack = hack;
-
-}
-
-PropertyName.prototype = new SyntaxUnit();
-PropertyName.prototype.constructor = PropertyName;
-PropertyName.prototype.toString = function(){
- return (this.hack ? this.hack : "") + this.text;
-};
-/**
- * Represents a single part of a CSS property value, meaning that it represents
- * just everything single part between ":" and ";". If there are multiple values
- * separated by commas, this type represents just one of the values.
- * @param {String[]} parts An array of value parts making up this value.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- * @namespace parserlib.css
- * @class PropertyValue
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- */
-function PropertyValue(parts, line, col){
-
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
-
- /**
- * The parts that make up the selector.
- * @type Array
- * @property parts
- */
- this.parts = parts;
-
-}
-
-PropertyValue.prototype = new SyntaxUnit();
-PropertyValue.prototype.constructor = PropertyValue;
-
-/**
- * A utility class that allows for easy iteration over the various parts of a
- * property value.
- * @param {parserlib.css.PropertyValue} value The property value to iterate over.
- * @namespace parserlib.css
- * @class PropertyValueIterator
- * @constructor
- */
-function PropertyValueIterator(value){
-
- /**
- * Iterator value
- * @type int
- * @property _i
- * @private
- */
- this._i = 0;
-
- /**
- * The parts that make up the value.
- * @type Array
- * @property _parts
- * @private
- */
- this._parts = value.parts;
-
- /**
- * Keeps track of bookmarks along the way.
- * @type Array
- * @property _marks
- * @private
- */
- this._marks = [];
-
- /**
- * Holds the original property value.
- * @type parserlib.css.PropertyValue
- * @property value
- */
- this.value = value;
-
-}
-
-/**
- * Returns the total number of parts in the value.
- * @return {int} The total number of parts in the value.
- * @method count
- */
-PropertyValueIterator.prototype.count = function(){
- return this._parts.length;
-};
-
-/**
- * Indicates if the iterator is positioned at the first item.
- * @return {Boolean} True if positioned at first item, false if not.
- * @method isFirst
- */
-PropertyValueIterator.prototype.isFirst = function(){
- return this._i === 0;
-};
-
-/**
- * Indicates if there are more parts of the property value.
- * @return {Boolean} True if there are more parts, false if not.
- * @method hasNext
- */
-PropertyValueIterator.prototype.hasNext = function(){
- return (this._i < this._parts.length);
-};
-
-/**
- * Marks the current spot in the iteration so it can be restored to
- * later on.
- * @return {void}
- * @method mark
- */
-PropertyValueIterator.prototype.mark = function(){
- this._marks.push(this._i);
-};
-
-/**
- * Returns the next part of the property value or null if there is no next
- * part. Does not move the internal counter forward.
- * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
- * part.
- * @method peek
- */
-PropertyValueIterator.prototype.peek = function(count){
- return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
-};
-
-/**
- * Returns the next part of the property value or null if there is no next
- * part.
- * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
- * part.
- * @method next
- */
-PropertyValueIterator.prototype.next = function(){
- return this.hasNext() ? this._parts[this._i++] : null;
-};
-
-/**
- * Returns the previous part of the property value or null if there is no
- * previous part.
- * @return {parserlib.css.PropertyValuePart} The previous part of the
- * property value or null if there is no previous part.
- * @method previous
- */
-PropertyValueIterator.prototype.previous = function(){
- return this._i > 0 ? this._parts[--this._i] : null;
-};
-
-/**
- * Restores the last saved bookmark.
- * @return {void}
- * @method restore
- */
-PropertyValueIterator.prototype.restore = function(){
- if (this._marks.length){
- this._i = this._marks.pop();
- }
-};
-
-/**
- * Represents a single part of a CSS property value, meaning that it represents
- * just one part of the data between ":" and ";".
- * @param {String} text The text representation of the unit.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- * @namespace parserlib.css
- * @class PropertyValuePart
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- */
-function PropertyValuePart(text, line, col){
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
-
- /**
- * Indicates the type of value unit.
- * @type String
- * @property type
- */
- this.type = "unknown";
-
- //figure out what type of data it is
-
- var temp;
- //it is a measurement?
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Propertiesa
- var match;
- if (match = /^([+\-]?[\d\.]+)([a-z]+)$/i.exec(text)){ //dimension
- this.type = "dimension";
- this.value = +match[1];
- this.units = match[2];
-
- //try to narrow down
- switch(this.units.toLowerCase()){
-
- case "em":
- case "rem":
- case "ex":
- case "px":
- case "cm":
- case "mm":
- case "in":
- case "pt":
- case "pc":
- case "ch":
- case "vh":
- case "vw":
- case "vmax":
- case "vmin":
- this.type = "length";
- break;
-
- case "fr":
- this.type = "grid";
- break;
-
- case "deg":
- case "rad":
- case "grad":
- this.type = "angle";
- break;
-
- case "ms":
- case "s":
- this.type = "time";
- break;
-
- case "hz":
- case "khz":
- this.type = "frequency";
- break;
-
- case "dpi":
- case "dpcm":
- this.type = "resolution";
- break;
-
- //default
-
- }
-
- } else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
- this.type = "percentage";
- this.value = +RegExp.$1;
- } else if (/^([+\-]?\d+)$/i.test(text)){ //integer
- this.type = "integer";
- this.value = +RegExp.$1;
- } else if (/^([+\-]?[\d\.]+)$/i.test(text)){ //number
- this.type = "number";
- this.value = +RegExp.$1;
-
- } else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
- this.type = "color";
- temp = RegExp.$1;
- if (temp.length === 3){
- this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
- this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
- this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);
- } else {
- this.red = parseInt(temp.substring(0,2),16);
- this.green = parseInt(temp.substring(2,4),16);
- this.blue = parseInt(temp.substring(4,6),16);
- }
- } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){ //rgb() color with absolute numbers
- this.type = "color";
- this.red = +RegExp.$1;
- this.green = +RegExp.$2;
- this.blue = +RegExp.$3;
- } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //rgb() color with percentages
- this.type = "color";
- this.red = +RegExp.$1 * 255 / 100;
- this.green = +RegExp.$2 * 255 / 100;
- this.blue = +RegExp.$3 * 255 / 100;
- } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with absolute numbers
- this.type = "color";
- this.red = +RegExp.$1;
- this.green = +RegExp.$2;
- this.blue = +RegExp.$3;
- this.alpha = +RegExp.$4;
- } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with percentages
- this.type = "color";
- this.red = +RegExp.$1 * 255 / 100;
- this.green = +RegExp.$2 * 255 / 100;
- this.blue = +RegExp.$3 * 255 / 100;
- this.alpha = +RegExp.$4;
- } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //hsl()
- this.type = "color";
- this.hue = +RegExp.$1;
- this.saturation = +RegExp.$2 / 100;
- this.lightness = +RegExp.$3 / 100;
- } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //hsla() color with percentages
- this.type = "color";
- this.hue = +RegExp.$1;
- this.saturation = +RegExp.$2 / 100;
- this.lightness = +RegExp.$3 / 100;
- this.alpha = +RegExp.$4;
- } else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)){ //URI
- this.type = "uri";
- this.uri = RegExp.$1;
- } else if (/^([^\(]+)\(/i.test(text)){
- this.type = "function";
- this.name = RegExp.$1;
- this.value = text;
- } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)){ //double-quoted string
- this.type = "string";
- this.value = PropertyValuePart.parseString(text);
- } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)){ //single-quoted string
- this.type = "string";
- this.value = PropertyValuePart.parseString(text);
- } else if (Colors[text.toLowerCase()]){ //named color
- this.type = "color";
- temp = Colors[text.toLowerCase()].substring(1);
- this.red = parseInt(temp.substring(0,2),16);
- this.green = parseInt(temp.substring(2,4),16);
- this.blue = parseInt(temp.substring(4,6),16);
- } else if (/^[\,\/]$/.test(text)){
- this.type = "operator";
- this.value = text;
- } else if (/^[a-z\-_\u0080-\uFFFF][a-z0-9\-_\u0080-\uFFFF]*$/i.test(text)){
- this.type = "identifier";
- this.value = text;
- }
-
-}
-
-PropertyValuePart.prototype = new SyntaxUnit();
-PropertyValuePart.prototype.constructor = PropertyValuePart;
-
-/**
- * Helper method to parse a CSS string.
- */
-PropertyValuePart.parseString = function(str) {
- str = str.slice(1, -1); // Strip surrounding single/double quotes
- var replacer = function(match, esc) {
- if (/^(\n|\r\n|\r|\f)$/.test(esc)) { return ''; }
- var m = /^[0-9a-f]{1,6}/i.exec(esc);
- if (m) {
- var codePoint = parseInt(m[0], 16);
- if (String.fromCodePoint) {
- return String.fromCodePoint(codePoint);
- } else {
- // XXX No support for surrogates on old JavaScript engines.
- return String.fromCharCode(codePoint);
- }
- }
- return esc;
- };
- return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
- replacer);
-};
-
-/**
- * Helper method to serialize a CSS string.
- */
-PropertyValuePart.serializeString = function(value) {
- var replacer = function(match, c) {
- if (c === '"') {
- return "\\" + c;
- }
- var cp = String.codePointAt ? String.codePointAt(0) :
- // We only escape non-surrogate chars, so using charCodeAt
- // is harmless here.
- String.charCodeAt(0);
- return "\\" + cp.toString(16) + " ";
- };
- return '"' + value.replace(/["\r\n\f]/g, replacer) + '"';
-};
-
-/**
- * Create a new syntax unit based solely on the given token.
- * Convenience method for creating a new syntax unit when
- * it represents a single token instead of multiple.
- * @param {Object} token The token object to represent.
- * @return {parserlib.css.PropertyValuePart} The object representing the token.
- * @static
- * @method fromToken
- */
-PropertyValuePart.fromToken = function(token){
- return new PropertyValuePart(token.value, token.startLine, token.startCol);
-};
-var Pseudos = {
- __proto__: null,
- ":first-letter": 1,
- ":first-line": 1,
- ":before": 1,
- ":after": 1
-};
-
-Pseudos.ELEMENT = 1;
-Pseudos.CLASS = 2;
-
-Pseudos.isElement = function(pseudo){
- return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
-};
-/**
- * Represents an entire single selector, including all parts but not
- * including multiple selectors (those separated by commas).
- * @namespace parserlib.css
- * @class Selector
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {Array} parts Array of selectors parts making up this selector.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function Selector(parts, line, col){
-
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
-
- /**
- * The parts that make up the selector.
- * @type Array
- * @property parts
- */
- this.parts = parts;
-
- /**
- * The specificity of the selector.
- * @type parserlib.css.Specificity
- * @property specificity
- */
- this.specificity = Specificity.calculate(this);
-
-}
-
-Selector.prototype = new SyntaxUnit();
-Selector.prototype.constructor = Selector;
-
-/**
- * Represents a single part of a selector string, meaning a single set of
- * element name and modifiers. This does not include combinators such as
- * spaces, +, >, etc.
- * @namespace parserlib.css
- * @class SelectorPart
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {String} elementName The element name in the selector or null
- * if there is no element name.
- * @param {Array} modifiers Array of individual modifiers for the element.
- * May be empty if there are none.
- * @param {String} text The text representation of the unit.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function SelectorPart(elementName, modifiers, text, line, col){
-
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
-
- /**
- * The tag name of the element to which this part
- * of the selector affects.
- * @type String
- * @property elementName
- */
- this.elementName = elementName;
-
- /**
- * The parts that come after the element name, such as class names, IDs,
- * pseudo classes/elements, etc.
- * @type Array
- * @property modifiers
- */
- this.modifiers = modifiers;
-
-}
-
-SelectorPart.prototype = new SyntaxUnit();
-SelectorPart.prototype.constructor = SelectorPart;
-
-/**
- * Represents a selector modifier string, meaning a class name, element name,
- * element ID, pseudo rule, etc.
- * @namespace parserlib.css
- * @class SelectorSubPart
- * @extends parserlib.util.SyntaxUnit
- * @constructor
- * @param {String} text The text representation of the unit.
- * @param {String} type The type of selector modifier.
- * @param {int} line The line of text on which the unit resides.
- * @param {int} col The column of text on which the unit resides.
- */
-function SelectorSubPart(text, type, line, col){
-
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
-
- /**
- * The type of modifier.
- * @type String
- * @property type
- */
- this.type = type;
-
- /**
- * Some subparts have arguments, this represents them.
- * @type Array
- * @property args
- */
- this.args = [];
-
-}
-
-SelectorSubPart.prototype = new SyntaxUnit();
-SelectorSubPart.prototype.constructor = SelectorSubPart;
-
-/**
- * Represents a selector's specificity.
- * @namespace parserlib.css
- * @class Specificity
- * @constructor
- * @param {int} a Should be 1 for inline styles, zero for stylesheet styles
- * @param {int} b Number of ID selectors
- * @param {int} c Number of classes and pseudo classes
- * @param {int} d Number of element names and pseudo elements
- */
-function Specificity(a, b, c, d){
- this.a = a;
- this.b = b;
- this.c = c;
- this.d = d;
-}
-
-Specificity.prototype = {
- constructor: Specificity,
-
- /**
- * Compare this specificity to another.
- * @param {Specificity} other The other specificity to compare to.
- * @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
- * @method compare
- */
- compare: function(other){
- var comps = ["a", "b", "c", "d"],
- i, len;
-
- for (i=0, len=comps.length; i < len; i++){
- if (this[comps[i]] < other[comps[i]]){
- return -1;
- } else if (this[comps[i]] > other[comps[i]]){
- return 1;
- }
- }
-
- return 0;
- },
-
- /**
- * Creates a numeric value for the specificity.
- * @return {int} The numeric value for the specificity.
- * @method valueOf
- */
- valueOf: function(){
- return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
- },
-
- /**
- * Returns a string representation for specificity.
- * @return {String} The string representation of specificity.
- * @method toString
- */
- toString: function(){
- return this.a + "," + this.b + "," + this.c + "," + this.d;
- }
-
-};
-
-/**
- * Calculates the specificity of the given selector.
- * @param {parserlib.css.Selector} The selector to calculate specificity for.
- * @return {parserlib.css.Specificity} The specificity of the selector.
- * @static
- * @method calculate
- */
-Specificity.calculate = function(selector){
-
- var i, len,
- part,
- b=0, c=0, d=0;
-
- function updateValues(part){
-
- var i, j, len, num,
- elementName = part.elementName ? part.elementName.text : "",
- modifier;
-
- if (elementName && elementName.charAt(elementName.length-1) !== "*") {
- d++;
- }
-
- for (i=0, len=part.modifiers.length; i < len; i++){
- modifier = part.modifiers[i];
- switch(modifier.type){
- case "class":
- case "attribute":
- c++;
- break;
-
- case "id":
- b++;
- break;
-
- case "pseudo":
- if (Pseudos.isElement(modifier.text)){
- d++;
- } else {
- c++;
- }
- break;
-
- case "not":
- for (j=0, num=modifier.args.length; j < num; j++){
- updateValues(modifier.args[j]);
- }
- }
- }
- }
-
- for (i=0, len=selector.parts.length; i < len; i++){
- part = selector.parts[i];
-
- if (part instanceof SelectorPart){
- updateValues(part);
- }
- }
-
- return new Specificity(0, b, c, d);
-};
-
-var h = /^[0-9a-fA-F]$/,
- //nonascii = /^[\u0080-\uFFFF]$/,
- nl = /\n|\r\n|\r|\f/;
-
-//-----------------------------------------------------------------------------
-// Helper functions
-//-----------------------------------------------------------------------------
-
-
-function isHexDigit(c){
- return c !== null && h.test(c);
-}
-
-function isDigit(c){
- return c !== null && /\d/.test(c);
-}
-
-function isWhitespace(c){
- return c !== null && /\s/.test(c);
-}
-
-function isNewLine(c){
- return c !== null && nl.test(c);
-}
-
-function isNameStart(c){
- return c !== null && (/[a-z_\u0080-\uFFFF\\]/i.test(c));
-}
-
-function isNameChar(c){
- return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
-}
-
-function isIdentStart(c){
- return c !== null && (isNameStart(c) || /\-\\/.test(c));
-}
-
-function mix(receiver, supplier){
- for (var prop in supplier){
- if (Object.prototype.hasOwnProperty.call(supplier, prop)){
- receiver[prop] = supplier[prop];
- }
- }
- return receiver;
-}
-
-//-----------------------------------------------------------------------------
-// CSS Token Stream
-//-----------------------------------------------------------------------------
-
-
-/**
- * A token stream that produces CSS tokens.
- * @param {String|Reader} input The source of text to tokenize.
- * @constructor
- * @class TokenStream
- * @namespace parserlib.css
- */
-function TokenStream(input){
- TokenStreamBase.call(this, input, Tokens);
-}
-
-TokenStream.prototype = mix(new TokenStreamBase(), {
-
- /**
- * Overrides the TokenStreamBase method of the same name
- * to produce CSS tokens.
- * @param {variant} channel The name of the channel to use
- * for the next token.
- * @return {Object} A token object representing the next token.
- * @method _getToken
- * @private
- */
- _getToken: function(channel){
-
- var c,
- reader = this._reader,
- token = null,
- startLine = reader.getLine(),
- startCol = reader.getCol();
-
- c = reader.read();
-
-
- while(c){
- switch(c){
-
- /*
- * Potential tokens:
- * - COMMENT
- * - SLASH
- * - CHAR
- */
- case "/":
-
- if(reader.peek() === "*"){
- token = this.commentToken(c, startLine, startCol);
- } else {
- token = this.charToken(c, startLine, startCol);
- }
- break;
-
- /*
- * Potential tokens:
- * - DASHMATCH
- * - INCLUDES
- * - PREFIXMATCH
- * - SUFFIXMATCH
- * - SUBSTRINGMATCH
- * - CHAR
- */
- case "|":
- case "~":
- case "^":
- case "$":
- case "*":
- if(reader.peek() === "="){
- token = this.comparisonToken(c, startLine, startCol);
- } else {
- token = this.charToken(c, startLine, startCol);
- }
- break;
-
- /*
- * Potential tokens:
- * - STRING
- * - INVALID
- */
- case "\"":
- case "'":
- token = this.stringToken(c, startLine, startCol);
- break;
-
- /*
- * Potential tokens:
- * - HASH
- * - CHAR
- */
- case "#":
- if (isNameChar(reader.peek())){
- token = this.hashToken(c, startLine, startCol);
- } else {
- token = this.charToken(c, startLine, startCol);
- }
- break;
-
- /*
- * Potential tokens:
- * - DOT
- * - NUMBER
- * - DIMENSION
- * - PERCENTAGE
- */
- case ".":
- if (isDigit(reader.peek())){
- token = this.numberToken(c, startLine, startCol);
- } else {
- token = this.charToken(c, startLine, startCol);
- }
- break;
-
- /*
- * Potential tokens:
- * - CDC
- * - MINUS
- * - NUMBER
- * - DIMENSION
- * - PERCENTAGE
- */
- case "-":
- if (reader.peek() === "-"){ //could be closing HTML-style comment
- token = this.htmlCommentEndToken(c, startLine, startCol);
- } else if (isNameStart(reader.peek())){
- token = this.identOrFunctionToken(c, startLine, startCol);
- } else {
- token = this.charToken(c, startLine, startCol);
- }
- break;
-
- /*
- * Potential tokens:
- * - IMPORTANT_SYM
- * - CHAR
- */
- case "!":
- token = this.importantToken(c, startLine, startCol);
- break;
-
- /*
- * Any at-keyword or CHAR
- */
- case "@":
- token = this.atRuleToken(c, startLine, startCol);
- break;
-
- /*
- * Potential tokens:
- * - NOT
- * - CHAR
- */
- case ":":
- token = this.notToken(c, startLine, startCol);
- break;
-
- /*
- * Potential tokens:
- * - CDO
- * - CHAR
- */
- case "<":
- token = this.htmlCommentStartToken(c, startLine, startCol);
- break;
-
- /*
- * Potential tokens:
- * - UNICODE_RANGE
- * - URL
- * - CHAR
- */
- case "U":
- case "u":
- if (reader.peek() === "+"){
- token = this.unicodeRangeToken(c, startLine, startCol);
- break;
- }
- /* falls through */
- default:
-
- /*
- * Potential tokens:
- * - NUMBER
- * - DIMENSION
- * - LENGTH
- * - FREQ
- * - TIME
- * - EMS
- * - EXS
- * - ANGLE
- */
- if (isDigit(c)){
- token = this.numberToken(c, startLine, startCol);
- } else
-
- /*
- * Potential tokens:
- * - S
- */
- if (isWhitespace(c)){
- token = this.whitespaceToken(c, startLine, startCol);
- } else
-
- /*
- * Potential tokens:
- * - IDENT
- */
- if (isIdentStart(c)){
- token = this.identOrFunctionToken(c, startLine, startCol);
- } else
-
- /*
- * Potential tokens:
- * - CHAR
- * - PLUS
- */
- {
- token = this.charToken(c, startLine, startCol);
- }
-
-
-
-
-
-
- }
-
- //make sure this token is wanted
- //TODO: check channel
- break;
- }
-
- if (!token && c === null){
- token = this.createToken(Tokens.EOF,null,startLine,startCol);
- }
-
- return token;
- },
-
- //-------------------------------------------------------------------------
- // Methods to create tokens
- //-------------------------------------------------------------------------
-
- /**
- * Produces a token based on available data and the current
- * reader position information. This method is called by other
- * private methods to create tokens and is never called directly.
- * @param {int} tt The token type.
- * @param {String} value The text value of the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @param {Object} options (Optional) Specifies a channel property
- * to indicate that a different channel should be scanned
- * and/or a hide property indicating that the token should
- * be hidden.
- * @return {Object} A token object.
- * @method createToken
- */
- createToken: function(tt, value, startLine, startCol, options){
- var reader = this._reader;
- options = options || {};
-
- return {
- value: value,
- type: tt,
- channel: options.channel,
- endChar: options.endChar,
- hide: options.hide || false,
- startLine: startLine,
- startCol: startCol,
- endLine: reader.getLine(),
- endCol: reader.getCol()
- };
- },
-
- //-------------------------------------------------------------------------
- // Methods to create specific tokens
- //-------------------------------------------------------------------------
-
- /**
- * Produces a token for any at-rule. If the at-rule is unknown, then
- * the token is for a single "@" character.
- * @param {String} first The first character for the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method atRuleToken
- */
- atRuleToken: function(first, startLine, startCol){
- var rule = first,
- reader = this._reader,
- tt = Tokens.CHAR,
- ident;
-
- /*
- * First, mark where we are. There are only four @ rules,
- * so anything else is really just an invalid token.
- * Basically, if this doesn't match one of the known @
- * rules, just return '@' as an unknown token and allow
- * parsing to continue after that point.
- */
- reader.mark();
-
- //try to find the at-keyword
- ident = this.readName();
- rule = first + ident;
- tt = Tokens.type(rule.toLowerCase());
-
- //if it's not valid, use the first character only and reset the reader
- if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN){
- if (rule.length > 1){
- tt = Tokens.UNKNOWN_SYM;
- } else {
- tt = Tokens.CHAR;
- rule = first;
- reader.reset();
- }
- }
-
- return this.createToken(tt, rule, startLine, startCol);
- },
-
- /**
- * Produces a character token based on the given character
- * and location in the stream. If there's a special (non-standard)
- * token name, this is used; otherwise CHAR is used.
- * @param {String} c The character for the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method charToken
- */
- charToken: function(c, startLine, startCol){
- var tt = Tokens.type(c);
- var opts = {};
-
- if (tt === -1){
- tt = Tokens.CHAR;
- } else {
- opts.endChar = Tokens[tt].endChar;
- }
-
- return this.createToken(tt, c, startLine, startCol, opts);
- },
-
- /**
- * Produces a character token based on the given character
- * and location in the stream. If there's a special (non-standard)
- * token name, this is used; otherwise CHAR is used.
- * @param {String} first The first character for the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method commentToken
- */
- commentToken: function(first, startLine, startCol){
- var comment = this.readComment(first);
-
- return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
- },
-
- /**
- * Produces a comparison token based on the given character
- * and location in the stream. The next character must be
- * read and is already known to be an equals sign.
- * @param {String} c The character for the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method comparisonToken
- */
- comparisonToken: function(c, startLine, startCol){
- var reader = this._reader,
- comparison = c + reader.read(),
- tt = Tokens.type(comparison) || Tokens.CHAR;
-
- return this.createToken(tt, comparison, startLine, startCol);
- },
-
- /**
- * Produces a hash token based on the specified information. The
- * first character provided is the pound sign (#) and then this
- * method reads a name afterward.
- * @param {String} first The first character (#) in the hash name.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method hashToken
- */
- hashToken: function(first, startLine, startCol){
- var name = this.readName(first);
-
- return this.createToken(Tokens.HASH, name, startLine, startCol);
- },
-
- /**
- * Produces a CDO or CHAR token based on the specified information. The
- * first character is provided and the rest is read by the function to determine
- * the correct token to create.
- * @param {String} first The first character in the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method htmlCommentStartToken
- */
- htmlCommentStartToken: function(first, startLine, startCol){
- var reader = this._reader,
- text = first;
-
- reader.mark();
- text += reader.readCount(3);
-
- if (text === "<!--"){
- return this.createToken(Tokens.CDO, text, startLine, startCol);
- } else {
- reader.reset();
- return this.charToken(first, startLine, startCol);
- }
- },
-
- /**
- * Produces a CDC or CHAR token based on the specified information. The
- * first character is provided and the rest is read by the function to determine
- * the correct token to create.
- * @param {String} first The first character in the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method htmlCommentEndToken
- */
- htmlCommentEndToken: function(first, startLine, startCol){
- var reader = this._reader,
- text = first;
-
- reader.mark();
- text += reader.readCount(2);
-
- if (text === "-->"){
- return this.createToken(Tokens.CDC, text, startLine, startCol);
- } else {
- reader.reset();
- return this.charToken(first, startLine, startCol);
- }
- },
-
- /**
- * Produces an IDENT or FUNCTION token based on the specified information. The
- * first character is provided and the rest is read by the function to determine
- * the correct token to create.
- * @param {String} first The first character in the identifier.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method identOrFunctionToken
- */
- identOrFunctionToken: function(first, startLine, startCol){
- var reader = this._reader,
- ident = this.readName(first),
- tt = Tokens.IDENT,
- uriFns = ["url(", "url-prefix(", "domain("];
-
- //if there's a left paren immediately after, it's a URI or function
- if (reader.peek() === "("){
- ident += reader.read();
- if (uriFns.indexOf(ident.toLowerCase()) > -1){
- tt = Tokens.URI;
- ident = this.readURI(ident);
-
- //didn't find a valid URL or there's no closing paren
- if (uriFns.indexOf(ident.toLowerCase()) > -1){
- tt = Tokens.FUNCTION;
- }
- } else {
- tt = Tokens.FUNCTION;
- }
- } else if (reader.peek() === ":"){ //might be an IE function
-
- //IE-specific functions always being with progid:
- if (ident.toLowerCase() === "progid"){
- ident += reader.readTo("(");
- tt = Tokens.IE_FUNCTION;
- }
- }
-
- return this.createToken(tt, ident, startLine, startCol);
- },
-
- /**
- * Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
- * first character is provided and the rest is read by the function to determine
- * the correct token to create.
- * @param {String} first The first character in the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method importantToken
- */
- importantToken: function(first, startLine, startCol){
- var reader = this._reader,
- important = first,
- tt = Tokens.CHAR,
- temp,
- c;
-
- reader.mark();
- c = reader.read();
-
- while(c){
-
- //there can be a comment in here
- if (c === "/"){
-
- //if the next character isn't a star, then this isn't a valid !important token
- if (reader.peek() !== "*"){
- break;
- } else {
- temp = this.readComment(c);
- if (temp === ""){ //broken!
- break;
- }
- }
- } else if (isWhitespace(c)){
- important += c + this.readWhitespace();
- } else if (/i/i.test(c)){
- temp = reader.readCount(8);
- if (/mportant/i.test(temp)){
- important += c + temp;
- tt = Tokens.IMPORTANT_SYM;
-
- }
- break; //we're done
- } else {
- break;
- }
-
- c = reader.read();
- }
-
- if (tt === Tokens.CHAR){
- reader.reset();
- return this.charToken(first, startLine, startCol);
- } else {
- return this.createToken(tt, important, startLine, startCol);
- }
-
-
- },
-
- /**
- * Produces a NOT or CHAR token based on the specified information. The
- * first character is provided and the rest is read by the function to determine
- * the correct token to create.
- * @param {String} first The first character in the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method notToken
- */
- notToken: function(first, startLine, startCol){
- var reader = this._reader,
- text = first;
-
- reader.mark();
- text += reader.readCount(4);
-
- if (text.toLowerCase() === ":not("){
- return this.createToken(Tokens.NOT, text, startLine, startCol);
- } else {
- reader.reset();
- return this.charToken(first, startLine, startCol);
- }
- },
-
- /**
- * Produces a number token based on the given character
- * and location in the stream. This may return a token of
- * NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
- * or PERCENTAGE.
- * @param {String} first The first character for the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method numberToken
- */
- numberToken: function(first, startLine, startCol){
- var reader = this._reader,
- value = this.readNumber(first),
- ident,
- tt = Tokens.NUMBER,
- c = reader.peek();
-
- if (isIdentStart(c)){
- ident = this.readName(reader.read());
- value += ident;
-
- if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){
- tt = Tokens.LENGTH;
- } else if (/^deg|^rad$|^grad$/i.test(ident)){
- tt = Tokens.ANGLE;
- } else if (/^ms$|^s$/i.test(ident)){
- tt = Tokens.TIME;
- } else if (/^hz$|^khz$/i.test(ident)){
- tt = Tokens.FREQ;
- } else if (/^dpi$|^dpcm$/i.test(ident)){
- tt = Tokens.RESOLUTION;
- } else {
- tt = Tokens.DIMENSION;
- }
-
- } else if (c === "%"){
- value += reader.read();
- tt = Tokens.PERCENTAGE;
- }
-
- return this.createToken(tt, value, startLine, startCol);
- },
-
- /**
- * Produces a string token based on the given character
- * and location in the stream. Since strings may be indicated
- * by single or double quotes, a failure to match starting
- * and ending quotes results in an INVALID token being generated.
- * The first character in the string is passed in and then
- * the rest are read up to and including the final quotation mark.
- * @param {String} first The first character in the string.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method stringToken
- */
- stringToken: function(first, startLine, startCol){
- var delim = first,
- string = first,
- reader = this._reader,
- prev = first,
- tt = Tokens.STRING,
- c = reader.read();
-
- while(c){
- string += c;
-
- //if the delimiter is found with an escapement, we're done.
- if (c === delim && prev !== "\\"){
- break;
- }
-
- //if there's a newline without an escapement, it's an invalid string
- if (isNewLine(reader.peek()) && c !== "\\"){
- tt = Tokens.INVALID;
- break;
- }
-
- //save previous and get next
- prev = c;
- c = reader.read();
- }
-
- //if c is null, that means we're out of input and the string was never closed
- if (c === null){
- tt = Tokens.INVALID;
- }
-
- return this.createToken(tt, string, startLine, startCol);
- },
-
- unicodeRangeToken: function(first, startLine, startCol){
- var reader = this._reader,
- value = first,
- temp,
- tt = Tokens.CHAR;
-
- //then it should be a unicode range
- if (reader.peek() === "+"){
- reader.mark();
- value += reader.read();
- value += this.readUnicodeRangePart(true);
-
- //ensure there's an actual unicode range here
- if (value.length === 2){
- reader.reset();
- } else {
-
- tt = Tokens.UNICODE_RANGE;
-
- //if there's a ? in the first part, there can't be a second part
- if (value.indexOf("?") === -1){
-
- if (reader.peek() === "-"){
- reader.mark();
- temp = reader.read();
- temp += this.readUnicodeRangePart(false);
-
- //if there's not another value, back up and just take the first
- if (temp.length === 1){
- reader.reset();
- } else {
- value += temp;
- }
- }
-
- }
- }
- }
-
- return this.createToken(tt, value, startLine, startCol);
- },
-
- /**
- * Produces a S token based on the specified information. Since whitespace
- * may have multiple characters, this consumes all whitespace characters
- * into a single token.
- * @param {String} first The first character in the token.
- * @param {int} startLine The beginning line for the character.
- * @param {int} startCol The beginning column for the character.
- * @return {Object} A token object.
- * @method whitespaceToken
- */
- whitespaceToken: function(first, startLine, startCol){
- var value = first + this.readWhitespace();
- return this.createToken(Tokens.S, value, startLine, startCol);
- },
-
-
-
-
- //-------------------------------------------------------------------------
- // Methods to read values from the string stream
- //-------------------------------------------------------------------------
-
- readUnicodeRangePart: function(allowQuestionMark){
- var reader = this._reader,
- part = "",
- c = reader.peek();
-
- //first read hex digits
- while(isHexDigit(c) && part.length < 6){
- reader.read();
- part += c;
- c = reader.peek();
- }
-
- //then read question marks if allowed
- if (allowQuestionMark){
- while(c === "?" && part.length < 6){
- reader.read();
- part += c;
- c = reader.peek();
- }
- }
-
- //there can't be any other characters after this point
-
- return part;
- },
-
- readWhitespace: function(){
- var reader = this._reader,
- whitespace = "",
- c = reader.peek();
-
- while(isWhitespace(c)){
- reader.read();
- whitespace += c;
- c = reader.peek();
- }
-
- return whitespace;
- },
- readNumber: function(first){
- var reader = this._reader,
- number = first,
- hasDot = (first === "."),
- c = reader.peek();
-
-
- while(c){
- if (isDigit(c)){
- number += reader.read();
- } else if (c === "."){
- if (hasDot){
- break;
- } else {
- hasDot = true;
- number += reader.read();
- }
- } else {
- break;
- }
-
- c = reader.peek();
- }
-
- return number;
- },
- readString: function(){
- var reader = this._reader,
- delim = reader.read(),
- string = delim,
- prev = delim,
- c = reader.peek();
-
- while(c){
- c = reader.read();
- string += c;
-
- //if the delimiter is found with an escapement, we're done.
- if (c === delim && prev !== "\\"){
- break;
- }
-
- //if there's a newline without an escapement, it's an invalid string
- if (isNewLine(reader.peek()) && c !== "\\"){
- string = "";
- break;
- }
-
- //save previous and get next
- prev = c;
- c = reader.peek();
- }
-
- //if c is null, that means we're out of input and the string was never closed
- if (c === null){
- string = "";
- }
-
- return string;
- },
- readURI: function(first){
- var reader = this._reader,
- uri = first,
- inner = "",
- c = reader.peek();
-
- reader.mark();
-
- //skip whitespace before
- while(c && isWhitespace(c)){
- reader.read();
- c = reader.peek();
- }
-
- //it's a string
- if (c === "'" || c === "\""){
- inner = this.readString();
- } else {
- inner = this.readURL();
- }
-
- c = reader.peek();
-
- //skip whitespace after
- while(c && isWhitespace(c)){
- reader.read();
- c = reader.peek();
- }
-
- //if there was no inner value or the next character isn't closing paren, it's not a URI
- if (inner === "" || c !== ")"){
- uri = first;
- reader.reset();
- } else {
- uri += inner + reader.read();
- }
-
- return uri;
- },
- readURL: function(){
- var reader = this._reader,
- url = "",
- c = reader.peek();
-
- //TODO: Check for escape and nonascii
- while (/^[!#$%&\\*-~]$/.test(c)){
- url += reader.read();
- c = reader.peek();
- }
-
- return url;
-
- },
- readName: function(first){
- var reader = this._reader,
- ident = first || "",
- c = reader.peek();
-
- while(true){
- if (c === "\\"){
- ident += this.readEscape(reader.read());
- c = reader.peek();
- } else if(c && isNameChar(c)){
- ident += reader.read();
- c = reader.peek();
- } else {
- break;
- }
- }
-
- return ident;
- },
-
- readEscape: function(first){
- var reader = this._reader,
- cssEscape = first || "",
- i = 0,
- c = reader.peek();
-
- if (isHexDigit(c)){
- do {
- cssEscape += reader.read();
- c = reader.peek();
- } while(c && isHexDigit(c) && ++i < 6);
- }
-
- if (cssEscape.length === 3 && /\s/.test(c) ||
- cssEscape.length === 7 || cssEscape.length === 1){
- reader.read();
- } else {
- c = "";
- }
-
- return cssEscape + c;
- },
-
- readComment: function(first){
- var reader = this._reader,
- comment = first || "",
- c = reader.read();
-
- if (c === "*"){
- while(c){
- comment += c;
-
- //look for end of comment
- if (comment.length > 2 && c === "*" && reader.peek() === "/"){
- comment += reader.read();
- break;
- }
-
- c = reader.read();
- }
-
- return comment;
- } else {
- return "";
- }
-
- }
-});
-
-var Tokens = [
-
- /*
- * The following token names are defined in CSS3 Grammar: http://www.w3.org/TR/css3-syntax/#lexical
- */
-
- //HTML-style comments
- { name: "CDO"},
- { name: "CDC"},
-
- //ignorables
- { name: "S", whitespace: true/*, channel: "ws"*/},
- { name: "COMMENT", comment: true, hide: true, channel: "comment" },
-
- //attribute equality
- { name: "INCLUDES", text: "~="},
- { name: "DASHMATCH", text: "|="},
- { name: "PREFIXMATCH", text: "^="},
- { name: "SUFFIXMATCH", text: "$="},
- { name: "SUBSTRINGMATCH", text: "*="},
-
- //identifier types
- { name: "STRING"},
- { name: "IDENT"},
- { name: "HASH"},
-
- //at-keywords
- { name: "IMPORT_SYM", text: "@import"},
- { name: "PAGE_SYM", text: "@page"},
- { name: "MEDIA_SYM", text: "@media"},
- { name: "FONT_FACE_SYM", text: "@font-face"},
- { name: "CHARSET_SYM", text: "@charset"},
- { name: "NAMESPACE_SYM", text: "@namespace"},
- { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"]},
- { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"]},
- { name: "UNKNOWN_SYM" },
- //{ name: "ATKEYWORD"},
-
- //CSS3 animations
- { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
-
- //important symbol
- { name: "IMPORTANT_SYM"},
-
- //measurements
- { name: "LENGTH"},
- { name: "ANGLE"},
- { name: "TIME"},
- { name: "FREQ"},
- { name: "DIMENSION"},
- { name: "PERCENTAGE"},
- { name: "NUMBER"},
-
- //functions
- { name: "URI"},
- { name: "FUNCTION"},
-
- //Unicode ranges
- { name: "UNICODE_RANGE"},
-
- /*
- * The following token names are defined in CSS3 Selectors: http://www.w3.org/TR/css3-selectors/#selector-syntax
- */
-
- //invalid string
- { name: "INVALID"},
-
- //combinators
- { name: "PLUS", text: "+" },
- { name: "GREATER", text: ">"},
- { name: "COMMA", text: ","},
- { name: "TILDE", text: "~"},
-
- //modifier
- { name: "NOT"},
-
- /*
- * Defined in CSS3 Paged Media
- */
- { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner"},
- { name: "TOPLEFT_SYM", text: "@top-left"},
- { name: "TOPCENTER_SYM", text: "@top-center"},
- { name: "TOPRIGHT_SYM", text: "@top-right"},
- { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner"},
- { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner"},
- { name: "BOTTOMLEFT_SYM", text: "@bottom-left"},
- { name: "BOTTOMCENTER_SYM", text: "@bottom-center"},
- { name: "BOTTOMRIGHT_SYM", text: "@bottom-right"},
- { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner"},
- { name: "LEFTTOP_SYM", text: "@left-top"},
- { name: "LEFTMIDDLE_SYM", text: "@left-middle"},
- { name: "LEFTBOTTOM_SYM", text: "@left-bottom"},
- { name: "RIGHTTOP_SYM", text: "@right-top"},
- { name: "RIGHTMIDDLE_SYM", text: "@right-middle"},
- { name: "RIGHTBOTTOM_SYM", text: "@right-bottom"},
-
- /*
- * The following token names are defined in CSS3 Media Queries: http://www.w3.org/TR/css3-mediaqueries/#syntax
- */
- /*{ name: "MEDIA_ONLY", state: "media"},
- { name: "MEDIA_NOT", state: "media"},
- { name: "MEDIA_AND", state: "media"},*/
- { name: "RESOLUTION", state: "media"},
-
- /*
- * The following token names are not defined in any CSS specification but are used by the lexer.
- */
-
- //not a real token, but useful for stupid IE filters
- { name: "IE_FUNCTION" },
-
- //part of CSS3 grammar but not the Flex code
- { name: "CHAR" },
-
- //TODO: Needed?
- //Not defined as tokens, but might as well be
- {
- name: "PIPE",
- text: "|"
- },
- {
- name: "SLASH",
- text: "/"
- },
- {
- name: "MINUS",
- text: "-"
- },
- {
- name: "STAR",
- text: "*"
- },
-
- {
- name: "LBRACE",
- endChar: "}",
- text: "{"
- },
- {
- name: "RBRACE",
- text: "}"
- },
- {
- name: "LBRACKET",
- endChar: "]",
- text: "["
- },
- {
- name: "RBRACKET",
- text: "]"
- },
- {
- name: "EQUALS",
- text: "="
- },
- {
- name: "COLON",
- text: ":"
- },
- {
- name: "SEMICOLON",
- text: ";"
- },
-
- {
- name: "LPAREN",
- endChar: ")",
- text: "("
- },
- {
- name: "RPAREN",
- text: ")"
- },
- {
- name: "DOT",
- text: "."
- }
-];
-
-(function(){
-
- var nameMap = [],
- typeMap = Object.create(null);
-
- Tokens.UNKNOWN = -1;
- Tokens.unshift({name:"EOF"});
- for (var i=0, len = Tokens.length; i < len; i++){
- nameMap.push(Tokens[i].name);
- Tokens[Tokens[i].name] = i;
- if (Tokens[i].text){
- if (Tokens[i].text instanceof Array){
- for (var j=0; j < Tokens[i].text.length; j++){
- typeMap[Tokens[i].text[j]] = i;
- }
- } else {
- typeMap[Tokens[i].text] = i;
- }
- }
- }
-
- Tokens.name = function(tt){
- return nameMap[tt];
- };
-
- Tokens.type = function(c){
- return typeMap[c] || -1;
- };
-
-})();
-
-
-
-//This file will likely change a lot! Very experimental!
-var Validation = {
-
- validate: function(property, value){
-
- //normalize name
- var name = property.toString().toLowerCase(),
- expression = new PropertyValueIterator(value),
- spec = Properties[name];
-
- if (!spec) {
- if (name.indexOf("-") !== 0){ //vendor prefixed are ok
- throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
- }
- } else if (typeof spec !== "number"){
-
- //initialization
- if (typeof spec === "string"){
- if (spec.indexOf("||") > -1) {
- this.groupProperty(spec, expression);
- } else {
- this.singleProperty(spec, expression, 1);
- }
-
- } else if (spec.multi) {
- this.multiProperty(spec.multi, expression, spec.comma, spec.max || Infinity);
- } else if (typeof spec === "function") {
- spec(expression);
- }
-
- }
-
- },
-
- singleProperty: function(types, expression, max, partial) {
-
- var result = false,
- value = expression.value,
- count = 0,
- part;
-
- while (expression.hasNext() && count < max) {
- result = ValidationTypes.isAny(expression, types);
- if (!result) {
- break;
- }
- count++;
- }
-
- if (!result) {
- if (expression.hasNext() && !expression.isFirst()) {
- part = expression.peek();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
- }
- } else if (expression.hasNext()) {
- part = expression.next();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- }
-
- },
-
- multiProperty: function (types, expression, comma, max) {
-
- var result = false,
- value = expression.value,
- count = 0,
- part;
-
- while(expression.hasNext() && !result && count < max) {
- if (ValidationTypes.isAny(expression, types)) {
- count++;
- if (!expression.hasNext()) {
- result = true;
-
- } else if (comma) {
- if (String(expression.peek()) === ",") {
- part = expression.next();
- } else {
- break;
- }
- }
- } else {
- break;
-
- }
- }
-
- if (!result) {
- if (expression.hasNext() && !expression.isFirst()) {
- part = expression.peek();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- part = expression.previous();
- if (comma && String(part) === ",") {
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
- }
- }
-
- } else if (expression.hasNext()) {
- part = expression.next();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- }
-
- },
-
- groupProperty: function (types, expression, comma) {
-
- var result = false,
- value = expression.value,
- typeCount = types.split("||").length,
- groups = { count: 0 },
- partial = false,
- name,
- part;
-
- while(expression.hasNext() && !result) {
- name = ValidationTypes.isAnyOfGroup(expression, types);
- if (name) {
-
- //no dupes
- if (groups[name]) {
- break;
- } else {
- groups[name] = 1;
- groups.count++;
- partial = true;
-
- if (groups.count === typeCount || !expression.hasNext()) {
- result = true;
- }
- }
- } else {
- break;
- }
- }
-
- if (!result) {
- if (partial && expression.hasNext()) {
- part = expression.peek();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- } else {
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
- }
- } else if (expression.hasNext()) {
- part = expression.next();
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
- }
- }
-
-
-
-};
-/**
- * Type to use when a validation error occurs.
- * @class ValidationError
- * @namespace parserlib.util
- * @constructor
- * @param {String} message The error message.
- * @param {int} line The line at which the error occurred.
- * @param {int} col The column at which the error occurred.
- */
-function ValidationError(message, line, col){
-
- /**
- * The column at which the error occurred.
- * @type int
- * @property col
- */
- this.col = col;
-
- /**
- * The line at which the error occurred.
- * @type int
- * @property line
- */
- this.line = line;
-
- /**
- * The text representation of the unit.
- * @type String
- * @property text
- */
- this.message = message;
-
-}
-
-//inherit from Error
-ValidationError.prototype = new Error();
-//This file will likely change a lot! Very experimental!
-var ValidationTypes = {
-
- isLiteral: function (part, literals) {
- var text = part.text.toString().toLowerCase(),
- args = literals.split(" | "),
- i, len, found = false;
-
- for (i=0,len=args.length; i < len && !found; i++){
- if (text === args[i].toLowerCase()){
- found = true;
- }
- }
-
- return found;
- },
-
- isSimple: function(type) {
- return !!this.simple[type];
- },
-
- isComplex: function(type) {
- return !!this.complex[type];
- },
-
- /**
- * Determines if the next part(s) of the given expression
- * are any of the given types.
- */
- isAny: function (expression, types) {
- var args = types.split(" | "),
- i, len, found = false;
-
- for (i=0,len=args.length; i < len && !found && expression.hasNext(); i++){
- found = this.isType(expression, args[i]);
- }
-
- return found;
- },
-
- /**
- * Determines if the next part(s) of the given expression
- * are one of a group.
- */
- isAnyOfGroup: function(expression, types) {
- var args = types.split(" || "),
- i, len, found = false;
-
- for (i=0,len=args.length; i < len && !found; i++){
- found = this.isType(expression, args[i]);
- }
-
- return found ? args[i-1] : false;
- },
-
- /**
- * Determines if the next part(s) of the given expression
- * are of a given type.
- */
- isType: function (expression, type) {
- var part = expression.peek(),
- result = false;
-
- if (type.charAt(0) !== "<") {
- result = this.isLiteral(part, type);
- if (result) {
- expression.next();
- }
- } else if (this.simple[type]) {
- result = this.simple[type](part);
- if (result) {
- expression.next();
- }
- } else {
- result = this.complex[type](expression);
- }
-
- return result;
- },
-
-
-
- simple: {
- __proto__: null,
-
- "<absolute-size>": function(part){
- return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
- },
-
- "<attachment>": function(part){
- return ValidationTypes.isLiteral(part, "scroll | fixed | local");
- },
-
- "<attr>": function(part){
- return part.type === "function" && part.name === "attr";
- },
-
- "<bg-image>": function(part){
- return this["<image>"](part) || this["<gradient>"](part) || String(part) === "none";
- },
-
- "<gradient>": function(part) {
- return part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
- },
-
- "<box>": function(part){
- return ValidationTypes.isLiteral(part, "padding-box | border-box | content-box");
- },
-
- "<content>": function(part){
- return part.type === "function" && part.name === "content";
- },
-
- "<relative-size>": function(part){
- return ValidationTypes.isLiteral(part, "smaller | larger");
- },
-
- //any identifier
- "<ident>": function(part){
- return part.type === "identifier";
- },
-
- "<length>": function(part){
- if (part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
- return true;
- }else{
- return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
- }
- },
-
- "<color>": function(part){
- return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
- },
-
- "<number>": function(part){
- return part.type === "number" || this["<integer>"](part);
- },
-
- "<integer>": function(part){
- return part.type === "integer";
- },
-
- "<line>": function(part){
- return part.type === "integer";
- },
-
- "<angle>": function(part){
- return part.type === "angle";
- },
-
- "<uri>": function(part){
- return part.type === "uri";
- },
-
- "<image>": function(part){
- return this["<uri>"](part);
- },
-
- "<percentage>": function(part){
- return part.type === "percentage" || String(part) === "0";
- },
-
- "<border-width>": function(part){
- return this["<length>"](part) || ValidationTypes.isLiteral(part, "thin | medium | thick");
- },
-
- "<border-style>": function(part){
- return ValidationTypes.isLiteral(part, "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");
- },
-
- "<content-sizing>": function(part){ // http://www.w3.org/TR/css3-sizing/#width-height-keywords
- return ValidationTypes.isLiteral(part, "fill-available | -moz-available | -webkit-fill-available | max-content | -moz-max-content | -webkit-max-content | min-content | -moz-min-content | -webkit-min-content | fit-content | -moz-fit-content | -webkit-fit-content");
- },
-
- "<margin-width>": function(part){
- return this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "auto");
- },
-
- "<padding-width>": function(part){
- return this["<length>"](part) || this["<percentage>"](part);
- },
-
- "<shape>": function(part){
- return part.type === "function" && (part.name === "rect" || part.name === "inset-rect");
- },
-
- "<time>": function(part) {
- return part.type === "time";
- },
-
- "<flex-grow>": function(part){
- return this["<number>"](part);
- },
-
- "<flex-shrink>": function(part){
- return this["<number>"](part);
- },
-
- "<width>": function(part){
- return this["<margin-width>"](part);
- },
-
- "<flex-basis>": function(part){
- return this["<width>"](part);
- },
-
- "<flex-direction>": function(part){
- return ValidationTypes.isLiteral(part, "row | row-reverse | column | column-reverse");
- },
-
- "<flex-wrap>": function(part){
- return ValidationTypes.isLiteral(part, "nowrap | wrap | wrap-reverse");
- },
-
- "<feature-tag-value>": function(part){
- return (part.type === "function" && /^[A-Z0-9]{4}$/i.test(part));
- }
- },
-
- complex: {
- __proto__: null,
-
- "<bg-position>": function(expression){
- var result = false,
- numeric = "<percentage> | <length>",
- xDir = "left | right",
- yDir = "top | bottom",
- count = 0;
-
- while (expression.peek(count) && expression.peek(count).text !== ",") {
- count++;
- }
-
-/*
-<position> = [
- [ left | center | right | top | bottom | <percentage> | <length> ]
-|
- [ left | center | right | <percentage> | <length> ]
- [ top | center | bottom | <percentage> | <length> ]
-|
- [ center | [ left | right ] [ <percentage> | <length> ]? ] &&
- [ center | [ top | bottom ] [ <percentage> | <length> ]? ]
-]
-*/
-
- if (count < 3) {
- if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
- result = true;
- ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
- } else if (ValidationTypes.isAny(expression, yDir)) {
- result = true;
- ValidationTypes.isAny(expression, xDir + " | center");
- }
- } else {
- if (ValidationTypes.isAny(expression, xDir)) {
- if (ValidationTypes.isAny(expression, yDir)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- } else if (ValidationTypes.isAny(expression, numeric)) {
- if (ValidationTypes.isAny(expression, yDir)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- } else if (ValidationTypes.isAny(expression, "center")) {
- result = true;
- }
- }
- } else if (ValidationTypes.isAny(expression, yDir)) {
- if (ValidationTypes.isAny(expression, xDir)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- } else if (ValidationTypes.isAny(expression, numeric)) {
- if (ValidationTypes.isAny(expression, xDir)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- } else if (ValidationTypes.isAny(expression, "center")) {
- result = true;
- }
- }
- } else if (ValidationTypes.isAny(expression, "center")) {
- if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- }
- }
- }
-
- return result;
- },
-
- "<bg-size>": function(expression){
- //<bg-size> = [ <length> | <percentage> | auto ]{1,2} | cover | contain
- var result = false,
- numeric = "<percentage> | <length> | auto";
-
- if (ValidationTypes.isAny(expression, "cover | contain")) {
- result = true;
- } else if (ValidationTypes.isAny(expression, numeric)) {
- result = true;
- ValidationTypes.isAny(expression, numeric);
- }
-
- return result;
- },
-
- "<repeat-style>": function(expression){
- //repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
- var result = false,
- values = "repeat | space | round | no-repeat",
- part;
-
- if (expression.hasNext()){
- part = expression.next();
-
- if (ValidationTypes.isLiteral(part, "repeat-x | repeat-y")) {
- result = true;
- } else if (ValidationTypes.isLiteral(part, values)) {
- result = true;
-
- if (expression.hasNext() && ValidationTypes.isLiteral(expression.peek(), values)) {
- expression.next();
- }
- }
- }
-
- return result;
-
- },
-
- "<shadow>": function(expression) {
- //inset? && [ <length>{2,4} && <color>? ]
- var result = false,
- count = 0,
- inset = false,
- color = false;
-
- if (expression.hasNext()) {
-
- if (ValidationTypes.isAny(expression, "inset")){
- inset = true;
- }
-
- if (ValidationTypes.isAny(expression, "<color>")) {
- color = true;
- }
-
- while (ValidationTypes.isAny(expression, "<length>") && count < 4) {
- count++;
- }
-
-
- if (expression.hasNext()) {
- if (!color) {
- ValidationTypes.isAny(expression, "<color>");
- }
-
- if (!inset) {
- ValidationTypes.isAny(expression, "inset");
- }
-
- }
-
- result = (count >= 2 && count <= 4);
-
- }
-
- return result;
- },
-
- "<x-one-radius>": function(expression) {
- //[ <length> | <percentage> ] [ <length> | <percentage> ]?
- var result = false,
- simple = "<length> | <percentage> | inherit";
-
- if (ValidationTypes.isAny(expression, simple)){
- result = true;
- ValidationTypes.isAny(expression, simple);
- }
-
- return result;
- },
-
- "<flex>": function(expression) {
- // http://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/#flex-property
- // none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]
- // Valid syntaxes, according to https://developer.mozilla.org/en-US/docs/Web/CSS/flex#Syntax
- // * none
- // * <flex-grow>
- // * <flex-basis>
- // * <flex-grow> <flex-basis>
- // * <flex-grow> <flex-shrink>
- // * <flex-grow> <flex-shrink> <flex-basis>
- // * inherit
- var part,
- result = false;
- if (ValidationTypes.isAny(expression, "none | inherit")) {
- result = true;
- } else {
- if (ValidationTypes.isType(expression, "<flex-grow>")) {
- if (expression.peek()) {
- if (ValidationTypes.isType(expression, "<flex-shrink>")) {
- if (expression.peek()) {
- result = ValidationTypes.isType(expression, "<flex-basis>");
- } else {
- result = true;
- }
- } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
- result = expression.peek() === null;
- }
- } else {
- result = true;
- }
- } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
- result = true;
- }
- }
-
- if (!result) {
- // Generate a more verbose error than "Expected <flex>..."
- part = expression.peek();
- throw new ValidationError("Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '" + expression.value.text + "'.", part.line, part.col);
- }
-
- return result;
- }
- }
-};
-
-parserlib.css = {
-__proto__ :null,
-Colors :Colors,
-Combinator :Combinator,
-Parser :Parser,
-PropertyName :PropertyName,
-PropertyValue :PropertyValue,
-PropertyValuePart :PropertyValuePart,
-MediaFeature :MediaFeature,
-MediaQuery :MediaQuery,
-Selector :Selector,
-SelectorPart :SelectorPart,
-SelectorSubPart :SelectorSubPart,
-Specificity :Specificity,
-TokenStream :TokenStream,
-Tokens :Tokens,
-ValidationError :ValidationError
-};
-})();
-
-(function(){
-/* jshint forin:false */
-for(var prop in parserlib){
-exports[prop] = parserlib[prop];
-}
-})();
--- a/domino/domino-lib/defineElement.js
+++ /dev/null
@@ -1,70 +1,0 @@
-"use strict";
-
-var attributes = require('./attributes');
-var sloppy = require('./sloppy');
-var isApiWritable = require("./config").isApiWritable;
-
-module.exports = function(spec, defaultConstructor, tagList, tagNameToImpl) {
- var c = spec.ctor;
- if (c) {
- var props = spec.props || {};
-
- if (spec.attributes) {
- for (var n in spec.attributes) {
- var attr = spec.attributes[n];
- if (typeof attr !== 'object' || Array.isArray(attr)) attr = {type: attr};
- if (!attr.name) attr.name = n.toLowerCase();
- props[n] = attributes.property(attr);
- }
- }
-
- props.constructor = { value : c, writable: isApiWritable };
- c.prototype = Object.create((spec.superclass || defaultConstructor).prototype, props);
- if (spec.events) {
- addEventHandlers(c, spec.events);
- }
- tagList[c.name] = c;
- }
- else {
- c = defaultConstructor;
- }
-
- (spec.tags || spec.tag && [spec.tag] || []).forEach(function(tag) {
- tagNameToImpl[tag] = c;
- });
-
- return c;
-};
-
-function EventHandlerBuilder(body, document, form, element) {
- this.body = body;
- this.document = document;
- this.form = form;
- this.element = element;
-}
-
-EventHandlerBuilder.prototype.build = sloppy.EventHandlerBuilder_build;
-
-function EventHandlerChangeHandler(elt, name, oldval, newval) {
- var doc = elt.ownerDocument || Object.create(null);
- var form = elt.form || Object.create(null);
- elt[name] = new EventHandlerBuilder(newval, doc, form, elt).build();
-}
-
-function addEventHandlers(c, eventHandlerTypes) {
- var p = c.prototype;
- eventHandlerTypes.forEach(function(type) {
- // Define the event handler registration IDL attribute for this type
- Object.defineProperty(p, "on" + type, {
- get: function() {
- return this._getEventHandler(type);
- },
- set: function(v) {
- this._setEventHandler(type, v);
- },
- });
-
- // Define special behavior for the content attribute as well
- attributes.registerChangeHandler(c, "on" + type, EventHandlerChangeHandler);
- });
-}
--- a/domino/domino-lib/events.js
+++ /dev/null
@@ -1,7 +1,0 @@
-"use strict";
-module.exports = {
- Event: require('./Event'),
- UIEvent: require('./UIEvent'),
- MouseEvent: require('./MouseEvent'),
- CustomEvent: require('./CustomEvent')
-};
--- a/domino/domino-lib/htmlelts.js
+++ /dev/null
@@ -1,1426 +1,0 @@
-"use strict";
-var Node = require('./Node');
-var Element = require('./Element');
-var CSSStyleDeclaration = require('./CSSStyleDeclaration');
-var utils = require('./utils');
-var URLUtils = require('./URLUtils');
-var defineElement = require('./defineElement');
-
-var htmlElements = exports.elements = {};
-var htmlNameToImpl = Object.create(null);
-
-exports.createElement = function(doc, localName, prefix) {
- var impl = htmlNameToImpl[localName] || HTMLUnknownElement;
- return new impl(doc, localName, prefix);
-};
-
-function define(spec) {
- return defineElement(spec, HTMLElement, htmlElements, htmlNameToImpl);
-}
-
-function URL(attr) {
- return {
- get: function() {
- var v = this._getattr(attr);
- if (v === null) { return ''; }
- var url = this.doc._resolve(v);
- return (url === null) ? v : url;
- },
- set: function(value) {
- this._setattr(attr, value);
- }
- };
-}
-
-function CORS(attr) {
- return {
- get: function() {
- var v = this._getattr(attr);
- if (v === null) { return null; }
- if (v.toLowerCase() === 'use-credentials') { return 'use-credentials'; }
- return 'anonymous';
- },
- set: function(value) {
- if (value===null || value===undefined) {
- this.removeAttribute(attr);
- } else {
- this._setattr(attr, value);
- }
- }
- };
-}
-
-var REFERRER = {
- type: ["", "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url"],
- missing: '',
-};
-
-
-// XXX: the default value for tabIndex should be 0 if the element is
-// focusable and -1 if it is not. But the full definition of focusable
-// is actually hard to compute, so for now, I'll follow Firefox and
-// just base the default value on the type of the element.
-var focusableElements = {
- "A":true, "LINK":true, "BUTTON":true, "INPUT":true,
- "SELECT":true, "TEXTAREA":true, "COMMAND":true
-};
-
-var HTMLFormElement = function(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- this._form = null; // Prevent later deoptimization
-};
-
-var HTMLElement = exports.HTMLElement = define({
- superclass: Element,
- ctor: function HTMLElement(doc, localName, prefix) {
- Element.call(this, doc, localName, utils.NAMESPACE.HTML, prefix);
- },
- props: {
- innerHTML: {
- get: function() {
- return this.serialize();
- },
- set: function(v) {
- var parser = this.ownerDocument.implementation.mozHTMLParser(
- this.ownerDocument._address,
- this);
- parser.parse(v===null ? '' : String(v), true);
-
- // Remove any existing children of this node
- var target = (this instanceof htmlNameToImpl.template) ?
- this.content : this;
- while(target.hasChildNodes())
- target.removeChild(target.firstChild);
-
- // Now copy newly parsed children to this node
- target.appendChild(parser._asDocumentFragment());
- }
- },
- style: { get: function() {
- if (!this._style)
- this._style = new CSSStyleDeclaration(this);
- return this._style;
- }, set: function(v) {
- if (v===null||v===undefined) { v = ''; }
- this._setattr('style', String(v));
- }},
-
- // These can't really be implemented server-side in a reasonable way.
- blur: { value: function() {}},
- focus: { value: function() {}},
- forceSpellCheck: { value: function() {}},
-
- click: { value: function() {
- if (this._click_in_progress) return;
- this._click_in_progress = true;
- try {
- if (this._pre_click_activation_steps)
- this._pre_click_activation_steps();
-
- var event = this.ownerDocument.createEvent("MouseEvent");
- event.initMouseEvent("click", true, true,
- this.ownerDocument.defaultView, 1,
- 0, 0, 0, 0,
- // These 4 should be initialized with
- // the actually current keyboard state
- // somehow...
- false, false, false, false,
- 0, null
- );
-
- // Dispatch this as an untrusted event since it is synthetic
- var success = this.dispatchEvent(event);
-
- if (success) {
- if (this._post_click_activation_steps)
- this._post_click_activation_steps(event);
- }
- else {
- if (this._cancelled_activation_steps)
- this._cancelled_activation_steps();
- }
- }
- finally {
- this._click_in_progress = false;
- }
- }},
- submit: { value: utils.nyi },
- },
- attributes: {
- title: String,
- lang: String,
- dir: {type: ["ltr", "rtl", "auto"], missing: ''},
- accessKey: String,
- hidden: Boolean,
- tabIndex: {type: "long", default: function() {
- if (this.tagName in focusableElements ||
- this.contentEditable)
- return 0;
- else
- return -1;
- }}
- },
- events: [
- "abort", "canplay", "canplaythrough", "change", "click", "contextmenu",
- "cuechange", "dblclick", "drag", "dragend", "dragenter", "dragleave",
- "dragover", "dragstart", "drop", "durationchange", "emptied", "ended",
- "input", "invalid", "keydown", "keypress", "keyup", "loadeddata",
- "loadedmetadata", "loadstart", "mousedown", "mousemove", "mouseout",
- "mouseover", "mouseup", "mousewheel", "pause", "play", "playing",
- "progress", "ratechange", "readystatechange", "reset", "seeked",
- "seeking", "select", "show", "stalled", "submit", "suspend",
- "timeupdate", "volumechange", "waiting",
-
- // These last 5 event types will be overriden by HTMLBodyElement
- "blur", "error", "focus", "load", "scroll"
- ]
-});
-
-
-// XXX: reflect contextmenu as contextMenu, with element type
-
-
-// style: the spec doesn't call this a reflected attribute.
-// may want to handle it manually.
-
-// contentEditable: enumerated, not clear if it is actually
-// reflected or requires custom getter/setter. Not listed as
-// "limited to known values". Raises syntax_err on bad setting,
-// so I think this is custom.
-
-// contextmenu: content is element id, idl type is an element
-// draggable: boolean, but not a reflected attribute
-// dropzone: reflected SettableTokenList, experimental, so don't
-// implement it right away.
-
-// data-* attributes: need special handling in setAttribute?
-// Or maybe that isn't necessary. Can I just scan the attribute list
-// when building the dataset? Liveness and caching issues?
-
-// microdata attributes: many are simple reflected attributes, but
-// I'm not going to implement this now.
-
-
-var HTMLUnknownElement = define({
- ctor: function HTMLUnknownElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-
-var formAssociatedProps = {
- // See http://www.w3.org/TR/html5/association-of-controls-and-forms.html#form-owner
- form: { get: function() {
- return this._form;
- }}
-};
-
-define({
- tag: 'a',
- ctor: function HTMLAnchorElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- _post_click_activation_steps: { value: function(e) {
- if (this.href) {
- // Follow the link
- // XXX: this is just a quick hack
- // XXX: the HTML spec probably requires more than this
- this.ownerDocument.defaultView.location = this.href;
- }
- }},
- },
- attributes: {
- href: URL,
- ping: String,
- download: String,
- target: String,
- rel: String,
- media: String,
- hreflang: String,
- type: String,
- referrerPolicy: REFERRER,
- // Obsolete
- coords: String,
- charset: String,
- name: String,
- rev: String,
- shape: String,
- }
-});
-// Latest WhatWG spec says these methods come via HTMLHyperlinkElementUtils
-URLUtils._inherit(htmlNameToImpl.a.prototype);
-
-define({
- tag: 'area',
- ctor: function HTMLAreaElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- alt: String,
- target: String,
- download: String,
- rel: String,
- media: String,
- href: URL,
- hreflang: String,
- type: String,
- shape: String,
- coords: String,
- ping: String,
- // XXX: also reflect relList
- referrerPolicy: REFERRER,
- // Obsolete
- noHref: Boolean,
- }
-});
-// Latest WhatWG spec says these methods come via HTMLHyperlinkElementUtils
-URLUtils._inherit(htmlNameToImpl.area.prototype);
-
-define({
- tag: 'br',
- ctor: function HTMLBRElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- clear: String
- },
-});
-
-define({
- tag: 'base',
- ctor: function HTMLBaseElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- "target": String
- }
-});
-
-
-define({
- tag: 'body',
- ctor: function HTMLBodyElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- // Certain event handler attributes on a <body> tag actually set
- // handlers for the window rather than just that element. Define
- // getters and setters for those here. Note that some of these override
- // properties on HTMLElement.prototype.
- // XXX: If I add support for <frameset>, these have to go there, too
- // XXX
- // When the Window object is implemented, these attribute will have
- // to work with the same-named attributes on the Window.
- events: [
- "afterprint", "beforeprint", "beforeunload", "blur", "error",
- "focus","hashchange", "load", "message", "offline", "online",
- "pagehide", "pageshow","popstate","resize","scroll","storage","unload",
- ],
- attributes: {
- // Obsolete
- text: { type: String, treatNullAsEmptyString: true },
- link: { type: String, treatNullAsEmptyString: true },
- vLink: { type: String, treatNullAsEmptyString: true },
- aLink: { type: String, treatNullAsEmptyString: true },
- bgColor: { type: String, treatNullAsEmptyString: true },
- background: String,
- }
-});
-
-define({
- tag: 'button',
- ctor: function HTMLButtonElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- name: String,
- value: String,
- disabled: Boolean,
- autofocus: Boolean,
- type: { type:["submit", "reset", "button", "menu"], missing: 'submit' },
- formTarget: String,
- formNoValidate: Boolean,
- formMethod: { type: ["get", "post", "dialog"], invalid: 'get', missing: '' },
- formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' },
- }
-});
-
-define({
- tag: 'dl',
- ctor: function HTMLDListElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- compact: Boolean,
- }
-});
-
-define({
- tag: 'data',
- ctor: function HTMLDataElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- value: String,
- }
-});
-
-define({
- tag: 'datalist',
- ctor: function HTMLDataListElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'details',
- ctor: function HTMLDetailsElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- "open": Boolean
- }
-});
-
-define({
- tag: 'div',
- ctor: function HTMLDivElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String
- }
-});
-
-define({
- tag: 'embed',
- ctor: function HTMLEmbedElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- src: URL,
- type: String,
- width: String,
- height: String,
- // Obsolete
- align: String,
- name: String,
- }
-});
-
-define({
- tag: 'fieldset',
- ctor: function HTMLFieldSetElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- disabled: Boolean,
- name: String
- }
-});
-
-define({
- tag: 'form',
- ctor: function HTMLFormElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- action: String,
- autocomplete: {type:['on', 'off'], missing: 'on'},
- name: String,
- acceptCharset: {name: "accept-charset"},
- target: String,
- noValidate: Boolean,
- method: { type: ["get", "post", "dialog"], invalid: 'get', missing: 'get' },
- // Both enctype and encoding reflect the enctype content attribute
- enctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" },
- encoding: {name: 'enctype', type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" },
- }
-});
-
-define({
- tag: 'hr',
- ctor: function HTMLHRElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String,
- color: String,
- noShade: Boolean,
- size: String,
- width: String,
- },
-});
-
-define({
- tag: 'head',
- ctor: function HTMLHeadElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tags: ['h1','h2','h3','h4','h5','h6'],
- ctor: function HTMLHeadingElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String,
- },
-});
-
-define({
- tag: 'html',
- ctor: function HTMLHtmlElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- version: String
- }
-});
-
-define({
- tag: 'iframe',
- ctor: function HTMLIFrameElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- var Window = require('./Window'); // Avoid circular dependencies.
- this._contentWindow = new Window();
- },
- props: {
- contentWindow: { get: function() {
- return this._contentWindow;
- } },
- contentDocument: { get: function() {
- return this.contentWindow.document;
- } },
- },
- attributes: {
- src: URL,
- srcdoc: String,
- name: String,
- width: String,
- height: String,
- // XXX: sandbox is a reflected settable token list
- seamless: Boolean,
- allowFullscreen: Boolean,
- allowUserMedia: Boolean,
- allowPaymentRequest: Boolean,
- referrerPolicy: REFERRER,
- // Obsolete
- align: String,
- scrolling: String,
- frameBorder: String,
- longDesc: URL,
- marginHeight: { type: String, treatNullAsEmptyString: true },
- marginWidth: { type: String, treatNullAsEmptyString: true },
- }
-});
-
-define({
- tag: 'img',
- ctor: function HTMLImageElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- alt: String,
- src: URL,
- srcset: String,
- crossOrigin: CORS,
- useMap: String,
- isMap: Boolean,
- height: { type: "unsigned long", default: 0 },
- width: { type: "unsigned long", default: 0 },
- referrerPolicy: REFERRER,
- // Obsolete:
- name: String,
- lowsrc: URL,
- align: String,
- hspace: { type: "unsigned long", default: 0 },
- vspace: { type: "unsigned long", default: 0 },
- longDesc: URL,
- border: { type: String, treatNullAsEmptyString: true },
- }
-});
-
-define({
- tag: 'input',
- ctor: function HTMLInputElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: {
- form: formAssociatedProps.form,
- _post_click_activation_steps: { value: function(e) {
- if (this.type === 'checkbox') {
- this.checked = !this.checked;
- }
- else if (this.type === 'radio') {
- var group = this.form.getElementsByName(this.name);
- for (var i=group.length-1; i >= 0; i--) {
- var el = group[i];
- el.checked = (el === this);
- }
- }
- }},
- },
- attributes: {
- name: String,
- disabled: Boolean,
- autofocus: Boolean,
- accept: String,
- alt: String,
- max: String,
- min: String,
- pattern: String,
- placeholder: String,
- step: String,
- dirName: String,
- defaultValue: {name: 'value'},
- multiple: Boolean,
- required: Boolean,
- readOnly: Boolean,
- checked: Boolean,
- value: String,
- src: URL,
- defaultChecked: {name: 'checked', type: Boolean},
- size: {type: 'unsigned long', default: 20, min: 1, setmin: 1},
- width: {type: 'unsigned long', min: 0, setmin: 0, default: 0},
- height: {type: 'unsigned long', min: 0, setmin: 0, default: 0},
- minLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
- maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
- autocomplete: String, // It's complicated
- type: { type:
- ["text", "hidden", "search", "tel", "url", "email", "password",
- "datetime", "date", "month", "week", "time", "datetime-local",
- "number", "range", "color", "checkbox", "radio", "file", "submit",
- "image", "reset", "button"],
- missing: 'text' },
- formTarget: String,
- formNoValidate: Boolean,
- formMethod: { type: ["get", "post"], invalid: 'get', missing: '' },
- formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' },
- inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' },
- // Obsolete
- align: String,
- useMap: String,
- }
-});
-
-define({
- tag: 'keygen',
- ctor: function HTMLKeygenElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- name: String,
- disabled: Boolean,
- autofocus: Boolean,
- challenge: String,
- keytype: { type:["rsa"], missing: '' },
- }
-});
-
-define({
- tag: 'li',
- ctor: function HTMLLIElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- value: {type: "long", default: 0},
- // Obsolete
- type: String,
- }
-});
-
-define({
- tag: 'label',
- ctor: function HTMLLabelElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- htmlFor: {name: 'for', type: String}
- }
-});
-
-define({
- tag: 'legend',
- ctor: function HTMLLegendElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String
- },
-});
-
-define({
- tag: 'link',
- ctor: function HTMLLinkElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // XXX Reflect DOMSettableTokenList sizes also DOMTokenList relList
- href: URL,
- rel: String,
- media: String,
- hreflang: String,
- type: String,
- crossOrigin: CORS,
- nonce: String,
- integrity: String,
- referrerPolicy: REFERRER,
- // Obsolete
- charset: String,
- rev: String,
- target: String,
- }
-});
-
-define({
- tag: 'map',
- ctor: function HTMLMapElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- name: String
- }
-});
-
-define({
- tag: 'menu',
- ctor: function HTMLMenuElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // XXX: not quite right, default should be popup if parent element is
- // popup.
- type: { type: [ 'context', 'popup', 'toolbar' ], missing: 'toolbar' },
- label: String,
- // Obsolete
- compact: Boolean,
- }
-});
-
-define({
- tag: 'meta',
- ctor: function HTMLMetaElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- name: String,
- content: String,
- httpEquiv: {name: 'http-equiv', type: String},
- // Obsolete
- scheme: String,
- }
-});
-
-define({
- tag: 'meter',
- ctor: function HTMLMeterElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps
-});
-
-define({
- tags: ['ins', 'del'],
- ctor: function HTMLModElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- cite: URL,
- dateTime: String
- }
-});
-
-define({
- tag: 'ol',
- ctor: function HTMLOListElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- // Utility function (see the start attribute default value). Returns
- // the number of <li> children of this element
- _numitems: { get: function() {
- var items = 0;
- this.childNodes.forEach(function(n) {
- if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "LI")
- items++;
- });
- return items;
- }}
- },
- attributes: {
- type: String,
- reversed: Boolean,
- start: {
- type: "long",
- default: function() {
- // The default value of the start attribute is 1 unless the list is
- // reversed. Then it is the # of li children
- if (this.reversed)
- return this._numitems;
- else
- return 1;
- }
- },
- // Obsolete
- compact: Boolean,
- }
-});
-
-define({
- tag: 'object',
- ctor: function HTMLObjectElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- data: URL,
- type: String,
- name: String,
- useMap: String,
- typeMustMatch: Boolean,
- width: String,
- height: String,
- // Obsolete
- align: String,
- archive: String,
- code: String,
- declare: Boolean,
- hspace: { type: "unsigned long", default: 0 },
- standby: String,
- vspace: { type: "unsigned long", default: 0 },
- codeBase: URL,
- codeType: String,
- border: { type: String, treatNullAsEmptyString: true },
- }
-});
-
-define({
- tag: 'optgroup',
- ctor: function HTMLOptGroupElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- disabled: Boolean,
- label: String
- }
-});
-
-define({
- tag: 'option',
- ctor: function HTMLOptionElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- form: { get: function() {
- var p = this.parentNode;
- while (p && p.nodeType === Node.ELEMENT_NODE) {
- if (p.localName === 'select') return p.form;
- p = p.parentNode;
- }
- }},
- value: {
- get: function() { return this._getattr('value') || this.text; },
- set: function(v) { this._setattr('value', v); },
- },
- text: {
- get: function() {
- // Strip and collapse whitespace
- return this.textContent.replace(/[ \t\n\f\r]+/g, ' ').trim();
- },
- set: function(v) { this.textContent = v; },
- },
- // missing: index
- },
- attributes: {
- disabled: Boolean,
- defaultSelected: {name: 'selected', type: Boolean},
- label: String,
- }
-});
-
-define({
- tag: 'output',
- ctor: function HTMLOutputElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- // XXX Reflect for/htmlFor as a settable token list
- name: String
- }
-});
-
-define({
- tag: 'p',
- ctor: function HTMLParagraphElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String
- }
-});
-
-define({
- tag: 'param',
- ctor: function HTMLParamElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- name: String,
- value: String,
- // Obsolete
- type: String,
- valueType: String,
- }
-});
-
-define({
- tags: ['pre',/*legacy elements:*/'listing','xmp'],
- ctor: function HTMLPreElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- width: { type: "long", default: 0 },
- }
-});
-
-define({
- tag: 'progress',
- ctor: function HTMLProgressElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: formAssociatedProps,
- attributes: {
- max: {type: Number, float: true, default: 1.0, min: 0}
- }
-});
-
-define({
- tags: ['q', 'blockquote'],
- ctor: function HTMLQuoteElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- cite: URL
- }
-});
-
-define({
- tag: 'script',
- ctor: function HTMLScriptElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- text: {
- get: function() {
- var s = "";
- for(var i = 0, n = this.childNodes.length; i < n; i++) {
- var child = this.childNodes[i];
- if (child.nodeType === Node.TEXT_NODE)
- s += child._data;
- }
- return s;
- },
- set: function(value) {
- this.removeChildren();
- if (value !== null && value !== "") {
- this.appendChild(this.ownerDocument.createTextNode(value));
- }
- }
- }
- },
- attributes: {
- src: URL,
- type: String,
- charset: String,
- defer: Boolean,
- async: Boolean,
- crossOrigin: CORS,
- nonce: String,
- integrity: String,
- }
-});
-
-define({
- tag: 'select',
- ctor: function HTMLSelectElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: {
- form: formAssociatedProps.form,
- options: { get: function() {
- return this.getElementsByTagName('option');
- }}
- },
- attributes: {
- autocomplete: String, // It's complicated
- name: String,
- disabled: Boolean,
- autofocus: Boolean,
- multiple: Boolean,
- required: Boolean,
- size: {type: "unsigned long", default: 0}
- }
-});
-
-define({
- tag: 'source',
- ctor: function HTMLSourceElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- src: URL,
- type: String,
- media: String
- }
-});
-
-define({
- tag: 'span',
- ctor: function HTMLSpanElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'style',
- ctor: function HTMLStyleElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- media: String,
- type: String,
- scoped: Boolean
- }
-});
-
-define({
- tag: 'caption',
- ctor: function HTMLTableCaptionElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- // Obsolete
- align: String,
- }
-});
-
-
-define({
- ctor: function HTMLTableCellElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- colSpan: {type: "unsigned long", default: 1},
- rowSpan: {type: "unsigned long", default: 1},
- //XXX Also reflect settable token list headers
- scope: { type: ['row','col','rowgroup','colgroup'], missing: '' },
- abbr: String,
- // Obsolete
- align: String,
- axis: String,
- height: String,
- width: String,
- ch: { name: 'char', type: String },
- chOff: { name: 'charoff', type: String },
- noWrap: Boolean,
- vAlign: String,
- bgColor: { type: String, treatNullAsEmptyString: true },
- }
-});
-
-define({
- tags: ['col', 'colgroup'],
- ctor: function HTMLTableColElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- span: {type: 'limited unsigned long with fallback', default: 1, min: 1},
- // Obsolete
- align: String,
- ch: { name: 'char', type: String },
- chOff: { name: 'charoff', type: String },
- vAlign: String,
- width: String,
- }
-});
-
-define({
- tag: 'table',
- ctor: function HTMLTableElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- rows: { get: function() {
- return this.getElementsByTagName('tr');
- }}
- },
- attributes: {
- // Obsolete
- align: String,
- border: String,
- frame: String,
- rules: String,
- summary: String,
- width: String,
- bgColor: { type: String, treatNullAsEmptyString: true },
- cellPadding: { type: String, treatNullAsEmptyString: true },
- cellSpacing: { type: String, treatNullAsEmptyString: true },
- }
-});
-
-define({
- tag: 'template',
- ctor: function HTMLTemplateElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- this._contentFragment = doc._templateDoc.createDocumentFragment();
- },
- props: {
- content: { get: function() { return this._contentFragment; } },
- serialize: { value: function() { return this.content.serialize(); } }
- }
-});
-
-define({
- tag: 'tr',
- ctor: function HTMLTableRowElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- cells: { get: function() {
- return this.querySelectorAll('td,th');
- }}
- },
- attributes: {
- // Obsolete
- align: String,
- ch: { name: 'char', type: String },
- chOff: { name: 'charoff', type: String },
- vAlign: String,
- bgColor: { type: String, treatNullAsEmptyString: true },
- },
-});
-
-define({
- tags: ['thead', 'tfoot', 'tbody'],
- ctor: function HTMLTableSectionElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- rows: { get: function() {
- return this.getElementsByTagName('tr');
- }}
- },
- attributes: {
- // Obsolete
- align: String,
- ch: { name: 'char', type: String },
- chOff: { name: 'charoff', type: String },
- vAlign: String,
- }
-});
-
-define({
- tag: 'textarea',
- ctor: function HTMLTextAreaElement(doc, localName, prefix) {
- HTMLFormElement.call(this, doc, localName, prefix);
- },
- props: {
- form: formAssociatedProps.form,
- type: { get: function() { return 'textarea'; } },
- defaultValue: {
- get: function() { return this.textContent; },
- set: function(v) { this.textContent = v; },
- },
- value: {
- get: function() { return this.defaultValue; /* never dirty */ },
- set: function(v) {
- // This isn't completely correct: according to the spec, this
- // should "dirty" the API value, and result in
- // `this.value !== this.defaultValue`. But for most of what
- // folks want to do, this implementation should be fine:
- this.defaultValue = v;
- },
- },
- textLength: { get: function() { return this.value.length; } },
- },
- attributes: {
- autocomplete: String, // It's complicated
- name: String,
- disabled: Boolean,
- autofocus: Boolean,
- placeholder: String,
- wrap: String,
- dirName: String,
- required: Boolean,
- readOnly: Boolean,
- rows: {type: 'limited unsigned long with fallback', default: 2 },
- cols: {type: 'limited unsigned long with fallback', default: 20 },
- maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
- minLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1},
- inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' },
- }
-});
-
-define({
- tag: 'time',
- ctor: function HTMLTimeElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- dateTime: String,
- pubDate: Boolean
- }
-});
-
-define({
- tag: 'title',
- ctor: function HTMLTitleElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- text: { get: function() {
- return this.textContent;
- }}
- }
-});
-
-define({
- tag: 'ul',
- ctor: function HTMLUListElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- type: String,
- // Obsolete
- compact: Boolean,
- }
-});
-
-define({
- ctor: function HTMLMediaElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- src: URL,
- crossOrigin: CORS,
- preload: { type:["metadata", "none", "auto", {value: "", alias: "auto"}], missing: 'auto' },
- loop: Boolean,
- autoplay: Boolean,
- mediaGroup: String,
- controls: Boolean,
- defaultMuted: {name: "muted", type: Boolean}
- }
-});
-
-define({
- tag: 'audio',
- superclass: htmlElements.HTMLMediaElement,
- ctor: function HTMLAudioElement(doc, localName, prefix) {
- htmlElements.HTMLMediaElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'video',
- superclass: htmlElements.HTMLMediaElement,
- ctor: function HTMLVideoElement(doc, localName, prefix) {
- htmlElements.HTMLMediaElement.call(this, doc, localName, prefix);
- },
- attributes: {
- poster: URL,
- width: {type: "unsigned long", min: 0, default: 0 },
- height: {type: "unsigned long", min: 0, default: 0 }
- }
-});
-
-define({
- tag: 'td',
- superclass: htmlElements.HTMLTableCellElement,
- ctor: function HTMLTableDataCellElement(doc, localName, prefix) {
- htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'th',
- superclass: htmlElements.HTMLTableCellElement,
- ctor: function HTMLTableHeaderCellElement(doc, localName, prefix) {
- htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix);
- },
-});
-
-define({
- tag: 'frameset',
- ctor: function HTMLFrameSetElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'frame',
- ctor: function HTMLFrameElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- }
-});
-
-define({
- tag: 'canvas',
- ctor: function HTMLCanvasElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- getContext: { value: utils.nyi },
- probablySupportsContext: { value: utils.nyi },
- setContext: { value: utils.nyi },
- transferControlToProxy: { value: utils.nyi },
- toDataURL: { value: utils.nyi },
- toBlob: { value: utils.nyi }
- },
- attributes: {
- width: { type: "unsigned long", default: 300},
- height: { type: "unsigned long", default: 150}
- }
-});
-
-define({
- tag: 'dialog',
- ctor: function HTMLDialogElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- show: { value: utils.nyi },
- showModal: { value: utils.nyi },
- close: { value: utils.nyi }
- },
- attributes: {
- open: Boolean,
- returnValue: String
- }
-});
-
-define({
- tag: 'menuitem',
- ctor: function HTMLMenuItemElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- props: {
- // The menuitem's label
- _label: {
- get: function() {
- var val = this._getattr('label');
- if (val !== null && val !== '') { return val; }
- val = this.textContent;
- // Strip and collapse whitespace
- return val.replace(/[ \t\n\f\r]+/g, ' ').trim();
- }
- },
- // The menuitem label IDL attribute
- label: {
- get: function() {
- var val = this._getattr('label');
- if (val !== null) { return val; }
- return this._label;
- },
- set: function(v) {
- this._setattr('label', v);
- },
- }
- },
- attributes: {
- type: { type: ["command","checkbox","radio"], missing: 'command' },
- icon: URL,
- disabled: Boolean,
- checked: Boolean,
- radiogroup: String,
- default: Boolean
- }
-});
-
-define({
- tag: 'source',
- ctor: function HTMLSourceElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- srcset: String,
- sizes: String,
- media: String,
- src: URL,
- type: String
- }
-});
-
-define({
- tag: 'track',
- ctor: function HTMLTrackElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- src: URL,
- srclang: String,
- label: String,
- default: Boolean,
- kind: { type: ["subtitles", "captions", "descriptions", "chapters", "metadata"], missing: 'subtitles', invalid: 'metadata' },
- },
- props: {
- NONE: { get: function() { return 0; } },
- LOADING: { get: function() { return 1; } },
- LOADED: { get: function() { return 2; } },
- ERROR: { get: function() { return 3; } },
- readyState: { get: utils.nyi },
- track: { get: utils.nyi }
- }
-});
-
-define({
- // obsolete
- tag: 'font',
- ctor: function HTMLFontElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- color: { type: String, treatNullAsEmptyString: true },
- face: { type: String },
- size: { type: String },
- },
-});
-
-define({
- // obsolete
- tag: 'dir',
- ctor: function HTMLDirectoryElement(doc, localName, prefix) {
- HTMLElement.call(this, doc, localName, prefix);
- },
- attributes: {
- compact: Boolean,
- },
-});
-
-define({
- tags: [
- "abbr", "address", "article", "aside", "b", "bdi", "bdo",
- "cite", "code", "dd", "dfn", "dt", "em", "figcaption", "figure",
- "footer", "header", "hgroup", "i", "kbd", "main", "mark", "nav", "noscript",
- "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "section", "small", "strong",
- "sub", "summary", "sup", "u", "var", "wbr",
- // Legacy elements
- "acronym", "basefont", "big", "center", "nobr", "noembed", "noframes",
- "plaintext", "strike", "tt"
- ]
-});
--- a/domino/domino-lib/impl.js
+++ /dev/null
@@ -1,27 +1,0 @@
-"use strict";
-var utils = require('./utils');
-
-exports = module.exports = {
- CSSStyleDeclaration: require('./CSSStyleDeclaration'),
- CharacterData: require('./CharacterData'),
- Comment: require('./Comment'),
- DOMException: require('./DOMException'),
- DOMImplementation: require('./DOMImplementation'),
- DOMTokenList: require('./DOMTokenList'),
- Document: require('./Document'),
- DocumentFragment: require('./DocumentFragment'),
- DocumentType: require('./DocumentType'),
- Element: require('./Element'),
- HTMLParser: require('./HTMLParser'),
- NamedNodeMap: require('./NamedNodeMap'),
- Node: require('./Node'),
- NodeList: require('./NodeList'),
- NodeFilter: require('./NodeFilter'),
- ProcessingInstruction: require('./ProcessingInstruction'),
- Text: require('./Text'),
- Window: require('./Window')
-};
-
-utils.merge(exports, require('./events'));
-utils.merge(exports, require('./htmlelts').elements);
-utils.merge(exports, require('./svg').elements);
--- a/domino/domino-lib/index.d.ts
+++ /dev/null
@@ -1,5 +1,0 @@
-declare module "domino" {
- function createDOMImplementation(): DOMImplementation;
- function createDocument(html?: string, force?: boolean): Document;
- function createWindow(html?: string, address?: string): Window;
-}
\ No newline at end of file
--- a/domino/domino-lib/index.js
+++ /dev/null
@@ -1,79 +1,0 @@
-"use strict";
-var DOMImplementation = require('./DOMImplementation');
-var HTMLParser = require('./HTMLParser');
-var Window = require('./Window');
-
-exports.createDOMImplementation = function() {
- return new DOMImplementation(null);
-};
-
-exports.createDocument = function(html, force) {
- // Previous API couldn't let you pass '' as a document, and that
- // yields a slightly different document than createHTMLDocument('')
- // does. The new `force` parameter lets you pass '' if you want to.
- if (html || force) {
- var parser = new HTMLParser();
- parser.parse(html || '', true);
- return parser.document();
- }
- return new DOMImplementation(null).createHTMLDocument("");
-};
-
-exports.createIncrementalHTMLParser = function() {
- var parser = new HTMLParser();
- /** API for incremental parser. */
- return {
- /** Provide an additional chunk of text to be parsed. */
- write: function(s) {
- if (s.length > 0) {
- parser.parse(s, false, function() { return true; });
- }
- },
- /**
- * Signal that we are done providing input text, optionally
- * providing one last chunk as a parameter.
- */
- end: function(s) {
- parser.parse(s || '', true, function() { return true; });
- },
- /**
- * Performs a chunk of parsing work, returning at the end of
- * the next token as soon as shouldPauseFunc() returns true.
- * Returns true iff there is more work to do.
- *
- * For example:
- * ```
- * var incrParser = domino.createIncrementalHTMLParser();
- * incrParser.end('...long html document...');
- * while (true) {
- * // Pause every 10ms
- * var start = Date.now();
- * var pauseIn10 = function() { return (Date.now() - start) >= 10; };
- * if (!incrParser.process(pauseIn10)) {
- * break;
- * }
- * ...yield to other tasks, do other housekeeping, etc...
- * }
- * ```
- */
- process: function(shouldPauseFunc) {
- return parser.parse('', false, shouldPauseFunc);
- },
- /**
- * Returns the result of the incremental parse. Valid after
- * `this.end()` has been called and `this.process()` has returned
- * false.
- */
- document: function() {
- return parser.document();
- },
- };
-};
-
-exports.createWindow = function(html, address) {
- var document = exports.createDocument(html);
- if (address !== undefined) { document._address = address; }
- return new Window(document);
-};
-
-exports.impl = require('./impl');
--- a/domino/domino-lib/select.js
+++ /dev/null
@@ -1,933 +1,0 @@
-"use strict";
-/* jshint eqnull: true */
-/**
- * Zest (https://github.com/chjj/zest)
- * A css selector engine.
- * Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed)
- * Domino version based on Zest v0.1.3 with bugfixes applied.
- */
-
-/**
- * Helpers
- */
-
-var window = Object.create(null, {
- location: { get: function() {
- throw new Error('window.location is not supported.');
- } }
-});
-
-var compareDocumentPosition = function(a, b) {
- return a.compareDocumentPosition(b);
-};
-
-var order = function(a, b) {
- /* jshint bitwise: false */
- return compareDocumentPosition(a, b) & 2 ? 1 : -1;
-};
-
-var next = function(el) {
- while ((el = el.nextSibling)
- && el.nodeType !== 1);
- return el;
-};
-
-var prev = function(el) {
- while ((el = el.previousSibling)
- && el.nodeType !== 1);
- return el;
-};
-
-var child = function(el) {
- /*jshint -W084 */
- if (el = el.firstChild) {
- while (el.nodeType !== 1
- && (el = el.nextSibling));
- }
- return el;
-};
-
-var lastChild = function(el) {
- /*jshint -W084 */
- if (el = el.lastChild) {
- while (el.nodeType !== 1
- && (el = el.previousSibling));
- }
- return el;
-};
-
-var parentIsElement = function(n) {
- if (!n.parentNode) { return false; }
- var nodeType = n.parentNode.nodeType;
- // The root `html` element can be a first- or last-child, too.
- return nodeType === 1 || nodeType === 9;
-};
-
-var unquote = function(str) {
- if (!str) return str;
- var ch = str[0];
- if (ch === '"' || ch === '\'') {
- if (str[str.length-1] === ch) {
- str = str.slice(1, -1);
- } else {
- // bad string.
- str = str.slice(1);
- }
- return str.replace(rules.str_escape, function(s) {
- var m = /^\\(?:([0-9A-Fa-f]+)|([\r\n\f]+))/.exec(s);
- if (!m) { return s.slice(1); }
- if (m[2]) { return ''; /* escaped newlines are ignored in strings. */ }
- var cp = parseInt(m[1], 16);
- return String.fromCodePoint ? String.fromCodePoint(cp) :
- // Not all JavaScript implementations have String.fromCodePoint yet.
- String.fromCharCode(cp);
- });
- } else if (rules.ident.test(str)) {
- return decodeid(str);
- } else {
- // NUMBER, PERCENTAGE, DIMENSION, etc
- return str;
- }
-};
-
-var decodeid = function(str) {
- return str.replace(rules.escape, function(s) {
- var m = /^\\([0-9A-Fa-f]+)/.exec(s);
- if (!m) { return s[1]; }
- var cp = parseInt(m[1], 16);
- return String.fromCodePoint ? String.fromCodePoint(cp) :
- // Not all JavaScript implementations have String.fromCodePoint yet.
- String.fromCharCode(cp);
- });
-};
-
-var indexOf = (function() {
- if (Array.prototype.indexOf) {
- return Array.prototype.indexOf;
- }
- return function(obj, item) {
- var i = this.length;
- while (i--) {
- if (this[i] === item) return i;
- }
- return -1;
- };
-})();
-
-var makeInside = function(start, end) {
- var regex = rules.inside.source
- .replace(/</g, start)
- .replace(/>/g, end);
-
- return new RegExp(regex);
-};
-
-var replace = function(regex, name, val) {
- regex = regex.source;
- regex = regex.replace(name, val.source || val);
- return new RegExp(regex);
-};
-
-var truncateUrl = function(url, num) {
- return url
- .replace(/^(?:\w+:\/\/|\/+)/, '')
- .replace(/(?:\/+|\/*#.*?)$/, '')
- .split('/', num)
- .join('/');
-};
-
-/**
- * Handle `nth` Selectors
- */
-
-var parseNth = function(param_, test) {
- var param = param_.replace(/\s+/g, '')
- , cap;
-
- if (param === 'even') {
- param = '2n+0';
- } else if (param === 'odd') {
- param = '2n+1';
- } else if (param.indexOf('n') === -1) {
- param = '0n' + param;
- }
-
- cap = /^([+-])?(\d+)?n([+-])?(\d+)?$/.exec(param);
-
- return {
- group: cap[1] === '-'
- ? -(cap[2] || 1)
- : +(cap[2] || 1),
- offset: cap[4]
- ? (cap[3] === '-' ? -cap[4] : +cap[4])
- : 0
- };
-};
-
-var nth = function(param_, test, last) {
- var param = parseNth(param_)
- , group = param.group
- , offset = param.offset
- , find = !last ? child : lastChild
- , advance = !last ? next : prev;
-
- return function(el) {
- if (!parentIsElement(el)) return;
-
- var rel = find(el.parentNode)
- , pos = 0;
-
- while (rel) {
- if (test(rel, el)) pos++;
- if (rel === el) {
- pos -= offset;
- return group && pos
- ? (pos % group) === 0 && (pos < 0 === group < 0)
- : !pos;
- }
- rel = advance(rel);
- }
- };
-};
-
-/**
- * Simple Selectors
- */
-
-var selectors = {
- '*': (function() {
- if (false/*function() {
- var el = document.createElement('div');
- el.appendChild(document.createComment(''));
- return !!el.getElementsByTagName('*')[0];
- }()*/) {
- return function(el) {
- if (el.nodeType === 1) return true;
- };
- }
- return function() {
- return true;
- };
- })(),
- 'type': function(type) {
- type = type.toLowerCase();
- return function(el) {
- return el.nodeName.toLowerCase() === type;
- };
- },
- 'attr': function(key, op, val, i) {
- op = operators[op];
- return function(el) {
- var attr;
- switch (key) {
- case 'for':
- attr = el.htmlFor;
- break;
- case 'class':
- // className is '' when non-existent
- // getAttribute('class') is null
- attr = el.className;
- if (attr === '' && el.getAttribute('class') == null) {
- attr = null;
- }
- break;
- case 'href':
- case 'src':
- attr = el.getAttribute(key, 2);
- break;
- case 'title':
- // getAttribute('title') can be '' when non-existent sometimes?
- attr = el.getAttribute('title') || null;
- break;
- // careful with attributes with special getter functions
- case 'id':
- case 'lang':
- case 'dir':
- case 'accessKey':
- case 'hidden':
- case 'tabIndex':
- case 'style':
- if (el.getAttribute) {
- attr = el.getAttribute(key);
- break;
- }
- /* falls through */
- default:
- if (el.hasAttribute && !el.hasAttribute(key)) {
- break;
- }
- attr = el[key] != null
- ? el[key]
- : el.getAttribute && el.getAttribute(key);
- break;
- }
- if (attr == null) return;
- attr = attr + '';
- if (i) {
- attr = attr.toLowerCase();
- val = val.toLowerCase();
- }
- return op(attr, val);
- };
- },
- ':first-child': function(el) {
- return !prev(el) && parentIsElement(el);
- },
- ':last-child': function(el) {
- return !next(el) && parentIsElement(el);
- },
- ':only-child': function(el) {
- return !prev(el) && !next(el) && parentIsElement(el);
- },
- ':nth-child': function(param, last) {
- return nth(param, function() {
- return true;
- }, last);
- },
- ':nth-last-child': function(param) {
- return selectors[':nth-child'](param, true);
- },
- ':root': function(el) {
- return el.ownerDocument.documentElement === el;
- },
- ':empty': function(el) {
- return !el.firstChild;
- },
- ':not': function(sel) {
- var test = compileGroup(sel);
- return function(el) {
- return !test(el);
- };
- },
- ':first-of-type': function(el) {
- if (!parentIsElement(el)) return;
- var type = el.nodeName;
- /*jshint -W084 */
- while (el = prev(el)) {
- if (el.nodeName === type) return;
- }
- return true;
- },
- ':last-of-type': function(el) {
- if (!parentIsElement(el)) return;
- var type = el.nodeName;
- /*jshint -W084 */
- while (el = next(el)) {
- if (el.nodeName === type) return;
- }
- return true;
- },
- ':only-of-type': function(el) {
- return selectors[':first-of-type'](el)
- && selectors[':last-of-type'](el);
- },
- ':nth-of-type': function(param, last) {
- return nth(param, function(rel, el) {
- return rel.nodeName === el.nodeName;
- }, last);
- },
- ':nth-last-of-type': function(param) {
- return selectors[':nth-of-type'](param, true);
- },
- ':checked': function(el) {
- return !!(el.checked || el.selected);
- },
- ':indeterminate': function(el) {
- return !selectors[':checked'](el);
- },
- ':enabled': function(el) {
- return !el.disabled && el.type !== 'hidden';
- },
- ':disabled': function(el) {
- return !!el.disabled;
- },
- ':target': function(el) {
- return el.id === window.location.hash.substring(1);
- },
- ':focus': function(el) {
- return el === el.ownerDocument.activeElement;
- },
- ':is': function(sel) {
- return compileGroup(sel);
- },
- // :matches is an older name for :is; see
- // https://github.com/w3c/csswg-drafts/issues/3258
- ':matches': function(sel) {
- return selectors[':is'](sel);
- },
- ':nth-match': function(param, last) {
- var args = param.split(/\s*,\s*/)
- , arg = args.shift()
- , test = compileGroup(args.join(','));
-
- return nth(arg, test, last);
- },
- ':nth-last-match': function(param) {
- return selectors[':nth-match'](param, true);
- },
- ':links-here': function(el) {
- return el + '' === window.location + '';
- },
- ':lang': function(param) {
- return function(el) {
- while (el) {
- if (el.lang) return el.lang.indexOf(param) === 0;
- el = el.parentNode;
- }
- };
- },
- ':dir': function(param) {
- return function(el) {
- while (el) {
- if (el.dir) return el.dir === param;
- el = el.parentNode;
- }
- };
- },
- ':scope': function(el, con) {
- var context = con || el.ownerDocument;
- if (context.nodeType === 9) {
- return el === context.documentElement;
- }
- return el === context;
- },
- ':any-link': function(el) {
- return typeof el.href === 'string';
- },
- ':local-link': function(el) {
- if (el.nodeName) {
- return el.href && el.host === window.location.host;
- }
- var param = +el + 1;
- return function(el) {
- if (!el.href) return;
-
- var url = window.location + ''
- , href = el + '';
-
- return truncateUrl(url, param) === truncateUrl(href, param);
- };
- },
- ':default': function(el) {
- return !!el.defaultSelected;
- },
- ':valid': function(el) {
- return el.willValidate || (el.validity && el.validity.valid);
- },
- ':invalid': function(el) {
- return !selectors[':valid'](el);
- },
- ':in-range': function(el) {
- return el.value > el.min && el.value <= el.max;
- },
- ':out-of-range': function(el) {
- return !selectors[':in-range'](el);
- },
- ':required': function(el) {
- return !!el.required;
- },
- ':optional': function(el) {
- return !el.required;
- },
- ':read-only': function(el) {
- if (el.readOnly) return true;
-
- var attr = el.getAttribute('contenteditable')
- , prop = el.contentEditable
- , name = el.nodeName.toLowerCase();
-
- name = name !== 'input' && name !== 'textarea';
-
- return (name || el.disabled) && attr == null && prop !== 'true';
- },
- ':read-write': function(el) {
- return !selectors[':read-only'](el);
- },
- ':hover': function() {
- throw new Error(':hover is not supported.');
- },
- ':active': function() {
- throw new Error(':active is not supported.');
- },
- ':link': function() {
- throw new Error(':link is not supported.');
- },
- ':visited': function() {
- throw new Error(':visited is not supported.');
- },
- ':column': function() {
- throw new Error(':column is not supported.');
- },
- ':nth-column': function() {
- throw new Error(':nth-column is not supported.');
- },
- ':nth-last-column': function() {
- throw new Error(':nth-last-column is not supported.');
- },
- ':current': function() {
- throw new Error(':current is not supported.');
- },
- ':past': function() {
- throw new Error(':past is not supported.');
- },
- ':future': function() {
- throw new Error(':future is not supported.');
- },
- // Non-standard, for compatibility purposes.
- ':contains': function(param) {
- return function(el) {
- var text = el.innerText || el.textContent || el.value || '';
- return text.indexOf(param) !== -1;
- };
- },
- ':has': function(param) {
- return function(el) {
- return find(param, el).length > 0;
- };
- }
- // Potentially add more pseudo selectors for
- // compatibility with sizzle and most other
- // selector engines (?).
-};
-
-/**
- * Attribute Operators
- */
-
-var operators = {
- '-': function() {
- return true;
- },
- '=': function(attr, val) {
- return attr === val;
- },
- '*=': function(attr, val) {
- return attr.indexOf(val) !== -1;
- },
- '~=': function(attr, val) {
- var i
- , s
- , f
- , l;
-
- for (s = 0; true; s = i + 1) {
- i = attr.indexOf(val, s);
- if (i === -1) return false;
- f = attr[i - 1];
- l = attr[i + val.length];
- if ((!f || f === ' ') && (!l || l === ' ')) return true;
- }
- },
- '|=': function(attr, val) {
- var i = attr.indexOf(val)
- , l;
-
- if (i !== 0) return;
- l = attr[i + val.length];
-
- return l === '-' || !l;
- },
- '^=': function(attr, val) {
- return attr.indexOf(val) === 0;
- },
- '$=': function(attr, val) {
- var i = attr.lastIndexOf(val);
- return i !== -1 && i + val.length === attr.length;
- },
- // non-standard
- '!=': function(attr, val) {
- return attr !== val;
- }
-};
-
-/**
- * Combinator Logic
- */
-
-var combinators = {
- ' ': function(test) {
- return function(el) {
- /*jshint -W084 */
- while (el = el.parentNode) {
- if (test(el)) return el;
- }
- };
- },
- '>': function(test) {
- return function(el) {
- /*jshint -W084 */
- if (el = el.parentNode) {
- return test(el) && el;
- }
- };
- },
- '+': function(test) {
- return function(el) {
- /*jshint -W084 */
- if (el = prev(el)) {
- return test(el) && el;
- }
- };
- },
- '~': function(test) {
- return function(el) {
- /*jshint -W084 */
- while (el = prev(el)) {
- if (test(el)) return el;
- }
- };
- },
- 'noop': function(test) {
- return function(el) {
- return test(el) && el;
- };
- },
- 'ref': function(test, name) {
- var node;
-
- function ref(el) {
- var doc = el.ownerDocument
- , nodes = doc.getElementsByTagName('*')
- , i = nodes.length;
-
- while (i--) {
- node = nodes[i];
- if (ref.test(el)) {
- node = null;
- return true;
- }
- }
-
- node = null;
- }
-
- ref.combinator = function(el) {
- if (!node || !node.getAttribute) return;
-
- var attr = node.getAttribute(name) || '';
- if (attr[0] === '#') attr = attr.substring(1);
-
- if (attr === el.id && test(node)) {
- return node;
- }
- };
-
- return ref;
- }
-};
-
-/**
- * Grammar
- */
-
-var rules = {
- escape: /\\(?:[^0-9A-Fa-f\r\n]|[0-9A-Fa-f]{1,6}[\r\n\t ]?)/g,
- str_escape: /(escape)|\\(\n|\r\n?|\f)/g,
- nonascii: /[\u00A0-\uFFFF]/,
- cssid: /(?:(?!-?[0-9])(?:escape|nonascii|[-_a-zA-Z0-9])+)/,
- qname: /^ *(cssid|\*)/,
- simple: /^(?:([.#]cssid)|pseudo|attr)/,
- ref: /^ *\/(cssid)\/ */,
- combinator: /^(?: +([^ \w*.#\\]) +|( )+|([^ \w*.#\\]))(?! *$)/,
- attr: /^\[(cssid)(?:([^\w]?=)(inside))?\]/,
- pseudo: /^(:cssid)(?:\((inside)\))?/,
- inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
- ident: /^(cssid)$/
-};
-
-rules.cssid = replace(rules.cssid, 'nonascii', rules.nonascii);
-rules.cssid = replace(rules.cssid, 'escape', rules.escape);
-rules.qname = replace(rules.qname, 'cssid', rules.cssid);
-rules.simple = replace(rules.simple, 'cssid', rules.cssid);
-rules.ref = replace(rules.ref, 'cssid', rules.cssid);
-rules.attr = replace(rules.attr, 'cssid', rules.cssid);
-rules.pseudo = replace(rules.pseudo, 'cssid', rules.cssid);
-rules.inside = replace(rules.inside, '[^"\'>]*', rules.inside);
-rules.attr = replace(rules.attr, 'inside', makeInside('\\[', '\\]'));
-rules.pseudo = replace(rules.pseudo, 'inside', makeInside('\\(', '\\)'));
-rules.simple = replace(rules.simple, 'pseudo', rules.pseudo);
-rules.simple = replace(rules.simple, 'attr', rules.attr);
-rules.ident = replace(rules.ident, 'cssid', rules.cssid);
-rules.str_escape = replace(rules.str_escape, 'escape', rules.escape);
-
-/**
- * Compiling
- */
-
-var compile = function(sel_) {
- var sel = sel_.replace(/^\s+|\s+$/g, '')
- , test
- , filter = []
- , buff = []
- , subject
- , qname
- , cap
- , op
- , ref;
-
- /*jshint -W084 */
- while (sel) {
- if (cap = rules.qname.exec(sel)) {
- sel = sel.substring(cap[0].length);
- qname = decodeid(cap[1]);
- buff.push(tok(qname, true));
- } else if (cap = rules.simple.exec(sel)) {
- sel = sel.substring(cap[0].length);
- qname = '*';
- buff.push(tok(qname, true));
- buff.push(tok(cap));
- } else {
- throw new SyntaxError('Invalid selector.');
- }
-
- while (cap = rules.simple.exec(sel)) {
- sel = sel.substring(cap[0].length);
- buff.push(tok(cap));
- }
-
- if (sel[0] === '!') {
- sel = sel.substring(1);
- subject = makeSubject();
- subject.qname = qname;
- buff.push(subject.simple);
- }
-
- if (cap = rules.ref.exec(sel)) {
- sel = sel.substring(cap[0].length);
- ref = combinators.ref(makeSimple(buff), decodeid(cap[1]));
- filter.push(ref.combinator);
- buff = [];
- continue;
- }
-
- if (cap = rules.combinator.exec(sel)) {
- sel = sel.substring(cap[0].length);
- op = cap[1] || cap[2] || cap[3];
- if (op === ',') {
- filter.push(combinators.noop(makeSimple(buff)));
- break;
- }
- } else {
- op = 'noop';
- }
-
- if (!combinators[op]) { throw new SyntaxError('Bad combinator.'); }
- filter.push(combinators[op](makeSimple(buff)));
- buff = [];
- }
-
- test = makeTest(filter);
- test.qname = qname;
- test.sel = sel;
-
- if (subject) {
- subject.lname = test.qname;
-
- subject.test = test;
- subject.qname = subject.qname;
- subject.sel = test.sel;
- test = subject;
- }
-
- if (ref) {
- ref.test = test;
- ref.qname = test.qname;
- ref.sel = test.sel;
- test = ref;
- }
-
- return test;
-};
-
-var tok = function(cap, qname) {
- // qname
- if (qname) {
- return cap === '*'
- ? selectors['*']
- : selectors.type(cap);
- }
-
- // class/id
- if (cap[1]) {
- return cap[1][0] === '.'
- // XXX unescape here? or in attr?
- ? selectors.attr('class', '~=', decodeid(cap[1].substring(1)), false)
- : selectors.attr('id', '=', decodeid(cap[1].substring(1)), false);
- }
-
- // pseudo-name
- // inside-pseudo
- if (cap[2]) {
- return cap[3]
- ? selectors[decodeid(cap[2])](unquote(cap[3]))
- : selectors[decodeid(cap[2])];
- }
-
- // attr name
- // attr op
- // attr value
- if (cap[4]) {
- var value = cap[6];
- var i = /["'\s]\s*I$/i.test(value);
- if (i) {
- value = value.replace(/\s*I$/i, '');
- }
- return selectors.attr(decodeid(cap[4]), cap[5] || '-', unquote(value), i);
- }
-
- throw new SyntaxError('Unknown Selector.');
-};
-
-var makeSimple = function(func) {
- var l = func.length
- , i;
-
- // Potentially make sure
- // `el` is truthy.
- if (l < 2) return func[0];
-
- return function(el) {
- if (!el) return;
- for (i = 0; i < l; i++) {
- if (!func[i](el)) return;
- }
- return true;
- };
-};
-
-var makeTest = function(func) {
- if (func.length < 2) {
- return function(el) {
- return !!func[0](el);
- };
- }
- return function(el) {
- var i = func.length;
- while (i--) {
- if (!(el = func[i](el))) return;
- }
- return true;
- };
-};
-
-var makeSubject = function() {
- var target;
-
- function subject(el) {
- var node = el.ownerDocument
- , scope = node.getElementsByTagName(subject.lname)
- , i = scope.length;
-
- while (i--) {
- if (subject.test(scope[i]) && target === el) {
- target = null;
- return true;
- }
- }
-
- target = null;
- }
-
- subject.simple = function(el) {
- target = el;
- return true;
- };
-
- return subject;
-};
-
-var compileGroup = function(sel) {
- var test = compile(sel)
- , tests = [ test ];
-
- while (test.sel) {
- test = compile(test.sel);
- tests.push(test);
- }
-
- if (tests.length < 2) return test;
-
- return function(el) {
- var l = tests.length
- , i = 0;
-
- for (; i < l; i++) {
- if (tests[i](el)) return true;
- }
- };
-};
-
-/**
- * Selection
- */
-
-var find = function(sel, node) {
- var results = []
- , test = compile(sel)
- , scope = node.getElementsByTagName(test.qname)
- , i = 0
- , el;
-
- /*jshint -W084 */
- while (el = scope[i++]) {
- if (test(el)) results.push(el);
- }
-
- if (test.sel) {
- while (test.sel) {
- test = compile(test.sel);
- scope = node.getElementsByTagName(test.qname);
- i = 0;
- /*jshint -W084 */
- while (el = scope[i++]) {
- if (test(el) && indexOf.call(results, el) === -1) {
- results.push(el);
- }
- }
- }
- results.sort(order);
- }
-
- return results;
-};
-
-/**
- * Expose
- */
-
-module.exports = exports = function(sel, context) {
- /* when context isn't a DocumentFragment and the selector is simple: */
- var id, r;
- if (context.nodeType !== 11 && sel.indexOf(' ') === -1) {
- if (sel[0] === '#' && context.rooted && /^#[A-Z_][-A-Z0-9_]*$/i.test(sel)) {
- if (context.doc._hasMultipleElementsWithId) {
- id = sel.substring(1);
- if (!context.doc._hasMultipleElementsWithId(id)) {
- r = context.doc.getElementById(id);
- return r ? [r] : [];
- }
- }
- }
- if (sel[0] === '.' && /^\.\w+$/.test(sel)) {
- return context.getElementsByClassName(sel.substring(1));
- }
- if (/^\w+$/.test(sel)) {
- return context.getElementsByTagName(sel);
- }
- }
- /* do things the hard/slow way */
- return find(sel, context);
-};
-
-exports.selectors = selectors;
-exports.operators = operators;
-exports.combinators = combinators;
-
-exports.matches = function(el, sel) {
- var test = { sel: sel };
- do {
- test = compile(test.sel);
- if (test(el)) { return true; }
- } while (test.sel);
- return false;
-};
--- a/domino/domino-lib/sloppy.js
+++ /dev/null
@@ -1,24 +1,0 @@
-/* Domino uses sloppy-mode features (in particular, `with`) for a few
- * minor things. This file encapsulates all the sloppiness; every
- * other module should be strict. */
-/* jshint strict: false */
-/* jshint evil: true */
-/* jshint -W085 */
-module.exports = {
- Window_run: function _run(code, file) {
- if (file) code += '\n//@ sourceURL=' + file;
- with(this) eval(code);
- },
- EventHandlerBuilder_build: function build() {
- try {
- with(this.document.defaultView || Object.create(null))
- with(this.document)
- with(this.form)
- with(this.element)
- return eval("(function(event){" + this.body + "})");
- }
- catch (err) {
- return function() { throw err; };
- }
- }
-};
--- a/domino/domino-lib/svg.js
+++ /dev/null
@@ -1,57 +1,0 @@
-"use strict";
-var Element = require('./Element');
-var defineElement = require('./defineElement');
-var utils = require('./utils');
-var CSSStyleDeclaration = require('./CSSStyleDeclaration');
-
-var svgElements = exports.elements = {};
-var svgNameToImpl = Object.create(null);
-
-exports.createElement = function(doc, localName, prefix) {
- var impl = svgNameToImpl[localName] || SVGElement;
- return new impl(doc, localName, prefix);
-};
-
-function define(spec) {
- return defineElement(spec, SVGElement, svgElements, svgNameToImpl);
-}
-
-var SVGElement = define({
- superclass: Element,
- ctor: function SVGElement(doc, localName, prefix) {
- Element.call(this, doc, localName, utils.NAMESPACE.SVG, prefix);
- },
- props: {
- style: { get: function() {
- if (!this._style)
- this._style = new CSSStyleDeclaration(this);
- return this._style;
- }}
- }
-});
-
-define({
- ctor: function SVGSVGElement(doc, localName, prefix) {
- SVGElement.call(this, doc, localName, prefix);
- },
- tag: 'svg',
- props: {
- createSVGRect: { value: function () {
- return exports.createElement(this.ownerDocument, 'rect', null);
- } }
- }
-});
-
-define({
- tags: [
- 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform',
- 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix',
- 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight',
- 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode',
- 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter',
- 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g',
- 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph',
- 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style',
- 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'
- ]
-});
--- a/domino/domino-lib/utils.js
+++ /dev/null
@@ -1,85 +1,0 @@
-"use strict";
-var DOMException = require('./DOMException');
-var ERR = DOMException;
-var isApiWritable = require("./config").isApiWritable;
-
-exports.NAMESPACE = {
- HTML: 'http://www.w3.org/1999/xhtml',
- XML: 'http://www.w3.org/XML/1998/namespace',
- XMLNS: 'http://www.w3.org/2000/xmlns/',
- MATHML: 'http://www.w3.org/1998/Math/MathML',
- SVG: 'http://www.w3.org/2000/svg',
- XLINK: 'http://www.w3.org/1999/xlink'
-};
-
-//
-// Shortcut functions for throwing errors of various types.
-//
-exports.IndexSizeError = function() { throw new DOMException(ERR.INDEX_SIZE_ERR); };
-exports.HierarchyRequestError = function() { throw new DOMException(ERR.HIERARCHY_REQUEST_ERR); };
-exports.WrongDocumentError = function() { throw new DOMException(ERR.WRONG_DOCUMENT_ERR); };
-exports.InvalidCharacterError = function() { throw new DOMException(ERR.INVALID_CHARACTER_ERR); };
-exports.NoModificationAllowedError = function() { throw new DOMException(ERR.NO_MODIFICATION_ALLOWED_ERR); };
-exports.NotFoundError = function() { throw new DOMException(ERR.NOT_FOUND_ERR); };
-exports.NotSupportedError = function() { throw new DOMException(ERR.NOT_SUPPORTED_ERR); };
-exports.InvalidStateError = function() { throw new DOMException(ERR.INVALID_STATE_ERR); };
-exports.SyntaxError = function() { throw new DOMException(ERR.SYNTAX_ERR); };
-exports.InvalidModificationError = function() { throw new DOMException(ERR.INVALID_MODIFICATION_ERR); };
-exports.NamespaceError = function() { throw new DOMException(ERR.NAMESPACE_ERR); };
-exports.InvalidAccessError = function() { throw new DOMException(ERR.INVALID_ACCESS_ERR); };
-exports.TypeMismatchError = function() { throw new DOMException(ERR.TYPE_MISMATCH_ERR); };
-exports.SecurityError = function() { throw new DOMException(ERR.SECURITY_ERR); };
-exports.NetworkError = function() { throw new DOMException(ERR.NETWORK_ERR); };
-exports.AbortError = function() { throw new DOMException(ERR.ABORT_ERR); };
-exports.UrlMismatchError = function() { throw new DOMException(ERR.URL_MISMATCH_ERR); };
-exports.QuotaExceededError = function() { throw new DOMException(ERR.QUOTA_EXCEEDED_ERR); };
-exports.TimeoutError = function() { throw new DOMException(ERR.TIMEOUT_ERR); };
-exports.InvalidNodeTypeError = function() { throw new DOMException(ERR.INVALID_NODE_TYPE_ERR); };
-exports.DataCloneError = function() { throw new DOMException(ERR.DATA_CLONE_ERR); };
-
-exports.nyi = function(what) {
- throw new Error("NotYetImplemented " + what);
-};
-
-exports.shouldOverride = function() {
- throw new Error("Abstract function; should be overriding in subclass.");
-};
-
-exports.assert = function(expr, msg) {
- if (!expr) {
- throw new Error("Assertion failed: " + (msg || "") + "\n" + new Error().stack);
- }
-};
-
-exports.expose = function(src, c) {
- for (var n in src) {
- Object.defineProperty(c.prototype, n, { value: src[n], writable: isApiWritable });
- }
-};
-
-exports.merge = function(a, b) {
- for (var n in b) {
- a[n] = b[n];
- }
-};
-
-// Compare two nodes based on their document order. This function is intended
-// to be passed to sort(). Assumes that the array being sorted does not
-// contain duplicates. And that all nodes are connected and comparable.
-// Clever code by ppk via jeresig.
-exports.documentOrder = function(n,m) {
- /* jshint bitwise: false */
- return 3 - (n.compareDocumentPosition(m) & 6);
-};
-
-exports.toASCIILowerCase = function(s) {
- return s.replace(/[A-Z]+/g, function(c) {
- return c.toLowerCase();
- });
-};
-
-exports.toASCIIUpperCase = function(s) {
- return s.replace(/[a-z]+/g, function(c) {
- return c.toUpperCase();
- });
-};
--- a/domino/domino-lib/xmlnames.js
+++ /dev/null
@@ -1,91 +1,0 @@
-"use strict";
-// This grammar is from the XML and XML Namespace specs. It specifies whether
-// a string (such as an element or attribute name) is a valid Name or QName.
-//
-// Name ::= NameStartChar (NameChar)*
-// NameStartChar ::= ":" | [A-Z] | "_" | [a-z] |
-// [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
-// [#x370-#x37D] | [#x37F-#x1FFF] |
-// [#x200C-#x200D] | [#x2070-#x218F] |
-// [#x2C00-#x2FEF] | [#x3001-#xD7FF] |
-// [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
-// [#x10000-#xEFFFF]
-//
-// NameChar ::= NameStartChar | "-" | "." | [0-9] |
-// #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
-//
-// QName ::= PrefixedName| UnprefixedName
-// PrefixedName ::= Prefix ':' LocalPart
-// UnprefixedName ::= LocalPart
-// Prefix ::= NCName
-// LocalPart ::= NCName
-// NCName ::= Name - (Char* ':' Char*)
-// # An XML Name, minus the ":"
-//
-
-exports.isValidName = isValidName;
-exports.isValidQName = isValidQName;
-
-// Most names will be ASCII only. Try matching against simple regexps first
-var simplename = /^[_:A-Za-z][-.:\w]+$/;
-var simpleqname = /^([_A-Za-z][-.\w]+|[_A-Za-z][-.\w]+:[_A-Za-z][-.\w]+)$/;
-
-// If the regular expressions above fail, try more complex ones that work
-// for any identifiers using codepoints from the Unicode BMP
-var ncnamestartchars = "_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
-var ncnamechars = "-._A-Za-z0-9\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0300-\u037D\u037F-\u1FFF\u200C\u200D\u203f\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
-
-var ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*";
-var namestartchars = ncnamestartchars + ":";
-var namechars = ncnamechars + ":";
-var name = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$");
-var qname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$");
-
-// XML says that these characters are also legal:
-// [#x10000-#xEFFFF]. So if the patterns above fail, and the
-// target string includes surrogates, then try the following
-// patterns that allow surrogates and then run an extra validation
-// step to make sure that the surrogates are in valid pairs and in
-// the right range. Note that since the characters \uf0000 to \u1f0000
-// are not allowed, it means that the high surrogate can only go up to
-// \uDB7f instead of \uDBFF.
-var hassurrogates = /[\uD800-\uDB7F\uDC00-\uDFFF]/;
-var surrogatechars = /[\uD800-\uDB7F\uDC00-\uDFFF]/g;
-var surrogatepairs = /[\uD800-\uDB7F][\uDC00-\uDFFF]/g;
-
-// Modify the variables above to allow surrogates
-ncnamestartchars += "\uD800-\uDB7F\uDC00-\uDFFF";
-ncnamechars += "\uD800-\uDB7F\uDC00-\uDFFF";
-ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*";
-namestartchars = ncnamestartchars + ":";
-namechars = ncnamechars + ":";
-
-// Build another set of regexps that include surrogates
-var surrogatename = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$");
-var surrogateqname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$");
-
-function isValidName(s) {
- if (simplename.test(s)) return true; // Plain ASCII
- if (name.test(s)) return true; // Unicode BMP
-
- // Maybe the tests above failed because s includes surrogate pairs
- // Most likely, though, they failed for some more basic syntax problem
- if (!hassurrogates.test(s)) return false;
-
- // Is the string a valid name if we allow surrogates?
- if (!surrogatename.test(s)) return false;
-
- // Finally, are the surrogates all correctly paired up?
- var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs);
- return pairs !== null && 2*pairs.length === chars.length;
-}
-
-function isValidQName(s) {
- if (simpleqname.test(s)) return true; // Plain ASCII
- if (qname.test(s)) return true; // Unicode BMP
-
- if (!hassurrogates.test(s)) return false;
- if (!surrogateqname.test(s)) return false;
- var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs);
- return pairs !== null && 2*pairs.length === chars.length;
-}
--- a/domino/domino.go
+++ /dev/null
@@ -1,505 +1,0 @@
-package domino
-
-import (
- "bytes"
- "embed"
- "errors"
- "fmt"
- "github.com/dop251/goja"
- "github.com/dop251/goja/parser"
- "github.com/dop251/goja_nodejs/console"
- "github.com/dop251/goja_nodejs/eventloop"
- "github.com/dop251/goja_nodejs/require"
- "golang.org/x/net/html"
- "io/ioutil"
- "github.com/psilva261/opossum"
- "github.com/psilva261/opossum/logger"
- "github.com/psilva261/opossum/nodes"
- "net/http"
- "os"
- "os/exec"
- "path/filepath"
- "regexp"
- "strconv"
- "strings"
- "syscall"
- "time"
-)
-
-var DebugDumpJS *bool
-var log *logger.Logger
-var timeout = 60*time.Second
-
-//go:embed domino-lib/*js
-var lib embed.FS
-
-//go:embed domintf.js
-var domIntfJs embed.FS
-
-var domIntf string
-
-func init() {
- data, err := domIntfJs.ReadFile("domintf.js")
- if err != nil {
- panic(err.Error())
- }
- domIntf = string(data)
-}
-
-func SetLogger(l *logger.Logger) {
- log = l
-}
-
-type Mutation struct {
- time.Time
- Type int
- Sel string
-}
-
-type Domino struct {
- fetcher opossum.Fetcher
- loop *eventloop.EventLoop
- html string
- nt *nodes.Node
- outputHtml string
- domChange chan Mutation
-}
-
-func NewDomino(html string, fetcher opossum.Fetcher, nt *nodes.Node) (d *Domino) {
- d = &Domino{
- html: html,
- fetcher: fetcher,
- nt: nt,
- domChange: make(chan Mutation, 100),
- }
- return
-}
-
-func (d *Domino) Start() {
- log.Printf("Start event loop")
- d.loop = eventloop.NewEventLoop()
-
- d.loop.Start()
- log.Printf("event loop started")
-}
-
-func (d *Domino) Stop() {
- d.loop.Stop()
-}
-
-func IntrospectError(err error, script string) {
- prefix := "Line "
- i := strings.Index(err.Error(), prefix)
- if i > 0 {
- i += len(prefix)
- s := err.Error()[i:]
- yxStart := strings.Split(s, " ")[0]
- yx := strings.Split(yxStart, ":")
- y, _ := strconv.Atoi(yx[0])
- x, _ := strconv.Atoi(yx[1])
- lines := strings.Split(script, "\n")
-
- if y - 1 > len(lines) - 1 {
- y = len(lines)
- }
-
- if wholeLine := lines[y-1]; len(wholeLine) > 100 {
- from := x - 50
- to := x + 50
- if from < 0 {
- from = 0
- }
- if to >= len(wholeLine) {
- to = len(wholeLine) - 1
- }
- log.Printf("the line: %v", wholeLine[from:to])
- } else {
- if y > 0 && len(lines[y-1]) < 120 {
- log.Printf("%v: %v", y-1, lines[y-1])
- }
- if y < len(lines) {
- log.Printf("%v: %v", y, lines[y])
- }
- if y+1 < len(lines) && len(lines[y+1]) < 120 {
- log.Printf("%v: %v", y+1, lines[y+1])
- }
- }
- }
-}
-
-func printCode(code string, maxWidth int) {
- if maxWidth > len(code) {
- maxWidth = len(code)
- }
- log.Infof("js code: %v", code[:maxWidth])
-}
-
-func srcLoader(fn string) ([]byte, error) {
- path := filepath.FromSlash(fn)
- if !strings.Contains(path, "domino-lib/") || !strings.HasSuffix(path, ".js") {
- return nil, require.ModuleFileDoesNotExistError
- }
- data, err := lib.ReadFile(path)
- if err != nil {
- if os.IsNotExist(err) || errors.Is(err, syscall.EISDIR) {
- err = require.ModuleFileDoesNotExistError
- } else {
- log.Errorf("srcLoader: handling of require('%v') is not implemented", fn)
- }
- }
- return data, err
-}
-
-func (d *Domino) Exec(script string, initial bool) (res string, err error) {
- r := regexp.MustCompile(`^\s*<!--`)
- script = r.ReplaceAllString(script, "//")
- SCRIPT := domIntf + script
- if !initial {
- SCRIPT = script
- }
-
- if *DebugDumpJS {
- ioutil.WriteFile("main.js", []byte(SCRIPT), 0644)
- }
-
- ready := make(chan goja.Value)
- errCh := make(chan error)
- intCh := make(chan int)
- go func() {
- d.loop.RunOnLoop(func(vm *goja.Runtime) {
- log.Printf("RunOnLoop")
-
- if initial {
- vm.SetParserOptions(parser.WithDisableSourceMaps)
-
- // find domino-lib folder
- registry := require.NewRegistry(
- require.WithGlobalFolders("."),
- require.WithLoader(
- require.SourceLoader(srcLoader),
- ),
- )
-
- console.Enable(vm)
- registry.Enable(vm)
-
- type S struct {
- Buf string `json:"buf"`
- HTML string `json:"html"`
- Referrer func() string `json:"referrer"`
- Style func(string, string, string, string) string `json:"style"`
- XHR func(string, string, map[string]string, string, func(string, string)) `json:"xhr"`
- Mutated func(int, string) `json:"mutated"`
- }
-
- vm.SetFieldNameMapper(goja.TagFieldNameMapper("json", true))
- vm.Set("opossum", S{
- HTML: d.html,
- Buf: "yolo",
- Referrer: func() string { return "https://example.com" },
- Style: func(sel, pseudo, prop, prop2 string) string {
- res, err := d.nt.Query(sel)
- if err != nil {
- log.Errorf("query %v: %v", sel, err)
- return ""
- }
- if len(res) != 1 {
- log.Errorf("query %v: %v", res, err)
- return ""
- }
- return res[0].Css(prop)
- },
- XHR: d.xhr,
- Mutated: d.mutated,
- })
- }
-
- go func() {
- for _ = range intCh {
- vm.Interrupt("halt")
- }
- }()
-
- vv, err := vm.RunString(SCRIPT)
- if err != nil {
- IntrospectError(err, script)
- errCh <- fmt.Errorf("run program: %w", err)
- } else {
- ready <- vv
- }
- })
- }()
-
- for {
- select {
- case v := <-ready:
- log.Infof("ready")
- <-time.After(10 * time.Millisecond)
- if v != nil {
- res = v.String()
- }
- goto cleanup
- case er := <- errCh:
- log.Infof("err")
- <-time.After(10 * time.Millisecond)
- err = fmt.Errorf("event loop: %w", er)
- goto cleanup
- case <-time.After(timeout):
- log.Errorf("Interrupt JS after %v", timeout)
- intCh <- 1
- }
- }
-
-cleanup:
- close(ready)
- close(errCh)
- close(intCh)
-
- return
-}
-
-func (d *Domino) Exec6(script string, initial bool) (res string, err error) {
- cmd := exec.Command("6to5")
- cmd.Stdin = strings.NewReader(script)
- var out bytes.Buffer
- cmd.Stdout = &out
- if err = cmd.Run(); err != nil {
- return "", fmt.Errorf("6to5: %w", err)
- }
- return d.Exec(out.String(), initial)
-}
-
-// CloseDoc fires DOMContentLoaded to trigger $(document).ready(..)
-func (d *Domino) CloseDoc() (err error) {
- _, err = d.Exec("if (this.document) document.close();", false)
- return
-}
-
-// TriggerClick, and return the result html
-// ...then HTML5 parse it, diff the node tree
-// (probably faster and cleaner than anything else)
-func (d *Domino) TriggerClick(selector string) (newHTML string, ok bool, err error) {
- res, err := d.Exec(`
- var sel = '` + selector + `';
- var el = document.querySelector(sel);
-
- console.log('query ' + sel);
-
- if (!el) {
- console.log('el is null/undefined');
- null;
- } else if (el._listeners && el._listeners.click) {
- var fn = el.click.bind(el);
-
- if (fn) {
- console.log(' call click handler...');
- fn();
- }
-
- !!fn;
- } else {
- false;
- }
- `, false)
-
- if ok = res == "true"; ok {
- newHTML, ok, err = d.TrackChanges()
- }
-
- return
-}
-
-// Put change into html (e.g. from input field mutation)
-func (d *Domino) PutAttr(selector, attr, val string) (ok bool, err error) {
- res, err := d.Exec(`
- var sel = '` + selector + `';
- var el = document.querySelector(sel);
- el.attr('` + attr + `', '` + val + `');
- !!el;
- `, false)
-
- ok = res == "true"
-
- return
-}
-
-func (d *Domino) TrackChanges() (html string, changed bool, err error) {
- outer:
- for {
- // TODO: either add other change types like ajax begin/end or
- // just have one channel for all events worth waiting for.
- select {
- case <-d.domChange:
- changed = true
- case <-time.After(time.Second):
- break outer
- }
- }
-
- if changed {
- html, err = d.Exec("document.querySelector('html').innerHTML;", false)
- if err != nil {
- return
- }
- }
- d.outputHtml = html
- return
-}
-
-func Srcs(doc *nodes.Node) (srcs []string) {
- srcs = make([]string, 0, 3)
-
- iterateJsElements(doc, func(src, inlineCode string) {
- if src = strings.TrimSpace(src); src != "" && !blocked(src) {
- srcs = append(srcs, src)
- }
- })
-
- return
-}
-
-func blocked(src string) bool {
- for _, s := range []string{
- "adsense",
- "adsystem",
- "adservice",
- "googletagservice",
- "googletagmanager",
- "script.ioam.de",
- "googlesyndication",
- "adserver",
- "nativeads",
- "prebid",
- ".ads.",
- "google-analytics.com",
- } {
- if strings.Contains(src, s) {
- return true
- }
- }
- return false
-}
-
-func Scripts(doc *nodes.Node, downloads map[string]string) (codes []string) {
- codes = make([]string, 0, 3)
-
- iterateJsElements(doc, func(src, inlineCode string) {
- if strings.TrimSpace(inlineCode) != "" {
- log.Infof("domino.Scripts: inline code:")
- printCode(inlineCode, 20)
- codes = append(codes, inlineCode)
- } else if c, ok := downloads[src]; ok {
- log.Infof("domino.Scripts: referenced code (%v)", src)
- codes = append(codes, c)
- }
- })
-
- return
-}
-
-func iterateJsElements(doc *nodes.Node, fn func(src string, inlineCode string)) {
- var f func(n *nodes.Node)
- f = func(n *nodes.Node) {
- if n.Type() == html.ElementNode && n.Data() == "script" {
- isJS := true
- src := ""
-
- for _, a := range n.Attrs {
- switch strings.ToLower(a.Key) {
- case "type":
- t, err := opossum.NewContentType(a.Val, nil)
- if err != nil {
- log.Printf("t: %v", err)
- }
- if a.Val == "" || t.IsJS() {
- isJS = true
- } else {
- isJS = false
- }
- case "src":
- src = a.Val
- }
- }
-
- if isJS {
- fn(src, n.ContentString(true))
- }
- }
- for _, c := range n.Children {
- f(c)
- }
- }
-
- f(doc)
-
- return
-}
-
-func (d *Domino) xhr(method, uri string, h map[string]string, data string, cb func(data string, err string)) {
- c := &http.Client{}
- u, err := d.fetcher.LinkedUrl(uri)
- if err != nil {
- cb("", err.Error())
- return
- }
- if u.Host != d.fetcher.Origin().Host {
- log.Infof("origin: %v", d.fetcher.Origin())
- log.Infof("uri: %v", uri)
- cb("", "cannot do crossorigin request to " + u.String())
- return
- }
-
- req, err := http.NewRequest(method, u.String(), strings.NewReader(data))
- if err != nil {
- cb("", err.Error())
- return
- }
- for k, v := range h {
- req.Header.Add(k, v)
- }
- // TODO: timeout? context? http timeout?
- go func() {
- resp, err := c.Do(req)
- if err != nil {
- cb("", err.Error())
- return
- }
- defer resp.Body.Close()
- bs, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- cb("", err.Error())
- return
- }
- d.loop.RunOnLoop(func(*goja.Runtime) {
- defer func() {
- if r := recover(); r != nil {
- log.Errorf("recovered in xhr: %v", r)
- }
- }()
- cb(string(bs), "")
- })
- }()
-}
-
-func (d *Domino) mutated(t int, q string) {
- m := Mutation{
- Time: time.Now(),
- Type: t,
- Sel: q,
- }
-
- select {
- case d.domChange <- m:
- default:
- log.Printf("dom changes backlog full")
- }
-}
-
-// AJAX:
-// https://stackoverflow.com/questions/7086858/loading-ajax-app-with-jsdom
-
-// Babel on Goja:
-// https://github.com/dop251/goja/issues/5#issuecomment-259996573
-
-// Goja supports ES5.1 which is essentially JS assembly:
-// https://github.com/dop251/goja/issues/76#issuecomment-399253779
--- a/domino/domino_test.go
+++ /dev/null
@@ -1,717 +1,0 @@
-package domino
-
-import (
- "io/ioutil"
- "github.com/psilva261/opossum"
- "github.com/psilva261/opossum/logger"
- "github.com/psilva261/opossum/nodes"
- "github.com/psilva261/opossum/style"
- "golang.org/x/net/html"
- "net/url"
- "strings"
- "testing"
- "time"
-)
-
-const simpleHTML = `
-<html>
-<body>
-<h1 id="title">Hello</h1>
-</body>
-</html>
-`
-
-func init() {
- f := false
- t := true
- DebugDumpJS = &t
- logger.Quiet = &f
- logger.Init()
- log = &logger.Logger{Debug: true}
-}
-
-func TestSimple(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- s := `
- var state = 'empty';
- var a = 1;
- b = 2;
- `
- _, err := d.Exec(s, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- s2 := `
- (function() {
- if (state !== 'empty') throw new Exception(state);
-
- state = a + b;
- })()
- var a = 1;
- b = 2;
- `
- _, err = d.Exec(s2, false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- d.Stop()
-}
-
-func TestGlobals(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
-}
-
-func TestJQuery(t *testing.T) {
- buf, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- $(document).ready(function() {
- gfgf
- });
- setTimeout(function() {
- console.log("ok");
- }, 1000);
- var numberOne = 1;
- `
- _=buf
- _, err = d.Exec(string(buf) + ";" + script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("numberOne+1", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if res != "2" {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestJQueryHide(t *testing.T) {
- buf, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- $(document).ready(function() {
- $('h1').hide();
- });
- `
- _, err = d.Exec(string(buf) + ";" + script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("$('h1').attr('style')", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if res != "display: none;" {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestJQueryCss(t *testing.T) {
- buf, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- h := `
- <html>
- <body>
- <h1 id="title" style="display: inline-block;">Hello</h1>
- </body>
- </html>
- `
- d := NewDomino(h, nil, nil)
- r := strings.NewReader(h)
- doc, err := html.Parse(r)
- if err != nil { t.Fatalf(err.Error()) }
- d.nt = nodes.NewNodeTree(doc, style.Map{}, make(map[*html.Node]style.Map), nil)
- d.Start()
- _, err = d.Exec(string(buf), true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("$('h1').css('display')", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if res != "inline-block" {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestGodoc(t *testing.T) {
- buf, err := ioutil.ReadFile("godoc/pkg.html")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(string(buf), nil, nil)
- d.Start()
- for i, fn := range []string{"initfuncs.js", "jquery-1.8.2.js", "goversion.js", "godocs.js"} {
- buf, err := ioutil.ReadFile("godoc/"+fn)
- if err != nil {
- t.Fatalf("%v", err)
- }
- _, err = d.Exec(string(buf) /*+ ";" + script*/, i == 0)
- if err != nil {
- t.Fatalf("%v", err)
- }
- }
- d.Stop()
-}
-
-func TestGoplayground(t *testing.T) {
- buf, err := ioutil.ReadFile("godoc/golang.html")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(string(buf), nil, nil)
- d.Start()
- for i, fn := range []string{"initfuncs.js", "jquery-1.8.2.js", "playground.js", "goversion.js", "godocs.js", "golang.js"} {
- buf, err := ioutil.ReadFile("godoc/"+fn)
- if err != nil {
- t.Fatalf("%v", err)
- }
- _, err = d.Exec(string(buf) /*+ ";" + script*/, i == 0)
- if err != nil {
- t.Fatalf("%v", err)
- }
- }
- res, err := d.Exec("window.playground", false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if !strings.Contains(res, "function playground(opts) {") {
- t.Fatalf("%v", res)
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
-
- d.Stop()
-}
-
-func TestJqueryUI(t *testing.T) {
- buf, err := ioutil.ReadFile("jqueryui/tabs.html")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(string(buf), nil, nil)
- d.Start()
- script := `
- Object.assign(this, window);
- `
- _ = script
- for i, fn := range []string{"jquery-1.12.4.js", "jquery-ui.js", "tabs.js"} {
- buf, err := ioutil.ReadFile("jqueryui/"+fn)
- if err != nil {
- t.Fatalf("%v", err)
- }
- _, err = d.Exec(string(buf) /*+ ";" + script*/, i == 0)
- if err != nil {
- t.Fatalf("%v", err)
- }
- }
- d.Stop()
-}
-
-func TestRun(t *testing.T) {
- jQuery, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- SCRIPT := string(jQuery) + `
- ;;;
- setTimeout(function() {
- var h = document.querySelector('html');
- console.log(h.innerHTML);
- }, 1000);
- Object.assign(this, window);
- $(document).ready(function() {
- console.log('READDDYYYYY!!!!!!!');
- });
-
- console.log(window.location.href);
- `
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- _, err = d.Exec(SCRIPT, true)
- if err != nil {
- t.Fatalf(err.Error())
- }
-
- res, err := d.Exec("$('h1').html()", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- if res != "Hello" {
- t.Fatalf(res)
- }
- d.Stop()
-}
-
-func TestTriggerClick(t *testing.T) {
- jQuery, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- SCRIPT := string(jQuery) + `
- var clicked = false;
- $(document).ready(function() {
- $('h1').click(function() {
- clicked = true;
- });
- });
- `
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- _, err = d.Exec(SCRIPT, true)
- if err != nil {
- t.Fatalf(err.Error())
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
-
- res, err := d.Exec("$('h1').html()", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- if res != "Hello" {
- t.Fatalf(res)
- }
-
- if _, _, err = d.TrackChanges(); err != nil {
- t.Fatalf(err.Error())
- }
- _, changed, err := d.TriggerClick("h1")
- if err != nil {
- t.Fatalf(err.Error())
- }
- if changed {
- t.Fatal()
- }
- res, err = d.Exec("clicked", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- if res != "true" {
- t.Fatalf(res)
- }
- d.Stop()
-}
-
-func TestDomChanged(t *testing.T) {
- jQuery, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- //t.Parallel()
- SCRIPT := string(jQuery) + `
- ;;;
- setTimeout(function() {
- var h = document.querySelector('html');
- console.log(h.innerHTML);
- }, 1000);
- Object.assign(this, window);
- $(document).ready(function() {
- console.log('READDDYYYYY!!!!!!!');
- });
- `
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- _, err = d.Exec(SCRIPT, true)
- if err != nil {
- t.Fatalf(err.Error())
- }
-
- res, err := d.Exec("$('h1').html()", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- _=res
- res, err = d.Exec("$('h1').html('minor updates :-)'); $('h1').html();", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- t.Logf("new res=%v", res)
- d.Stop()
-}
-
-func TestTrackChanges(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- _, err := d.Exec(``, true)
- if err != nil {
- t.Fatalf(err.Error())
- }
- // 0th time: init
- if _, _, err = d.TrackChanges(); err != nil {
- t.Fatalf(err.Error())
- }
- // 1st time: no change
- html, changed, err := d.TrackChanges()
- if err != nil {
- t.Fatalf(err.Error())
- }
- if changed == true {
- t.Fatal()
- }
- // 2nd time: no change
- html, changed, err = d.TrackChanges()
- if err != nil {
- t.Fatalf(err.Error())
- }
- if changed == true {
- t.Fatal()
- }
- _, err = d.Exec("document.getElementById('title').innerHTML='new title'; true;", false)
- if err != nil {
- t.Fatalf(err.Error())
- }
- // 3rd time: yes change
- html, changed, err = d.TrackChanges()
- if err != nil {
- t.Fatalf(err.Error())
- }
- if html == "" {
- t.Fatalf(err.Error())
- }
- if changed == false {
- t.Fatal()
- }
- if !strings.Contains(html, "new title") {
- t.Fatalf(html)
- }
- d.Stop()
-}
-
-/*func TestExecInlinedScripts(t *testing.T) {
- const h = `
- <html>
- <body>
- <h1 id="title">Hello</h1>
- <script>
- document.getElementById('title').innerHTML = 'Good day';
- </script>
- </body>
- </html>
- `
- d := NewDomino(h)
- d.Start()
- err := d.ExecInlinedScripts()
- if err != nil {
- t.Fatalf(err.Error())
- }
- res, err := d.Export("document.getElementById('title').innerHTML")
- if err != nil {
- t.Fatalf(err.Error())
- }
- if !strings.Contains(res, "Good day") {
- t.Fatalf(res)
- }
- d.Stop()
-}*/
-
-/*func TestWindowEqualsGlobal(t *testing.T) {
- const h = `
- <html>
- <body>
- <script>
- a = 2;
- window.b = 5;
- </script>
- <script>
- console.log('window.a=', window.a);
- console.log('wot');
- console.log('window.b=', window.b);
- console.log('wit');
- window.a++;
- b++;
- </script>
- </body>
- </html>
- `
- d := NewDomino(h)
- d.Start()
- err := d.ExecInlinedScripts()
- if err != nil {
- t.Fatalf(err.Error())
- }
- res, err := d.Export("window.a")
- if err != nil {
- t.Fatalf(err.Error())
- }
- if !strings.Contains(res, "3") {
- t.Fatalf(res)
- }
- res, err = d.Export("window.b")
- if err != nil {
- t.Fatalf(err.Error())
- }
- if !strings.Contains(res, "6") {
- t.Fatalf(res)
- }
- d.Stop()
-}*/
-
-func TestES6(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- var foo = function(data={}) {}
- var h = {
- a: 1,
- b: 11
- };
- var {a, b} = h;
- `
- _, err := d.Exec6(script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("a+b", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if res != "12" {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestWindowParent(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- console.log('Hello!!')
- `
- _, err := d.Exec(script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("window === window.parent", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if res != "true" {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestReferrer(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- document.referrer;
- `
- res, err := d.Exec(script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("res=%v", res)
- if res != "https://example.com" {
- t.Fatal()
- }
- d.Stop()
-}
-
-type MockBrowser struct {
- origin *url.URL
- linkedUrl *url.URL
-}
-
-func (mb *MockBrowser) LinkedUrl(string) (*url.URL, error) {
- return mb.linkedUrl, nil
-}
-
-func (mb *MockBrowser) Origin() (*url.URL) {
- return mb.origin
-}
-
-func (mb *MockBrowser) Get(*url.URL) (bs []byte, ct opossum.ContentType, err error) {
- return
-}
-
-func TestXMLHttpRequest(t *testing.T) {
- mb := &MockBrowser{}
- mb.origin, _ = url.Parse("https://example.com")
- mb.linkedUrl, _ = url.Parse("https://example.com")
- d := NewDomino(simpleHTML, mb, nil)
- d.Start()
- script := `
- var oReq = new XMLHttpRequest();
- var loaded = false;
- oReq.addEventListener("load", function() {
- loaded = true;
- });
- oReq.open("GET", "http://www.example.org/example.txt");
- oReq.send();
- `
- _, err := d.Exec(script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- <-time.After(time.Second)
- res, err := d.Exec("oReq.responseText;", false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("res=%v", res)
- if !strings.Contains(res, "<html") {
- t.Fatal()
- }
- d.Stop()
-}
-
-func TestJQueryAjax(t *testing.T) {
- mb := &MockBrowser{}
- mb.origin, _ = url.Parse("https://example.com")
- mb.linkedUrl, _ = url.Parse("https://example.com")
- buf, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(simpleHTML, mb, nil)
- d.Start()
- script := `
- var res;
- $.ajax({
- url: '/',
- success: function() {
- res = 'success';
- },
- error: function() {
- res = 'err';
- }
- });
- `
- _, err = d.Exec(string(buf) + ";" + script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
- <-time.After(time.Second)
- res, err := d.Exec("res;", false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("res=%v", res)
- if res != "success" {
- t.Fatalf(res)
- }
- d.Stop()
-}
-
-func TestJQueryAjax182(t *testing.T) {
- mb := &MockBrowser{}
- mb.origin, _ = url.Parse("https://example.com")
- mb.linkedUrl, _ = url.Parse("https://example.com")
- buf, err := ioutil.ReadFile("godoc/jquery-1.8.2.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(simpleHTML, mb, nil)
- d.Start()
- script := `
- var res;
- $.ajax({
- url: '/',
- success: function() {
- res = 'success';
- },
- error: function() {
- res = 'err';
- }
- });
- `
- _, err = d.Exec(string(buf) + ";" + script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
- <-time.After(5*time.Second)
- res, err := d.Exec("res;", false)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("res=%v", res)
- if res != "success" {
- t.Fatalf(res)
- }
- d.Stop()
-}
-
-func TestMutationEvents(t *testing.T) {
- buf, err := ioutil.ReadFile("jquery-3.5.1.js")
- if err != nil {
- t.Fatalf("%v", err)
- }
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
- $('h1').hide();
- $('h1').show();
- `
- _, err = d.Exec(string(buf) + ";" + script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- if err = d.CloseDoc(); err != nil {
- t.Fatalf("%v", err)
- }
- res, err := d.Exec("$('h1').attr('style')", false)
- t.Logf("res=%v", res)
- if err != nil {
- t.Fatalf("%v", err)
- }
- d.Stop()
-}
-
-func TestNoJsCompatComment(t *testing.T) {
- d := NewDomino(simpleHTML, nil, nil)
- d.Start()
- script := `
-
-<!-- This is an actual comment
-
- ''.replace(/^\s*<!--/g, '');
- const a = 1;
- a + 7;
-// -->
- `
- res, err := d.Exec(script, true)
- if err != nil {
- t.Fatalf("%v", err)
- }
- t.Logf("res=%v", res)
- if res != "8" {
- t.Fatal()
- }
- d.Stop()
-}
--- a/domino/domintf.js
+++ /dev/null
@@ -1,195 +1,0 @@
-global = {};
-//global.__domino_frozen__ = true; // Must precede any require('domino')
-var domino = require('domino-lib/index');
-
-Object.assign(this, domino.createWindow(opossum.html, 'http://example.com'));
-window = this;
-window.self = window;
-window.parent = window;
-window.top = window;
-window.history = {
- replaceState: function() {}
-};
-window.location.href = 'http://example.com';
-window.screen = {
- width: 1280,
- height: 1024
-};
-window.screenX = 0;
-window.screenY = 25;
-window.getComputedStyle = function(el, pseudo) {
- this.el = el;
- this.getPropertyValue = function(prop) {
- return opossum.style(___fq('', el), pseudo, prop, arguments[2]);
- };
- return this;
-};
-(function() {
- var utils = require('domino-lib/utils');
- utils.merge(window, domino.impl);
-})()
-
-location = window.location;
-navigator = {
- platform: 'plan9(port)',
- userAgent: 'opossum'
-};
-Element.prototype.getClientRects = function() { /* I'm a stub */ return []; }
-
-document._setMutationHandler(function(a) {
- // a provides attributes type, target and node or attr
- // (cf Object.keys(a))
- opossum.mutated(a.type, ___fq('yolo', a.target));
-});
-
-addEventListener = function() {};
-removeEventListener = function() {};
-
-function XMLHttpRequest() {
- var _method, _uri;
- var h = {};
- var ls = {};
-
- this.readyState = 0;
-
- var cb = function(data, err) {
- if (data !== '') {
- this.responseText = data;
- this.readyState = 4;
- this.state = 200;
- this.status = 200;
- if (ls['load']) ls['load'].bind(this)();
- if (this.onload) this.onload.bind(this)();
-
- if (this.onreadystatechange) this.onreadystatechange.bind(this)();
- }
- }.bind(this);
-
- this.addEventListener = function(k, fn) {
- ls[k] = fn;
- };
- this.open = function(method, uri) {
- _method = method;
- _uri = uri;
- };
- this.setRequestHeader = function(k, v) {
- h[k] = v;
- };
- this.send = function(data) {
- opossum.xhr(_method, _uri, h, data, cb);
- this.readyState = 2;
- };
- this.getAllResponseHeaders = function() {
- return '';
- };
-}
-
-var ___fq;
-___fq = function(pre, el) {
- var i, p;
-
- if (!el) {
- return undefined;
- }
- p = el.parentElement;
-
- if (p) {
- for (i = 0; i < p.children.length; i++) {
- if (p.children[i] === el) {
- return ___fq('', p) + ' > :nth-child(' + (i+1) + ')';
- }
- }
- } else {
- return el.tagName;
- }
-};
-
-// https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
-// CC0
-if (typeof TextEncoder === "undefined") {
- TextEncoder=function TextEncoder(){};
- TextEncoder.prototype.encode = function encode(str) {
- "use strict";
- var Len = str.length, resPos = -1;
- // The Uint8Array's length must be at least 3x the length of the string because an invalid UTF-16
- // takes up the equivelent space of 3 UTF-8 characters to encode it properly. However, Array's
- // have an auto expanding length and 1.5x should be just the right balance for most uses.
- var resArr = typeof Uint8Array === "undefined" ? new Array(Len * 1.5) : new Uint8Array(Len * 3);
- for (var point=0, nextcode=0, i = 0; i !== Len; ) {
- point = str.charCodeAt(i), i += 1;
- if (point >= 0xD800 && point <= 0xDBFF) {
- if (i === Len) {
- resArr[resPos += 1] = 0xef/*0b11101111*/; resArr[resPos += 1] = 0xbf/*0b10111111*/;
- resArr[resPos += 1] = 0xbd/*0b10111101*/; break;
- }
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- nextcode = str.charCodeAt(i);
- if (nextcode >= 0xDC00 && nextcode <= 0xDFFF) {
- point = (point - 0xD800) * 0x400 + nextcode - 0xDC00 + 0x10000;
- i += 1;
- if (point > 0xffff) {
- resArr[resPos += 1] = (0x1e/*0b11110*/<<3) | (point>>>18);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>12)&0x3f/*0b00111111*/);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
- continue;
- }
- } else {
- resArr[resPos += 1] = 0xef/*0b11101111*/; resArr[resPos += 1] = 0xbf/*0b10111111*/;
- resArr[resPos += 1] = 0xbd/*0b10111101*/; continue;
- }
- }
- if (point <= 0x007f) {
- resArr[resPos += 1] = (0x0/*0b0*/<<7) | point;
- } else if (point <= 0x07ff) {
- resArr[resPos += 1] = (0x6/*0b110*/<<5) | (point>>>6);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
- } else {
- resArr[resPos += 1] = (0xe/*0b1110*/<<4) | (point>>>12);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/);
- resArr[resPos += 1] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
- }
- }
- if (typeof Uint8Array !== "undefined") return resArr.subarray(0, resPos + 1);
- // else // IE 6-9
- resArr.length = resPos + 1; // trim off extra weight
- return resArr;
- };
- TextEncoder.prototype.toString = function(){return "[object TextEncoder]"};
- try { // Object.defineProperty only works on DOM prototypes in IE8
- Object.defineProperty(TextEncoder.prototype,"encoding",{
- get:function(){if(TextEncoder.prototype.isPrototypeOf(this)) return"utf-8";
- else throw TypeError("Illegal invocation");}
- });
- } catch(e) { /*IE6-8 fallback*/ TextEncoder.prototype.encoding = "utf-8"; }
- if(typeof Symbol!=="undefined")TextEncoder.prototype[Symbol.toStringTag]="TextEncoder";
-}
-
-function LocalStorage() {
- var data = {};
- this.setItem = function(id, val) {
- return data[id] = String(val);
- };
- this.getItem = function(id) {
- return data.hasOwnProperty(id) ? data[id] : undefined;
- };
- this.removeItem = function(id) {
- return delete data[id];
- };
- this.clear = function() {
- return data = {};
- };
-}
-window.localStorage = new LocalStorage();
-
-const imageHandler = {
- construct(target, args) {
- var el = document.createElement('img');
-
- if (args.length >= 1) el.width = args[0];
- if (args.length >= 2) el.height = args[1];
-
- return el;
- }
-};
-const Image = new Proxy(HTMLImageElement, imageHandler);
--- a/domino/godoc/godocs.js
+++ /dev/null
@@ -1,381 +1,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/* A little code to ease navigation of these documents.
- *
- * On window load we:
- * + Generate a table of contents (generateTOC)
- * + Bind foldable sections (bindToggles)
- * + Bind links to foldable sections (bindToggleLinks)
- */
-
-(function() {
- 'use strict';
-
- var headerEl = document.querySelector('.js-header');
- var menuButtonEl = document.querySelector('.js-headerMenuButton');
- menuButtonEl.addEventListener('click', function(e) {
- e.preventDefault();
- headerEl.classList.toggle('is-active');
- menuButtonEl.setAttribute(
- 'aria-expanded',
- headerEl.classList.contains('is-active')
- );
- });
-
- /* Generates a table of contents: looks for h2 and h3 elements and generates
- * links. "Decorates" the element with id=="nav" with this table of contents.
- */
- function generateTOC() {
- if ($('#manual-nav').length > 0) {
- return;
- }
-
- // For search, we send the toc precomputed from server-side.
- // TODO: Ideally, this should always be precomputed for all pages, but then
- // we need to do HTML parsing on the server-side.
- if (location.pathname === '/search') {
- return;
- }
-
- var nav = $('#nav');
- if (nav.length === 0) {
- return;
- }
-
- var toc_items = [];
- $(nav)
- .nextAll('h2, h3')
- .each(function() {
- var node = this;
- if (node.id == '') node.id = 'tmp_' + toc_items.length;
- var link = $('<a/>')
- .attr('href', '#' + node.id)
- .text($(node).text());
- var item;
- if ($(node).is('h2')) {
- item = $('<dt/>');
- } else {
- // h3
- item = $('<dd class="indent"/>');
- }
- item.append(link);
- toc_items.push(item);
- });
- if (toc_items.length <= 1) {
- return;
- }
- var dl1 = $('<dl/>');
- var dl2 = $('<dl/>');
-
- var split_index = toc_items.length / 2 + 1;
- if (split_index < 8) {
- split_index = toc_items.length;
- }
- for (var i = 0; i < split_index; i++) {
- dl1.append(toc_items[i]);
- }
- for (; /* keep using i */ i < toc_items.length; i++) {
- dl2.append(toc_items[i]);
- }
-
- var tocTable = $('<table class="unruled"/>').appendTo(nav);
- var tocBody = $('<tbody/>').appendTo(tocTable);
- var tocRow = $('<tr/>').appendTo(tocBody);
-
- // 1st column
- $('<td class="first"/>')
- .appendTo(tocRow)
- .append(dl1);
- // 2nd column
- $('<td/>')
- .appendTo(tocRow)
- .append(dl2);
- }
-
- function bindToggle(el) {
- $('.toggleButton', el).click(function() {
- if ($(this).closest('.toggle, .toggleVisible')[0] != el) {
- // Only trigger the closest toggle header.
- return;
- }
-
- if ($(el).is('.toggle')) {
- $(el)
- .addClass('toggleVisible')
- .removeClass('toggle');
- } else {
- $(el)
- .addClass('toggle')
- .removeClass('toggleVisible');
- }
- });
- }
-
- function bindToggles(selector) {
- $(selector).each(function(i, el) {
- bindToggle(el);
- });
- }
-
- function bindToggleLink(el, prefix) {
- $(el).click(function() {
- var href = $(el).attr('href');
- var i = href.indexOf('#' + prefix);
- if (i < 0) {
- return;
- }
- var id = '#' + prefix + href.slice(i + 1 + prefix.length);
- if ($(id).is('.toggle')) {
- $(id)
- .find('.toggleButton')
- .first()
- .click();
- }
- });
- }
- function bindToggleLinks(selector, prefix) {
- $(selector).each(function(i, el) {
- bindToggleLink(el, prefix);
- });
- }
-
- function setupInlinePlayground() {
- 'use strict';
- // Set up playground when each element is toggled.
- $('div.play').each(function(i, el) {
- // Set up playground for this example.
- var setup = function() {
- var code = $('.code', el);
- playground({
- codeEl: code,
- outputEl: $('.output', el),
- runEl: $('.run', el),
- fmtEl: $('.fmt', el),
- shareEl: $('.share', el),
- shareRedirect: '//play.golang.org/p/',
- });
-
- // Make the code textarea resize to fit content.
- var resize = function() {
- code.height(0);
- var h = code[0].scrollHeight;
- code.height(h + 20); // minimize bouncing.
- code.closest('.input').height(h);
- };
- code.on('keydown', resize);
- code.on('keyup', resize);
- code.keyup(); // resize now.
- };
-
- // If example already visible, set up playground now.
- if ($(el).is(':visible')) {
- setup();
- return;
- }
-
- // Otherwise, set up playground when example is expanded.
- var built = false;
- $(el)
- .closest('.toggle')
- .click(function() {
- // Only set up once.
- if (!built) {
- setup();
- built = true;
- }
- });
- });
- }
-
- // fixFocus tries to put focus to #page so that keyboard navigation works.
- function fixFocus() {
- var page = $('#page');
- var topbar = $('div#topbar');
- page.css('outline', 0); // disable outline when focused
- page.attr('tabindex', -1); // and set tabindex so that it is focusable
- $(window)
- .resize(function(evt) {
- // only focus page when the topbar is at fixed position (that is, it's in
- // front of page, and keyboard event will go to the former by default.)
- // by focusing page, keyboard event will go to page so that up/down arrow,
- // space, etc. will work as expected.
- if (topbar.css('position') == 'fixed') page.focus();
- })
- .resize();
- }
-
- function toggleHash() {
- var id = window.location.hash.substring(1);
- // Open all of the toggles for a particular hash.
- var els = $(
- document.getElementById(id),
- $('a[name]').filter(function() {
- return $(this).attr('name') == id;
- })
- );
-
- while (els.length) {
- for (var i = 0; i < els.length; i++) {
- var el = $(els[i]);
- if (el.is('.toggle')) {
- el.find('.toggleButton')
- .first()
- .click();
- }
- }
- els = el.parent();
- }
- }
-
- function personalizeInstallInstructions() {
- var prefix = '?download=';
- var s = window.location.search;
- if (s.indexOf(prefix) != 0) {
- // No 'download' query string; detect "test" instructions from User Agent.
- if (navigator.platform.indexOf('Win') != -1) {
- $('.testUnix').hide();
- $('.testWindows').show();
- } else {
- $('.testUnix').show();
- $('.testWindows').hide();
- }
- return;
- }
-
- var filename = s.substr(prefix.length);
- var filenameRE = /^go1\.\d+(\.\d+)?([a-z0-9]+)?\.([a-z0-9]+)(-[a-z0-9]+)?(-osx10\.[68])?\.([a-z.]+)$/;
- var m = filenameRE.exec(filename);
- if (!m) {
- // Can't interpret file name; bail.
- return;
- }
- $('.downloadFilename').text(filename);
- $('.hideFromDownload').hide();
-
- var os = m[3];
- var ext = m[6];
- if (ext != 'tar.gz') {
- $('#tarballInstructions').hide();
- }
- if (os != 'darwin' || ext != 'pkg') {
- $('#darwinPackageInstructions').hide();
- }
- if (os != 'windows') {
- $('#windowsInstructions').hide();
- $('.testUnix').show();
- $('.testWindows').hide();
- } else {
- if (ext != 'msi') {
- $('#windowsInstallerInstructions').hide();
- }
- if (ext != 'zip') {
- $('#windowsZipInstructions').hide();
- }
- $('.testUnix').hide();
- $('.testWindows').show();
- }
-
- var download = '/dl/' + filename;
-
- var message = $(
- '<p class="downloading">' +
- 'Your download should begin shortly. ' +
- 'If it does not, click <a>this link</a>.</p>'
- );
- message.find('a').attr('href', download);
- message.insertAfter('#nav');
-
- window.location = download;
- }
-
- function updateVersionTags() {
- var v = window.goVersion;
- if (/^go[0-9.]+$/.test(v)) {
- $('.versionTag')
- .empty()
- .text(v);
- $('.whereTag').hide();
- }
- }
-
- function addPermalinks() {
- function addPermalink(source, parent) {
- var id = source.attr('id');
- if (id == '' || id.indexOf('tmp_') === 0) {
- // Auto-generated permalink.
- return;
- }
- if (parent.find('> .permalink').length) {
- // Already attached.
- return;
- }
- parent
- .append(' ')
- .append($("<a class='permalink'>¶</a>").attr('href', '#' + id));
- }
-
- $('#page .container')
- .find('h2[id], h3[id]')
- .each(function() {
- var el = $(this);
- addPermalink(el, el);
- });
-
- $('#page .container')
- .find('dl[id]')
- .each(function() {
- var el = $(this);
- // Add the anchor to the "dt" element.
- addPermalink(el, el.find('> dt').first());
- });
- }
-
- $('.js-expandAll').click(function() {
- if ($(this).hasClass('collapsed')) {
- toggleExamples('toggle');
- $(this).text('(Collapse All)');
- } else {
- toggleExamples('toggleVisible');
- $(this).text('(Expand All)');
- }
- $(this).toggleClass('collapsed');
- });
-
- function toggleExamples(className) {
- // We need to explicitly iterate through divs starting with "example_"
- // to avoid toggling Overview and Index collapsibles.
- $("[id^='example_']").each(function() {
- // Check for state and click it only if required.
- if ($(this).hasClass(className)) {
- $(this)
- .find('.toggleButton')
- .first()
- .click();
- }
- });
- }
-
- $(document).ready(function() {
- generateTOC();
- addPermalinks();
- bindToggles('.toggle');
- bindToggles('.toggleVisible');
- bindToggleLinks('.exampleLink', 'example_');
- bindToggleLinks('.overviewLink', '');
- bindToggleLinks('.examplesLink', '');
- bindToggleLinks('.indexLink', '');
- setupInlinePlayground();
- fixFocus();
- toggleHash();
- personalizeInstallInstructions();
- updateVersionTags();
-
- // godoc.html defines window.initFuncs in the <head> tag, and root.html and
- // codewalk.js push their on-page-ready functions to the list.
- // We execute those functions here, to avoid loading jQuery until the page
- // content is loaded.
- for (var i = 0; i < window.initFuncs.length; i++) window.initFuncs[i]();
- });
-})();
--- a/domino/godoc/golang.html
+++ /dev/null
@@ -1,299 +1,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<meta charset="utf-8">
-<meta name="description" content="Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<meta name="theme-color" content="#00ADD8">
-
- <title>The Go Programming Language</title>
-
-<link href="https://fonts.googleapis.com/css?family=Work+Sans:600|Roboto:400,700" rel="stylesheet">
-<link href="https://fonts.googleapis.com/css?family=Product+Sans&text=Supported%20by%20Google&display=swap" rel="stylesheet">
-<link type="text/css" rel="stylesheet" href="/lib/godoc/style.css">
-
-<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
-
-<script>window.initFuncs = [];</script>
-
-<script>
-var _gaq = _gaq || [];
-_gaq.push(["_setAccount", "UA-11222381-2"]);
-window.trackPageview = function() {
- _gaq.push(["_trackPageview", location.pathname+location.hash]);
-};
-window.trackPageview();
-window.trackEvent = function(category, action, opt_label, opt_value, opt_noninteraction) {
- _gaq.push(["_trackEvent", category, action, opt_label, opt_value, opt_noninteraction]);
-};
-</script>
-
-<script src="/lib/godoc/jquery.js" defer></script>
-
-
-<script src="/lib/godoc/playground.js" defer></script>
-
-<script>var goVersion = "go1.15.8";</script>
-<script src="/lib/godoc/godocs.js" defer></script>
-
-<body class="Site">
-<header class="Header js-header">
- <div class="Header-banner">
- Black Lives Matter.
- <a href="https://support.eji.org/give/153413/#!/donation/checkout"
- target="_blank"
- rel="noopener">Support the Equal Justice Initiative.</a>
- </div>
- <nav class="Header-nav ">
- <a href="/"><img class="Header-logo" src="/lib/godoc/images/go-logo-blue.svg" alt="Go"></a>
- <button class="Header-menuButton js-headerMenuButton" aria-label="Main menu" aria-expanded="false">
- <div class="Header-menuButtonInner"></div>
- </button>
- <ul class="Header-menu">
- <li class="Header-menuItem"><a href="/doc/">Documents</a></li>
- <li class="Header-menuItem"><a href="/pkg/">Packages</a></li>
- <li class="Header-menuItem"><a href="/project/">The Project</a></li>
- <li class="Header-menuItem"><a href="/help/">Help</a></li>
-
- <li class="Header-menuItem"><a href="/blog/">Blog</a></li>
-
- <li class="Header-menuItem"><a href="https://play.golang.org/">Play</a></li>
-
-
- <li class="Header-menuItem Header-menuItem--search">
- <form class="HeaderSearch" role="search" action="/search">
- <input class="HeaderSearch-input"
- type="search"
- name="q"
- placeholder="Search"
- aria-label="Search"
- autocapitalize="off"
- autocomplete="off"
- autocorrect="off"
- spellcheck="false"
- required>
- <button class="HeaderSearch-submit">
- <!-- magnifying glass: --><svg class="HeaderSearch-icon" width="24" height="24" viewBox="0 0 24 24"><title>Search</title><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
- </button>
- </form>
- </li>
- </ul>
- </nav>
-</header>
-
-<main id="page" class="Site-content">
-<div class="container">
-
-
-
-
-
-
-
-
-<div id="nav"></div>
-
-
-
-
-<div class="HomeContainer">
- <section class="HomeSection Hero">
- <h1 class="Hero-header">
- Go is an open source programming language that makes it easy to build
- <strong>simple</strong>, <strong>reliable</strong>, and <strong>efficient</strong> software.
- </h1>
- <i class="Hero-gopher"></i>
- <a href="/dl/" class="Button Button--big HeroDownloadButton">
- <img class="HeroDownloadButton-image" src="/lib/godoc/images/cloud-download.svg" alt="">
- Download Go
- </a>
- <p class="Hero-description">
- Binary distributions available for<br>
- Linux, macOS, Windows, and more.
- </p>
- </section>
-
- <section class="HomeSection Playground">
- <div class="Playground-headerContainer">
- <h2 class="HomeSection-header">Try Go</h2>
-
- <a class="Playground-popout js-playgroundShareEl">Open in Playground</a>
-
- </div>
- <div class="Playground-inputContainer">
- <textarea class="Playground-input js-playgroundCodeEl" spellcheck="false" aria-label="Try Go">// You can edit this code!
-// Click here and start typing.
-package main
-
-import "fmt"
-
-func main() {
- fmt.Println("Hello, 世界")
-}
-</textarea>
- </div>
- <div class="Playground-outputContainer js-playgroundOutputEl">
- <pre class="Playground-output"><noscript>Hello, 世界</noscript></pre>
- </div>
- <div class="Playground-controls">
- <select class="Playground-selectExample js-playgroundToysEl" aria-label="Code examples">
- <option value="hello.go">Hello, World!</option>
- <option value="life.go">Conway's Game of Life</option>
- <option value="fib.go">Fibonacci Closure</option>
- <option value="peano.go">Peano Integers</option>
- <option value="pi.go">Concurrent pi</option>
- <option value="sieve.go">Concurrent Prime Sieve</option>
- <option value="solitaire.go">Peg Solitaire Solver</option>
- <option value="tree.go">Tree Comparison</option>
- </select>
- <div class="Playground-buttons">
- <button class="Button Button--primary js-playgroundRunEl" title="Run this code [shift-enter]">Run</button>
- <div class="Playground-secondaryButtons">
-
- <button class="Button js-playgroundShareEl" title="Share this code">Share</button>
- <a class="Button tour" href="https://tour.golang.org/" title="Playground Go from your browser">Tour</a>
-
- </div>
- </div>
- </div>
- </section>
-
-
- <section class="HomeSection Blog js-blogContainerEl">
- <h2 class="HomeSection-header">Featured articles</h2>
- <div class="Blog-footer js-blogFooterEl"><a class="Button Button--primary" href="https://blog.golang.org/">Read more ></a></div>
- </section>
-
- <section class="HomeSection">
- <h2 class="HomeSection-header">Featured video</h2>
- <div class="js-videoContainer" style="--aspect-ratio-padding: 58.07%;">
- <iframe width="415" height="241" src="https://www.youtube.com/embed/rFejpH_tAHM" frameborder="0" allowfullscreen></iframe>
- </div>
- </section>
-
-</div>
-<script>
-(function() {
- 'use strict';
-
- window.initFuncs.push(function() {
- // Set up playground if enabled.
- if (window.playground) {
- window.playground({
- "codeEl": ".js-playgroundCodeEl",
- "outputEl": ".js-playgroundOutputEl",
- "runEl": ".js-playgroundRunEl",
- "shareEl": ".js-playgroundShareEl",
- "shareRedirect": "//play.golang.org/p/",
- "toysEl": ".js-playgroundToysEl"
- });
-
- // The pre matched below is added by the code above. Style it appropriately.
- document.querySelector(".js-playgroundOutputEl pre").classList.add("Playground-output");
- } else {
- $(".Playground").hide();
- }
- });
-
-
- function readableTime(t) {
- var m = ["January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December"];
- var p = t.substring(0, t.indexOf("T")).split("-");
- var d = new Date(p[0], p[1]-1, p[2]);
- return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
- }
-
- window.feedLoaded = function(result) {
- var read = document.querySelector(".js-blogFooterEl");
- for (var i = 0; i < result.length && i < 2; i++) {
- var entry = result[i];
- var header = document.createElement("h3");
- header.className = "Blog-title";
- var titleLink = document.createElement("a");
- titleLink.href = entry.Link;
- titleLink.rel = "noopener";
- titleLink.textContent = entry.Title;
- header.appendChild(titleLink);
- read.parentNode.insertBefore(header, read);
- var extract = document.createElement("div");
- extract.className = "Blog-extract";
- extract.innerHTML = entry.Summary;
- // Ensure any cross-origin links have rel=noopener set.
- var links = extract.querySelectorAll("a");
- for (var j = 0; j < links.length; j++) {
- links[j].rel = "noopener";
- links[j].classList.add("Blog-link");
- }
- read.parentNode.insertBefore(extract, read);
- var when = document.createElement("div");
- when.className = "Blog-when";
- when.textContent = "Published " + readableTime(entry.Time);
- read.parentNode.insertBefore(when, read);
- }
- }
-
- window.initFuncs.push(function() {
- // Load blog feed.
- $("<script/>")
- .attr("src", "//blog.golang.org/.json?jsonp=feedLoaded")
- .appendTo("body");
-
- // Set the video at random.
- var videos = [
- {
- s: "https://www.youtube.com/embed/rFejpH_tAHM",
- title: "dotGo 2015 - Rob Pike - Simplicity is Complicated",
- },
- {
- s: "https://www.youtube.com/embed/0ReKdcpNyQg",
- title: "GopherCon 2015: Robert Griesemer - The Evolution of Go",
- },
- {
- s: "https://www.youtube.com/embed/sX8r6zATHGU",
- title: "Steve Francia - Go: building on the shoulders of giants and stepping on a few toes",
- },
- {
- s: "https://www.youtube.com/embed/rWJHbh6qO_Y",
- title: "Brad Fitzpatrick Go 1.11 and beyond",
- },
- {
- s: "https://www.youtube.com/embed/bmZNaUcwBt4",
- title: "The Why of Go",
- },
- {
- s: "https://www.youtube.com/embed/0Zbh_vmAKvk",
- title: "GopherCon 2017: Russ Cox - The Future of Go",
- },
- ];
- var v = videos[Math.floor(Math.random()*videos.length)];
- $(".js-videoContainer iframe").attr("src", v.s).attr("title", v.title);
- });
-
-})();
-</script>
-
-
-</div><!-- .container -->
-</main><!-- #page -->
-<footer>
- <div class="Footer ">
- <img class="Footer-gopher" src="/lib/godoc/images/footer-gopher.jpg" alt="The Go Gopher">
- <ul class="Footer-links">
- <li class="Footer-link"><a href="/doc/copyright.html">Copyright</a></li>
- <li class="Footer-link"><a href="/doc/tos.html">Terms of Service</a></li>
- <li class="Footer-link"><a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a></li>
- <li class="Footer-link"><a href="http://golang.org/issues/new?title=x/website:" target="_blank" rel="noopener">Report a website issue</a></li>
- </ul>
- <a class="Footer-supportedBy" href="https://google.com">Supported by Google</a>
- </div>
-</footer>
-
-<script>
-(function() {
- var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
- ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
- var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
-})();
-</script>
-
-
--- a/domino/godoc/golang.js
+++ /dev/null
@@ -1,97 +1,0 @@
-(function() {
- 'use strict';
- window.initFuncs.push(function() {
- // Set up playground if enabled.
- if (window.playground) {
- window.playground({
- "codeEl": ".js-playgroundCodeEl",
- "outputEl": ".js-playgroundOutputEl",
- "runEl": ".js-playgroundRunEl",
- "shareEl": ".js-playgroundShareEl",
- "shareRedirect": "//play.golang.org/p/",
- "toysEl": ".js-playgroundToysEl"
- });
-
- // The pre matched below is added by the code above. Style it appropriately.
- document.querySelector(".js-playgroundOutputEl pre").classList.add("Playground-output");
- } else {
- $(".Playground").hide();
- }
- });
-
-
- function readableTime(t) {
- var m = ["January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December"];
- var p = t.substring(0, t.indexOf("T")).split("-");
- var d = new Date(p[0], p[1]-1, p[2]);
- return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
- }
-
- window.feedLoaded = function(result) {
- var read = document.querySelector(".js-blogFooterEl");
- for (var i = 0; i < result.length && i < 2; i++) {
- var entry = result[i];
- var header = document.createElement("h3");
- header.className = "Blog-title";
- var titleLink = document.createElement("a");
- titleLink.href = entry.Link;
- titleLink.rel = "noopener";
- titleLink.textContent = entry.Title;
- header.appendChild(titleLink);
- read.parentNode.insertBefore(header, read);
- var extract = document.createElement("div");
- extract.className = "Blog-extract";
- extract.innerHTML = entry.Summary;
- // Ensure any cross-origin links have rel=noopener set.
- var links = extract.querySelectorAll("a");
- for (var j = 0; j < links.length; j++) {
- links[j].rel = "noopener";
- links[j].classList.add("Blog-link");
- }
- read.parentNode.insertBefore(extract, read);
- var when = document.createElement("div");
- when.className = "Blog-when";
- when.textContent = "Published " + readableTime(entry.Time);
- read.parentNode.insertBefore(when, read);
- }
- }
-
- window.initFuncs.push(function() {
- // Load blog feed.
- $("<script/>")
- .attr("src", "//blog.golang.org/.json?jsonp=feedLoaded")
- .appendTo("body");
-
- // Set the video at random.
- var videos = [
- {
- s: "https://www.youtube.com/embed/rFejpH_tAHM",
- title: "dotGo 2015 - Rob Pike - Simplicity is Complicated",
- },
- {
- s: "https://www.youtube.com/embed/0ReKdcpNyQg",
- title: "GopherCon 2015: Robert Griesemer - The Evolution of Go",
- },
- {
- s: "https://www.youtube.com/embed/sX8r6zATHGU",
- title: "Steve Francia - Go: building on the shoulders of giants and stepping on a few toes",
- },
- {
- s: "https://www.youtube.com/embed/rWJHbh6qO_Y",
- title: "Brad Fitzpatrick Go 1.11 and beyond",
- },
- {
- s: "https://www.youtube.com/embed/bmZNaUcwBt4",
- title: "The Why of Go",
- },
- {
- s: "https://www.youtube.com/embed/0Zbh_vmAKvk",
- title: "GopherCon 2017: Russ Cox - The Future of Go",
- },
- ];
- var v = videos[Math.floor(Math.random()*videos.length)];
- $(".js-videoContainer iframe").attr("src", v.s).attr("title", v.title);
- });
-
-})();
\ No newline at end of file
--- a/domino/godoc/goversion.js
+++ /dev/null
@@ -1,2 +1,0 @@
-var goVersion = "go1.15.6";
-
--- a/domino/godoc/initfuncs.js
+++ /dev/null
@@ -1,2 +1,0 @@
-window.initFuncs = [];
-
--- a/domino/godoc/jquery-1.8.2.js
+++ /dev/null
@@ -1,9440 +1,0 @@
-/*!
- * jQuery JavaScript Library v1.8.2
- * http://jquery.com/
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- *
- * Copyright 2012 jQuery Foundation and other contributors
- * Released under the MIT license
- * http://jquery.org/license
- *
- * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time)
- */
-(function( window, undefined ) {
-var
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // The deferred used on DOM ready
- readyList,
-
- // Use the correct document accordingly with window argument (sandbox)
- document = window.document,
- location = window.location,
- navigator = window.navigator,
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$,
-
- // Save a reference to some core methods
- core_push = Array.prototype.push,
- core_slice = Array.prototype.slice,
- core_indexOf = Array.prototype.indexOf,
- core_toString = Object.prototype.toString,
- core_hasOwn = Object.prototype.hasOwnProperty,
- core_trim = String.prototype.trim,
-
- // Define a local copy of jQuery
- jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context, rootjQuery );
- },
-
- // Used for matching numbers
- core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
-
- // Used for detecting and trimming whitespace
- core_rnotwhite = /\S/,
- core_rspace = /\s+/,
-
- // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
- rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
-
- // A simple way to check for HTML strings
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
- rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
-
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
-
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
-
- // Matches dashed string for camelizing
- rmsPrefix = /^-ms-/,
- rdashAlpha = /-([\da-z])/gi,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return ( letter + "" ).toUpperCase();
- },
-
- // The ready event handler and self cleanup method
- DOMContentLoaded = function() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- } else if ( document.readyState === "complete" ) {
- // we're here because readyState === "complete" in oldIE
- // which is good enough for us to call the dom ready!
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
- },
-
- // [[Class]] -> type pairs
- class2type = {};
-
-jQuery.fn = jQuery.prototype = {
- constructor: jQuery,
- init: function( selector, context, rootjQuery ) {
- var match, elem, ret, doc;
-
- // Handle $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // Handle $(DOMElement)
- if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
- doc = ( context && context.nodeType ? context.ownerDocument || context : document );
-
- // scripts is true for back-compat
- selector = jQuery.parseHTML( match[1], doc, true );
- if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
- this.attr.call( selector, context, true );
- }
-
- return jQuery.merge( this, selector );
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || rootjQuery ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
-
- if ( selector.selector !== undefined ) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- },
-
- // Start with an empty selector
- selector: "",
-
- // The current version of jQuery being used
- jquery: "1.8.2",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
-
- toArray: function() {
- return core_slice.call( this );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
-
- // Return a 'clean' array
- this.toArray() :
-
- // Return just the object
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems, name, selector ) {
-
- // Build a new jQuery matched element set
- var ret = jQuery.merge( this.constructor(), elems );
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- ret.context = this.context;
-
- if ( name === "find" ) {
- ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
- } else if ( name ) {
- ret.selector = this.selector + "." + name + "(" + selector + ")";
- }
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
-
- ready: function( fn ) {
- // Add the callback
- jQuery.ready.promise().done( fn );
-
- return this;
- },
-
- eq: function( i ) {
- i = +i;
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, i + 1 );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- slice: function() {
- return this.pushStack( core_slice.apply( this, arguments ),
- "slice", core_slice.call(arguments).join(",") );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
-
- end: function() {
- return this.prevObject || this.constructor(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: core_push,
- sort: [].sort,
- splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- noConflict: function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
- },
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger("ready").off("ready");
- }
- },
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- isWindow: function( obj ) {
- return obj != null && obj == obj.window;
- },
-
- isNumeric: function( obj ) {
- return !isNaN( parseFloat(obj) ) && isFinite( obj );
- },
-
- type: function( obj ) {
- return obj == null ?
- String( obj ) :
- class2type[ core_toString.call(obj) ] || "object";
- },
-
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !core_hasOwn.call(obj, "constructor") &&
- !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- } catch ( e ) {
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || core_hasOwn.call( obj, key );
- },
-
- isEmptyObject: function( obj ) {
- var name;
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- // data: string of html
- // context (optional): If specified, the fragment will be created in this context, defaults to document
- // scripts (optional): If true, will include scripts passed in the html string
- parseHTML: function( data, context, scripts ) {
- var parsed;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- if ( typeof context === "boolean" ) {
- scripts = context;
- context = 0;
- }
- context = context || document;
-
- // Single tag
- if ( (parsed = rsingleTag.exec( data )) ) {
- return [ context.createElement( parsed[1] ) ];
- }
-
- parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
- return jQuery.merge( [],
- (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
- },
-
- parseJSON: function( data ) {
- if ( !data || typeof data !== "string") {
- return null;
- }
-
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
-
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- return window.JSON.parse( data );
- }
-
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test( data.replace( rvalidescape, "@" )
- .replace( rvalidtokens, "]" )
- .replace( rvalidbraces, "")) ) {
-
- return ( new Function( "return " + data ) )();
-
- }
- jQuery.error( "Invalid JSON: " + data );
- },
-
- // Cross-browser xml parsing
- parseXML: function( data ) {
- var xml, tmp;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data , "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
- },
-
- noop: function() {},
-
- // Evaluates a script in a global context
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && core_rnotwhite.test( data ) ) {
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data );
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
- },
-
- // args is for internal usage only
- each: function( obj, callback, args ) {
- var name,
- i = 0,
- length = obj.length,
- isObj = length === undefined || jQuery.isFunction( obj );
-
- if ( args ) {
- if ( isObj ) {
- for ( name in obj ) {
- if ( callback.apply( obj[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( obj[ i++ ], args ) === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in obj ) {
- if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
- break;
- }
- }
- }
- }
-
- return obj;
- },
-
- // Use native String.trim function wherever possible
- trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
- function( text ) {
- return text == null ?
- "" :
- core_trim.call( text );
- } :
-
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- ( text + "" ).replace( rtrim, "" );
- },
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var type,
- ret = results || [];
-
- if ( arr != null ) {
- // The window, strings (and functions) also have 'length'
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- type = jQuery.type( arr );
-
- if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
- core_push.call( ret, arr );
- } else {
- jQuery.merge( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- var len;
-
- if ( arr ) {
- if ( core_indexOf ) {
- return core_indexOf.call( arr, elem, i );
- }
-
- len = arr.length;
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
-
- for ( ; i < len; i++ ) {
- // Skip accessing in sparse arrays
- if ( i in arr && arr[ i ] === elem ) {
- return i;
- }
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var l = second.length,
- i = first.length,
- j = 0;
-
- if ( typeof l === "number" ) {
- for ( ; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, inv ) {
- var retVal,
- ret = [],
- i = 0,
- length = elems.length;
- inv = !!inv;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var value, key,
- ret = [],
- i = 0,
- length = elems.length,
- // jquery objects are treated as arrays
- isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
-
- // Go through the array, translating each of the items to their
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( key in elems ) {
- value = callback( elems[ key ], key, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
- }
-
- // Flatten any nested arrays
- return ret.concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- var tmp, args, proxy;
-
- if ( typeof context === "string" ) {
- tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- args = core_slice.call( arguments, 2 );
- proxy = function() {
- return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || jQuery.guid++;
-
- return proxy;
- },
-
- // Multifunctional method to get and set values of a collection
- // The value/s can optionally be executed if it's a function
- access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
- var exec,
- bulk = key == null,
- i = 0,
- length = elems.length;
-
- // Sets many values
- if ( key && typeof key === "object" ) {
- for ( i in key ) {
- jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
- }
- chainable = 1;
-
- // Sets one value
- } else if ( value !== undefined ) {
- // Optionally, function values get executed if exec is true
- exec = pass === undefined && jQuery.isFunction( value );
-
- if ( bulk ) {
- // Bulk operations only iterate when executing function values
- if ( exec ) {
- exec = fn;
- fn = function( elem, key, value ) {
- return exec.call( jQuery( elem ), value );
- };
-
- // Otherwise they run against the entire set
- } else {
- fn.call( elems, value );
- fn = null;
- }
- }
-
- if ( fn ) {
- for (; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
- }
- }
-
- chainable = 1;
- }
-
- return chainable ?
- elems :
-
- // Gets
- bulk ?
- fn.call( elems ) :
- length ? fn( elems[0], key ) : emptyGet;
- },
-
- now: function() {
- return ( new Date() ).getTime();
- }
-});
-
-jQuery.ready.promise = function( obj ) {
- if ( !readyList ) {
-
- readyList = jQuery.Deferred();
-
- // Catch cases where $(document).ready() is called after the browser event has already occurred.
- // we once tried to use readyState "interactive" here, but it caused issues like the one
- // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- setTimeout( jQuery.ready, 1 );
-
- // Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else {
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch(e) {}
-
- if ( top && top.doScroll ) {
- (function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll("left");
- } catch(e) {
- return setTimeout( doScrollCheck, 50 );
- }
-
- // and execute any waiting functions
- jQuery.ready();
- }
- })();
- }
- }
- }
- return readyList.promise( obj );
-};
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-// String to Object options format cache
-var optionsCache = {};
-
-// Convert String-formatted options into Object-formatted ones and store in cache
-function createOptions( options ) {
- var object = optionsCache[ options ] = {};
- jQuery.each( options.split( core_rspace ), function( _, flag ) {
- object[ flag ] = true;
- });
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * options: an optional list of space-separated options that will change how
- * the callback list behaves or a more traditional option object
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible options:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( options ) {
-
- // Convert options from String-formatted to Object-formatted if needed
- // (we check in cache first)
- options = typeof options === "string" ?
- ( optionsCache[ options ] || createOptions( options ) ) :
- jQuery.extend( {}, options );
-
- var // Last fire value (for non-forgettable lists)
- memory,
- // Flag to know if list was already fired
- fired,
- // Flag to know if list is currently firing
- firing,
- // First callback to fire (used internally by add and fireWith)
- firingStart,
- // End of the loop when firing
- firingLength,
- // Index of currently firing callback (modified by remove if needed)
- firingIndex,
- // Actual callback list
- list = [],
- // Stack of fire calls for repeatable lists
- stack = !options.once && [],
- // Fire callbacks
- fire = function( data ) {
- memory = options.memory && data;
- fired = true;
- firingIndex = firingStart || 0;
- firingStart = 0;
- firingLength = list.length;
- firing = true;
- for ( ; list && firingIndex < firingLength; firingIndex++ ) {
- if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
- memory = false; // To prevent further calls using add
- break;
- }
- }
- firing = false;
- if ( list ) {
- if ( stack ) {
- if ( stack.length ) {
- fire( stack.shift() );
- }
- } else if ( memory ) {
- list = [];
- } else {
- self.disable();
- }
- }
- },
- // Actual Callbacks object
- self = {
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
- // First, we save the current length
- var start = list.length;
- (function add( args ) {
- jQuery.each( args, function( _, arg ) {
- var type = jQuery.type( arg );
- if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
- list.push( arg );
- } else if ( arg && arg.length && type !== "string" ) {
- // Inspect recursively
- add( arg );
- }
- });
- })( arguments );
- // Do we need to add the callbacks to the
- // current firing batch?
- if ( firing ) {
- firingLength = list.length;
- // With memory, if we're not firing then
- // we should call right away
- } else if ( memory ) {
- firingStart = start;
- fire( memory );
- }
- }
- return this;
- },
- // Remove a callback from the list
- remove: function() {
- if ( list ) {
- jQuery.each( arguments, function( _, arg ) {
- var index;
- while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
- list.splice( index, 1 );
- // Handle firing indexes
- if ( firing ) {
- if ( index <= firingLength ) {
- firingLength--;
- }
- if ( index <= firingIndex ) {
- firingIndex--;
- }
- }
- }
- });
- }
- return this;
- },
- // Control if a given callback is in the list
- has: function( fn ) {
- return jQuery.inArray( fn, list ) > -1;
- },
- // Remove all callbacks from the list
- empty: function() {
- list = [];
- return this;
- },
- // Have the list do nothing anymore
- disable: function() {
- list = stack = memory = undefined;
- return this;
- },
- // Is it disabled?
- disabled: function() {
- return !list;
- },
- // Lock the list in its current state
- lock: function() {
- stack = undefined;
- if ( !memory ) {
- self.disable();
- }
- return this;
- },
- // Is it locked?
- locked: function() {
- return !stack;
- },
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- args = args || [];
- args = [ context, args.slice ? args.slice() : args ];
- if ( list && ( !fired || stack ) ) {
- if ( firing ) {
- stack.push( args );
- } else {
- fire( args );
- }
- }
- return this;
- },
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!fired;
- }
- };
-
- return self;
-};
-jQuery.extend({
-
- Deferred: function( func ) {
- var tuples = [
- // action, add listener, listener list, final state
- [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
- [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
- [ "notify", "progress", jQuery.Callbacks("memory") ]
- ],
- state = "pending",
- promise = {
- state: function() {
- return state;
- },
- always: function() {
- deferred.done( arguments ).fail( arguments );
- return this;
- },
- then: function( /* fnDone, fnFail, fnProgress */ ) {
- var fns = arguments;
- return jQuery.Deferred(function( newDefer ) {
- jQuery.each( tuples, function( i, tuple ) {
- var action = tuple[ 0 ],
- fn = fns[ i ];
- // deferred[ done | fail | progress ] for forwarding actions to newDefer
- deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
- function() {
- var returned = fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise()
- .done( newDefer.resolve )
- .fail( newDefer.reject )
- .progress( newDefer.notify );
- } else {
- newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
- }
- } :
- newDefer[ action ]
- );
- });
- fns = null;
- }).promise();
- },
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- return obj != null ? jQuery.extend( obj, promise ) : promise;
- }
- },
- deferred = {};
-
- // Keep pipe for back-compat
- promise.pipe = promise.then;
-
- // Add list-specific methods
- jQuery.each( tuples, function( i, tuple ) {
- var list = tuple[ 2 ],
- stateString = tuple[ 3 ];
-
- // promise[ done | fail | progress ] = list.add
- promise[ tuple[1] ] = list.add;
-
- // Handle state
- if ( stateString ) {
- list.add(function() {
- // state = [ resolved | rejected ]
- state = stateString;
-
- // [ reject_list | resolve_list ].disable; progress_list.lock
- }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
- }
-
- // deferred[ resolve | reject | notify ] = list.fire
- deferred[ tuple[0] ] = list.fire;
- deferred[ tuple[0] + "With" ] = list.fireWith;
- });
-
- // Make the deferred a promise
- promise.promise( deferred );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( subordinate /* , ..., subordinateN */ ) {
- var i = 0,
- resolveValues = core_slice.call( arguments ),
- length = resolveValues.length,
-
- // the count of uncompleted subordinates
- remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
-
- // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
- deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
-
- // Update function for both resolve and progress values
- updateFunc = function( i, contexts, values ) {
- return function( value ) {
- contexts[ i ] = this;
- values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
- if( values === progressValues ) {
- deferred.notifyWith( contexts, values );
- } else if ( !( --remaining ) ) {
- deferred.resolveWith( contexts, values );
- }
- };
- },
-
- progressValues, progressContexts, resolveContexts;
-
- // add listeners to Deferred subordinates; treat others as resolved
- if ( length > 1 ) {
- progressValues = new Array( length );
- progressContexts = new Array( length );
- resolveContexts = new Array( length );
- for ( ; i < length; i++ ) {
- if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
- resolveValues[ i ].promise()
- .done( updateFunc( i, resolveContexts, resolveValues ) )
- .fail( deferred.reject )
- .progress( updateFunc( i, progressContexts, progressValues ) );
- } else {
- --remaining;
- }
- }
- }
-
- // if we're not waiting on anything, resolve the master
- if ( !remaining ) {
- deferred.resolveWith( resolveContexts, resolveValues );
- }
-
- return deferred.promise();
- }
-});
-jQuery.support = (function() {
-
- var support,
- all,
- a,
- select,
- opt,
- input,
- fragment,
- eventName,
- i,
- isSupported,
- clickFn,
- div = document.createElement("div");
-
- // Preliminary tests
- div.setAttribute( "className", "t" );
- div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
-
- all = div.getElementsByTagName("*");
- a = div.getElementsByTagName("a")[ 0 ];
- a.style.cssText = "top:1px;float:left;opacity:.5";
-
- // Can't get basic test support
- if ( !all || !all.length ) {
- return {};
- }
-
- // First batch of supports tests
- select = document.createElement("select");
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName("input")[ 0 ];
-
- support = {
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: ( div.firstChild.nodeType === 3 ),
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName("tbody").length,
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName("link").length,
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- style: /top/.test( a.getAttribute("style") ),
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: ( a.getAttribute("href") === "/a" ),
-
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.5/.test( a.style.opacity ),
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
-
- // Make sure that if no value is specified for a checkbox
- // that it defaults to "on".
- // (WebKit defaults to "" instead)
- checkOn: ( input.value === "on" ),
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
-
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- getSetAttribute: div.className !== "t",
-
- // Tests for enctype support on a form(#6743)
- enctype: !!document.createElement("form").enctype,
-
- // Makes sure cloning an html5 element does not cause problems
- // Where outerHTML is undefined, this still works
- html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
-
- // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
- boxModel: ( document.compatMode === "CSS1Compat" ),
-
- // Will be defined later
- submitBubbles: true,
- changeBubbles: true,
- focusinBubbles: false,
- deleteExpando: true,
- noCloneEvent: true,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableMarginRight: true,
- boxSizingReliable: true,
- pixelPosition: false
- };
-
- // Make sure checked status is properly cloned
- input.checked = true;
- support.noCloneChecked = input.cloneNode( true ).checked;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Test to see if it's possible to delete an expando from an element
- // Fails in Internet Explorer
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
-
- if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
- div.attachEvent( "onclick", clickFn = function() {
- // Cloning a node shouldn't copy over any
- // bound event handlers (IE does this)
- support.noCloneEvent = false;
- });
- div.cloneNode( true ).fireEvent("onclick");
- div.detachEvent( "onclick", clickFn );
- }
-
- // Check if a radio maintains its value
- // after being appended to the DOM
- input = document.createElement("input");
- input.value = "t";
- input.setAttribute( "type", "radio" );
- support.radioValue = input.value === "t";
-
- input.setAttribute( "checked", "checked" );
-
- // #11217 - WebKit loses check when the name is after the checked attribute
- input.setAttribute( "name", "t" );
-
- div.appendChild( input );
- fragment = document.createDocumentFragment();
- fragment.appendChild( div.lastChild );
-
- // WebKit doesn't clone checked state correctly in fragments
- support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- support.appendChecked = input.checked;
-
- fragment.removeChild( input );
- fragment.appendChild( div );
-
- // Technique from Juriy Zaytsev
- // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
- // We only care about the case where non-standard event systems
- // are used, namely in IE. Short-circuiting here helps us to
- // avoid an eval call (in setAttribute) which can cause CSP
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
- if ( div.attachEvent ) {
- for ( i in {
- submit: true,
- change: true,
- focusin: true
- }) {
- eventName = "on" + i;
- isSupported = ( eventName in div );
- if ( !isSupported ) {
- div.setAttribute( eventName, "return;" );
- isSupported = ( typeof div[ eventName ] === "function" );
- }
- support[ i + "Bubbles" ] = isSupported;
- }
- }
-
- // Run tests that need a body at doc ready
- jQuery(function() {
- var container, div, tds, marginDiv,
- divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
- body = document.getElementsByTagName("body")[0];
-
- if ( !body ) {
- // Return for frameset docs that don't have a body
- return;
- }
-
- container = document.createElement("div");
- container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
- body.insertBefore( container, body.firstChild );
-
- // Construct the test element
- div = document.createElement("div");
- container.appendChild( div );
-
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- // (only IE 8 fails this test)
- div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
- tds = div.getElementsByTagName("td");
- tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
- isSupported = ( tds[ 0 ].offsetHeight === 0 );
-
- tds[ 0 ].style.display = "";
- tds[ 1 ].style.display = "none";
-
- // Check if empty table cells still have offsetWidth/Height
- // (IE <= 8 fail this test)
- support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
-
- // Check box-sizing and margin behavior
- div.innerHTML = "";
- div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
- support.boxSizing = ( div.offsetWidth === 4 );
- support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
-
- // NOTE: To any future maintainer, we've window.getComputedStyle
- // because jsdom on node.js will break without it.
- if ( window.getComputedStyle ) {
- support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
- support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
-
- // Check if div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container. For more
- // info see bug #3333
- // Fails in WebKit before Feb 2011 nightlies
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- marginDiv = document.createElement("div");
- marginDiv.style.cssText = div.style.cssText = divReset;
- marginDiv.style.marginRight = marginDiv.style.width = "0";
- div.style.width = "1px";
- div.appendChild( marginDiv );
- support.reliableMarginRight =
- !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
- }
-
- if ( typeof div.style.zoom !== "undefined" ) {
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- // (IE < 8 does this)
- div.innerHTML = "";
- div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
-
- // Check if elements with layout shrink-wrap their children
- // (IE 6 does this)
- div.style.display = "block";
- div.style.overflow = "visible";
- div.innerHTML = "<div></div>";
- div.firstChild.style.width = "5px";
- support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
-
- container.style.zoom = 1;
- }
-
- // Null elements to avoid leaks in IE
- body.removeChild( container );
- container = div = tds = marginDiv = null;
- });
-
- // Null elements to avoid leaks in IE
- fragment.removeChild( div );
- all = a = select = opt = input = fragment = div = null;
-
- return support;
-})();
-var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
- rmultiDash = /([A-Z])/g;
-
-jQuery.extend({
- cache: {},
-
- deletedIds: [],
-
- // Remove at next major release (1.9/2.0)
- uuid: 0,
-
- // Unique for each copy of jQuery on the page
- // Non-digits removed to match rinlinejQuery
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
-
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, ret,
- internalKey = jQuery.expando,
- getByName = typeof name === "string",
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
- return;
- }
-
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
- } else {
- id = internalKey;
- }
- }
-
- if ( !cache[ id ] ) {
- cache[ id ] = {};
-
- // Avoids exposing jQuery metadata on plain JS objects when the object
- // is serialized using JSON.stringify
- if ( !isNode ) {
- cache[ id ].toJSON = jQuery.noop;
- }
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ] = jQuery.extend( cache[ id ], name );
- } else {
- cache[ id ].data = jQuery.extend( cache[ id ].data, name );
- }
- }
-
- thisCache = cache[ id ];
-
- // jQuery data() is stored in a separate object inside the object's internal data
- // cache in order to avoid key collisions between internal data and user-defined
- // data.
- if ( !pvt ) {
- if ( !thisCache.data ) {
- thisCache.data = {};
- }
-
- thisCache = thisCache.data;
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( getByName ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
- },
-
- removeData: function( elem, name, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, i, l,
-
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ] : cache[ id ].data;
-
- if ( thisCache ) {
-
- // Support array or space separated string names for data keys
- if ( !jQuery.isArray( name ) ) {
-
- // try the string as a key before any manipulation
- if ( name in thisCache ) {
- name = [ name ];
- } else {
-
- // split the camel cased version by spaces unless a key with the spaces exists
- name = jQuery.camelCase( name );
- if ( name in thisCache ) {
- name = [ name ];
- } else {
- name = name.split(" ");
- }
- }
- }
-
- for ( i = 0, l = name.length; i < l; i++ ) {
- delete thisCache[ name[i] ];
- }
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( !pvt ) {
- delete cache[ id ].data;
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject( cache[ id ] ) ) {
- return;
- }
- }
-
- // Destroy the cache
- if ( isNode ) {
- jQuery.cleanData( [ elem ], true );
-
- // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
- } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
- delete cache[ id ];
-
- // When all else fails, null
- } else {
- cache[ id ] = null;
- }
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return jQuery.data( elem, name, data, true );
- },
-
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
-
- // nodes accept data unless otherwise specified; rejection can be conditional
- return !noData || noData !== true && elem.getAttribute("classid") === noData;
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var parts, part, attr, name, l,
- elem = this[0],
- i = 0,
- data = null;
-
- // Gets all values
- if ( key === undefined ) {
- if ( this.length ) {
- data = jQuery.data( elem );
-
- if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
- attr = elem.attributes;
- for ( l = attr.length; i < l; i++ ) {
- name = attr[i].name;
-
- if ( !name.indexOf( "data-" ) ) {
- name = jQuery.camelCase( name.substring(5) );
-
- dataAttr( elem, name, data[ name ] );
- }
- }
- jQuery._data( elem, "parsedAttrs", true );
- }
- }
-
- return data;
- }
-
- // Sets multiple values
- if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- parts = key.split( ".", 2 );
- parts[1] = parts[1] ? "." + parts[1] : "";
- part = parts[1] + "!";
-
- return jQuery.access( this, function( value ) {
-
- if ( value === undefined ) {
- data = this.triggerHandler( "getData" + part, [ parts[0] ] );
-
- // Try to fetch any internally stored data first
- if ( data === undefined && elem ) {
- data = jQuery.data( elem, key );
- data = dataAttr( elem, key, data );
- }
-
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
- }
-
- parts[1] = value;
- this.each(function() {
- var self = jQuery( this );
-
- self.triggerHandler( "setData" + part, parts );
- jQuery.data( this, key, value );
- self.triggerHandler( "changeData" + part, parts );
- });
- }, null, value, arguments.length > 1, null, false );
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- // Only convert to a number if it doesn't change the string
- +data + "" === data ? +data :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-// checks a cache object for emptiness
-function isEmptyDataObject( obj ) {
- var name;
- for ( name in obj ) {
-
- // if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
- continue;
- }
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-jQuery.extend({
- queue: function( elem, type, data ) {
- var queue;
-
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- queue = jQuery._data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !queue || jQuery.isArray(data) ) {
- queue = jQuery._data( elem, type, jQuery.makeArray(data) );
- } else {
- queue.push( data );
- }
- }
- return queue || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- startLength = queue.length,
- fn = queue.shift(),
- hooks = jQuery._queueHooks( elem, type ),
- next = function() {
- jQuery.dequeue( elem, type );
- };
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- startLength--;
- }
-
- if ( fn ) {
-
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- // clear up the last queue stop function
- delete hooks.stop;
- fn.call( elem, next, hooks );
- }
-
- if ( !startLength && hooks ) {
- hooks.empty.fire();
- }
- },
-
- // not intended for public consumption - generates a queueHooks object, or returns the current one
- _queueHooks: function( elem, type ) {
- var key = type + "queueHooks";
- return jQuery._data( elem, key ) || jQuery._data( elem, key, {
- empty: jQuery.Callbacks("once memory").add(function() {
- jQuery.removeData( elem, type + "queue", true );
- jQuery.removeData( elem, key, true );
- })
- });
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- var setter = 2;
-
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- setter--;
- }
-
- if ( arguments.length < setter ) {
- return jQuery.queue( this[0], type );
- }
-
- return data === undefined ?
- this :
- this.each(function() {
- var queue = jQuery.queue( this, type, data );
-
- // ensure a hooks for this queue
- jQuery._queueHooks( this, type );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = setTimeout( next, time );
- hooks.stop = function() {
- clearTimeout( timeout );
- };
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, obj ) {
- var tmp,
- count = 1,
- defer = jQuery.Deferred(),
- elements = this,
- i = this.length,
- resolve = function() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- };
-
- if ( typeof type !== "string" ) {
- obj = type;
- type = undefined;
- }
- type = type || "fx";
-
- while( i-- ) {
- tmp = jQuery._data( elements[ i ], type + "queueHooks" );
- if ( tmp && tmp.empty ) {
- count++;
- tmp.empty.add( resolve );
- }
- }
- resolve();
- return defer.promise( obj );
- }
-});
-var nodeHook, boolHook, fixSpecified,
- rclass = /[\t\r\n]/g,
- rreturn = /\r/g,
- rtype = /^(?:button|input)$/i,
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
- rclickable = /^a(?:rea|)$/i,
- rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
- getSetAttribute = jQuery.support.getSetAttribute;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- },
-
- prop: function( name, value ) {
- return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each(function() {
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch( e ) {}
- });
- },
-
- addClass: function( value ) {
- var classNames, i, l, elem,
- setClass, c, cl;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call(this, j, this.className) );
- });
- }
-
- if ( value && typeof value === "string" ) {
- classNames = value.split( core_rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
-
- if ( elem.nodeType === 1 ) {
- if ( !elem.className && classNames.length === 1 ) {
- elem.className = value;
-
- } else {
- setClass = " " + elem.className + " ";
-
- for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
- setClass += classNames[ c ] + " ";
- }
- }
- elem.className = jQuery.trim( setClass );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var removes, className, elem, c, cl, i, l;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call(this, j, this.className) );
- });
- }
- if ( (value && typeof value === "string") || value === undefined ) {
- removes = ( value || "" ).split( core_rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
- if ( elem.nodeType === 1 && elem.className ) {
-
- className = (" " + elem.className + " ").replace( rclass, " " );
-
- // loop over each item in the removal list
- for ( c = 0, cl = removes.length; c < cl; c++ ) {
- // Remove until there is nothing to remove,
- while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
- className = className.replace( " " + removes[ c ] + " " , " " );
- }
- }
- elem.className = value ? jQuery.trim( className ) : "";
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.split( core_rspace );
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space separated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
-
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
-
- // toggle whole className
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- var hooks, ret, isFunction,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var val,
- self = jQuery(this);
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, self.val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map(val, function ( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- },
- select: {
- get: function( elem ) {
- var value, i, max, option,
- index = elem.selectedIndex,
- values = [],
- options = elem.options,
- one = elem.type === "select-one";
-
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
-
- // Loop through all the selected options
- i = one ? index : 0;
- max = one ? index + 1 : options.length;
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
- if ( one && !values.length && options.length ) {
- return jQuery( options[ index ] ).val();
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var values = jQuery.makeArray( value );
-
- jQuery(elem).find("option").each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
-
- if ( !values.length ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- },
-
- // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
- attrFn: {},
-
- attr: function( elem, name, value, pass ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
- return jQuery( elem )[ name ]( value );
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === "undefined" ) {
- return jQuery.prop( elem, name, value );
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( notxml ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
- return;
-
- } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
-
- ret = elem.getAttribute( name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret === null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, value ) {
- var propName, attrNames, name, isBool,
- i = 0;
-
- if ( value && elem.nodeType === 1 ) {
-
- attrNames = value.split( core_rspace );
-
- for ( ; i < attrNames.length; i++ ) {
- name = attrNames[ i ];
-
- if ( name ) {
- propName = jQuery.propFix[ name ] || name;
- isBool = rboolean.test( name );
-
- // See #9699 for explanation of this approach (setting first, then removal)
- // Do not do this for boolean attributes (see #10870)
- if ( !isBool ) {
- jQuery.attr( elem, name, "" );
- }
- elem.removeAttribute( getSetAttribute ? name : propName );
-
- // Set corresponding property to false for boolean attributes
- if ( isBool && propName in elem ) {
- elem[ propName ] = false;
- }
- }
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to it's default in case type is set after value
- // This is for element creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- },
- // Use the value property for back compat
- // Use the nodeHook for button elements in IE6/7 (#1954)
- value: {
- get: function( elem, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.get( elem, name );
- }
- return name in elem ?
- elem.value :
- null;
- },
- set: function( elem, value, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.set( elem, value, name );
- }
- // Does not return so that setAttribute is also used
- elem.value = value;
- }
- }
- },
-
- propFix: {
- tabindex: "tabIndex",
- readonly: "readOnly",
- "for": "htmlFor",
- "class": "className",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- cellpadding: "cellPadding",
- rowspan: "rowSpan",
- colspan: "colSpan",
- usemap: "useMap",
- frameborder: "frameBorder",
- contenteditable: "contentEditable"
- },
-
- prop: function( elem, name, value ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- return ( elem[ name ] = value );
- }
-
- } else {
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- return elem[ name ];
- }
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- var attributeNode = elem.getAttributeNode("tabindex");
-
- return attributeNode && attributeNode.specified ?
- parseInt( attributeNode.value, 10 ) :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
- }
- }
-});
-
-// Hook for boolean attributes
-boolHook = {
- get: function( elem, name ) {
- // Align boolean attributes with corresponding properties
- // Fall back to attribute presence where some booleans are not supported
- var attrNode,
- property = jQuery.prop( elem, name );
- return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
- name.toLowerCase() :
- undefined;
- },
- set: function( elem, value, name ) {
- var propName;
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- // value is true since we know at this point it's type boolean and not false
- // Set boolean attributes to the same name and set the DOM property
- propName = jQuery.propFix[ name ] || name;
- if ( propName in elem ) {
- // Only set the IDL specifically if it already exists on the element
- elem[ propName ] = true;
- }
-
- elem.setAttribute( name, name.toLowerCase() );
- }
- return name;
- }
-};
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !getSetAttribute ) {
-
- fixSpecified = {
- name: true,
- id: true,
- coords: true
- };
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret;
- ret = elem.getAttributeNode( name );
- return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
- ret.value :
- undefined;
- },
- set: function( elem, value, name ) {
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- ret = document.createAttribute( name );
- elem.setAttributeNode( ret );
- }
- return ( ret.value = value + "" );
- }
- };
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each([ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- });
- });
-
- // Set contenteditable to false on removals(#10429)
- // Setting to empty string throws an error as an invalid value
- jQuery.attrHooks.contenteditable = {
- get: nodeHook.get,
- set: function( elem, value, name ) {
- if ( value === "" ) {
- value = "false";
- }
- nodeHook.set( elem, value, name );
- }
- };
-}
-
-
-// Some attributes require a special call on IE
-if ( !jQuery.support.hrefNormalized ) {
- jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- get: function( elem ) {
- var ret = elem.getAttribute( name, 2 );
- return ret === null ? undefined : ret;
- }
- });
- });
-}
-
-if ( !jQuery.support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
- // Return undefined in the case of empty string
- // Normalize to lowercase since IE uppercases css property names
- return elem.style.cssText.toLowerCase() || undefined;
- },
- set: function( elem, value ) {
- return ( elem.style.cssText = value + "" );
- }
- };
-}
-
-// Safari mis-reports the default selected property of an option
-// Accessing the parent's selectedIndex property fixes it
-if ( !jQuery.support.optSelected ) {
- jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- }
- });
-}
-
-// IE6/7 call enctype encoding
-if ( !jQuery.support.enctype ) {
- jQuery.propFix.enctype = "encoding";
-}
-
-// Radios and checkboxes getter/setter
-if ( !jQuery.support.checkOn ) {
- jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- get: function( elem ) {
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
- };
- });
-}
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
- }
- }
- });
-});
-var rformElems = /^(?:textarea|input|select)$/i,
- rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
- rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|contextmenu)|click/,
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- hoverHack = function( events ) {
- return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
- };
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- add: function( elem, types, handler, data, selector ) {
-
- var elemData, eventHandle, events,
- t, tns, type, namespaces, handleObj,
- handleObjIn, handlers, special;
-
- // Don't attach events to noData or text/comment nodes (allow plain objects tho)
- if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- selector = handleObjIn.selector;
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- events = elemData.events;
- if ( !events ) {
- elemData.events = events = {};
- }
- eventHandle = elemData.handle;
- if ( !eventHandle ) {
- elemData.handle = eventHandle = function( e ) {
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
- jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
- eventHandle.elem = elem;
- }
-
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = jQuery.trim( hoverHack(types) ).split( " " );
- for ( t = 0; t < types.length; t++ ) {
-
- tns = rtypenamespace.exec( types[t] ) || [];
- type = tns[1];
- namespaces = ( tns[2] || "" ).split( "." ).sort();
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend({
- type: type,
- origType: tns[1],
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
- namespace: namespaces.join(".")
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- handlers = events[ type ];
- if ( !handlers ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener/attachEvent if the special events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- global: {},
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
-
- var t, tns, type, origType, namespaces, origCount,
- j, events, special, eventType, handleObj,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem );
-
- if ( !elemData || !(events = elemData.events) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
- for ( t = 0; t < types.length; t++ ) {
- tns = rtypenamespace.exec( types[t] ) || [];
- type = origType = tns[1];
- namespaces = tns[2];
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector? special.delegateType : special.bindType ) || type;
- eventType = events[ type ] || [];
- origCount = eventType.length;
- namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
-
- // Remove matching events
- for ( j = 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
- eventType.splice( j--, 1 );
-
- if ( handleObj.selector ) {
- eventType.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( eventType.length === 0 && origCount !== eventType.length ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- delete elemData.handle;
-
- // removeData also checks for emptiness and clears the expando if empty
- // so use it instead of delete
- jQuery.removeData( elem, "events", true );
- }
- },
-
- // Events that are safe to short-circuit if no handlers are attached.
- // Native DOM events should not be added, they may have inline handlers.
- customEvent: {
- "getData": true,
- "setData": true,
- "changeData": true
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- // Don't do events on text and comment nodes
- if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
- return;
- }
-
- // Event object or event type
- var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
- type = event.type || event,
- namespaces = [];
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf( "!" ) >= 0 ) {
- // Exclusive events trigger only for the exact event (no namespaces)
- type = type.slice(0, -1);
- exclusive = true;
- }
-
- if ( type.indexOf( "." ) >= 0 ) {
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split(".");
- type = namespaces.shift();
- namespaces.sort();
- }
-
- if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
- // No jQuery handlers for this event type, and it can't have inline handlers
- return;
- }
-
- // Caller can pass in an Event, Object, or just an event type string
- event = typeof event === "object" ?
- // jQuery.Event object
- event[ jQuery.expando ] ? event :
- // Object literal
- new jQuery.Event( type, event ) :
- // Just the event type (string)
- new jQuery.Event( type );
-
- event.type = type;
- event.isTrigger = true;
- event.exclusive = exclusive;
- event.namespace = namespaces.join( "." );
- event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
- ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
-
- // Handle a global trigger
- if ( !elem ) {
-
- // TODO: Stop taunting the data cache; remove global events and always attach to document
- cache = jQuery.cache;
- for ( i in cache ) {
- if ( cache[ i ].events && cache[ i ].events[ type ] ) {
- jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
- }
- }
- return;
- }
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data != null ? jQuery.makeArray( data ) : [];
- data.unshift( event );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- eventPath = [[ elem, special.bindType || type ]];
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
- for ( old = elem; cur; cur = cur.parentNode ) {
- eventPath.push([ cur, bubbleType ]);
- old = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( old === (elem.ownerDocument || document) ) {
- eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
- }
- }
-
- // Fire handlers on the event path
- for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
-
- cur = eventPath[i][0];
- event.type = eventPath[i][1];
-
- handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
- if ( handle ) {
- handle.apply( cur, data );
- }
- // Note that this is a bare JS function and not a jQuery handler
- handle = ontype && cur[ ontype ];
- if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
- event.preventDefault();
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
- !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
-
- // Call a native DOM method on the target with the same name name as the event.
- // Can't use an .isFunction() check here because IE6/7 fails that test.
- // Don't do default actions on window, that's where global variables be (#6170)
- // IE<9 dies on focus/blur to hidden element (#1486)
- if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
-
- // Don't re-trigger an onFOO event when we call its FOO() method
- old = elem[ ontype ];
-
- if ( old ) {
- elem[ ontype ] = null;
- }
-
- // Prevent re-triggering of the same event, since we already bubbled it above
- jQuery.event.triggered = type;
- elem[ type ]();
- jQuery.event.triggered = undefined;
-
- if ( old ) {
- elem[ ontype ] = old;
- }
- }
- }
- }
-
- return event.result;
- },
-
- dispatch: function( event ) {
-
- // Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( event || window.event );
-
- var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
- handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
- delegateCount = handlers.delegateCount,
- args = core_slice.call( arguments ),
- run_all = !event.exclusive && !event.namespace,
- special = jQuery.event.special[ event.type ] || {},
- handlerQueue = [];
-
- // Use the fix-ed jQuery.Event rather than the (read-only) native event
- args[0] = event;
- event.delegateTarget = this;
-
- // Call the preDispatch hook for the mapped type, and let it bail if desired
- if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
- return;
- }
-
- // Determine handlers that should run if there are delegated events
- // Avoid non-left-click bubbling in Firefox (#3861)
- if ( delegateCount && !(event.button && event.type === "click") ) {
-
- for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
-
- // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
- if ( cur.disabled !== true || event.type !== "click" ) {
- selMatch = {};
- matches = [];
- for ( i = 0; i < delegateCount; i++ ) {
- handleObj = handlers[ i ];
- sel = handleObj.selector;
-
- if ( selMatch[ sel ] === undefined ) {
- selMatch[ sel ] = handleObj.needsContext ?
- jQuery( sel, this ).index( cur ) >= 0 :
- jQuery.find( sel, this, null, [ cur ] ).length;
- }
- if ( selMatch[ sel ] ) {
- matches.push( handleObj );
- }
- }
- if ( matches.length ) {
- handlerQueue.push({ elem: cur, matches: matches });
- }
- }
- }
- }
-
- // Add the remaining (directly-bound) handlers
- if ( handlers.length > delegateCount ) {
- handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
- }
-
- // Run delegates first; they may want to stop propagation beneath us
- for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
- matched = handlerQueue[ i ];
- event.currentTarget = matched.elem;
-
- for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
- handleObj = matched.matches[ j ];
-
- // Triggered event must either 1) be non-exclusive and have no namespace, or
- // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
- if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
-
- event.data = handleObj.data;
- event.handleObj = handleObj;
-
- ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
- .apply( matched.elem, args );
-
- if ( ret !== undefined ) {
- event.result = ret;
- if ( ret === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- }
- }
- }
-
- // Call the postDispatch hook for the mapped type
- if ( special.postDispatch ) {
- special.postDispatch.call( this, event );
- }
-
- return event.result;
- },
-
- // Includes some event props shared by KeyEvent and MouseEvent
- // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
- props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
-
- fixHooks: {},
-
- keyHooks: {
- props: "char charCode key keyCode".split(" "),
- filter: function( event, original ) {
-
- // Add which for key events
- if ( event.which == null ) {
- event.which = original.charCode != null ? original.charCode : original.keyCode;
- }
-
- return event;
- }
- },
-
- mouseHooks: {
- props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
- filter: function( event, original ) {
- var eventDoc, doc, body,
- button = original.button,
- fromElement = original.fromElement;
-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && original.clientX != null ) {
- eventDoc = event.target.ownerDocument || document;
- doc = eventDoc.documentElement;
- body = eventDoc.body;
-
- event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
- event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
- }
-
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && fromElement ) {
- event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && button !== undefined ) {
- event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
- }
-
- return event;
- }
- },
-
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
-
- // Create a writable copy of the event object and normalize some properties
- var i, prop,
- originalEvent = event,
- fixHook = jQuery.event.fixHooks[ event.type ] || {},
- copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
-
- event = jQuery.Event( originalEvent );
-
- for ( i = copy.length; i; ) {
- prop = copy[ --i ];
- event[ prop ] = originalEvent[ prop ];
- }
-
- // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
- if ( !event.target ) {
- event.target = originalEvent.srcElement || document;
- }
-
- // Target should not be a text node (#504, Safari)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
-
- // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
- event.metaKey = !!event.metaKey;
-
- return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
- },
-
- special: {
- load: {
- // Prevent triggered image.load events from bubbling to window.load
- noBubble: true
- },
-
- focus: {
- delegateType: "focusin"
- },
- blur: {
- delegateType: "focusout"
- },
-
- beforeunload: {
- setup: function( data, namespaces, eventHandle ) {
- // We only want to do this special case on windows
- if ( jQuery.isWindow( this ) ) {
- this.onbeforeunload = eventHandle;
- }
- },
-
- teardown: function( namespaces, eventHandle ) {
- if ( this.onbeforeunload === eventHandle ) {
- this.onbeforeunload = null;
- }
- }
- }
- },
-
- simulate: function( type, elem, event, bubble ) {
- // Piggyback on a donor event to simulate a different one.
- // Fake originalEvent to avoid donor's stopPropagation, but if the
- // simulated event prevents default then we do the same on the donor.
- var e = jQuery.extend(
- new jQuery.Event(),
- event,
- { type: type,
- isSimulated: true,
- originalEvent: {}
- }
- );
- if ( bubble ) {
- jQuery.event.trigger( e, null, elem );
- } else {
- jQuery.event.dispatch.call( elem, e );
- }
- if ( e.isDefaultPrevented() ) {
- event.preventDefault();
- }
- }
-};
-
-// Some plugins are using, but it's undocumented/deprecated and will be removed.
-// The 1.7 special event interface should provide all the hooks needed now.
-jQuery.event.handle = jQuery.event.dispatch;
-
-jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle, false );
- }
- } :
- function( elem, type, handle ) {
- var name = "on" + type;
-
- if ( elem.detachEvent ) {
-
- // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
- // detachEvent needed property on element, by name of that event, to properly expose it to GC
- if ( typeof elem[ name ] === "undefined" ) {
- elem[ name ] = null;
- }
-
- elem.detachEvent( name, handle );
- }
- };
-
-jQuery.Event = function( src, props ) {
- // Allow instantiation without the 'new' keyword
- if ( !(this instanceof jQuery.Event) ) {
- return new jQuery.Event( src, props );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
-
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
- src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
-
- // Event type
- } else {
- this.type = src;
- }
-
- // Put explicitly provided properties onto the event object
- if ( props ) {
- jQuery.extend( this, props );
- }
-
- // Create a timestamp if incoming event doesn't have one
- this.timeStamp = src && src.timeStamp || jQuery.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
-
-function returnFalse() {
- return false;
-}
-function returnTrue() {
- return true;
-}
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
- preventDefault: function() {
- this.isDefaultPrevented = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
-
- // if preventDefault exists run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
-
- // otherwise set the returnValue property of the original event to false (IE)
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- this.isPropagationStopped = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
- // if stopPropagation exists run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
- // otherwise set the cancelBubble property of the original event to true (IE)
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- this.isImmediatePropagationStopped = returnTrue;
- this.stopPropagation();
- },
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse
-};
-
-// Create mouseenter/leave events using mouseover/out and event-time checks
-jQuery.each({
- mouseenter: "mouseover",
- mouseleave: "mouseout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- delegateType: fix,
- bindType: fix,
-
- handle: function( event ) {
- var ret,
- target = this,
- related = event.relatedTarget,
- handleObj = event.handleObj,
- selector = handleObj.selector;
-
- // For mousenter/leave call the handler if related is outside the target.
- // NB: No relatedTarget if the mouse left/entered the browser window
- if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
- event.type = handleObj.origType;
- ret = handleObj.handler.apply( this, arguments );
- event.type = fix;
- }
- return ret;
- }
- };
-});
-
-// IE submit delegation
-if ( !jQuery.support.submitBubbles ) {
-
- jQuery.event.special.submit = {
- setup: function() {
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Lazy-add a submit handler when a descendant form may potentially be submitted
- jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
- // Node name check avoids a VML-related crash in IE (#9807)
- var elem = e.target,
- form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
- if ( form && !jQuery._data( form, "_submit_attached" ) ) {
- jQuery.event.add( form, "submit._submit", function( event ) {
- event._submit_bubble = true;
- });
- jQuery._data( form, "_submit_attached", true );
- }
- });
- // return undefined since we don't need an event listener
- },
-
- postDispatch: function( event ) {
- // If form was submitted by the user, bubble the event up the tree
- if ( event._submit_bubble ) {
- delete event._submit_bubble;
- if ( this.parentNode && !event.isTrigger ) {
- jQuery.event.simulate( "submit", this.parentNode, event, true );
- }
- }
- },
-
- teardown: function() {
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
- jQuery.event.remove( this, "._submit" );
- }
- };
-}
-
-// IE change delegation and checkbox/radio fix
-if ( !jQuery.support.changeBubbles ) {
-
- jQuery.event.special.change = {
-
- setup: function() {
-
- if ( rformElems.test( this.nodeName ) ) {
- // IE doesn't fire change on a check/radio until blur; trigger it on click
- // after a propertychange. Eat the blur-change in special.change.handle.
- // This still fires onchange a second time for check/radio after blur.
- if ( this.type === "checkbox" || this.type === "radio" ) {
- jQuery.event.add( this, "propertychange._change", function( event ) {
- if ( event.originalEvent.propertyName === "checked" ) {
- this._just_changed = true;
- }
- });
- jQuery.event.add( this, "click._change", function( event ) {
- if ( this._just_changed && !event.isTrigger ) {
- this._just_changed = false;
- }
- // Allow triggered, simulated change events (#11500)
- jQuery.event.simulate( "change", this, event, true );
- });
- }
- return false;
- }
- // Delegated event; lazy-add a change handler on descendant inputs
- jQuery.event.add( this, "beforeactivate._change", function( e ) {
- var elem = e.target;
-
- if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
- jQuery.event.add( elem, "change._change", function( event ) {
- if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
- jQuery.event.simulate( "change", this.parentNode, event, true );
- }
- });
- jQuery._data( elem, "_change_attached", true );
- }
- });
- },
-
- handle: function( event ) {
- var elem = event.target;
-
- // Swallow native change events from checkbox/radio, we already triggered them above
- if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
- return event.handleObj.handler.apply( this, arguments );
- }
- },
-
- teardown: function() {
- jQuery.event.remove( this, "._change" );
-
- return !rformElems.test( this.nodeName );
- }
- };
-}
-
-// Create "bubbling" focus and blur events
-if ( !jQuery.support.focusinBubbles ) {
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
- // Attach a single capturing handler while someone wants focusin/focusout
- var attaches = 0,
- handler = function( event ) {
- jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
- };
-
- jQuery.event.special[ fix ] = {
- setup: function() {
- if ( attaches++ === 0 ) {
- document.addEventListener( orig, handler, true );
- }
- },
- teardown: function() {
- if ( --attaches === 0 ) {
- document.removeEventListener( orig, handler, true );
- }
- }
- };
- });
-}
-
-jQuery.fn.extend({
-
- on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
- var origFn, type;
-
- // Types can be a map of types/handlers
- if ( typeof types === "object" ) {
- // ( types-Object, selector, data )
- if ( typeof selector !== "string" ) { // && selector != null
- // ( types-Object, data )
- data = data || selector;
- selector = undefined;
- }
- for ( type in types ) {
- this.on( type, selector, data, types[ type ], one );
- }
- return this;
- }
-
- if ( data == null && fn == null ) {
- // ( types, fn )
- fn = selector;
- data = selector = undefined;
- } else if ( fn == null ) {
- if ( typeof selector === "string" ) {
- // ( types, selector, fn )
- fn = data;
- data = undefined;
- } else {
- // ( types, data, fn )
- fn = data;
- data = selector;
- selector = undefined;
- }
- }
- if ( fn === false ) {
- fn = returnFalse;
- } else if ( !fn ) {
- return this;
- }
-
- if ( one === 1 ) {
- origFn = fn;
- fn = function( event ) {
- // Can use an empty set, since event contains the info
- jQuery().off( event );
- return origFn.apply( this, arguments );
- };
- // Use same guid so caller can remove using origFn
- fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
- }
- return this.each( function() {
- jQuery.event.add( this, types, fn, data, selector );
- });
- },
- one: function( types, selector, data, fn ) {
- return this.on( types, selector, data, fn, 1 );
- },
- off: function( types, selector, fn ) {
- var handleObj, type;
- if ( types && types.preventDefault && types.handleObj ) {
- // ( event ) dispatched jQuery.Event
- handleObj = types.handleObj;
- jQuery( types.delegateTarget ).off(
- handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
- handleObj.selector,
- handleObj.handler
- );
- return this;
- }
- if ( typeof types === "object" ) {
- // ( types-object [, selector] )
- for ( type in types ) {
- this.off( type, selector, types[ type ] );
- }
- return this;
- }
- if ( selector === false || typeof selector === "function" ) {
- // ( types [, fn] )
- fn = selector;
- selector = undefined;
- }
- if ( fn === false ) {
- fn = returnFalse;
- }
- return this.each(function() {
- jQuery.event.remove( this, types, fn, selector );
- });
- },
-
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
-
- live: function( types, data, fn ) {
- jQuery( this.context ).on( types, this.selector, data, fn );
- return this;
- },
- die: function( types, fn ) {
- jQuery( this.context ).off( types, this.selector || "**", fn );
- return this;
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
- },
-
- trigger: function( type, data ) {
- return this.each(function() {
- jQuery.event.trigger( type, data, this );
- });
- },
- triggerHandler: function( type, data ) {
- if ( this[0] ) {
- return jQuery.event.trigger( type, data, this[0], true );
- }
- },
-
- toggle: function( fn ) {
- // Save reference to arguments for access in closure
- var args = arguments,
- guid = fn.guid || jQuery.guid++,
- i = 0,
- toggler = function( event ) {
- // Figure out which function to execute
- var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
- jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
-
- // Make sure that clicks stop
- event.preventDefault();
-
- // and execute the function
- return args[ lastToggle ].apply( this, arguments ) || false;
- };
-
- // link all the functions, so any of them can unbind this click handler
- toggler.guid = guid;
- while ( i < args.length ) {
- args[ i++ ].guid = guid;
- }
-
- return this.click( toggler );
- },
-
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-});
-
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- if ( fn == null ) {
- fn = data;
- data = null;
- }
-
- return arguments.length > 0 ?
- this.on( name, null, data, fn ) :
- this.trigger( name );
- };
-
- if ( rkeyEvent.test( name ) ) {
- jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
- }
-
- if ( rmouseEvent.test( name ) ) {
- jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
- }
-});
-/*!
- * Sizzle CSS Selector Engine
- * Copyright 2012 jQuery Foundation and other contributors
- * Released under the MIT license
- * http://sizzlejs.com/
- */
-(function( window, undefined ) {
-
-var cachedruns,
- assertGetIdNotName,
- Expr,
- getText,
- isXML,
- contains,
- compile,
- sortOrder,
- hasDuplicate,
- outermostContext,
-
- baseHasDuplicate = true,
- strundefined = "undefined",
-
- expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
-
- Token = String,
- document = window.document,
- docElem = document.documentElement,
- dirruns = 0,
- done = 0,
- pop = [].pop,
- push = [].push,
- slice = [].slice,
- // Use a stripped-down indexOf if a native one is unavailable
- indexOf = [].indexOf || function( elem ) {
- var i = 0,
- len = this.length;
- for ( ; i < len; i++ ) {
- if ( this[i] === elem ) {
- return i;
- }
- }
- return -1;
- },
-
- // Augment a function for special use by Sizzle
- markFunction = function( fn, value ) {
- fn[ expando ] = value == null || value;
- return fn;
- },
-
- createCache = function() {
- var cache = {},
- keys = [];
-
- return markFunction(function( key, value ) {
- // Only keep the most recent entries
- if ( keys.push( key ) > Expr.cacheLength ) {
- delete cache[ keys.shift() ];
- }
-
- return (cache[ key ] = value);
- }, cache );
- },
-
- classCache = createCache(),
- tokenCache = createCache(),
- compilerCache = createCache(),
-
- // Regex
-
- // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
- whitespace = "[\\x20\\t\\r\\n\\f]",
- // http://www.w3.org/TR/css3-syntax/#characters
- characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
-
- // Loosely modeled on CSS identifier characters
- // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
- // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
- identifier = characterEncoding.replace( "w", "w#" ),
-
- // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
- operators = "([*^$|!~]?=)",
- attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
- "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
-
- // Prefer arguments not in parens/brackets,
- // then attribute selectors and non-pseudos (denoted by :),
- // then anything else
- // These preferences are here to reduce the number of selectors
- // needing tokenize in the PSEUDO preFilter
- pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
-
- // For matchExpr.POS and matchExpr.needsContext
- pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
- "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
-
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
-
- rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
- rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
- rpseudo = new RegExp( pseudos ),
-
- // Easily-parseable/retrievable ID or TAG or CLASS selectors
- rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
-
- rnot = /^:not/,
- rsibling = /[\x20\t\r\n\f]*[+~]/,
- rendsWithNot = /:not\($/,
-
- rheader = /h\d/i,
- rinputs = /input|select|textarea|button/i,
-
- rbackslash = /\\(?!\\)/g,
-
- matchExpr = {
- "ID": new RegExp( "^#(" + characterEncoding + ")" ),
- "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
- "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
- "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
- "ATTR": new RegExp( "^" + attributes ),
- "PSEUDO": new RegExp( "^" + pseudos ),
- "POS": new RegExp( pos, "i" ),
- "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
- "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
- "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- // For use in libraries implementing .is()
- "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
- },
-
- // Support
-
- // Used for testing something on an element
- assert = function( fn ) {
- var div = document.createElement("div");
-
- try {
- return fn( div );
- } catch (e) {
- return false;
- } finally {
- // release memory in IE
- div = null;
- }
- },
-
- // Check if getElementsByTagName("*") returns only elements
- assertTagNameNoComments = assert(function( div ) {
- div.appendChild( document.createComment("") );
- return !div.getElementsByTagName("*").length;
- }),
-
- // Check if getAttribute returns normalized href attributes
- assertHrefNotNormalized = assert(function( div ) {
- div.innerHTML = "<a href='#'></a>";
- return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
- div.firstChild.getAttribute("href") === "#";
- }),
-
- // Check if attributes should be retrieved by attribute nodes
- assertAttributes = assert(function( div ) {
- div.innerHTML = "<select></select>";
- var type = typeof div.lastChild.getAttribute("multiple");
- // IE8 returns a string for some attributes even when not present
- return type !== "boolean" && type !== "string";
- }),
-
- // Check if getElementsByClassName can be trusted
- assertUsableClassName = assert(function( div ) {
- // Opera can't find a second classname (in 9.6)
- div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
- if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
- return false;
- }
-
- // Safari 3.2 caches class attributes and doesn't catch changes
- div.lastChild.className = "e";
- return div.getElementsByClassName("e").length === 2;
- }),
-
- // Check if getElementById returns elements by name
- // Check if getElementsByName privileges form controls or returns elements by ID
- assertUsableName = assert(function( div ) {
- // Inject content
- div.id = expando + 0;
- div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
- docElem.insertBefore( div, docElem.firstChild );
-
- // Test
- var pass = document.getElementsByName &&
- // buggy browsers will return fewer than the correct 2
- document.getElementsByName( expando ).length === 2 +
- // buggy browsers will return more than the correct 0
- document.getElementsByName( expando + 0 ).length;
- assertGetIdNotName = !document.getElementById( expando );
-
- // Cleanup
- docElem.removeChild( div );
-
- return pass;
- });
-
-// If slice is not available, provide a backup
-try {
- slice.call( docElem.childNodes, 0 )[0].nodeType;
-} catch ( e ) {
- slice = function( i ) {
- var elem,
- results = [];
- for ( ; (elem = this[i]); i++ ) {
- results.push( elem );
- }
- return results;
- };
-}
-
-function Sizzle( selector, context, results, seed ) {
- results = results || [];
- context = context || document;
- var match, elem, xml, m,
- nodeType = context.nodeType;
-
- if ( !selector || typeof selector !== "string" ) {
- return results;
- }
-
- if ( nodeType !== 1 && nodeType !== 9 ) {
- return [];
- }
-
- xml = isXML( context );
-
- if ( !xml && !seed ) {
- if ( (match = rquickExpr.exec( selector )) ) {
- // Speed-up: Sizzle("#ID")
- if ( (m = match[1]) ) {
- if ( nodeType === 9 ) {
- elem = context.getElementById( m );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE, Opera, and Webkit return items
- // by name instead of ID
- if ( elem.id === m ) {
- results.push( elem );
- return results;
- }
- } else {
- return results;
- }
- } else {
- // Context is not a document
- if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
- contains( context, elem ) && elem.id === m ) {
- results.push( elem );
- return results;
- }
- }
-
- // Speed-up: Sizzle("TAG")
- } else if ( match[2] ) {
- push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
- return results;
-
- // Speed-up: Sizzle(".CLASS")
- } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
- push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
- return results;
- }
- }
- }
-
- // All others
- return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
-}
-
-Sizzle.matches = function( expr, elements ) {
- return Sizzle( expr, null, null, elements );
-};
-
-Sizzle.matchesSelector = function( elem, expr ) {
- return Sizzle( expr, null, null, [ elem ] ).length > 0;
-};
-
-// Returns a function to use in pseudos for input types
-function createInputPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === type;
- };
-}
-
-// Returns a function to use in pseudos for buttons
-function createButtonPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return (name === "input" || name === "button") && elem.type === type;
- };
-}
-
-// Returns a function to use in pseudos for positionals
-function createPositionalPseudo( fn ) {
- return markFunction(function( argument ) {
- argument = +argument;
- return markFunction(function( seed, matches ) {
- var j,
- matchIndexes = fn( [], seed.length, argument ),
- i = matchIndexes.length;
-
- // Match elements found at the specified indexes
- while ( i-- ) {
- if ( seed[ (j = matchIndexes[i]) ] ) {
- seed[j] = !(matches[j] = seed[j]);
- }
- }
- });
- });
-}
-
-/**
- * Utility function for retrieving the text value of an array of DOM nodes
- * @param {Array|Element} elem
- */
-getText = Sizzle.getText = function( elem ) {
- var node,
- ret = "",
- i = 0,
- nodeType = elem.nodeType;
-
- if ( nodeType ) {
- if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
- // Use textContent for elements
- // innerText usage removed for consistency of new lines (see #11153)
- if ( typeof elem.textContent === "string" ) {
- return elem.textContent;
- } else {
- // Traverse its children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- ret += getText( elem );
- }
- }
- } else if ( nodeType === 3 || nodeType === 4 ) {
- return elem.nodeValue;
- }
- // Do not include comment or processing instruction nodes
- } else {
-
- // If no nodeType, this is expected to be an array
- for ( ; (node = elem[i]); i++ ) {
- // Do not traverse comment nodes
- ret += getText( node );
- }
- }
- return ret;
-};
-
-isXML = Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = elem && (elem.ownerDocument || elem).documentElement;
- return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-// Element contains another
-contains = Sizzle.contains = docElem.contains ?
- function( a, b ) {
- var adown = a.nodeType === 9 ? a.documentElement : a,
- bup = b && b.parentNode;
- return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
- } :
- docElem.compareDocumentPosition ?
- function( a, b ) {
- return b && !!( a.compareDocumentPosition( b ) & 16 );
- } :
- function( a, b ) {
- while ( (b = b.parentNode) ) {
- if ( b === a ) {
- return true;
- }
- }
- return false;
- };
-
-Sizzle.attr = function( elem, name ) {
- var val,
- xml = isXML( elem );
-
- if ( !xml ) {
- name = name.toLowerCase();
- }
- if ( (val = Expr.attrHandle[ name ]) ) {
- return val( elem );
- }
- if ( xml || assertAttributes ) {
- return elem.getAttribute( name );
- }
- val = elem.getAttributeNode( name );
- return val ?
- typeof elem[ name ] === "boolean" ?
- elem[ name ] ? name : null :
- val.specified ? val.value : null :
- null;
-};
-
-Expr = Sizzle.selectors = {
-
- // Can be adjusted by the user
- cacheLength: 50,
-
- createPseudo: markFunction,
-
- match: matchExpr,
-
- // IE6/7 return a modified href
- attrHandle: assertHrefNotNormalized ?
- {} :
- {
- "href": function( elem ) {
- return elem.getAttribute( "href", 2 );
- },
- "type": function( elem ) {
- return elem.getAttribute("type");
- }
- },
-
- find: {
- "ID": assertGetIdNotName ?
- function( id, context, xml ) {
- if ( typeof context.getElementById !== strundefined && !xml ) {
- var m = context.getElementById( id );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- return m && m.parentNode ? [m] : [];
- }
- } :
- function( id, context, xml ) {
- if ( typeof context.getElementById !== strundefined && !xml ) {
- var m = context.getElementById( id );
-
- return m ?
- m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
- [m] :
- undefined :
- [];
- }
- },
-
- "TAG": assertTagNameNoComments ?
- function( tag, context ) {
- if ( typeof context.getElementsByTagName !== strundefined ) {
- return context.getElementsByTagName( tag );
- }
- } :
- function( tag, context ) {
- var results = context.getElementsByTagName( tag );
-
- // Filter out possible comments
- if ( tag === "*" ) {
- var elem,
- tmp = [],
- i = 0;
-
- for ( ; (elem = results[i]); i++ ) {
- if ( elem.nodeType === 1 ) {
- tmp.push( elem );
- }
- }
-
- return tmp;
- }
- return results;
- },
-
- "NAME": assertUsableName && function( tag, context ) {
- if ( typeof context.getElementsByName !== strundefined ) {
- return context.getElementsByName( name );
- }
- },
-
- "CLASS": assertUsableClassName && function( className, context, xml ) {
- if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
- return context.getElementsByClassName( className );
- }
- }
- },
-
- relative: {
- ">": { dir: "parentNode", first: true },
- " ": { dir: "parentNode" },
- "+": { dir: "previousSibling", first: true },
- "~": { dir: "previousSibling" }
- },
-
- preFilter: {
- "ATTR": function( match ) {
- match[1] = match[1].replace( rbackslash, "" );
-
- // Move the given value to match[3] whether quoted or unquoted
- match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
-
- if ( match[2] === "~=" ) {
- match[3] = " " + match[3] + " ";
- }
-
- return match.slice( 0, 4 );
- },
-
- "CHILD": function( match ) {
- /* matches from matchExpr["CHILD"]
- 1 type (only|nth|...)
- 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
- 3 xn-component of xn+y argument ([+-]?\d*n|)
- 4 sign of xn-component
- 5 x of xn-component
- 6 sign of y-component
- 7 y of y-component
- */
- match[1] = match[1].toLowerCase();
-
- if ( match[1] === "nth" ) {
- // nth-child requires argument
- if ( !match[2] ) {
- Sizzle.error( match[0] );
- }
-
- // numeric x and y parameters for Expr.filter.CHILD
- // remember that false/true cast respectively to 0/1
- match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
- match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
-
- // other types prohibit arguments
- } else if ( match[2] ) {
- Sizzle.error( match[0] );
- }
-
- return match;
- },
-
- "PSEUDO": function( match ) {
- var unquoted, excess;
- if ( matchExpr["CHILD"].test( match[0] ) ) {
- return null;
- }
-
- if ( match[3] ) {
- match[2] = match[3];
- } else if ( (unquoted = match[4]) ) {
- // Only check arguments that contain a pseudo
- if ( rpseudo.test(unquoted) &&
- // Get excess from tokenize (recursively)
- (excess = tokenize( unquoted, true )) &&
- // advance to the next closing parenthesis
- (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
-
- // excess is a negative index
- unquoted = unquoted.slice( 0, excess );
- match[0] = match[0].slice( 0, excess );
- }
- match[2] = unquoted;
- }
-
- // Return only captures needed by the pseudo filter method (type and argument)
- return match.slice( 0, 3 );
- }
- },
-
- filter: {
- "ID": assertGetIdNotName ?
- function( id ) {
- id = id.replace( rbackslash, "" );
- return function( elem ) {
- return elem.getAttribute("id") === id;
- };
- } :
- function( id ) {
- id = id.replace( rbackslash, "" );
- return function( elem ) {
- var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
- return node && node.value === id;
- };
- },
-
- "TAG": function( nodeName ) {
- if ( nodeName === "*" ) {
- return function() { return true; };
- }
- nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
-
- return function( elem ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
- };
- },
-
- "CLASS": function( className ) {
- var pattern = classCache[ expando ][ className ];
- if ( !pattern ) {
- pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
- }
- return function( elem ) {
- return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
- };
- },
-
- "ATTR": function( name, operator, check ) {
- return function( elem, context ) {
- var result = Sizzle.attr( elem, name );
-
- if ( result == null ) {
- return operator === "!=";
- }
- if ( !operator ) {
- return true;
- }
-
- result += "";
-
- return operator === "=" ? result === check :
- operator === "!=" ? result !== check :
- operator === "^=" ? check && result.indexOf( check ) === 0 :
- operator === "*=" ? check && result.indexOf( check ) > -1 :
- operator === "$=" ? check && result.substr( result.length - check.length ) === check :
- operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
- operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
- false;
- };
- },
-
- "CHILD": function( type, argument, first, last ) {
-
- if ( type === "nth" ) {
- return function( elem ) {
- var node, diff,
- parent = elem.parentNode;
-
- if ( first === 1 && last === 0 ) {
- return true;
- }
-
- if ( parent ) {
- diff = 0;
- for ( node = parent.firstChild; node; node = node.nextSibling ) {
- if ( node.nodeType === 1 ) {
- diff++;
- if ( elem === node ) {
- break;
- }
- }
- }
- }
-
- // Incorporate the offset (or cast to NaN), then check against cycle size
- diff -= last;
- return diff === first || ( diff % first === 0 && diff / first >= 0 );
- };
- }
-
- return function( elem ) {
- var node = elem;
-
- switch ( type ) {
- case "only":
- case "first":
- while ( (node = node.previousSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- if ( type === "first" ) {
- return true;
- }
-
- node = elem;
-
- /* falls through */
- case "last":
- while ( (node = node.nextSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- return true;
- }
- };
- },
-
- "PSEUDO": function( pseudo, argument ) {
- // pseudo-class names are case-insensitive
- // http://www.w3.org/TR/selectors/#pseudo-classes
- // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
- // Remember that setFilters inherits from pseudos
- var args,
- fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
- Sizzle.error( "unsupported pseudo: " + pseudo );
-
- // The user may use createPseudo to indicate that
- // arguments are needed to create the filter function
- // just as Sizzle does
- if ( fn[ expando ] ) {
- return fn( argument );
- }
-
- // But maintain support for old signatures
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
- markFunction(function( seed, matches ) {
- var idx,
- matched = fn( seed, argument ),
- i = matched.length;
- while ( i-- ) {
- idx = indexOf.call( seed, matched[i] );
- seed[ idx ] = !( matches[ idx ] = matched[i] );
- }
- }) :
- function( elem ) {
- return fn( elem, 0, args );
- };
- }
-
- return fn;
- }
- },
-
- pseudos: {
- "not": markFunction(function( selector ) {
- // Trim the selector passed to compile
- // to avoid treating leading and trailing
- // spaces as combinators
- var input = [],
- results = [],
- matcher = compile( selector.replace( rtrim, "$1" ) );
-
- return matcher[ expando ] ?
- markFunction(function( seed, matches, context, xml ) {
- var elem,
- unmatched = matcher( seed, null, xml, [] ),
- i = seed.length;
-
- // Match elements unmatched by `matcher`
- while ( i-- ) {
- if ( (elem = unmatched[i]) ) {
- seed[i] = !(matches[i] = elem);
- }
- }
- }) :
- function( elem, context, xml ) {
- input[0] = elem;
- matcher( input, null, xml, results );
- return !results.pop();
- };
- }),
-
- "has": markFunction(function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- }),
-
- "contains": markFunction(function( text ) {
- return function( elem ) {
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
- };
- }),
-
- "enabled": function( elem ) {
- return elem.disabled === false;
- },
-
- "disabled": function( elem ) {
- return elem.disabled === true;
- },
-
- "checked": function( elem ) {
- // In CSS3, :checked should return both checked and selected elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- var nodeName = elem.nodeName.toLowerCase();
- return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
- },
-
- "selected": function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- if ( elem.parentNode ) {
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- "parent": function( elem ) {
- return !Expr.pseudos["empty"]( elem );
- },
-
- "empty": function( elem ) {
- // http://www.w3.org/TR/selectors/#empty-pseudo
- // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
- // not comment, processing instructions, or others
- // Thanks to Diego Perini for the nodeName shortcut
- // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
- var nodeType;
- elem = elem.firstChild;
- while ( elem ) {
- if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
- return false;
- }
- elem = elem.nextSibling;
- }
- return true;
- },
-
- "header": function( elem ) {
- return rheader.test( elem.nodeName );
- },
-
- "text": function( elem ) {
- var type, attr;
- // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
- // use getAttribute instead to test this case
- return elem.nodeName.toLowerCase() === "input" &&
- (type = elem.type) === "text" &&
- ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
- },
-
- // Input types
- "radio": createInputPseudo("radio"),
- "checkbox": createInputPseudo("checkbox"),
- "file": createInputPseudo("file"),
- "password": createInputPseudo("password"),
- "image": createInputPseudo("image"),
-
- "submit": createButtonPseudo("submit"),
- "reset": createButtonPseudo("reset"),
-
- "button": function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === "button" || name === "button";
- },
-
- "input": function( elem ) {
- return rinputs.test( elem.nodeName );
- },
-
- "focus": function( elem ) {
- var doc = elem.ownerDocument;
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
- },
-
- "active": function( elem ) {
- return elem === elem.ownerDocument.activeElement;
- },
-
- // Positional types
- "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
- return [ 0 ];
- }),
-
- "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
- return [ length - 1 ];
- }),
-
- "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
- return [ argument < 0 ? argument + length : argument ];
- }),
-
- "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
- for ( var i = 0; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
- for ( var i = 1; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- })
- }
-};
-
-function siblingCheck( a, b, ret ) {
- if ( a === b ) {
- return ret;
- }
-
- var cur = a.nextSibling;
-
- while ( cur ) {
- if ( cur === b ) {
- return -1;
- }
-
- cur = cur.nextSibling;
- }
-
- return 1;
-}
-
-sortOrder = docElem.compareDocumentPosition ?
- function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
- a.compareDocumentPosition :
- a.compareDocumentPosition(b) & 4
- ) ? -1 : 1;
- } :
- function( a, b ) {
- // The nodes are identical, we can exit early
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
-
- // Fallback to using sourceIndex (in IE) if it's available on both nodes
- } else if ( a.sourceIndex && b.sourceIndex ) {
- return a.sourceIndex - b.sourceIndex;
- }
-
- var al, bl,
- ap = [],
- bp = [],
- aup = a.parentNode,
- bup = b.parentNode,
- cur = aup;
-
- // If the nodes are siblings (or identical) we can do a quick check
- if ( aup === bup ) {
- return siblingCheck( a, b );
-
- // If no parents were found then the nodes are disconnected
- } else if ( !aup ) {
- return -1;
-
- } else if ( !bup ) {
- return 1;
- }
-
- // Otherwise they're somewhere else in the tree so we need
- // to build up a full list of the parentNodes for comparison
- while ( cur ) {
- ap.unshift( cur );
- cur = cur.parentNode;
- }
-
- cur = bup;
-
- while ( cur ) {
- bp.unshift( cur );
- cur = cur.parentNode;
- }
-
- al = ap.length;
- bl = bp.length;
-
- // Start walking down the tree looking for a discrepancy
- for ( var i = 0; i < al && i < bl; i++ ) {
- if ( ap[i] !== bp[i] ) {
- return siblingCheck( ap[i], bp[i] );
- }
- }
-
- // We ended someplace up the tree so do a sibling check
- return i === al ?
- siblingCheck( a, bp[i], -1 ) :
- siblingCheck( ap[i], b, 1 );
- };
-
-// Always assume the presence of duplicates if sort doesn't
-// pass them to our comparison function (as in Google Chrome).
-[0, 0].sort( sortOrder );
-baseHasDuplicate = !hasDuplicate;
-
-// Document sorting and removing duplicates
-Sizzle.uniqueSort = function( results ) {
- var elem,
- i = 1;
-
- hasDuplicate = baseHasDuplicate;
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- for ( ; (elem = results[i]); i++ ) {
- if ( elem === results[ i - 1 ] ) {
- results.splice( i--, 1 );
- }
- }
- }
-
- return results;
-};
-
-Sizzle.error = function( msg ) {
- throw new Error( "Syntax error, unrecognized expression: " + msg );
-};
-
-function tokenize( selector, parseOnly ) {
- var matched, match, tokens, type, soFar, groups, preFilters,
- cached = tokenCache[ expando ][ selector ];
-
- if ( cached ) {
- return parseOnly ? 0 : cached.slice( 0 );
- }
-
- soFar = selector;
- groups = [];
- preFilters = Expr.preFilter;
-
- while ( soFar ) {
-
- // Comma and first run
- if ( !matched || (match = rcomma.exec( soFar )) ) {
- if ( match ) {
- soFar = soFar.slice( match[0].length );
- }
- groups.push( tokens = [] );
- }
-
- matched = false;
-
- // Combinators
- if ( (match = rcombinators.exec( soFar )) ) {
- tokens.push( matched = new Token( match.shift() ) );
- soFar = soFar.slice( matched.length );
-
- // Cast descendant combinators to space
- matched.type = match[0].replace( rtrim, " " );
- }
-
- // Filters
- for ( type in Expr.filter ) {
- if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
- // The last two arguments here are (context, xml) for backCompat
- (match = preFilters[ type ]( match, document, true ))) ) {
-
- tokens.push( matched = new Token( match.shift() ) );
- soFar = soFar.slice( matched.length );
- matched.type = type;
- matched.matches = match;
- }
- }
-
- if ( !matched ) {
- break;
- }
- }
-
- // Return the length of the invalid excess
- // if we're just parsing
- // Otherwise, throw an error or return tokens
- return parseOnly ?
- soFar.length :
- soFar ?
- Sizzle.error( selector ) :
- // Cache the tokens
- tokenCache( selector, groups ).slice( 0 );
-}
-
-function addCombinator( matcher, combinator, base ) {
- var dir = combinator.dir,
- checkNonElements = base && combinator.dir === "parentNode",
- doneName = done++;
-
- return combinator.first ?
- // Check against closest ancestor/preceding element
- function( elem, context, xml ) {
- while ( (elem = elem[ dir ]) ) {
- if ( checkNonElements || elem.nodeType === 1 ) {
- return matcher( elem, context, xml );
- }
- }
- } :
-
- // Check against all ancestor/preceding elements
- function( elem, context, xml ) {
- // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
- if ( !xml ) {
- var cache,
- dirkey = dirruns + " " + doneName + " ",
- cachedkey = dirkey + cachedruns;
- while ( (elem = elem[ dir ]) ) {
- if ( checkNonElements || elem.nodeType === 1 ) {
- if ( (cache = elem[ expando ]) === cachedkey ) {
- return elem.sizset;
- } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
- if ( elem.sizset ) {
- return elem;
- }
- } else {
- elem[ expando ] = cachedkey;
- if ( matcher( elem, context, xml ) ) {
- elem.sizset = true;
- return elem;
- }
- elem.sizset = false;
- }
- }
- }
- } else {
- while ( (elem = elem[ dir ]) ) {
- if ( checkNonElements || elem.nodeType === 1 ) {
- if ( matcher( elem, context, xml ) ) {
- return elem;
- }
- }
- }
- }
- };
-}
-
-function elementMatcher( matchers ) {
- return matchers.length > 1 ?
- function( elem, context, xml ) {
- var i = matchers.length;
- while ( i-- ) {
- if ( !matchers[i]( elem, context, xml ) ) {
- return false;
- }
- }
- return true;
- } :
- matchers[0];
-}
-
-function condense( unmatched, map, filter, context, xml ) {
- var elem,
- newUnmatched = [],
- i = 0,
- len = unmatched.length,
- mapped = map != null;
-
- for ( ; i < len; i++ ) {
- if ( (elem = unmatched[i]) ) {
- if ( !filter || filter( elem, context, xml ) ) {
- newUnmatched.push( elem );
- if ( mapped ) {
- map.push( i );
- }
- }
- }
- }
-
- return newUnmatched;
-}
-
-function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
- if ( postFilter && !postFilter[ expando ] ) {
- postFilter = setMatcher( postFilter );
- }
- if ( postFinder && !postFinder[ expando ] ) {
- postFinder = setMatcher( postFinder, postSelector );
- }
- return markFunction(function( seed, results, context, xml ) {
- // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
- if ( seed && postFinder ) {
- return;
- }
-
- var i, elem, postFilterIn,
- preMap = [],
- postMap = [],
- preexisting = results.length,
-
- // Get initial elements from seed or context
- elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
-
- // Prefilter to get matcher input, preserving a map for seed-results synchronization
- matcherIn = preFilter && ( seed || !selector ) ?
- condense( elems, preMap, preFilter, context, xml ) :
- elems,
-
- matcherOut = matcher ?
- // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
- postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-
- // ...intermediate processing is necessary
- [] :
-
- // ...otherwise use results directly
- results :
- matcherIn;
-
- // Find primary matches
- if ( matcher ) {
- matcher( matcherIn, matcherOut, context, xml );
- }
-
- // Apply postFilter
- if ( postFilter ) {
- postFilterIn = condense( matcherOut, postMap );
- postFilter( postFilterIn, [], context, xml );
-
- // Un-match failing elements by moving them back to matcherIn
- i = postFilterIn.length;
- while ( i-- ) {
- if ( (elem = postFilterIn[i]) ) {
- matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
- }
- }
- }
-
- // Keep seed and results synchronized
- if ( seed ) {
- // Ignore postFinder because it can't coexist with seed
- i = preFilter && matcherOut.length;
- while ( i-- ) {
- if ( (elem = matcherOut[i]) ) {
- seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
- }
- }
- } else {
- matcherOut = condense(
- matcherOut === results ?
- matcherOut.splice( preexisting, matcherOut.length ) :
- matcherOut
- );
- if ( postFinder ) {
- postFinder( null, results, matcherOut, xml );
- } else {
- push.apply( results, matcherOut );
- }
- }
- });
-}
-
-function matcherFromTokens( tokens ) {
- var checkContext, matcher, j,
- len = tokens.length,
- leadingRelative = Expr.relative[ tokens[0].type ],
- implicitRelative = leadingRelative || Expr.relative[" "],
- i = leadingRelative ? 1 : 0,
-
- // The foundational matcher ensures that elements are reachable from top-level context(s)
- matchContext = addCombinator( function( elem ) {
- return elem === checkContext;
- }, implicitRelative, true ),
- matchAnyContext = addCombinator( function( elem ) {
- return indexOf.call( checkContext, elem ) > -1;
- }, implicitRelative, true ),
- matchers = [ function( elem, context, xml ) {
- return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
- (checkContext = context).nodeType ?
- matchContext( elem, context, xml ) :
- matchAnyContext( elem, context, xml ) );
- } ];
-
- for ( ; i < len; i++ ) {
- if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
- matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
- } else {
- // The concatenated values are (context, xml) for backCompat
- matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
-
- // Return special upon seeing a positional matcher
- if ( matcher[ expando ] ) {
- // Find the next relative operator (if any) for proper handling
- j = ++i;
- for ( ; j < len; j++ ) {
- if ( Expr.relative[ tokens[j].type ] ) {
- break;
- }
- }
- return setMatcher(
- i > 1 && elementMatcher( matchers ),
- i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
- matcher,
- i < j && matcherFromTokens( tokens.slice( i, j ) ),
- j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
- j < len && tokens.join("")
- );
- }
- matchers.push( matcher );
- }
- }
-
- return elementMatcher( matchers );
-}
-
-function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
- var bySet = setMatchers.length > 0,
- byElement = elementMatchers.length > 0,
- superMatcher = function( seed, context, xml, results, expandContext ) {
- var elem, j, matcher,
- setMatched = [],
- matchedCount = 0,
- i = "0",
- unmatched = seed && [],
- outermost = expandContext != null,
- contextBackup = outermostContext,
- // We must always have either seed elements or context
- elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
- // Nested matchers should use non-integer dirruns
- dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
-
- if ( outermost ) {
- outermostContext = context !== document && context;
- cachedruns = superMatcher.el;
- }
-
- // Add elements passing elementMatchers directly to results
- for ( ; (elem = elems[i]) != null; i++ ) {
- if ( byElement && elem ) {
- for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
- if ( matcher( elem, context, xml ) ) {
- results.push( elem );
- break;
- }
- }
- if ( outermost ) {
- dirruns = dirrunsUnique;
- cachedruns = ++superMatcher.el;
- }
- }
-
- // Track unmatched elements for set filters
- if ( bySet ) {
- // They will have gone through all possible matchers
- if ( (elem = !matcher && elem) ) {
- matchedCount--;
- }
-
- // Lengthen the array for every element, matched or not
- if ( seed ) {
- unmatched.push( elem );
- }
- }
- }
-
- // Apply set filters to unmatched elements
- matchedCount += i;
- if ( bySet && i !== matchedCount ) {
- for ( j = 0; (matcher = setMatchers[j]); j++ ) {
- matcher( unmatched, setMatched, context, xml );
- }
-
- if ( seed ) {
- // Reintegrate element matches to eliminate the need for sorting
- if ( matchedCount > 0 ) {
- while ( i-- ) {
- if ( !(unmatched[i] || setMatched[i]) ) {
- setMatched[i] = pop.call( results );
- }
- }
- }
-
- // Discard index placeholder values to get only actual matches
- setMatched = condense( setMatched );
- }
-
- // Add matches to results
- push.apply( results, setMatched );
-
- // Seedless set matches succeeding multiple successful matchers stipulate sorting
- if ( outermost && !seed && setMatched.length > 0 &&
- ( matchedCount + setMatchers.length ) > 1 ) {
-
- Sizzle.uniqueSort( results );
- }
- }
-
- // Override manipulation of globals by nested matchers
- if ( outermost ) {
- dirruns = dirrunsUnique;
- outermostContext = contextBackup;
- }
-
- return unmatched;
- };
-
- superMatcher.el = 0;
- return bySet ?
- markFunction( superMatcher ) :
- superMatcher;
-}
-
-compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
- var i,
- setMatchers = [],
- elementMatchers = [],
- cached = compilerCache[ expando ][ selector ];
-
- if ( !cached ) {
- // Generate a function of recursive functions that can be used to check each element
- if ( !group ) {
- group = tokenize( selector );
- }
- i = group.length;
- while ( i-- ) {
- cached = matcherFromTokens( group[i] );
- if ( cached[ expando ] ) {
- setMatchers.push( cached );
- } else {
- elementMatchers.push( cached );
- }
- }
-
- // Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
- }
- return cached;
-};
-
-function multipleContexts( selector, contexts, results, seed ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- Sizzle( selector, contexts[i], results, seed );
- }
- return results;
-}
-
-function select( selector, context, results, seed, xml ) {
- var i, tokens, token, type, find,
- match = tokenize( selector ),
- j = match.length;
-
- if ( !seed ) {
- // Try to minimize operations if there is only one group
- if ( match.length === 1 ) {
-
- // Take a shortcut and set the context if the root selector is an ID
- tokens = match[0] = match[0].slice( 0 );
- if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
- context.nodeType === 9 && !xml &&
- Expr.relative[ tokens[1].type ] ) {
-
- context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
- if ( !context ) {
- return results;
- }
-
- selector = selector.slice( tokens.shift().length );
- }
-
- // Fetch a seed set for right-to-left matching
- for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
- token = tokens[i];
-
- // Abort if we hit a combinator
- if ( Expr.relative[ (type = token.type) ] ) {
- break;
- }
- if ( (find = Expr.find[ type ]) ) {
- // Search, expanding context for leading sibling combinators
- if ( (seed = find(
- token.matches[0].replace( rbackslash, "" ),
- rsibling.test( tokens[0].type ) && context.parentNode || context,
- xml
- )) ) {
-
- // If seed is empty or no tokens remain, we can return early
- tokens.splice( i, 1 );
- selector = seed.length && tokens.join("");
- if ( !selector ) {
- push.apply( results, slice.call( seed, 0 ) );
- return results;
- }
-
- break;
- }
- }
- }
- }
- }
-
- // Compile and execute a filtering function
- // Provide `match` to avoid retokenization if we modified the selector above
- compile( selector, match )(
- seed,
- context,
- xml,
- results,
- rsibling.test( selector )
- );
- return results;
-}
-
-if ( document.querySelectorAll ) {
- (function() {
- var disconnectedMatch,
- oldSelect = select,
- rescape = /'|\\/g,
- rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
-
- // qSa(:focus) reports false when true (Chrome 21),
- // A support test would require too much code (would include document ready)
- rbuggyQSA = [":focus"],
-
- // matchesSelector(:focus) reports false when true (Chrome 21),
- // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
- // A support test would require too much code (would include document ready)
- // just skip matchesSelector for :active
- rbuggyMatches = [ ":active", ":focus" ],
- matches = docElem.matchesSelector ||
- docElem.mozMatchesSelector ||
- docElem.webkitMatchesSelector ||
- docElem.oMatchesSelector ||
- docElem.msMatchesSelector;
-
- // Build QSA regex
- // Regex strategy adopted from Diego Perini
- assert(function( div ) {
- // Select is set to empty string on purpose
- // This is to test IE's treatment of not explictly
- // setting a boolean content attribute,
- // since its presence should be enough
- // http://bugs.jquery.com/ticket/12359
- div.innerHTML = "<select><option selected=''></option></select>";
-
- // IE8 - Some boolean attributes are not treated correctly
- if ( !div.querySelectorAll("[selected]").length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
- }
-
- // Webkit/Opera - :checked should return selected option elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- // IE8 throws error here (do not put tests after this one)
- if ( !div.querySelectorAll(":checked").length ) {
- rbuggyQSA.push(":checked");
- }
- });
-
- assert(function( div ) {
-
- // Opera 10-12/IE9 - ^= $= *= and empty values
- // Should not select anything
- div.innerHTML = "<p test=''></p>";
- if ( div.querySelectorAll("[test^='']").length ) {
- rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
- }
-
- // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
- // IE8 throws error here (do not put tests after this one)
- div.innerHTML = "<input type='hidden'/>";
- if ( !div.querySelectorAll(":enabled").length ) {
- rbuggyQSA.push(":enabled", ":disabled");
- }
- });
-
- // rbuggyQSA always contains :focus, so no need for a length check
- rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
-
- select = function( selector, context, results, seed, xml ) {
- // Only use querySelectorAll when not filtering,
- // when this is not xml,
- // and when no QSA bugs apply
- if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
- var groups, i,
- old = true,
- nid = expando,
- newContext = context,
- newSelector = context.nodeType === 9 && selector;
-
- // qSA works strangely on Element-rooted queries
- // We can work around this by specifying an extra ID on the root
- // and working up from there (Thanks to Andrew Dupont for the technique)
- // IE 8 doesn't work on object elements
- if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- groups = tokenize( selector );
-
- if ( (old = context.getAttribute("id")) ) {
- nid = old.replace( rescape, "\\$&" );
- } else {
- context.setAttribute( "id", nid );
- }
- nid = "[id='" + nid + "'] ";
-
- i = groups.length;
- while ( i-- ) {
- groups[i] = nid + groups[i].join("");
- }
- newContext = rsibling.test( selector ) && context.parentNode || context;
- newSelector = groups.join(",");
- }
-
- if ( newSelector ) {
- try {
- push.apply( results, slice.call( newContext.querySelectorAll(
- newSelector
- ), 0 ) );
- return results;
- } catch(qsaError) {
- } finally {
- if ( !old ) {
- context.removeAttribute("id");
- }
- }
- }
- }
-
- return oldSelect( selector, context, results, seed, xml );
- };
-
- if ( matches ) {
- assert(function( div ) {
- // Check to see if it's possible to do matchesSelector
- // on a disconnected node (IE 9)
- disconnectedMatch = matches.call( div, "div" );
-
- // This should fail with an exception
- // Gecko does not error, returns false instead
- try {
- matches.call( div, "[test!='']:sizzle" );
- rbuggyMatches.push( "!=", pseudos );
- } catch ( e ) {}
- });
-
- // rbuggyMatches always contains :active and :focus, so no need for a length check
- rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
-
- Sizzle.matchesSelector = function( elem, expr ) {
- // Make sure that attribute selectors are quoted
- expr = expr.replace( rattributeQuotes, "='$1']" );
-
- // rbuggyMatches always contains :active, so no need for an existence check
- if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
- try {
- var ret = matches.call( elem, expr );
-
- // IE 9's matchesSelector returns false on disconnected nodes
- if ( ret || disconnectedMatch ||
- // As well, disconnected nodes are said to be in a document
- // fragment in IE 9
- elem.document && elem.document.nodeType !== 11 ) {
- return ret;
- }
- } catch(e) {}
- }
-
- return Sizzle( expr, null, null, [ elem ] ).length > 0;
- };
- }
- })();
-}
-
-// Deprecated
-Expr.pseudos["nth"] = Expr.pseudos["eq"];
-
-// Back-compat
-function setFilters() {}
-Expr.filters = setFilters.prototype = Expr.pseudos;
-Expr.setFilters = new setFilters();
-
-// Override sizzle attribute retrieval
-Sizzle.attr = jQuery.attr;
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[":"] = jQuery.expr.pseudos;
-jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-
-
-})( window );
-var runtil = /Until$/,
- rparentsprev = /^(?:parents|prev(?:Until|All))/,
- isSimple = /^.[^:#\[\.,]*$/,
- rneedsContext = jQuery.expr.match.needsContext,
- // methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.fn.extend({
- find: function( selector ) {
- var i, l, length, n, r, ret,
- self = this;
-
- if ( typeof selector !== "string" ) {
- return jQuery( selector ).filter(function() {
- for ( i = 0, l = self.length; i < l; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- });
- }
-
- ret = this.pushStack( "", "find", selector );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- length = ret.length;
- jQuery.find( selector, this[i], ret );
-
- if ( i > 0 ) {
- // Make sure that the results are unique
- for ( n = length; n < ret.length; n++ ) {
- for ( r = 0; r < length; r++ ) {
- if ( ret[r] === ret[n] ) {
- ret.splice(n--, 1);
- break;
- }
- }
- }
- }
- }
-
- return ret;
- },
-
- has: function( target ) {
- var i,
- targets = jQuery( target, this ),
- len = targets.length;
-
- return this.filter(function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
- return true;
- }
- }
- });
- },
-
- not: function( selector ) {
- return this.pushStack( winnow(this, selector, false), "not", selector);
- },
-
- filter: function( selector ) {
- return this.pushStack( winnow(this, selector, true), "filter", selector );
- },
-
- is: function( selector ) {
- return !!selector && (
- typeof selector === "string" ?
- // If this is a positional/relative selector, check membership in the returned set
- // so $("p:first").is("p:last") won't return true for a doc with two "p".
- rneedsContext.test( selector ) ?
- jQuery( selector, this.context ).index( this[0] ) >= 0 :
- jQuery.filter( selector, this ).length > 0 :
- this.filter( selector ).length > 0 );
- },
-
- closest: function( selectors, context ) {
- var cur,
- i = 0,
- l = this.length,
- ret = [],
- pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
- jQuery( selectors, context || this.context ) :
- 0;
-
- for ( ; i < l; i++ ) {
- cur = this[i];
-
- while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
- if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
- ret.push( cur );
- break;
- }
- cur = cur.parentNode;
- }
- }
-
- ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
-
- return this.pushStack( ret, "closest", selectors );
- },
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
- }
-
- // index in selector
- if ( typeof elem === "string" ) {
- return jQuery.inArray( this[0], jQuery( elem ) );
- }
-
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
-
- add: function( selector, context ) {
- var set = typeof selector === "string" ?
- jQuery( selector, context ) :
- jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
- all = jQuery.merge( this.get(), set );
-
- return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
- all :
- jQuery.unique( all ) );
- },
-
- addBack: function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter(selector)
- );
- }
-});
-
-jQuery.fn.andSelf = jQuery.fn.addBack;
-
-// A painfully simple check to see if an element is disconnected
-// from a document (should be improved, where feasible).
-function isDisconnected( node ) {
- return !node || !node.parentNode || node.parentNode.nodeType === 11;
-}
-
-function sibling( cur, dir ) {
- do {
- cur = cur[ dir ];
- } while ( cur && cur.nodeType !== 1 );
-
- return cur;
-}
-
-jQuery.each({
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return jQuery.dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return sibling( elem, "nextSibling" );
- },
- prev: function( elem ) {
- return sibling( elem, "previousSibling" );
- },
- nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
- },
- children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.merge( [], elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until );
-
- if ( !runtil.test( name ) ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
-
- ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
-
- if ( this.length > 1 && rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
-
- return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
- };
-});
-
-jQuery.extend({
- filter: function( expr, elems, not ) {
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- return elems.length === 1 ?
- jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
- jQuery.find.matches(expr, elems);
- },
-
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
-
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
-
- sibling: function( n, elem ) {
- var r = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
-
- return r;
- }
-});
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, keep ) {
-
- // Can't pass null or undefined to indexOf in Firefox 4
- // Set to 0 to skip string check
- qualifier = qualifier || 0;
-
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep(elements, function( elem, i ) {
- var retVal = !!qualifier.call( elem, i, elem );
- return retVal === keep;
- });
-
- } else if ( qualifier.nodeType ) {
- return jQuery.grep(elements, function( elem, i ) {
- return ( elem === qualifier ) === keep;
- });
-
- } else if ( typeof qualifier === "string" ) {
- var filtered = jQuery.grep(elements, function( elem ) {
- return elem.nodeType === 1;
- });
-
- if ( isSimple.test( qualifier ) ) {
- return jQuery.filter(qualifier, filtered, !keep);
- } else {
- qualifier = jQuery.filter( qualifier, filtered );
- }
- }
-
- return jQuery.grep(elements, function( elem, i ) {
- return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
- });
-}
-function createSafeFragment( document ) {
- var list = nodeNames.split( "|" ),
- safeFrag = document.createDocumentFragment();
-
- if ( safeFrag.createElement ) {
- while ( list.length ) {
- safeFrag.createElement(
- list.pop()
- );
- }
- }
- return safeFrag;
-}
-
-var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
- "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
- rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
- rleadingWhitespace = /^\s+/,
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
- rtagName = /<([\w:]+)/,
- rtbody = /<tbody/i,
- rhtml = /<|&#?\w+;/,
- rnoInnerhtml = /<(?:script|style|link)/i,
- rnocache = /<(?:script|object|embed|option|style)/i,
- rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
- rcheckableType = /^(?:checkbox|radio)$/,
- // checked="checked" or checked
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
- rscriptType = /\/(java|ecma)script/i,
- rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
- wrapMap = {
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
- legend: [ 1, "<fieldset>", "</fieldset>" ],
- thead: [ 1, "<table>", "</table>" ],
- tr: [ 2, "<table><tbody>", "</tbody></table>" ],
- td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
- col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
- area: [ 1, "<map>", "</map>" ],
- _default: [ 0, "", "" ]
- },
- safeFragment = createSafeFragment( document ),
- fragmentDiv = safeFragment.appendChild( document.createElement("div") );
-
-wrapMap.optgroup = wrapMap.option;
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
-// unless wrapped in a div with non-breaking characters in front of it.
-if ( !jQuery.support.htmlSerialize ) {
- wrapMap._default = [ 1, "X<div>", "</div>" ];
-}
-
-jQuery.fn.extend({
- text: function( value ) {
- return jQuery.access( this, function( value ) {
- return value === undefined ?
- jQuery.text( this ) :
- this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
- }, null, value, arguments.length );
- },
-
- wrapAll: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapAll( html.call(this, i) );
- });
- }
-
- if ( this[0] ) {
- // The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
-
- if ( this[0].parentNode ) {
- wrap.insertBefore( this[0] );
- }
-
- wrap.map(function() {
- var elem = this;
-
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
- }
-
- return elem;
- }).append( this );
- }
-
- return this;
- },
-
- wrapInner: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapInner( html.call(this, i) );
- });
- }
-
- return this.each(function() {
- var self = jQuery( this ),
- contents = self.contents();
-
- if ( contents.length ) {
- contents.wrapAll( html );
-
- } else {
- self.append( html );
- }
- });
- },
-
- wrap: function( html ) {
- var isFunction = jQuery.isFunction( html );
-
- return this.each(function(i) {
- jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
- });
- },
-
- unwrap: function() {
- return this.parent().each(function() {
- if ( !jQuery.nodeName( this, "body" ) ) {
- jQuery( this ).replaceWith( this.childNodes );
- }
- }).end();
- },
-
- append: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 ) {
- this.appendChild( elem );
- }
- });
- },
-
- prepend: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 ) {
- this.insertBefore( elem, this.firstChild );
- }
- });
- },
-
- before: function() {
- if ( !isDisconnected( this[0] ) ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this );
- });
- }
-
- if ( arguments.length ) {
- var set = jQuery.clean( arguments );
- return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
- }
- },
-
- after: function() {
- if ( !isDisconnected( this[0] ) ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- });
- }
-
- if ( arguments.length ) {
- var set = jQuery.clean( arguments );
- return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
- }
- },
-
- // keepData is for internal use only--do not document
- remove: function( selector, keepData ) {
- var elem,
- i = 0;
-
- for ( ; (elem = this[i]) != null; i++ ) {
- if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
- if ( !keepData && elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- jQuery.cleanData( [ elem ] );
- }
-
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
- }
- }
-
- return this;
- },
-
- empty: function() {
- var elem,
- i = 0;
-
- for ( ; (elem = this[i]) != null; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- }
-
- // Remove any remaining nodes
- while ( elem.firstChild ) {
- elem.removeChild( elem.firstChild );
- }
- }
-
- return this;
- },
-
- clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
-
- return this.map( function () {
- return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
- });
- },
-
- html: function( value ) {
- return jQuery.access( this, function( value ) {
- var elem = this[0] || {},
- i = 0,
- l = this.length;
-
- if ( value === undefined ) {
- return elem.nodeType === 1 ?
- elem.innerHTML.replace( rinlinejQuery, "" ) :
- undefined;
- }
-
- // See if we can take a shortcut and just use innerHTML
- if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
- ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
- ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
- !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
-
- value = value.replace( rxhtmlTag, "<$1></$2>" );
-
- try {
- for (; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- elem = this[i] || {};
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName( "*" ) );
- elem.innerHTML = value;
- }
- }
-
- elem = 0;
-
- // If using innerHTML throws an exception, use the fallback method
- } catch(e) {}
- }
-
- if ( elem ) {
- this.empty().append( value );
- }
- }, null, value, arguments.length );
- },
-
- replaceWith: function( value ) {
- if ( !isDisconnected( this[0] ) ) {
- // Make sure that the elements are removed from the DOM before they are inserted
- // this can help fix replacing a parent with child elements
- if ( jQuery.isFunction( value ) ) {
- return this.each(function(i) {
- var self = jQuery(this), old = self.html();
- self.replaceWith( value.call( this, i, old ) );
- });
- }
-
- if ( typeof value !== "string" ) {
- value = jQuery( value ).detach();
- }
-
- return this.each(function() {
- var next = this.nextSibling,
- parent = this.parentNode;
-
- jQuery( this ).remove();
-
- if ( next ) {
- jQuery(next).before( value );
- } else {
- jQuery(parent).append( value );
- }
- });
- }
-
- return this.length ?
- this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
- this;
- },
-
- detach: function( selector ) {
- return this.remove( selector, true );
- },
-
- domManip: function( args, table, callback ) {
-
- // Flatten any nested arrays
- args = [].concat.apply( [], args );
-
- var results, first, fragment, iNoClone,
- i = 0,
- value = args[0],
- scripts = [],
- l = this.length;
-
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
- return this.each(function() {
- jQuery(this).domManip( args, table, callback );
- });
- }
-
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- args[0] = value.call( this, i, table ? self.html() : undefined );
- self.domManip( args, table, callback );
- });
- }
-
- if ( this[0] ) {
- results = jQuery.buildFragment( args, this, scripts );
- fragment = results.fragment;
- first = fragment.firstChild;
-
- if ( fragment.childNodes.length === 1 ) {
- fragment = first;
- }
-
- if ( first ) {
- table = table && jQuery.nodeName( first, "tr" );
-
- // Use the original fragment for the last item instead of the first because it can end up
- // being emptied incorrectly in certain situations (#8070).
- // Fragments from the fragment cache must always be cloned and never used in place.
- for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
- callback.call(
- table && jQuery.nodeName( this[i], "table" ) ?
- findOrAppend( this[i], "tbody" ) :
- this[i],
- i === iNoClone ?
- fragment :
- jQuery.clone( fragment, true, true )
- );
- }
- }
-
- // Fix #11809: Avoid leaking memory
- fragment = first = null;
-
- if ( scripts.length ) {
- jQuery.each( scripts, function( i, elem ) {
- if ( elem.src ) {
- if ( jQuery.ajax ) {
- jQuery.ajax({
- url: elem.src,
- type: "GET",
- dataType: "script",
- async: false,
- global: false,
- "throws": true
- });
- } else {
- jQuery.error("no ajax");
- }
- } else {
- jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
- }
-
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
- });
- }
- }
-
- return this;
- }
-});
-
-function findOrAppend( elem, tag ) {
- return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
-}
-
-function cloneCopyEvent( src, dest ) {
-
- if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
- return;
- }
-
- var type, i, l,
- oldData = jQuery._data( src ),
- curData = jQuery._data( dest, oldData ),
- events = oldData.events;
-
- if ( events ) {
- delete curData.handle;
- curData.events = {};
-
- for ( type in events ) {
- for ( i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ] );
- }
- }
- }
-
- // make the cloned public data object a copy from the original
- if ( curData.data ) {
- curData.data = jQuery.extend( {}, curData.data );
- }
-}
-
-function cloneFixAttributes( src, dest ) {
- var nodeName;
-
- // We do not need to do anything for non-Elements
- if ( dest.nodeType !== 1 ) {
- return;
- }
-
- // clearAttributes removes the attributes, which we don't want,
- // but also removes the attachEvent events, which we *do* want
- if ( dest.clearAttributes ) {
- dest.clearAttributes();
- }
-
- // mergeAttributes, in contrast, only merges back on the
- // original attributes, not the events
- if ( dest.mergeAttributes ) {
- dest.mergeAttributes( src );
- }
-
- nodeName = dest.nodeName.toLowerCase();
-
- if ( nodeName === "object" ) {
- // IE6-10 improperly clones children of object elements using classid.
- // IE10 throws NoModificationAllowedError if parent is null, #12132.
- if ( dest.parentNode ) {
- dest.outerHTML = src.outerHTML;
- }
-
- // This path appears unavoidable for IE9. When cloning an object
- // element in IE9, the outerHTML strategy above is not sufficient.
- // If the src has innerHTML and the destination does not,
- // copy the src.innerHTML into the dest.innerHTML. #10324
- if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
- dest.innerHTML = src.innerHTML;
- }
-
- } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
- // IE6-8 fails to persist the checked state of a cloned checkbox
- // or radio button. Worse, IE6-7 fail to give the cloned element
- // a checked appearance if the defaultChecked value isn't also set
-
- dest.defaultChecked = dest.checked = src.checked;
-
- // IE6-7 get confused and end up setting the value of a cloned
- // checkbox/radio button to an empty string instead of "on"
- if ( dest.value !== src.value ) {
- dest.value = src.value;
- }
-
- // IE6-8 fails to return the selected option to the default selected
- // state when cloning options
- } else if ( nodeName === "option" ) {
- dest.selected = src.defaultSelected;
-
- // IE6-8 fails to set the defaultValue to the correct value when
- // cloning other types of input fields
- } else if ( nodeName === "input" || nodeName === "textarea" ) {
- dest.defaultValue = src.defaultValue;
-
- // IE blanks contents when cloning scripts
- } else if ( nodeName === "script" && dest.text !== src.text ) {
- dest.text = src.text;
- }
-
- // Event data gets referenced instead of copied if the expando
- // gets copied too
- dest.removeAttribute( jQuery.expando );
-}
-
-jQuery.buildFragment = function( args, context, scripts ) {
- var fragment, cacheable, cachehit,
- first = args[ 0 ];
-
- // Set context from what may come in as undefined or a jQuery collection or a node
- // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
- // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
- context = context || document;
- context = !context.nodeType && context[0] || context;
- context = context.ownerDocument || context;
-
- // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
- // Cloning options loses the selected state, so don't cache them
- // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
- // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
- // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
- if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
- first.charAt(0) === "<" && !rnocache.test( first ) &&
- (jQuery.support.checkClone || !rchecked.test( first )) &&
- (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
-
- // Mark cacheable and look for a hit
- cacheable = true;
- fragment = jQuery.fragments[ first ];
- cachehit = fragment !== undefined;
- }
-
- if ( !fragment ) {
- fragment = context.createDocumentFragment();
- jQuery.clean( args, context, fragment, scripts );
-
- // Update the cache, but only store false
- // unless this is a second parsing of the same content
- if ( cacheable ) {
- jQuery.fragments[ first ] = cachehit && fragment;
- }
- }
-
- return { fragment: fragment, cacheable: cacheable };
-};
-
-jQuery.fragments = {};
-
-jQuery.each({
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
-}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var elems,
- i = 0,
- ret = [],
- insert = jQuery( selector ),
- l = insert.length,
- parent = this.length === 1 && this[0].parentNode;
-
- if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
- insert[ original ]( this[0] );
- return this;
- } else {
- for ( ; i < l; i++ ) {
- elems = ( i > 0 ? this.clone(true) : this ).get();
- jQuery( insert[i] )[ original ]( elems );
- ret = ret.concat( elems );
- }
-
- return this.pushStack( ret, name, insert.selector );
- }
- };
-});
-
-function getAll( elem ) {
- if ( typeof elem.getElementsByTagName !== "undefined" ) {
- return elem.getElementsByTagName( "*" );
-
- } else if ( typeof elem.querySelectorAll !== "undefined" ) {
- return elem.querySelectorAll( "*" );
-
- } else {
- return [];
- }
-}
-
-// Used in clean, fixes the defaultChecked property
-function fixDefaultChecked( elem ) {
- if ( rcheckableType.test( elem.type ) ) {
- elem.defaultChecked = elem.checked;
- }
-}
-
-jQuery.extend({
- clone: function( elem, dataAndEvents, deepDataAndEvents ) {
- var srcElements,
- destElements,
- i,
- clone;
-
- if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
- clone = elem.cloneNode( true );
-
- // IE<=8 does not properly clone detached, unknown element nodes
- } else {
- fragmentDiv.innerHTML = elem.outerHTML;
- fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
- }
-
- if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
- (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
- // IE copies events bound via attachEvent when using cloneNode.
- // Calling detachEvent on the clone will also remove the events
- // from the original. In order to get around this, we use some
- // proprietary methods to clear the events. Thanks to MooTools
- // guys for this hotness.
-
- cloneFixAttributes( elem, clone );
-
- // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
- srcElements = getAll( elem );
- destElements = getAll( clone );
-
- // Weird iteration because IE will replace the length property
- // with an element if you are cloning the body and one of the
- // elements on the page has a name or id of "length"
- for ( i = 0; srcElements[i]; ++i ) {
- // Ensure that the destination node is not null; Fixes #9587
- if ( destElements[i] ) {
- cloneFixAttributes( srcElements[i], destElements[i] );
- }
- }
- }
-
- // Copy the events from the original to the clone
- if ( dataAndEvents ) {
- cloneCopyEvent( elem, clone );
-
- if ( deepDataAndEvents ) {
- srcElements = getAll( elem );
- destElements = getAll( clone );
-
- for ( i = 0; srcElements[i]; ++i ) {
- cloneCopyEvent( srcElements[i], destElements[i] );
- }
- }
- }
-
- srcElements = destElements = null;
-
- // Return the cloned set
- return clone;
- },
-
- clean: function( elems, context, fragment, scripts ) {
- var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
- safe = context === document && safeFragment,
- ret = [];
-
- // Ensure that context is a document
- if ( !context || typeof context.createDocumentFragment === "undefined" ) {
- context = document;
- }
-
- // Use the already-created safe fragment if context permits
- for ( i = 0; (elem = elems[i]) != null; i++ ) {
- if ( typeof elem === "number" ) {
- elem += "";
- }
-
- if ( !elem ) {
- continue;
- }
-
- // Convert html string into DOM nodes
- if ( typeof elem === "string" ) {
- if ( !rhtml.test( elem ) ) {
- elem = context.createTextNode( elem );
- } else {
- // Ensure a safe container in which to render the html
- safe = safe || createSafeFragment( context );
- div = context.createElement("div");
- safe.appendChild( div );
-
- // Fix "XHTML"-style tags in all browsers
- elem = elem.replace(rxhtmlTag, "<$1></$2>");
-
- // Go to html and back, then peel off extra wrappers
- tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
- wrap = wrapMap[ tag ] || wrapMap._default;
- depth = wrap[0];
- div.innerHTML = wrap[1] + elem + wrap[2];
-
- // Move to the right depth
- while ( depth-- ) {
- div = div.lastChild;
- }
-
- // Remove IE's autoinserted <tbody> from table fragments
- if ( !jQuery.support.tbody ) {
-
- // String was a <table>, *may* have spurious <tbody>
- hasBody = rtbody.test(elem);
- tbody = tag === "table" && !hasBody ?
- div.firstChild && div.firstChild.childNodes :
-
- // String was a bare <thead> or <tfoot>
- wrap[1] === "<table>" && !hasBody ?
- div.childNodes :
- [];
-
- for ( j = tbody.length - 1; j >= 0 ; --j ) {
- if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
- tbody[ j ].parentNode.removeChild( tbody[ j ] );
- }
- }
- }
-
- // IE completely kills leading whitespace when innerHTML is used
- if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
- }
-
- elem = div.childNodes;
-
- // Take out of fragment container (we need a fresh div each time)
- div.parentNode.removeChild( div );
- }
- }
-
- if ( elem.nodeType ) {
- ret.push( elem );
- } else {
- jQuery.merge( ret, elem );
- }
- }
-
- // Fix #11356: Clear elements from safeFragment
- if ( div ) {
- elem = div = safe = null;
- }
-
- // Reset defaultChecked for any radios and checkboxes
- // about to be appended to the DOM in IE 6/7 (#8060)
- if ( !jQuery.support.appendChecked ) {
- for ( i = 0; (elem = ret[i]) != null; i++ ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
- fixDefaultChecked( elem );
- } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
- jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
- }
- }
- }
-
- // Append elements to a provided document fragment
- if ( fragment ) {
- // Special handling of each script element
- handleScript = function( elem ) {
- // Check if we consider it executable
- if ( !elem.type || rscriptType.test( elem.type ) ) {
- // Detach the script and store it in the scripts array (if provided) or the fragment
- // Return truthy to indicate that it has been handled
- return scripts ?
- scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
- fragment.appendChild( elem );
- }
- };
-
- for ( i = 0; (elem = ret[i]) != null; i++ ) {
- // Check if we're done after handling an executable script
- if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
- // Append to fragment and handle embedded scripts
- fragment.appendChild( elem );
- if ( typeof elem.getElementsByTagName !== "undefined" ) {
- // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
- jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
-
- // Splice the scripts into ret after their former ancestor and advance our index beyond them
- ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
- i += jsTags.length;
- }
- }
- }
- }
-
- return ret;
- },
-
- cleanData: function( elems, /* internal */ acceptData ) {
- var data, id, elem, type,
- i = 0,
- internalKey = jQuery.expando,
- cache = jQuery.cache,
- deleteExpando = jQuery.support.deleteExpando,
- special = jQuery.event.special;
-
- for ( ; (elem = elems[i]) != null; i++ ) {
-
- if ( acceptData || jQuery.acceptData( elem ) ) {
-
- id = elem[ internalKey ];
- data = id && cache[ id ];
-
- if ( data ) {
- if ( data.events ) {
- for ( type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
-
- // This is a shortcut to avoid jQuery.event.remove's overhead
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- }
-
- // Remove cache only if it was not already removed by jQuery.event.remove
- if ( cache[ id ] ) {
-
- delete cache[ id ];
-
- // IE does not allow us to delete expando properties from nodes,
- // nor does it have a removeAttribute function on Document nodes;
- // we must handle all of these cases
- if ( deleteExpando ) {
- delete elem[ internalKey ];
-
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( internalKey );
-
- } else {
- elem[ internalKey ] = null;
- }
-
- jQuery.deletedIds.push( id );
- }
- }
- }
- }
- }
-});
-// Limit scope pollution from any deprecated API
-(function() {
-
-var matched, browser;
-
-// Use of jQuery.browser is frowned upon.
-// More details: http://api.jquery.com/jQuery.browser
-// jQuery.uaMatch maintained for back-compat
-jQuery.uaMatch = function( ua ) {
- ua = ua.toLowerCase();
-
- var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
- /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
- /(msie) ([\w.]+)/.exec( ua ) ||
- ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
- [];
-
- return {
- browser: match[ 1 ] || "",
- version: match[ 2 ] || "0"
- };
-};
-
-matched = jQuery.uaMatch( navigator.userAgent );
-browser = {};
-
-if ( matched.browser ) {
- browser[ matched.browser ] = true;
- browser.version = matched.version;
-}
-
-// Chrome is Webkit, but Webkit is also Safari.
-if ( browser.chrome ) {
- browser.webkit = true;
-} else if ( browser.webkit ) {
- browser.safari = true;
-}
-
-jQuery.browser = browser;
-
-jQuery.sub = function() {
- function jQuerySub( selector, context ) {
- return new jQuerySub.fn.init( selector, context );
- }
- jQuery.extend( true, jQuerySub, this );
- jQuerySub.superclass = this;
- jQuerySub.fn = jQuerySub.prototype = this();
- jQuerySub.fn.constructor = jQuerySub;
- jQuerySub.sub = this.sub;
- jQuerySub.fn.init = function init( selector, context ) {
- if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
- context = jQuerySub( context );
- }
-
- return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
- };
- jQuerySub.fn.init.prototype = jQuerySub.fn;
- var rootjQuerySub = jQuerySub(document);
- return jQuerySub;
-};
-
-})();
-var curCSS, iframe, iframeDoc,
- ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity=([^)]*)/,
- rposition = /^(top|right|bottom|left)$/,
- // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
- // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
- rdisplayswap = /^(none|table(?!-c[ea]).+)/,
- rmargin = /^margin/,
- rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
- rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
- rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
- elemdisplay = {},
-
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssNormalTransform = {
- letterSpacing: 0,
- fontWeight: 400
- },
-
- cssExpand = [ "Top", "Right", "Bottom", "Left" ],
- cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
-
- eventsToggle = jQuery.fn.toggle;
-
-// return a css property mapped to a potentially vendor prefixed property
-function vendorPropName( style, name ) {
-
- // shortcut for names that are not vendor prefixed
- if ( name in style ) {
- return name;
- }
-
- // check for vendor prefixed names
- var capName = name.charAt(0).toUpperCase() + name.slice(1),
- origName = name,
- i = cssPrefixes.length;
-
- while ( i-- ) {
- name = cssPrefixes[ i ] + capName;
- if ( name in style ) {
- return name;
- }
- }
-
- return origName;
-}
-
-function isHidden( elem, el ) {
- elem = el || elem;
- return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
-}
-
-function showHide( elements, show ) {
- var elem, display,
- values = [],
- index = 0,
- length = elements.length;
-
- for ( ; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
- values[ index ] = jQuery._data( elem, "olddisplay" );
- if ( show ) {
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !values[ index ] && elem.style.display === "none" ) {
- elem.style.display = "";
- }
-
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( elem.style.display === "" && isHidden( elem ) ) {
- values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
- }
- } else {
- display = curCSS( elem, "display" );
-
- if ( !values[ index ] && display !== "none" ) {
- jQuery._data( elem, "olddisplay", display );
- }
- }
- }
-
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( index = 0; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
- if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
- elem.style.display = show ? values[ index ] || "" : "none";
- }
- }
-
- return elements;
-}
-
-jQuery.fn.extend({
- css: function( name, value ) {
- return jQuery.access( this, function( elem, name, value ) {
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- }, name, value, arguments.length > 1 );
- },
- show: function() {
- return showHide( this, true );
- },
- hide: function() {
- return showHide( this );
- },
- toggle: function( state, fn2 ) {
- var bool = typeof state === "boolean";
-
- if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
- return eventsToggle.apply( this, arguments );
- }
-
- return this.each(function() {
- if ( bool ? state : isHidden( this ) ) {
- jQuery( this ).show();
- } else {
- jQuery( this ).hide();
- }
- });
- }
-});
-
-jQuery.extend({
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity" );
- return ret === "" ? "1" : ret;
-
- }
- }
- }
- },
-
- // Exclude the following css properties to add px
- cssNumber: {
- "fillOpacity": true,
- "fontWeight": true,
- "lineHeight": true,
- "opacity": true,
- "orphans": true,
- "widows": true,
- "zIndex": true,
- "zoom": true
- },
-
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {
- // normalize float css property
- "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
- },
-
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
-
- // Make sure that we're working with the right name
- var ret, type, hooks,
- origName = jQuery.camelCase( name ),
- style = elem.style;
-
- name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // Check if we're setting a value
- if ( value !== undefined ) {
- type = typeof value;
-
- // convert relative number strings (+= or -=) to relative numbers. #7345
- if ( type === "string" && (ret = rrelNum.exec( value )) ) {
- value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
- // Fixes bug #9237
- type = "number";
- }
-
- // Make sure that NaN and null values aren't set. See: #7116
- if ( value == null || type === "number" && isNaN( value ) ) {
- return;
- }
-
- // If a number was passed in, add 'px' to the (except for certain CSS properties)
- if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
- value += "px";
- }
-
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
- // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
- // Fixes bug #5509
- try {
- style[ name ] = value;
- } catch(e) {}
- }
-
- } else {
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
- return ret;
- }
-
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
-
- css: function( elem, name, numeric, extra ) {
- var val, num, hooks,
- origName = jQuery.camelCase( name );
-
- // Make sure that we're working with the right name
- name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks ) {
- val = hooks.get( elem, true, extra );
- }
-
- // Otherwise, if a way to get the computed value exists, use that
- if ( val === undefined ) {
- val = curCSS( elem, name );
- }
-
- //convert "normal" to computed value
- if ( val === "normal" && name in cssNormalTransform ) {
- val = cssNormalTransform[ name ];
- }
-
- // Return, converting to number if forced or a qualifier was provided and val looks numeric
- if ( numeric || extra !== undefined ) {
- num = parseFloat( val );
- return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
- }
- return val;
- },
-
- // A method for quickly swapping in/out CSS properties to get correct calculations
- swap: function( elem, options, callback ) {
- var ret, name,
- old = {};
-
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- ret = callback.call( elem );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
-
- return ret;
- }
-});
-
-// NOTE: To any future maintainer, we've window.getComputedStyle
-// because jsdom on node.js will break without it.
-if ( window.getComputedStyle ) {
- curCSS = function( elem, name ) {
- var ret, width, minWidth, maxWidth,
- computed = window.getComputedStyle( elem, null ),
- style = elem.style;
-
- if ( computed ) {
-
- ret = computed[ name ];
- if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
- ret = jQuery.style( elem, name );
- }
-
- // A tribute to the "awesome hack by Dean Edwards"
- // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
- // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
- // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
- if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
- width = style.width;
- minWidth = style.minWidth;
- maxWidth = style.maxWidth;
-
- style.minWidth = style.maxWidth = style.width = ret;
- ret = computed.width;
-
- style.width = width;
- style.minWidth = minWidth;
- style.maxWidth = maxWidth;
- }
- }
-
- return ret;
- };
-} else if ( document.documentElement.currentStyle ) {
- curCSS = function( elem, name ) {
- var left, rsLeft,
- ret = elem.currentStyle && elem.currentStyle[ name ],
- style = elem.style;
-
- // Avoid setting ret to empty string here
- // so we don't default to auto
- if ( ret == null && style && style[ name ] ) {
- ret = style[ name ];
- }
-
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- // but not position css attributes, as those are proportional to the parent element instead
- // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
- if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
-
- // Remember the original values
- left = style.left;
- rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
-
- // Put in the new values to get a computed value out
- if ( rsLeft ) {
- elem.runtimeStyle.left = elem.currentStyle.left;
- }
- style.left = name === "fontSize" ? "1em" : ret;
- ret = style.pixelLeft + "px";
-
- // Revert the changed values
- style.left = left;
- if ( rsLeft ) {
- elem.runtimeStyle.left = rsLeft;
- }
- }
-
- return ret === "" ? "auto" : ret;
- };
-}
-
-function setPositiveNumber( elem, value, subtract ) {
- var matches = rnumsplit.exec( value );
- return matches ?
- Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
- value;
-}
-
-function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
- var i = extra === ( isBorderBox ? "border" : "content" ) ?
- // If we already have the right measurement, avoid augmentation
- 4 :
- // Otherwise initialize for horizontal or vertical properties
- name === "width" ? 1 : 0,
-
- val = 0;
-
- for ( ; i < 4; i += 2 ) {
- // both box models exclude margin, so add it if we want it
- if ( extra === "margin" ) {
- // we use jQuery.css instead of curCSS here
- // because of the reliableMarginRight CSS hook!
- val += jQuery.css( elem, extra + cssExpand[ i ], true );
- }
-
- // From this point on we use curCSS for maximum performance (relevant in animations)
- if ( isBorderBox ) {
- // border-box includes padding, so remove it if we want content
- if ( extra === "content" ) {
- val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
- }
-
- // at this point, extra isn't border nor margin, so remove border
- if ( extra !== "margin" ) {
- val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
- }
- } else {
- // at this point, extra isn't content, so add padding
- val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
-
- // at this point, extra isn't content nor padding, so add border
- if ( extra !== "padding" ) {
- val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
- }
- }
- }
-
- return val;
-}
-
-function getWidthOrHeight( elem, name, extra ) {
-
- // Start with offset property, which is equivalent to the border-box value
- var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
- valueIsBorderBox = true,
- isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
-
- // some non-html elements return undefined for offsetWidth, so check for null/undefined
- // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
- // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
- if ( val <= 0 || val == null ) {
- // Fall back to computed then uncomputed css if necessary
- val = curCSS( elem, name );
- if ( val < 0 || val == null ) {
- val = elem.style[ name ];
- }
-
- // Computed unit is not pixels. Stop here and return.
- if ( rnumnonpx.test(val) ) {
- return val;
- }
-
- // we need the check for style in case a browser which returns unreliable values
- // for getComputedStyle silently falls back to the reliable elem.style
- valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
-
- // Normalize "", auto, and prepare for extra
- val = parseFloat( val ) || 0;
- }
-
- // use the active box-sizing model to add/subtract irrelevant styles
- return ( val +
- augmentWidthOrHeight(
- elem,
- name,
- extra || ( isBorderBox ? "border" : "content" ),
- valueIsBorderBox
- )
- ) + "px";
-}
-
-
-// Try to determine the default display value of an element
-function css_defaultDisplay( nodeName ) {
- if ( elemdisplay[ nodeName ] ) {
- return elemdisplay[ nodeName ];
- }
-
- var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
- display = elem.css("display");
- elem.remove();
-
- // If the simple way fails,
- // get element's real default display by attaching it to a temp iframe
- if ( display === "none" || display === "" ) {
- // Use the already-created iframe if possible
- iframe = document.body.appendChild(
- iframe || jQuery.extend( document.createElement("iframe"), {
- frameBorder: 0,
- width: 0,
- height: 0
- })
- );
-
- // Create a cacheable copy of the iframe document on first call.
- // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
- // document to it; WebKit & Firefox won't allow reusing the iframe document.
- if ( !iframeDoc || !iframe.createElement ) {
- iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
- iframeDoc.write("<!doctype html><html><body>");
- iframeDoc.close();
- }
-
- elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
-
- display = curCSS( elem, "display" );
- document.body.removeChild( iframe );
- }
-
- // Store the correct default display
- elemdisplay[ nodeName ] = display;
-
- return display;
-}
-
-jQuery.each([ "height", "width" ], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- if ( computed ) {
- // certain elements can have dimension info if we invisibly show them
- // however, it must have a current display style that would benefit from this
- if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
- return jQuery.swap( elem, cssShow, function() {
- return getWidthOrHeight( elem, name, extra );
- });
- } else {
- return getWidthOrHeight( elem, name, extra );
- }
- }
- },
-
- set: function( elem, value, extra ) {
- return setPositiveNumber( elem, value, extra ?
- augmentWidthOrHeight(
- elem,
- name,
- extra,
- jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
- ) : 0
- );
- }
- };
-});
-
-if ( !jQuery.support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
- // IE uses filters for opacity
- return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
- ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
- computed ? "1" : "";
- },
-
- set: function( elem, value ) {
- var style = elem.style,
- currentStyle = elem.currentStyle,
- opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
- filter = currentStyle && currentStyle.filter || style.filter || "";
-
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
-
- // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
- if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
- style.removeAttribute ) {
-
- // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
- // if "filter:" is present at all, clearType is disabled, we want to avoid this
- // style.removeAttribute is IE Only, but so apparently is this code path...
- style.removeAttribute( "filter" );
-
- // if there there is no filter style applied in a css rule, we are done
- if ( currentStyle && !currentStyle.filter ) {
- return;
- }
- }
-
- // otherwise, set new filter values
- style.filter = ralpha.test( filter ) ?
- filter.replace( ralpha, opacity ) :
- filter + " " + opacity;
- }
- };
-}
-
-// These hooks cannot be added until DOM ready because the support test
-// for it is not run until after DOM ready
-jQuery(function() {
- if ( !jQuery.support.reliableMarginRight ) {
- jQuery.cssHooks.marginRight = {
- get: function( elem, computed ) {
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- // Work around by temporarily setting element display to inline-block
- return jQuery.swap( elem, { "display": "inline-block" }, function() {
- if ( computed ) {
- return curCSS( elem, "marginRight" );
- }
- });
- }
- };
- }
-
- // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
- // getComputedStyle returns percent when specified for top/left/bottom/right
- // rather than make the css module depend on the offset module, we just check for it here
- if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
- jQuery.each( [ "top", "left" ], function( i, prop ) {
- jQuery.cssHooks[ prop ] = {
- get: function( elem, computed ) {
- if ( computed ) {
- var ret = curCSS( elem, prop );
- // if curCSS returns percentage, fallback to offset
- return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
- }
- }
- };
- });
- }
-
-});
-
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.hidden = function( elem ) {
- return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
- };
-
- jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
- };
-}
-
-// These hooks are used by animate to expand properties
-jQuery.each({
- margin: "",
- padding: "",
- border: "Width"
-}, function( prefix, suffix ) {
- jQuery.cssHooks[ prefix + suffix ] = {
- expand: function( value ) {
- var i,
-
- // assumes a single number if not a string
- parts = typeof value === "string" ? value.split(" ") : [ value ],
- expanded = {};
-
- for ( i = 0; i < 4; i++ ) {
- expanded[ prefix + cssExpand[ i ] + suffix ] =
- parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
- }
-
- return expanded;
- }
- };
-
- if ( !rmargin.test( prefix ) ) {
- jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
- }
-});
-var r20 = /%20/g,
- rbracket = /\[\]$/,
- rCRLF = /\r?\n/g,
- rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
- rselectTextarea = /^(?:select|textarea)/i;
-
-jQuery.fn.extend({
- serialize: function() {
- return jQuery.param( this.serializeArray() );
- },
- serializeArray: function() {
- return this.map(function(){
- return this.elements ? jQuery.makeArray( this.elements ) : this;
- })
- .filter(function(){
- return this.name && !this.disabled &&
- ( this.checked || rselectTextarea.test( this.nodeName ) ||
- rinput.test( this.type ) );
- })
- .map(function( i, elem ){
- var val = jQuery( this ).val();
-
- return val == null ?
- null :
- jQuery.isArray( val ) ?
- jQuery.map( val, function( val, i ){
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }) :
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }).get();
- }
-});
-
-//Serialize an array of form elements or a set of
-//key/values into a query string
-jQuery.param = function( a, traditional ) {
- var prefix,
- s = [],
- add = function( key, value ) {
- // If value is a function, invoke it and return its value
- value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
- s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
- };
-
- // Set traditional to true for jQuery <= 1.3.2 behavior.
- if ( traditional === undefined ) {
- traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
- }
-
- // If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- });
-
- } else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( prefix in a ) {
- buildParams( prefix, a[ prefix ], traditional, add );
- }
- }
-
- // Return the resulting serialization
- return s.join( "&" ).replace( r20, "+" );
-};
-
-function buildParams( prefix, obj, traditional, add ) {
- var name;
-
- if ( jQuery.isArray( obj ) ) {
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
- // Treat each array item as a scalar.
- add( prefix, v );
-
- } else {
- // If array item is non-scalar (array or object), encode its
- // numeric index to resolve deserialization ambiguity issues.
- // Note that rack (as of 1.0.0) can't currently deserialize
- // nested arrays properly, and attempting to do so may cause
- // a server error. Possible fixes are to modify rack's
- // deserialization algorithm or to provide an option or flag
- // to force array serialization to be shallow.
- buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
- }
- });
-
- } else if ( !traditional && jQuery.type( obj ) === "object" ) {
- // Serialize object item.
- for ( name in obj ) {
- buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
- }
-
- } else {
- // Serialize scalar item.
- add( prefix, obj );
- }
-}
-var
- // Document location
- ajaxLocParts,
- ajaxLocation,
-
- rhash = /#.*$/,
- rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
- // #7653, #8125, #8152: local protocol detection
- rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
- rnoContent = /^(?:GET|HEAD)$/,
- rprotocol = /^\/\//,
- rquery = /\?/,
- rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
- rts = /([?&])_=[^&]*/,
- rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
-
- // Keep a copy of the old load method
- _load = jQuery.fn.load,
-
- /* Prefilters
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
- * 2) These are called:
- * - BEFORE asking for a transport
- * - AFTER param serialization (s.data is a string if s.processData is true)
- * 3) key is the dataType
- * 4) the catchall symbol "*" can be used
- * 5) execution will start with transport dataType and THEN continue down to "*" if needed
- */
- prefilters = {},
-
- /* Transports bindings
- * 1) key is the dataType
- * 2) the catchall symbol "*" can be used
- * 3) selection will start with transport dataType and THEN go to "*" if needed
- */
- transports = {},
-
- // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
- allTypes = ["*/"] + ["*"];
-
-// #8138, IE may throw an exception when accessing
-// a field from window.location if document.domain has been set
-try {
- ajaxLocation = location.href;
-} catch( e ) {
- // Use the href attribute of an A element
- // since IE will modify it given document.location
- ajaxLocation = document.createElement( "a" );
- ajaxLocation.href = "";
- ajaxLocation = ajaxLocation.href;
-}
-
-// Segment location into parts
-ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
-
-// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
-function addToPrefiltersOrTransports( structure ) {
-
- // dataTypeExpression is optional and defaults to "*"
- return function( dataTypeExpression, func ) {
-
- if ( typeof dataTypeExpression !== "string" ) {
- func = dataTypeExpression;
- dataTypeExpression = "*";
- }
-
- var dataType, list, placeBefore,
- dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
- i = 0,
- length = dataTypes.length;
-
- if ( jQuery.isFunction( func ) ) {
- // For each dataType in the dataTypeExpression
- for ( ; i < length; i++ ) {
- dataType = dataTypes[ i ];
- // We control if we're asked to add before
- // any existing element
- placeBefore = /^\+/.test( dataType );
- if ( placeBefore ) {
- dataType = dataType.substr( 1 ) || "*";
- }
- list = structure[ dataType ] = structure[ dataType ] || [];
- // then we add to the structure accordingly
- list[ placeBefore ? "unshift" : "push" ]( func );
- }
- }
- };
-}
-
-// Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
- dataType /* internal */, inspected /* internal */ ) {
-
- dataType = dataType || options.dataTypes[ 0 ];
- inspected = inspected || {};
-
- inspected[ dataType ] = true;
-
- var selection,
- list = structure[ dataType ],
- i = 0,
- length = list ? list.length : 0,
- executeOnly = ( structure === prefilters );
-
- for ( ; i < length && ( executeOnly || !selection ); i++ ) {
- selection = list[ i ]( options, originalOptions, jqXHR );
- // If we got redirected to another dataType
- // we try there if executing only and not done already
- if ( typeof selection === "string" ) {
- if ( !executeOnly || inspected[ selection ] ) {
- selection = undefined;
- } else {
- options.dataTypes.unshift( selection );
- selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jqXHR, selection, inspected );
- }
- }
- }
- // If we're only executing or nothing was selected
- // we try the catchall dataType if not done already
- if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
- selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jqXHR, "*", inspected );
- }
- // unnecessary when only executing (prefilters)
- // but it'll be ignored by the caller in that case
- return selection;
-}
-
-// A special extend for ajax options
-// that takes "flat" options (not to be deep extended)
-// Fixes #9887
-function ajaxExtend( target, src ) {
- var key, deep,
- flatOptions = jQuery.ajaxSettings.flatOptions || {};
- for ( key in src ) {
- if ( src[ key ] !== undefined ) {
- ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
- }
- }
- if ( deep ) {
- jQuery.extend( true, target, deep );
- }
-}
-
-jQuery.fn.load = function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
- }
-
- // Don't do a request if no elements are being requested
- if ( !this.length ) {
- return this;
- }
-
- var selector, type, response,
- self = this,
- off = url.indexOf(" ");
-
- if ( off >= 0 ) {
- selector = url.slice( off, url.length );
- url = url.slice( 0, off );
- }
-
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
-
- // We assume that it's the callback
- callback = params;
- params = undefined;
-
- // Otherwise, build a param string
- } else if ( params && typeof params === "object" ) {
- type = "POST";
- }
-
- // Request the remote document
- jQuery.ajax({
- url: url,
-
- // if "type" variable is undefined, then "GET" method will be used
- type: type,
- dataType: "html",
- data: params,
- complete: function( jqXHR, status ) {
- if ( callback ) {
- self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
- }
- }
- }).done(function( responseText ) {
-
- // Save response for use in complete callback
- response = arguments;
-
- // See if a selector was specified
- self.html( selector ?
-
- // Create a dummy div to hold the results
- jQuery("<div>")
-
- // inject the contents of the document in, removing the scripts
- // to avoid any 'Permission Denied' errors in IE
- .append( responseText.replace( rscript, "" ) )
-
- // Locate the specified elements
- .find( selector ) :
-
- // If not, just inject the full result
- responseText );
-
- });
-
- return this;
-};
-
-// Attach a bunch of functions for handling common AJAX events
-jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
- jQuery.fn[ o ] = function( f ){
- return this.on( o, f );
- };
-});
-
-jQuery.each( [ "get", "post" ], function( i, method ) {
- jQuery[ method ] = function( url, data, callback, type ) {
- // shift arguments if data argument was omitted
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = undefined;
- }
-
- return jQuery.ajax({
- type: method,
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- };
-});
-
-jQuery.extend({
-
- getScript: function( url, callback ) {
- return jQuery.get( url, undefined, callback, "script" );
- },
-
- getJSON: function( url, data, callback ) {
- return jQuery.get( url, data, callback, "json" );
- },
-
- // Creates a full fledged settings object into target
- // with both ajaxSettings and settings fields.
- // If target is omitted, writes into ajaxSettings.
- ajaxSetup: function( target, settings ) {
- if ( settings ) {
- // Building a settings object
- ajaxExtend( target, jQuery.ajaxSettings );
- } else {
- // Extending ajaxSettings
- settings = target;
- target = jQuery.ajaxSettings;
- }
- ajaxExtend( target, settings );
- return target;
- },
-
- ajaxSettings: {
- url: ajaxLocation,
- isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
- global: true,
- type: "GET",
- contentType: "application/x-www-form-urlencoded; charset=UTF-8",
- processData: true,
- async: true,
- /*
- timeout: 0,
- data: null,
- dataType: null,
- username: null,
- password: null,
- cache: null,
- throws: false,
- traditional: false,
- headers: {},
- */
-
- accepts: {
- xml: "application/xml, text/xml",
- html: "text/html",
- text: "text/plain",
- json: "application/json, text/javascript",
- "*": allTypes
- },
-
- contents: {
- xml: /xml/,
- html: /html/,
- json: /json/
- },
-
- responseFields: {
- xml: "responseXML",
- text: "responseText"
- },
-
- // List of data converters
- // 1) key format is "source_type destination_type" (a single space in-between)
- // 2) the catchall symbol "*" can be used for source_type
- converters: {
-
- // Convert anything to text
- "* text": window.String,
-
- // Text to html (true = no transformation)
- "text html": true,
-
- // Evaluate text as a json expression
- "text json": jQuery.parseJSON,
-
- // Parse text as xml
- "text xml": jQuery.parseXML
- },
-
- // For options that shouldn't be deep extended:
- // you can add your own custom options here if
- // and when you create one that shouldn't be
- // deep extended (see ajaxExtend)
- flatOptions: {
- context: true,
- url: true
- }
- },
-
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
- ajaxTransport: addToPrefiltersOrTransports( transports ),
-
- // Main method
- ajax: function( url, options ) {
-
- // If url is an object, simulate pre-1.5 signature
- if ( typeof url === "object" ) {
- options = url;
- url = undefined;
- }
-
- // Force options to be an object
- options = options || {};
-
- var // ifModified key
- ifModifiedKey,
- // Response headers
- responseHeadersString,
- responseHeaders,
- // transport
- transport,
- // timeout handle
- timeoutTimer,
- // Cross-domain detection vars
- parts,
- // To know if global events are to be dispatched
- fireGlobals,
- // Loop variable
- i,
- // Create the final options object
- s = jQuery.ajaxSetup( {}, options ),
- // Callbacks context
- callbackContext = s.context || s,
- // Context for global events
- // It's the callbackContext if one was provided in the options
- // and if it's a DOM node or a jQuery collection
- globalEventContext = callbackContext !== s &&
- ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
- jQuery( callbackContext ) : jQuery.event,
- // Deferreds
- deferred = jQuery.Deferred(),
- completeDeferred = jQuery.Callbacks( "once memory" ),
- // Status-dependent callbacks
- statusCode = s.statusCode || {},
- // Headers (they are sent all at once)
- requestHeaders = {},
- requestHeadersNames = {},
- // The jqXHR state
- state = 0,
- // Default abort message
- strAbort = "canceled",
- // Fake xhr
- jqXHR = {
-
- readyState: 0,
-
- // Caches the header
- setRequestHeader: function( name, value ) {
- if ( !state ) {
- var lname = name.toLowerCase();
- name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
- requestHeaders[ name ] = value;
- }
- return this;
- },
-
- // Raw string
- getAllResponseHeaders: function() {
- return state === 2 ? responseHeadersString : null;
- },
-
- // Builds headers hashtable if needed
- getResponseHeader: function( key ) {
- var match;
- if ( state === 2 ) {
- if ( !responseHeaders ) {
- responseHeaders = {};
- while( ( match = rheaders.exec( responseHeadersString ) ) ) {
- responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
- }
- }
- match = responseHeaders[ key.toLowerCase() ];
- }
- return match === undefined ? null : match;
- },
-
- // Overrides response content-type header
- overrideMimeType: function( type ) {
- if ( !state ) {
- s.mimeType = type;
- }
- return this;
- },
-
- // Cancel the request
- abort: function( statusText ) {
- statusText = statusText || strAbort;
- if ( transport ) {
- transport.abort( statusText );
- }
- done( 0, statusText );
- return this;
- }
- };
-
- // Callback for when everything is done
- // It is defined here because jslint complains if it is declared
- // at the end of the function (which would be more logical and readable)
- function done( status, nativeStatusText, responses, headers ) {
- var isSuccess, success, error, response, modified,
- statusText = nativeStatusText;
-
- // Called once
- if ( state === 2 ) {
- return;
- }
-
- // State is "done" now
- state = 2;
-
- // Clear timeout if it exists
- if ( timeoutTimer ) {
- clearTimeout( timeoutTimer );
- }
-
- // Dereference transport for early garbage collection
- // (no matter how long the jqXHR object will be used)
- transport = undefined;
-
- // Cache response headers
- responseHeadersString = headers || "";
-
- // Set readyState
- jqXHR.readyState = status > 0 ? 4 : 0;
-
- // Get response data
- if ( responses ) {
- response = ajaxHandleResponses( s, jqXHR, responses );
- }
-
- // If successful, handle type chaining
- if ( status >= 200 && status < 300 || status === 304 ) {
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
-
- modified = jqXHR.getResponseHeader("Last-Modified");
- if ( modified ) {
- jQuery.lastModified[ ifModifiedKey ] = modified;
- }
- modified = jqXHR.getResponseHeader("Etag");
- if ( modified ) {
- jQuery.etag[ ifModifiedKey ] = modified;
- }
- }
-
- // If not modified
- if ( status === 304 ) {
-
- statusText = "notmodified";
- isSuccess = true;
-
- // If we have data
- } else {
-
- isSuccess = ajaxConvert( s, response );
- statusText = isSuccess.state;
- success = isSuccess.data;
- error = isSuccess.error;
- isSuccess = !error;
- }
- } else {
- // We extract error from statusText
- // then normalize statusText and status for non-aborts
- error = statusText;
- if ( !statusText || status ) {
- statusText = "error";
- if ( status < 0 ) {
- status = 0;
- }
- }
- }
-
- // Set data for the fake xhr object
- jqXHR.status = status;
- jqXHR.statusText = ( nativeStatusText || statusText ) + "";
-
- // Success/Error
- if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
- } else {
- deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
- }
-
- // Status-dependent callbacks
- jqXHR.statusCode( statusCode );
- statusCode = undefined;
-
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
- [ jqXHR, s, isSuccess ? success : error ] );
- }
-
- // Complete
- completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
-
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
- // Handle the global AJAX counter
- if ( !( --jQuery.active ) ) {
- jQuery.event.trigger( "ajaxStop" );
- }
- }
- }
-
- // Attach deferreds
- deferred.promise( jqXHR );
- jqXHR.success = jqXHR.done;
- jqXHR.error = jqXHR.fail;
- jqXHR.complete = completeDeferred.add;
-
- // Status-dependent callbacks
- jqXHR.statusCode = function( map ) {
- if ( map ) {
- var tmp;
- if ( state < 2 ) {
- for ( tmp in map ) {
- statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
- }
- } else {
- tmp = map[ jqXHR.status ];
- jqXHR.always( tmp );
- }
- }
- return this;
- };
-
- // Remove hash character (#7531: and string promotion)
- // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
- // We also use the url parameter if available
- s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
-
- // Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
-
- // A cross-domain request is in order when we have a protocol:host:port mismatch
- if ( s.crossDomain == null ) {
- parts = rurl.exec( s.url.toLowerCase() ) || false;
- s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
- ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
- }
-
- // Convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
-
- // Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
-
- // If request was aborted inside a prefilter, stop there
- if ( state === 2 ) {
- return jqXHR;
- }
-
- // We can fire global events as of now if asked to
- fireGlobals = s.global;
-
- // Uppercase the type
- s.type = s.type.toUpperCase();
-
- // Determine if request has content
- s.hasContent = !rnoContent.test( s.type );
-
- // Watch for a new set of requests
- if ( fireGlobals && jQuery.active++ === 0 ) {
- jQuery.event.trigger( "ajaxStart" );
- }
-
- // More options handling for requests with no content
- if ( !s.hasContent ) {
-
- // If data is available, append data to url
- if ( s.data ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
- // #9682: remove data so that it's not used in an eventual retry
- delete s.data;
- }
-
- // Get ifModifiedKey before adding the anti-cache parameter
- ifModifiedKey = s.url;
-
- // Add anti-cache in url if needed
- if ( s.cache === false ) {
-
- var ts = jQuery.now(),
- // try replacing _= if it is there
- ret = s.url.replace( rts, "$1_=" + ts );
-
- // if nothing was replaced, add timestamp to the end
- s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
- }
- }
-
- // Set the correct header, if data is being sent
- if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- jqXHR.setRequestHeader( "Content-Type", s.contentType );
- }
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- ifModifiedKey = ifModifiedKey || s.url;
- if ( jQuery.lastModified[ ifModifiedKey ] ) {
- jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
- }
- if ( jQuery.etag[ ifModifiedKey ] ) {
- jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
- }
- }
-
- // Set the Accepts header for the server, depending on the dataType
- jqXHR.setRequestHeader(
- "Accept",
- s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
- s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
- s.accepts[ "*" ]
- );
-
- // Check for headers option
- for ( i in s.headers ) {
- jqXHR.setRequestHeader( i, s.headers[ i ] );
- }
-
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
- // Abort if not done already and return
- return jqXHR.abort();
-
- }
-
- // aborting is no longer a cancellation
- strAbort = "abort";
-
- // Install callbacks on deferreds
- for ( i in { success: 1, error: 1, complete: 1 } ) {
- jqXHR[ i ]( s[ i ] );
- }
-
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
-
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- jqXHR.readyState = 1;
- // Send global event
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
- }
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = setTimeout( function(){
- jqXHR.abort( "timeout" );
- }, s.timeout );
- }
-
- try {
- state = 1;
- transport.send( requestHeaders, done );
- } catch (e) {
- // Propagate exception as error if not done
- if ( state < 2 ) {
- done( -1, e );
- // Simply rethrow otherwise
- } else {
- throw e;
- }
- }
- }
-
- return jqXHR;
- },
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {}
-
-});
-
-/* Handles responses to an ajax request:
- * - sets all responseXXX fields accordingly
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
-function ajaxHandleResponses( s, jqXHR, responses ) {
-
- var ct, type, finalDataType, firstDataType,
- contents = s.contents,
- dataTypes = s.dataTypes,
- responseFields = s.responseFields;
-
- // Fill responseXXX fields
- for ( type in responseFields ) {
- if ( type in responses ) {
- jqXHR[ responseFields[type] ] = responses[ type ];
- }
- }
-
- // Remove auto dataType and get content-type in the process
- while( dataTypes[ 0 ] === "*" ) {
- dataTypes.shift();
- if ( ct === undefined ) {
- ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
- }
- }
-
- // Check if we're dealing with a known content-type
- if ( ct ) {
- for ( type in contents ) {
- if ( contents[ type ] && contents[ type ].test( ct ) ) {
- dataTypes.unshift( type );
- break;
- }
- }
- }
-
- // Check to see if we have a response for the expected dataType
- if ( dataTypes[ 0 ] in responses ) {
- finalDataType = dataTypes[ 0 ];
- } else {
- // Try convertible dataTypes
- for ( type in responses ) {
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
- finalDataType = type;
- break;
- }
- if ( !firstDataType ) {
- firstDataType = type;
- }
- }
- // Or just use first one
- finalDataType = finalDataType || firstDataType;
- }
-
- // If we found a dataType
- // We add the dataType to the list if needed
- // and return the corresponding response
- if ( finalDataType ) {
- if ( finalDataType !== dataTypes[ 0 ] ) {
- dataTypes.unshift( finalDataType );
- }
- return responses[ finalDataType ];
- }
-}
-
-// Chain conversions given the request and the original response
-function ajaxConvert( s, response ) {
-
- var conv, conv2, current, tmp,
- // Work with a copy of dataTypes in case we need to modify it for conversion
- dataTypes = s.dataTypes.slice(),
- prev = dataTypes[ 0 ],
- converters = {},
- i = 0;
-
- // Apply the dataFilter if provided
- if ( s.dataFilter ) {
- response = s.dataFilter( response, s.dataType );
- }
-
- // Create converters map with lowercased keys
- if ( dataTypes[ 1 ] ) {
- for ( conv in s.converters ) {
- converters[ conv.toLowerCase() ] = s.converters[ conv ];
- }
- }
-
- // Convert to each sequential dataType, tolerating list modification
- for ( ; (current = dataTypes[++i]); ) {
-
- // There's only work to do if current dataType is non-auto
- if ( current !== "*" ) {
-
- // Convert response if prev dataType is non-auto and differs from current
- if ( prev !== "*" && prev !== current ) {
-
- // Seek a direct converter
- conv = converters[ prev + " " + current ] || converters[ "* " + current ];
-
- // If none found, seek a pair
- if ( !conv ) {
- for ( conv2 in converters ) {
-
- // If conv2 outputs current
- tmp = conv2.split(" ");
- if ( tmp[ 1 ] === current ) {
-
- // If prev can be converted to accepted input
- conv = converters[ prev + " " + tmp[ 0 ] ] ||
- converters[ "* " + tmp[ 0 ] ];
- if ( conv ) {
- // Condense equivalence converters
- if ( conv === true ) {
- conv = converters[ conv2 ];
-
- // Otherwise, insert the intermediate dataType
- } else if ( converters[ conv2 ] !== true ) {
- current = tmp[ 0 ];
- dataTypes.splice( i--, 0, current );
- }
-
- break;
- }
- }
- }
- }
-
- // Apply converter (if not an equivalence)
- if ( conv !== true ) {
-
- // Unless errors are allowed to bubble, catch and return them
- if ( conv && s["throws"] ) {
- response = conv( response );
- } else {
- try {
- response = conv( response );
- } catch ( e ) {
- return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
- }
- }
- }
- }
-
- // Update prev for next iteration
- prev = current;
- }
- }
-
- return { state: "success", data: response };
-}
-var oldCallbacks = [],
- rquestion = /\?/,
- rjsonp = /(=)\?(?=&|$)|\?\?/,
- nonce = jQuery.now();
-
-// Default jsonp settings
-jQuery.ajaxSetup({
- jsonp: "callback",
- jsonpCallback: function() {
- var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
- this[ callback ] = true;
- return callback;
- }
-});
-
-// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
-
- var callbackName, overwritten, responseContainer,
- data = s.data,
- url = s.url,
- hasCallback = s.jsonp !== false,
- replaceInUrl = hasCallback && rjsonp.test( url ),
- replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
- !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
- rjsonp.test( data );
-
- // Handle iff the expected data type is "jsonp" or we have a parameter to set
- if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
-
- // Get callback name, remembering preexisting value associated with it
- callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
- s.jsonpCallback() :
- s.jsonpCallback;
- overwritten = window[ callbackName ];
-
- // Insert callback into url or form data
- if ( replaceInUrl ) {
- s.url = url.replace( rjsonp, "$1" + callbackName );
- } else if ( replaceInData ) {
- s.data = data.replace( rjsonp, "$1" + callbackName );
- } else if ( hasCallback ) {
- s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
- }
-
- // Use data converter to retrieve json after script execution
- s.converters["script json"] = function() {
- if ( !responseContainer ) {
- jQuery.error( callbackName + " was not called" );
- }
- return responseContainer[ 0 ];
- };
-
- // force json dataType
- s.dataTypes[ 0 ] = "json";
-
- // Install callback
- window[ callbackName ] = function() {
- responseContainer = arguments;
- };
-
- // Clean-up function (fires after converters)
- jqXHR.always(function() {
- // Restore preexisting value
- window[ callbackName ] = overwritten;
-
- // Save back as free
- if ( s[ callbackName ] ) {
- // make sure that re-using the options doesn't screw things around
- s.jsonpCallback = originalSettings.jsonpCallback;
-
- // save the callback name for future use
- oldCallbacks.push( callbackName );
- }
-
- // Call if it was a function and we have a response
- if ( responseContainer && jQuery.isFunction( overwritten ) ) {
- overwritten( responseContainer[ 0 ] );
- }
-
- responseContainer = overwritten = undefined;
- });
-
- // Delegate to script
- return "script";
- }
-});
-// Install script dataType
-jQuery.ajaxSetup({
- accepts: {
- script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
- },
- contents: {
- script: /javascript|ecmascript/
- },
- converters: {
- "text script": function( text ) {
- jQuery.globalEval( text );
- return text;
- }
- }
-});
-
-// Handle cache's special case and global
-jQuery.ajaxPrefilter( "script", function( s ) {
- if ( s.cache === undefined ) {
- s.cache = false;
- }
- if ( s.crossDomain ) {
- s.type = "GET";
- s.global = false;
- }
-});
-
-// Bind script tag hack transport
-jQuery.ajaxTransport( "script", function(s) {
-
- // This transport only deals with cross domain requests
- if ( s.crossDomain ) {
-
- var script,
- head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
-
- return {
-
- send: function( _, callback ) {
-
- script = document.createElement( "script" );
-
- script.async = "async";
-
- if ( s.scriptCharset ) {
- script.charset = s.scriptCharset;
- }
-
- script.src = s.url;
-
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function( _, isAbort ) {
-
- if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
-
- // Remove the script
- if ( head && script.parentNode ) {
- head.removeChild( script );
- }
-
- // Dereference the script
- script = undefined;
-
- // Callback if not abort
- if ( !isAbort ) {
- callback( 200, "success" );
- }
- }
- };
- // Use insertBefore instead of appendChild to circumvent an IE6 bug.
- // This arises when a base node is used (#2709 and #4378).
- head.insertBefore( script, head.firstChild );
- },
-
- abort: function() {
- if ( script ) {
- script.onload( 0, 1 );
- }
- }
- };
- }
-});
-var xhrCallbacks,
- // #5280: Internet Explorer will keep connections alive if we don't abort on unload
- xhrOnUnloadAbort = window.ActiveXObject ? function() {
- // Abort all pending requests
- for ( var key in xhrCallbacks ) {
- xhrCallbacks[ key ]( 0, 1 );
- }
- } : false,
- xhrId = 0;
-
-// Functions to create xhrs
-function createStandardXHR() {
- try {
- return new window.XMLHttpRequest();
- } catch( e ) {}
-}
-
-function createActiveXHR() {
- try {
- return new window.ActiveXObject( "Microsoft.XMLHTTP" );
- } catch( e ) {}
-}
-
-// Create the request object
-// (This is still attached to ajaxSettings for backward compatibility)
-jQuery.ajaxSettings.xhr = window.ActiveXObject ?
- /* Microsoft failed to properly
- * implement the XMLHttpRequest in IE7 (can't request local files),
- * so we use the ActiveXObject when it is available
- * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
- * we need a fallback.
- */
- function() {
- return !this.isLocal && createStandardXHR() || createActiveXHR();
- } :
- // For all other browsers, use the standard XMLHttpRequest object
- createStandardXHR;
-
-// Determine support properties
-(function( xhr ) {
- jQuery.extend( jQuery.support, {
- ajax: !!xhr,
- cors: !!xhr && ( "withCredentials" in xhr )
- });
-})( jQuery.ajaxSettings.xhr() );
-
-// Create transport if the browser can provide an xhr
-if ( jQuery.support.ajax ) {
-
- jQuery.ajaxTransport(function( s ) {
- // Cross domain only allowed if supported through XMLHttpRequest
- if ( !s.crossDomain || jQuery.support.cors ) {
-
- var callback;
-
- return {
- send: function( headers, complete ) {
-
- // Get a new xhr
- var handle, i,
- xhr = s.xhr();
-
- // Open the socket
- // Passing null username, generates a login popup on Opera (#2865)
- if ( s.username ) {
- xhr.open( s.type, s.url, s.async, s.username, s.password );
- } else {
- xhr.open( s.type, s.url, s.async );
- }
-
- // Apply custom fields if provided
- if ( s.xhrFields ) {
- for ( i in s.xhrFields ) {
- xhr[ i ] = s.xhrFields[ i ];
- }
- }
-
- // Override mime type if needed
- if ( s.mimeType && xhr.overrideMimeType ) {
- xhr.overrideMimeType( s.mimeType );
- }
-
- // X-Requested-With header
- // For cross-domain requests, seeing as conditions for a preflight are
- // akin to a jigsaw puzzle, we simply never set it to be sure.
- // (it can always be set on a per-request basis or even using ajaxSetup)
- // For same-domain requests, won't change header if already provided.
- if ( !s.crossDomain && !headers["X-Requested-With"] ) {
- headers[ "X-Requested-With" ] = "XMLHttpRequest";
- }
-
- // Need an extra try/catch for cross domain requests in Firefox 3
- try {
- for ( i in headers ) {
- xhr.setRequestHeader( i, headers[ i ] );
- }
- } catch( _ ) {}
-
- // Do send the request
- // This may raise an exception which is actually
- // handled in jQuery.ajax (so no try/catch here)
- xhr.send( ( s.hasContent && s.data ) || null );
-
- // Listener
- callback = function( _, isAbort ) {
-
- var status,
- statusText,
- responseHeaders,
- responses,
- xml;
-
- // Firefox throws exceptions when accessing properties
- // of an xhr when a network error occurred
- // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
- try {
-
- // Was never called and is aborted or complete
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
-
- // Only called once
- callback = undefined;
-
- // Do not keep as active anymore
- if ( handle ) {
- xhr.onreadystatechange = jQuery.noop;
- if ( xhrOnUnloadAbort ) {
- delete xhrCallbacks[ handle ];
- }
- }
-
- // If it's an abort
- if ( isAbort ) {
- // Abort it manually if needed
- if ( xhr.readyState !== 4 ) {
- xhr.abort();
- }
- } else {
- status = xhr.status;
- responseHeaders = xhr.getAllResponseHeaders();
- responses = {};
- xml = xhr.responseXML;
-
- // Construct response list
- if ( xml && xml.documentElement /* #4958 */ ) {
- responses.xml = xml;
- }
-
- // When requesting binary data, IE6-9 will throw an exception
- // on any attempt to access responseText (#11426)
- try {
- responses.text = xhr.responseText;
- } catch( _ ) {
- }
-
- // Firefox throws an exception when accessing
- // statusText for faulty cross-domain requests
- try {
- statusText = xhr.statusText;
- } catch( e ) {
- // We normalize with Webkit giving an empty statusText
- statusText = "";
- }
-
- // Filter status for non standard behaviors
-
- // If the request is local and we have data: assume a success
- // (success with no data won't get notified, that's the best we
- // can do given current implementations)
- if ( !status && s.isLocal && !s.crossDomain ) {
- status = responses.text ? 200 : 404;
- // IE - #1450: sometimes returns 1223 when it should be 204
- } else if ( status === 1223 ) {
- status = 204;
- }
- }
- }
- } catch( firefoxAccessException ) {
- if ( !isAbort ) {
- complete( -1, firefoxAccessException );
- }
- }
-
- // Call complete if needed
- if ( responses ) {
- complete( status, statusText, responses, responseHeaders );
- }
- };
-
- if ( !s.async ) {
- // if we're in sync mode we fire the callback
- callback();
- } else if ( xhr.readyState === 4 ) {
- // (IE6 & IE7) if it's in cache and has been
- // retrieved directly we need to fire the callback
- setTimeout( callback, 0 );
- } else {
- handle = ++xhrId;
- if ( xhrOnUnloadAbort ) {
- // Create the active xhrs callbacks list if needed
- // and attach the unload handler
- if ( !xhrCallbacks ) {
- xhrCallbacks = {};
- jQuery( window ).unload( xhrOnUnloadAbort );
- }
- // Add to list of active xhrs callbacks
- xhrCallbacks[ handle ] = callback;
- }
- xhr.onreadystatechange = callback;
- }
- },
-
- abort: function() {
- if ( callback ) {
- callback(0,1);
- }
- }
- };
- }
- });
-}
-var fxNow, timerId,
- rfxtypes = /^(?:toggle|show|hide)$/,
- rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
- rrun = /queueHooks$/,
- animationPrefilters = [ defaultPrefilter ],
- tweeners = {
- "*": [function( prop, value ) {
- var end, unit,
- tween = this.createTween( prop, value ),
- parts = rfxnum.exec( value ),
- target = tween.cur(),
- start = +target || 0,
- scale = 1,
- maxIterations = 20;
-
- if ( parts ) {
- end = +parts[2];
- unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
-
- // We need to compute starting value
- if ( unit !== "px" && start ) {
- // Iteratively approximate from a nonzero starting point
- // Prefer the current property, because this process will be trivial if it uses the same units
- // Fallback to end or a simple constant
- start = jQuery.css( tween.elem, prop, true ) || end || 1;
-
- do {
- // If previous iteration zeroed out, double until we get *something*
- // Use a string for doubling factor so we don't accidentally see scale as unchanged below
- scale = scale || ".5";
-
- // Adjust and apply
- start = start / scale;
- jQuery.style( tween.elem, prop, start + unit );
-
- // Update scale, tolerating zero or NaN from tween.cur()
- // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
- } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
- }
-
- tween.unit = unit;
- tween.start = start;
- // If a +=/-= token was provided, we're doing a relative animation
- tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
- }
- return tween;
- }]
- };
-
-// Animations created synchronously will run synchronously
-function createFxNow() {
- setTimeout(function() {
- fxNow = undefined;
- }, 0 );
- return ( fxNow = jQuery.now() );
-}
-
-function createTweens( animation, props ) {
- jQuery.each( props, function( prop, value ) {
- var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
- index = 0,
- length = collection.length;
- for ( ; index < length; index++ ) {
- if ( collection[ index ].call( animation, prop, value ) ) {
-
- // we're done with this property
- return;
- }
- }
- });
-}
-
-function Animation( elem, properties, options ) {
- var result,
- index = 0,
- tweenerIndex = 0,
- length = animationPrefilters.length,
- deferred = jQuery.Deferred().always( function() {
- // don't match elem in the :animated selector
- delete tick.elem;
- }),
- tick = function() {
- var currentTime = fxNow || createFxNow(),
- remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
- percent = 1 - ( remaining / animation.duration || 0 ),
- index = 0,
- length = animation.tweens.length;
-
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( percent );
- }
-
- deferred.notifyWith( elem, [ animation, percent, remaining ]);
-
- if ( percent < 1 && length ) {
- return remaining;
- } else {
- deferred.resolveWith( elem, [ animation ] );
- return false;
- }
- },
- animation = deferred.promise({
- elem: elem,
- props: jQuery.extend( {}, properties ),
- opts: jQuery.extend( true, { specialEasing: {} }, options ),
- originalProperties: properties,
- originalOptions: options,
- startTime: fxNow || createFxNow(),
- duration: options.duration,
- tweens: [],
- createTween: function( prop, end, easing ) {
- var tween = jQuery.Tween( elem, animation.opts, prop, end,
- animation.opts.specialEasing[ prop ] || animation.opts.easing );
- animation.tweens.push( tween );
- return tween;
- },
- stop: function( gotoEnd ) {
- var index = 0,
- // if we are going to the end, we want to run all the tweens
- // otherwise we skip this part
- length = gotoEnd ? animation.tweens.length : 0;
-
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( 1 );
- }
-
- // resolve when we played the last frame
- // otherwise, reject
- if ( gotoEnd ) {
- deferred.resolveWith( elem, [ animation, gotoEnd ] );
- } else {
- deferred.rejectWith( elem, [ animation, gotoEnd ] );
- }
- return this;
- }
- }),
- props = animation.props;
-
- propFilter( props, animation.opts.specialEasing );
-
- for ( ; index < length ; index++ ) {
- result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
- if ( result ) {
- return result;
- }
- }
-
- createTweens( animation, props );
-
- if ( jQuery.isFunction( animation.opts.start ) ) {
- animation.opts.start.call( elem, animation );
- }
-
- jQuery.fx.timer(
- jQuery.extend( tick, {
- anim: animation,
- queue: animation.opts.queue,
- elem: elem
- })
- );
-
- // attach callbacks from options
- return animation.progress( animation.opts.progress )
- .done( animation.opts.done, animation.opts.complete )
- .fail( animation.opts.fail )
- .always( animation.opts.always );
-}
-
-function propFilter( props, specialEasing ) {
- var index, name, easing, value, hooks;
-
- // camelCase, specialEasing and expand cssHook pass
- for ( index in props ) {
- name = jQuery.camelCase( index );
- easing = specialEasing[ name ];
- value = props[ index ];
- if ( jQuery.isArray( value ) ) {
- easing = value[ 1 ];
- value = props[ index ] = value[ 0 ];
- }
-
- if ( index !== name ) {
- props[ name ] = value;
- delete props[ index ];
- }
-
- hooks = jQuery.cssHooks[ name ];
- if ( hooks && "expand" in hooks ) {
- value = hooks.expand( value );
- delete props[ name ];
-
- // not quite $.extend, this wont overwrite keys already present.
- // also - reusing 'index' from above because we have the correct "name"
- for ( index in value ) {
- if ( !( index in props ) ) {
- props[ index ] = value[ index ];
- specialEasing[ index ] = easing;
- }
- }
- } else {
- specialEasing[ name ] = easing;
- }
- }
-}
-
-jQuery.Animation = jQuery.extend( Animation, {
-
- tweener: function( props, callback ) {
- if ( jQuery.isFunction( props ) ) {
- callback = props;
- props = [ "*" ];
- } else {
- props = props.split(" ");
- }
-
- var prop,
- index = 0,
- length = props.length;
-
- for ( ; index < length ; index++ ) {
- prop = props[ index ];
- tweeners[ prop ] = tweeners[ prop ] || [];
- tweeners[ prop ].unshift( callback );
- }
- },
-
- prefilter: function( callback, prepend ) {
- if ( prepend ) {
- animationPrefilters.unshift( callback );
- } else {
- animationPrefilters.push( callback );
- }
- }
-});
-
-function defaultPrefilter( elem, props, opts ) {
- var index, prop, value, length, dataShow, tween, hooks, oldfire,
- anim = this,
- style = elem.style,
- orig = {},
- handled = [],
- hidden = elem.nodeType && isHidden( elem );
-
- // handle queue: false promises
- if ( !opts.queue ) {
- hooks = jQuery._queueHooks( elem, "fx" );
- if ( hooks.unqueued == null ) {
- hooks.unqueued = 0;
- oldfire = hooks.empty.fire;
- hooks.empty.fire = function() {
- if ( !hooks.unqueued ) {
- oldfire();
- }
- };
- }
- hooks.unqueued++;
-
- anim.always(function() {
- // doing this makes sure that the complete handler will be called
- // before this completes
- anim.always(function() {
- hooks.unqueued--;
- if ( !jQuery.queue( elem, "fx" ).length ) {
- hooks.empty.fire();
- }
- });
- });
- }
-
- // height/width overflow pass
- if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
- // Make sure that nothing sneaks out
- // Record all 3 overflow attributes because IE does not
- // change the overflow attribute when overflowX and
- // overflowY are set to the same value
- opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
-
- // Set display property to inline-block for height/width
- // animations on inline elements that are having width/height animated
- if ( jQuery.css( elem, "display" ) === "inline" &&
- jQuery.css( elem, "float" ) === "none" ) {
-
- // inline-level elements accept inline-block;
- // block-level elements need to be inline with layout
- if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
- style.display = "inline-block";
-
- } else {
- style.zoom = 1;
- }
- }
- }
-
- if ( opts.overflow ) {
- style.overflow = "hidden";
- if ( !jQuery.support.shrinkWrapBlocks ) {
- anim.done(function() {
- style.overflow = opts.overflow[ 0 ];
- style.overflowX = opts.overflow[ 1 ];
- style.overflowY = opts.overflow[ 2 ];
- });
- }
- }
-
-
- // show/hide pass
- for ( index in props ) {
- value = props[ index ];
- if ( rfxtypes.exec( value ) ) {
- delete props[ index ];
- if ( value === ( hidden ? "hide" : "show" ) ) {
- continue;
- }
- handled.push( index );
- }
- }
-
- length = handled.length;
- if ( length ) {
- dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
- if ( hidden ) {
- jQuery( elem ).show();
- } else {
- anim.done(function() {
- jQuery( elem ).hide();
- });
- }
- anim.done(function() {
- var prop;
- jQuery.removeData( elem, "fxshow", true );
- for ( prop in orig ) {
- jQuery.style( elem, prop, orig[ prop ] );
- }
- });
- for ( index = 0 ; index < length ; index++ ) {
- prop = handled[ index ];
- tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
- orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
-
- if ( !( prop in dataShow ) ) {
- dataShow[ prop ] = tween.start;
- if ( hidden ) {
- tween.end = tween.start;
- tween.start = prop === "width" || prop === "height" ? 1 : 0;
- }
- }
- }
- }
-}
-
-function Tween( elem, options, prop, end, easing ) {
- return new Tween.prototype.init( elem, options, prop, end, easing );
-}
-jQuery.Tween = Tween;
-
-Tween.prototype = {
- constructor: Tween,
- init: function( elem, options, prop, end, easing, unit ) {
- this.elem = elem;
- this.prop = prop;
- this.easing = easing || "swing";
- this.options = options;
- this.start = this.now = this.cur();
- this.end = end;
- this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
- },
- cur: function() {
- var hooks = Tween.propHooks[ this.prop ];
-
- return hooks && hooks.get ?
- hooks.get( this ) :
- Tween.propHooks._default.get( this );
- },
- run: function( percent ) {
- var eased,
- hooks = Tween.propHooks[ this.prop ];
-
- if ( this.options.duration ) {
- this.pos = eased = jQuery.easing[ this.easing ](
- percent, this.options.duration * percent, 0, 1, this.options.duration
- );
- } else {
- this.pos = eased = percent;
- }
- this.now = ( this.end - this.start ) * eased + this.start;
-
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- if ( hooks && hooks.set ) {
- hooks.set( this );
- } else {
- Tween.propHooks._default.set( this );
- }
- return this;
- }
-};
-
-Tween.prototype.init.prototype = Tween.prototype;
-
-Tween.propHooks = {
- _default: {
- get: function( tween ) {
- var result;
-
- if ( tween.elem[ tween.prop ] != null &&
- (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
- return tween.elem[ tween.prop ];
- }
-
- // passing any value as a 4th parameter to .css will automatically
- // attempt a parseFloat and fallback to a string if the parse fails
- // so, simple values such as "10px" are parsed to Float.
- // complex values such as "rotate(1rad)" are returned as is.
- result = jQuery.css( tween.elem, tween.prop, false, "" );
- // Empty strings, null, undefined and "auto" are converted to 0.
- return !result || result === "auto" ? 0 : result;
- },
- set: function( tween ) {
- // use step hook for back compat - use cssHook if its there - use .style if its
- // available and use plain properties where available
- if ( jQuery.fx.step[ tween.prop ] ) {
- jQuery.fx.step[ tween.prop ]( tween );
- } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
- jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
- } else {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- }
-};
-
-// Remove in 2.0 - this supports IE8's panic based approach
-// to setting things on disconnected nodes
-
-Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
- set: function( tween ) {
- if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
-};
-
-jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
- var cssFn = jQuery.fn[ name ];
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return speed == null || typeof speed === "boolean" ||
- // special check for .toggle( handler, handler, ... )
- ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
- cssFn.apply( this, arguments ) :
- this.animate( genFx( name, true ), speed, easing, callback );
- };
-});
-
-jQuery.fn.extend({
- fadeTo: function( speed, to, easing, callback ) {
-
- // show any hidden elements after setting opacity to 0
- return this.filter( isHidden ).css( "opacity", 0 ).show()
-
- // animate to the value specified
- .end().animate({ opacity: to }, speed, easing, callback );
- },
- animate: function( prop, speed, easing, callback ) {
- var empty = jQuery.isEmptyObject( prop ),
- optall = jQuery.speed( speed, easing, callback ),
- doAnimation = function() {
- // Operate on a copy of prop so per-property easing won't be lost
- var anim = Animation( this, jQuery.extend( {}, prop ), optall );
-
- // Empty animations resolve immediately
- if ( empty ) {
- anim.stop( true );
- }
- };
-
- return empty || optall.queue === false ?
- this.each( doAnimation ) :
- this.queue( optall.queue, doAnimation );
- },
- stop: function( type, clearQueue, gotoEnd ) {
- var stopQueue = function( hooks ) {
- var stop = hooks.stop;
- delete hooks.stop;
- stop( gotoEnd );
- };
-
- if ( typeof type !== "string" ) {
- gotoEnd = clearQueue;
- clearQueue = type;
- type = undefined;
- }
- if ( clearQueue && type !== false ) {
- this.queue( type || "fx", [] );
- }
-
- return this.each(function() {
- var dequeue = true,
- index = type != null && type + "queueHooks",
- timers = jQuery.timers,
- data = jQuery._data( this );
-
- if ( index ) {
- if ( data[ index ] && data[ index ].stop ) {
- stopQueue( data[ index ] );
- }
- } else {
- for ( index in data ) {
- if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
- stopQueue( data[ index ] );
- }
- }
- }
-
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
- timers[ index ].anim.stop( gotoEnd );
- dequeue = false;
- timers.splice( index, 1 );
- }
- }
-
- // start the next in the queue if the last step wasn't forced
- // timers currently will call their complete callbacks, which will dequeue
- // but only if they were gotoEnd
- if ( dequeue || !gotoEnd ) {
- jQuery.dequeue( this, type );
- }
- });
- }
-});
-
-// Generate parameters to create a standard animation
-function genFx( type, includeWidth ) {
- var which,
- attrs = { height: type },
- i = 0;
-
- // if we include width, step value is 1 to do all cssExpand values,
- // if we don't include width, step value is 2 to skip over Left and Right
- includeWidth = includeWidth? 1 : 0;
- for( ; i < 4 ; i += 2 - includeWidth ) {
- which = cssExpand[ i ];
- attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
- }
-
- if ( includeWidth ) {
- attrs.opacity = attrs.width = type;
- }
-
- return attrs;
-}
-
-// Generate shortcuts for custom animations
-jQuery.each({
- slideDown: genFx("show"),
- slideUp: genFx("hide"),
- slideToggle: genFx("toggle"),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
-});
-
-jQuery.speed = function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
- complete: fn || !fn && easing ||
- jQuery.isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
- };
-
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
-
- // normalize opt.queue - true/undefined/null -> "fx"
- if ( opt.queue == null || opt.queue === true ) {
- opt.queue = "fx";
- }
-
- // Queueing
- opt.old = opt.complete;
-
- opt.complete = function() {
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
-
- if ( opt.queue ) {
- jQuery.dequeue( this, opt.queue );
- }
- };
-
- return opt;
-};
-
-jQuery.easing = {
- linear: function( p ) {
- return p;
- },
- swing: function( p ) {
- return 0.5 - Math.cos( p*Math.PI ) / 2;
- }
-};
-
-jQuery.timers = [];
-jQuery.fx = Tween.prototype.init;
-jQuery.fx.tick = function() {
- var timer,
- timers = jQuery.timers,
- i = 0;
-
- for ( ; i < timers.length; i++ ) {
- timer = timers[ i ];
- // Checks the timer has not already been removed
- if ( !timer() && timers[ i ] === timer ) {
- timers.splice( i--, 1 );
- }
- }
-
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
-};
-
-jQuery.fx.timer = function( timer ) {
- if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
- timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
- }
-};
-
-jQuery.fx.interval = 13;
-
-jQuery.fx.stop = function() {
- clearInterval( timerId );
- timerId = null;
-};
-
-jQuery.fx.speeds = {
- slow: 600,
- fast: 200,
- // Default speed
- _default: 400
-};
-
-// Back Compat <1.8 extension point
-jQuery.fx.step = {};
-
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep(jQuery.timers, function( fn ) {
- return elem === fn.elem;
- }).length;
- };
-}
-var rroot = /^(?:body|html)$/i;
-
-jQuery.fn.offset = function( options ) {
- if ( arguments.length ) {
- return options === undefined ?
- this :
- this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
- box = { top: 0, left: 0 },
- elem = this[ 0 ],
- doc = elem && elem.ownerDocument;
-
- if ( !doc ) {
- return;
- }
-
- if ( (body = doc.body) === elem ) {
- return jQuery.offset.bodyOffset( elem );
- }
-
- docElem = doc.documentElement;
-
- // Make sure it's not a disconnected DOM node
- if ( !jQuery.contains( docElem, elem ) ) {
- return box;
- }
-
- // If we don't have gBCR, just use 0,0 rather than error
- // BlackBerry 5, iOS 3 (original iPhone)
- if ( typeof elem.getBoundingClientRect !== "undefined" ) {
- box = elem.getBoundingClientRect();
- }
- win = getWindow( doc );
- clientTop = docElem.clientTop || body.clientTop || 0;
- clientLeft = docElem.clientLeft || body.clientLeft || 0;
- scrollTop = win.pageYOffset || docElem.scrollTop;
- scrollLeft = win.pageXOffset || docElem.scrollLeft;
- return {
- top: box.top + scrollTop - clientTop,
- left: box.left + scrollLeft - clientLeft
- };
-};
-
-jQuery.offset = {
-
- bodyOffset: function( body ) {
- var top = body.offsetTop,
- left = body.offsetLeft;
-
- if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
- top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
- left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
- }
-
- return { top: top, left: left };
- },
-
- setOffset: function( elem, options, i ) {
- var position = jQuery.css( elem, "position" );
-
- // set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
-
- var curElem = jQuery( elem ),
- curOffset = curElem.offset(),
- curCSSTop = jQuery.css( elem, "top" ),
- curCSSLeft = jQuery.css( elem, "left" ),
- calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
- props = {}, curPosition = {}, curTop, curLeft;
-
- // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
- if ( calculatePosition ) {
- curPosition = curElem.position();
- curTop = curPosition.top;
- curLeft = curPosition.left;
- } else {
- curTop = parseFloat( curCSSTop ) || 0;
- curLeft = parseFloat( curCSSLeft ) || 0;
- }
-
- if ( jQuery.isFunction( options ) ) {
- options = options.call( elem, i, curOffset );
- }
-
- if ( options.top != null ) {
- props.top = ( options.top - curOffset.top ) + curTop;
- }
- if ( options.left != null ) {
- props.left = ( options.left - curOffset.left ) + curLeft;
- }
-
- if ( "using" in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- }
-};
-
-
-jQuery.fn.extend({
-
- position: function() {
- if ( !this[0] ) {
- return;
- }
-
- var elem = this[0],
-
- // Get *real* offsetParent
- offsetParent = this.offsetParent(),
-
- // Get correct offsets
- offset = this.offset(),
- parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
-
- // Subtract element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
- // are the same in Safari causing offset.left to incorrectly be 0
- offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
- offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
-
- // Add offsetParent borders
- parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
- parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
-
- // Subtract the two offsets
- return {
- top: offset.top - parentOffset.top,
- left: offset.left - parentOffset.left
- };
- },
-
- offsetParent: function() {
- return this.map(function() {
- var offsetParent = this.offsetParent || document.body;
- while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent || document.body;
- });
- }
-});
-
-
-// Create scrollLeft and scrollTop methods
-jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
- var top = /Y/.test( prop );
-
- jQuery.fn[ method ] = function( val ) {
- return jQuery.access( this, function( elem, method, val ) {
- var win = getWindow( elem );
-
- if ( val === undefined ) {
- return win ? (prop in win) ? win[ prop ] :
- win.document.documentElement[ method ] :
- elem[ method ];
- }
-
- if ( win ) {
- win.scrollTo(
- !top ? val : jQuery( win ).scrollLeft(),
- top ? val : jQuery( win ).scrollTop()
- );
-
- } else {
- elem[ method ] = val;
- }
- }, method, val, arguments.length, null );
- };
-});
-
-function getWindow( elem ) {
- return jQuery.isWindow( elem ) ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
-}
-// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
-jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
- jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
- // margin is only for outerHeight, outerWidth
- jQuery.fn[ funcName ] = function( margin, value ) {
- var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
- extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
-
- return jQuery.access( this, function( elem, type, value ) {
- var doc;
-
- if ( jQuery.isWindow( elem ) ) {
- // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
- // isn't a whole lot we can do. See pull request at this URL for discussion:
- // https://github.com/jquery/jquery/pull/764
- return elem.document.documentElement[ "client" + name ];
- }
-
- // Get document width or height
- if ( elem.nodeType === 9 ) {
- doc = elem.documentElement;
-
- // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
- // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
- return Math.max(
- elem.body[ "scroll" + name ], doc[ "scroll" + name ],
- elem.body[ "offset" + name ], doc[ "offset" + name ],
- doc[ "client" + name ]
- );
- }
-
- return value === undefined ?
- // Get width or height on the element, requesting but not forcing parseFloat
- jQuery.css( elem, type, value, extra ) :
-
- // Set width or height on the element
- jQuery.style( elem, type, value, extra );
- }, type, chainable ? margin : undefined, chainable, null );
- };
- });
-});
-// Expose jQuery to the global object
-window.jQuery = window.$ = jQuery;
-
-// Expose jQuery as an AMD module, but only for AMD loaders that
-// understand the issues with loading multiple versions of jQuery
-// in a page that all might call define(). The loader will indicate
-// they have special allowances for multiple jQuery versions by
-// specifying define.amd.jQuery = true. Register as a named module,
-// since jQuery can be concatenated with other files that may use define,
-// but not use a proper concatenation script that understands anonymous
-// AMD modules. A named AMD is safest and most robust way to register.
-// Lowercase jquery is used because AMD module names are derived from
-// file names, and jQuery is normally delivered in a lowercase file name.
-// Do this after creating the global so that if an AMD module wants to call
-// noConflict to hide this version of jQuery, it will work.
-if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
- define( "jquery", [], function () { return jQuery; } );
-}
-
-})( window );
--- a/domino/godoc/pkg.html
+++ /dev/null
@@ -1,2252 +1,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<meta charset="utf-8">
-<meta name="description" content="Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<meta name="theme-color" content="#00ADD8">
-
- <title>Packages - The Go Programming Language</title>
-
-<link href="https://fonts.googleapis.com/css?family=Work+Sans:600|Roboto:400,700" rel="stylesheet">
-<link href="https://fonts.googleapis.com/css?family=Product+Sans&text=Supported%20by%20Google&display=swap" rel="stylesheet">
-<link type="text/css" rel="stylesheet" href="/lib/godoc/style.css">
-
-<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
-
-<script>window.initFuncs = [];</script>
-
-<script>
-var _gaq = _gaq || [];
-_gaq.push(["_setAccount", "UA-11222381-2"]);
-window.trackPageview = function() {
- _gaq.push(["_trackPageview", location.pathname+location.hash]);
-};
-window.trackPageview();
-window.trackEvent = function(category, action, opt_label, opt_value, opt_noninteraction) {
- _gaq.push(["_trackEvent", category, action, opt_label, opt_value, opt_noninteraction]);
-};
-</script>
-
-<script src="/lib/godoc/jquery.js" defer></script>
-
-
-<script src="/lib/godoc/playground.js" defer></script>
-
-<script>var goVersion = "go1.15.6";</script>
-<script src="/lib/godoc/godocs.js" defer></script>
-
-<body class="Site">
-<header class="Header js-header">
- <div class="Header-banner">
- Black Lives Matter.
- <a href="https://support.eji.org/give/153413/#!/donation/checkout"
- target="_blank"
- rel="noopener">Support the Equal Justice Initiative.</a>
- </div>
- <nav class="Header-nav Header-nav--wide">
- <a href="/"><img class="Header-logo" src="/lib/godoc/images/go-logo-blue.svg" alt="Go"></a>
- <button class="Header-menuButton js-headerMenuButton" aria-label="Main menu" aria-expanded="false">
- <div class="Header-menuButtonInner"></div>
- </button>
- <ul class="Header-menu">
- <li class="Header-menuItem"><a href="/doc/">Documents</a></li>
- <li class="Header-menuItem"><a href="/pkg/">Packages</a></li>
- <li class="Header-menuItem"><a href="/project/">The Project</a></li>
- <li class="Header-menuItem"><a href="/help/">Help</a></li>
-
- <li class="Header-menuItem"><a href="/blog/">Blog</a></li>
-
- <li class="Header-menuItem"><a href="https://play.golang.org/">Play</a></li>
-
-
- <li class="Header-menuItem Header-menuItem--search">
- <form class="HeaderSearch" role="search" action="/search">
- <input class="HeaderSearch-input"
- type="search"
- name="q"
- placeholder="Search"
- aria-label="Search"
- autocapitalize="off"
- autocomplete="off"
- autocorrect="off"
- spellcheck="false"
- required>
- <button class="HeaderSearch-submit">
- <!-- magnifying glass: --><svg class="HeaderSearch-icon" width="24" height="24" viewBox="0 0 24 24"><title>Search</title><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
- </button>
- </form>
- </li>
- </ul>
- </nav>
-</header>
-
-<main id="page" class="Site-content wide">
-<div class="container">
-
-
- <h1>
- Packages
- <span class="text-muted"></span>
- </h1>
-
-
-
-
-
-
-
-<div id="nav"></div>
-
-
-<!--
- Copyright 2018 The Go Authors. All rights reserved.
- Use of this source code is governed by a BSD-style
- license that can be found in the LICENSE file.
--->
-<!--
- Note: Static (i.e., not template-generated) href and id
- attributes start with "pkg-" to make it impossible for
- them to conflict with generated attributes (some of which
- correspond to Go identifiers).
--->
-
-
-
-
-
- <div id="manual-nav">
- <dl>
- <dt><a href="#stdlib">Standard library</a></dt>
-
- <dt><a href="#other">Other packages</a></dt>
- <dd><a href="#subrepo">Sub-repositories</a></dd>
- <dd><a href="#community">Community</a></dd>
- </dl>
- </div>
-
- <div id="stdlib" class="toggleVisible">
- <div class="collapsed">
- <h2 class="toggleButton" title="Click to show Standard library section">Standard library ▹</h2>
- </div>
- <div class="expanded">
- <h2 class="toggleButton" title="Click to hide Standard library section">Standard library ▾</h2>
- <img alt="" class="gopher" src="/doc/gopher/pkg.png"/>
- <div class="pkg-dir">
- <table>
- <tr>
- <th class="pkg-name">Name</th>
- <th class="pkg-synopsis">Synopsis</th>
- </tr>
-
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="archive/">archive</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="archive/tar/">tar</a>
- </td>
-
- <td class="pkg-synopsis">
- Package tar implements access to tar archives.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="archive/zip/">zip</a>
- </td>
-
- <td class="pkg-synopsis">
- Package zip provides support for reading and writing ZIP archives.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="bufio/">bufio</a>
- </td>
-
- <td class="pkg-synopsis">
- Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="builtin/">builtin</a>
- </td>
-
- <td class="pkg-synopsis">
- Package builtin provides documentation for Go's predeclared identifiers.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="bytes/">bytes</a>
- </td>
-
- <td class="pkg-synopsis">
- Package bytes implements functions for the manipulation of byte slices.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="compress/">compress</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="compress/bzip2/">bzip2</a>
- </td>
-
- <td class="pkg-synopsis">
- Package bzip2 implements bzip2 decompression.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="compress/flate/">flate</a>
- </td>
-
- <td class="pkg-synopsis">
- Package flate implements the DEFLATE compressed data format, described in RFC 1951.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="compress/gzip/">gzip</a>
- </td>
-
- <td class="pkg-synopsis">
- Package gzip implements reading and writing of gzip format compressed files, as specified in RFC 1952.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="compress/lzw/">lzw</a>
- </td>
-
- <td class="pkg-synopsis">
- Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="compress/zlib/">zlib</a>
- </td>
-
- <td class="pkg-synopsis">
- Package zlib implements reading and writing of zlib format compressed data, as specified in RFC 1950.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="container/">container</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="container/heap/">heap</a>
- </td>
-
- <td class="pkg-synopsis">
- Package heap provides heap operations for any type that implements heap.Interface.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="container/list/">list</a>
- </td>
-
- <td class="pkg-synopsis">
- Package list implements a doubly linked list.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="container/ring/">ring</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ring implements operations on circular lists.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="context/">context</a>
- </td>
-
- <td class="pkg-synopsis">
- Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="crypto/">crypto</a>
- </td>
-
- <td class="pkg-synopsis">
- Package crypto collects common cryptographic constants.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/aes/">aes</a>
- </td>
-
- <td class="pkg-synopsis">
- Package aes implements AES encryption (formerly Rijndael), as defined in U.S. Federal Information Processing Standards Publication 197.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/cipher/">cipher</a>
- </td>
-
- <td class="pkg-synopsis">
- Package cipher implements standard block cipher modes that can be wrapped around low-level block cipher implementations.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/des/">des</a>
- </td>
-
- <td class="pkg-synopsis">
- Package des implements the Data Encryption Standard (DES) and the Triple Data Encryption Algorithm (TDEA) as defined in U.S. Federal Information Processing Standards Publication 46-3.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/dsa/">dsa</a>
- </td>
-
- <td class="pkg-synopsis">
- Package dsa implements the Digital Signature Algorithm, as defined in FIPS 186-3.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/ecdsa/">ecdsa</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ecdsa implements the Elliptic Curve Digital Signature Algorithm, as defined in FIPS 186-3.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/ed25519/">ed25519</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ed25519 implements the Ed25519 signature algorithm.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/elliptic/">elliptic</a>
- </td>
-
- <td class="pkg-synopsis">
- Package elliptic implements several standard elliptic curves over prime fields.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/hmac/">hmac</a>
- </td>
-
- <td class="pkg-synopsis">
- Package hmac implements the Keyed-Hash Message Authentication Code (HMAC) as defined in U.S. Federal Information Processing Standards Publication 198.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/md5/">md5</a>
- </td>
-
- <td class="pkg-synopsis">
- Package md5 implements the MD5 hash algorithm as defined in RFC 1321.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/rand/">rand</a>
- </td>
-
- <td class="pkg-synopsis">
- Package rand implements a cryptographically secure random number generator.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/rc4/">rc4</a>
- </td>
-
- <td class="pkg-synopsis">
- Package rc4 implements RC4 encryption, as defined in Bruce Schneier's Applied Cryptography.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/rsa/">rsa</a>
- </td>
-
- <td class="pkg-synopsis">
- Package rsa implements RSA encryption as specified in PKCS #1 and RFC 8017.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/sha1/">sha1</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sha1 implements the SHA-1 hash algorithm as defined in RFC 3174.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/sha256/">sha256</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/sha512/">sha512</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256 hash algorithms as defined in FIPS 180-4.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/subtle/">subtle</a>
- </td>
-
- <td class="pkg-synopsis">
- Package subtle implements functions that are often useful in cryptographic code but require careful thought to use correctly.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/tls/">tls</a>
- </td>
-
- <td class="pkg-synopsis">
- Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="crypto/x509/">x509</a>
- </td>
-
- <td class="pkg-synopsis">
- Package x509 parses X.509-encoded keys and certificates.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="crypto/x509/pkix/">pkix</a>
- </td>
-
- <td class="pkg-synopsis">
- Package pkix contains shared, low level structures used for ASN.1 parsing and serialization of X.509 certificates, CRL and OCSP.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="database/">database</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="database/sql/">sql</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sql provides a generic interface around SQL (or SQL-like) databases.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="database/sql/driver/">driver</a>
- </td>
-
- <td class="pkg-synopsis">
- Package driver defines interfaces to be implemented by database drivers as used by package sql.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="debug/">debug</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/dwarf/">dwarf</a>
- </td>
-
- <td class="pkg-synopsis">
- Package dwarf provides access to DWARF debugging information loaded from executable files, as defined in the DWARF 2.0 Standard at http://dwarfstd.org/doc/dwarf-2.0.0.pdf
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/elf/">elf</a>
- </td>
-
- <td class="pkg-synopsis">
- Package elf implements access to ELF object files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/gosym/">gosym</a>
- </td>
-
- <td class="pkg-synopsis">
- Package gosym implements access to the Go symbol and line number tables embedded in Go binaries generated by the gc compilers.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/macho/">macho</a>
- </td>
-
- <td class="pkg-synopsis">
- Package macho implements access to Mach-O object files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/pe/">pe</a>
- </td>
-
- <td class="pkg-synopsis">
- Package pe implements access to PE (Microsoft Windows Portable Executable) files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="debug/plan9obj/">plan9obj</a>
- </td>
-
- <td class="pkg-synopsis">
- Package plan9obj implements access to Plan 9 a.out object files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="encoding/">encoding</a>
- </td>
-
- <td class="pkg-synopsis">
- Package encoding defines interfaces shared by other packages that convert data to and from byte-level and textual representations.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/ascii85/">ascii85</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ascii85 implements the ascii85 data encoding as used in the btoa tool and Adobe's PostScript and PDF document formats.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/asn1/">asn1</a>
- </td>
-
- <td class="pkg-synopsis">
- Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/base32/">base32</a>
- </td>
-
- <td class="pkg-synopsis">
- Package base32 implements base32 encoding as specified by RFC 4648.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/base64/">base64</a>
- </td>
-
- <td class="pkg-synopsis">
- Package base64 implements base64 encoding as specified by RFC 4648.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/binary/">binary</a>
- </td>
-
- <td class="pkg-synopsis">
- Package binary implements simple translation between numbers and byte sequences and encoding and decoding of varints.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/csv/">csv</a>
- </td>
-
- <td class="pkg-synopsis">
- Package csv reads and writes comma-separated values (CSV) files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/gob/">gob</a>
- </td>
-
- <td class="pkg-synopsis">
- Package gob manages streams of gobs - binary values exchanged between an Encoder (transmitter) and a Decoder (receiver).
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/hex/">hex</a>
- </td>
-
- <td class="pkg-synopsis">
- Package hex implements hexadecimal encoding and decoding.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/json/">json</a>
- </td>
-
- <td class="pkg-synopsis">
- Package json implements encoding and decoding of JSON as defined in RFC 7159.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/pem/">pem</a>
- </td>
-
- <td class="pkg-synopsis">
- Package pem implements the PEM data encoding, which originated in Privacy Enhanced Mail.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="encoding/xml/">xml</a>
- </td>
-
- <td class="pkg-synopsis">
- Package xml implements a simple XML 1.0 parser that understands XML name spaces.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="errors/">errors</a>
- </td>
-
- <td class="pkg-synopsis">
- Package errors implements functions to manipulate errors.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="expvar/">expvar</a>
- </td>
-
- <td class="pkg-synopsis">
- Package expvar provides a standardized interface to public variables, such as operation counters in servers.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="flag/">flag</a>
- </td>
-
- <td class="pkg-synopsis">
- Package flag implements command-line flag parsing.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="fmt/">fmt</a>
- </td>
-
- <td class="pkg-synopsis">
- Package fmt implements formatted I/O with functions analogous to C's printf and scanf.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="go/">go</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/ast/">ast</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ast declares the types used to represent syntax trees for Go packages.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/build/">build</a>
- </td>
-
- <td class="pkg-synopsis">
- Package build gathers information about Go packages.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/constant/">constant</a>
- </td>
-
- <td class="pkg-synopsis">
- Package constant implements Values representing untyped Go constants and their corresponding operations.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/doc/">doc</a>
- </td>
-
- <td class="pkg-synopsis">
- Package doc extracts source code documentation from a Go AST.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/format/">format</a>
- </td>
-
- <td class="pkg-synopsis">
- Package format implements standard formatting of Go source.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/importer/">importer</a>
- </td>
-
- <td class="pkg-synopsis">
- Package importer provides access to export data importers.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/parser/">parser</a>
- </td>
-
- <td class="pkg-synopsis">
- Package parser implements a parser for Go source files.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/printer/">printer</a>
- </td>
-
- <td class="pkg-synopsis">
- Package printer implements printing of AST nodes.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/scanner/">scanner</a>
- </td>
-
- <td class="pkg-synopsis">
- Package scanner implements a scanner for Go source text.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/token/">token</a>
- </td>
-
- <td class="pkg-synopsis">
- Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="go/types/">types</a>
- </td>
-
- <td class="pkg-synopsis">
- Package types declares the data types and implements the algorithms for type-checking of Go packages.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="hash/">hash</a>
- </td>
-
- <td class="pkg-synopsis">
- Package hash provides interfaces for hash functions.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="hash/adler32/">adler32</a>
- </td>
-
- <td class="pkg-synopsis">
- Package adler32 implements the Adler-32 checksum.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="hash/crc32/">crc32</a>
- </td>
-
- <td class="pkg-synopsis">
- Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, checksum.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="hash/crc64/">crc64</a>
- </td>
-
- <td class="pkg-synopsis">
- Package crc64 implements the 64-bit cyclic redundancy check, or CRC-64, checksum.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="hash/fnv/">fnv</a>
- </td>
-
- <td class="pkg-synopsis">
- Package fnv implements FNV-1 and FNV-1a, non-cryptographic hash functions created by Glenn Fowler, Landon Curt Noll, and Phong Vo.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="hash/maphash/">maphash</a>
- </td>
-
- <td class="pkg-synopsis">
- Package maphash provides hash functions on byte sequences.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="html/">html</a>
- </td>
-
- <td class="pkg-synopsis">
- Package html provides functions for escaping and unescaping HTML text.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="html/template/">template</a>
- </td>
-
- <td class="pkg-synopsis">
- Package template (html/template) implements data-driven templates for generating HTML output safe against code injection.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="image/">image</a>
- </td>
-
- <td class="pkg-synopsis">
- Package image implements a basic 2-D image library.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="image/color/">color</a>
- </td>
-
- <td class="pkg-synopsis">
- Package color implements a basic color library.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="image/color/palette/">palette</a>
- </td>
-
- <td class="pkg-synopsis">
- Package palette provides standard color palettes.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="image/draw/">draw</a>
- </td>
-
- <td class="pkg-synopsis">
- Package draw provides image composition functions.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="image/gif/">gif</a>
- </td>
-
- <td class="pkg-synopsis">
- Package gif implements a GIF image decoder and encoder.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="image/jpeg/">jpeg</a>
- </td>
-
- <td class="pkg-synopsis">
- Package jpeg implements a JPEG image decoder and encoder.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="image/png/">png</a>
- </td>
-
- <td class="pkg-synopsis">
- Package png implements a PNG image decoder and encoder.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="index/">index</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="index/suffixarray/">suffixarray</a>
- </td>
-
- <td class="pkg-synopsis">
- Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="io/">io</a>
- </td>
-
- <td class="pkg-synopsis">
- Package io provides basic interfaces to I/O primitives.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="io/ioutil/">ioutil</a>
- </td>
-
- <td class="pkg-synopsis">
- Package ioutil implements some I/O utility functions.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="log/">log</a>
- </td>
-
- <td class="pkg-synopsis">
- Package log implements a simple logging package.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="log/syslog/">syslog</a>
- </td>
-
- <td class="pkg-synopsis">
- Package syslog provides a simple interface to the system log service.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="math/">math</a>
- </td>
-
- <td class="pkg-synopsis">
- Package math provides basic constants and mathematical functions.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="math/big/">big</a>
- </td>
-
- <td class="pkg-synopsis">
- Package big implements arbitrary-precision arithmetic (big numbers).
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="math/bits/">bits</a>
- </td>
-
- <td class="pkg-synopsis">
- Package bits implements bit counting and manipulation functions for the predeclared unsigned integer types.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="math/cmplx/">cmplx</a>
- </td>
-
- <td class="pkg-synopsis">
- Package cmplx provides basic constants and mathematical functions for complex numbers.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="math/rand/">rand</a>
- </td>
-
- <td class="pkg-synopsis">
- Package rand implements pseudo-random number generators.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="mime/">mime</a>
- </td>
-
- <td class="pkg-synopsis">
- Package mime implements parts of the MIME spec.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="mime/multipart/">multipart</a>
- </td>
-
- <td class="pkg-synopsis">
- Package multipart implements MIME multipart parsing, as defined in RFC 2046.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="mime/quotedprintable/">quotedprintable</a>
- </td>
-
- <td class="pkg-synopsis">
- Package quotedprintable implements quoted-printable encoding as specified by RFC 2045.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="net/">net</a>
- </td>
-
- <td class="pkg-synopsis">
- Package net provides a portable interface for network I/O, including TCP/IP, UDP, domain name resolution, and Unix domain sockets.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/http/">http</a>
- </td>
-
- <td class="pkg-synopsis">
- Package http provides HTTP client and server implementations.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/cgi/">cgi</a>
- </td>
-
- <td class="pkg-synopsis">
- Package cgi implements CGI (Common Gateway Interface) as specified in RFC 3875.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/cookiejar/">cookiejar</a>
- </td>
-
- <td class="pkg-synopsis">
- Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/fcgi/">fcgi</a>
- </td>
-
- <td class="pkg-synopsis">
- Package fcgi implements the FastCGI protocol.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/httptest/">httptest</a>
- </td>
-
- <td class="pkg-synopsis">
- Package httptest provides utilities for HTTP testing.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/httptrace/">httptrace</a>
- </td>
-
- <td class="pkg-synopsis">
- Package httptrace provides mechanisms to trace the events within HTTP client requests.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/httputil/">httputil</a>
- </td>
-
- <td class="pkg-synopsis">
- Package httputil provides HTTP utility functions, complementing the more common ones in the net/http package.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/http/pprof/">pprof</a>
- </td>
-
- <td class="pkg-synopsis">
- Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/mail/">mail</a>
- </td>
-
- <td class="pkg-synopsis">
- Package mail implements parsing of mail messages.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/rpc/">rpc</a>
- </td>
-
- <td class="pkg-synopsis">
- Package rpc provides access to the exported methods of an object across a network or other I/O connection.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="net/rpc/jsonrpc/">jsonrpc</a>
- </td>
-
- <td class="pkg-synopsis">
- Package jsonrpc implements a JSON-RPC 1.0 ClientCodec and ServerCodec for the rpc package.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/smtp/">smtp</a>
- </td>
-
- <td class="pkg-synopsis">
- Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/textproto/">textproto</a>
- </td>
-
- <td class="pkg-synopsis">
- Package textproto implements generic support for text-based request/response protocols in the style of HTTP, NNTP, and SMTP.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="net/url/">url</a>
- </td>
-
- <td class="pkg-synopsis">
- Package url parses URLs and implements query escaping.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="os/">os</a>
- </td>
-
- <td class="pkg-synopsis">
- Package os provides a platform-independent interface to operating system functionality.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="os/exec/">exec</a>
- </td>
-
- <td class="pkg-synopsis">
- Package exec runs external commands.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="os/signal/">signal</a>
- </td>
-
- <td class="pkg-synopsis">
- Package signal implements access to incoming signals.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="os/user/">user</a>
- </td>
-
- <td class="pkg-synopsis">
- Package user allows user account lookups by name or id.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="path/">path</a>
- </td>
-
- <td class="pkg-synopsis">
- Package path implements utility routines for manipulating slash-separated paths.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="path/filepath/">filepath</a>
- </td>
-
- <td class="pkg-synopsis">
- Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="plugin/">plugin</a>
- </td>
-
- <td class="pkg-synopsis">
- Package plugin implements loading and symbol resolution of Go plugins.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="reflect/">reflect</a>
- </td>
-
- <td class="pkg-synopsis">
- Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="regexp/">regexp</a>
- </td>
-
- <td class="pkg-synopsis">
- Package regexp implements regular expression search.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="regexp/syntax/">syntax</a>
- </td>
-
- <td class="pkg-synopsis">
- Package syntax parses regular expressions into parse trees and compiles parse trees into programs.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="runtime/">runtime</a>
- </td>
-
- <td class="pkg-synopsis">
- Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/cgo/">cgo</a>
- </td>
-
- <td class="pkg-synopsis">
- Package cgo contains runtime support for code generated by the cgo tool.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/debug/">debug</a>
- </td>
-
- <td class="pkg-synopsis">
- Package debug contains facilities for programs to debug themselves while they are running.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/msan/">msan</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/pprof/">pprof</a>
- </td>
-
- <td class="pkg-synopsis">
- Package pprof writes runtime profiling data in the format expected by the pprof visualization tool.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/race/">race</a>
- </td>
-
- <td class="pkg-synopsis">
- Package race implements data race detection logic.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="runtime/trace/">trace</a>
- </td>
-
- <td class="pkg-synopsis">
- Package trace contains facilities for programs to generate traces for the Go execution tracer.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="sort/">sort</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sort provides primitives for sorting slices and user-defined collections.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="strconv/">strconv</a>
- </td>
-
- <td class="pkg-synopsis">
- Package strconv implements conversions to and from string representations of basic data types.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="strings/">strings</a>
- </td>
-
- <td class="pkg-synopsis">
- Package strings implements simple functions to manipulate UTF-8 encoded strings.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="sync/">sync</a>
- </td>
-
- <td class="pkg-synopsis">
- Package sync provides basic synchronization primitives such as mutual exclusion locks.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="sync/atomic/">atomic</a>
- </td>
-
- <td class="pkg-synopsis">
- Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="syscall/">syscall</a>
- </td>
-
- <td class="pkg-synopsis">
- Package syscall contains an interface to the low-level operating system primitives.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="syscall/js/">js</a>
- </td>
-
- <td class="pkg-synopsis">
- Package js gives access to the WebAssembly host environment when using the js/wasm architecture.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="testing/">testing</a>
- </td>
-
- <td class="pkg-synopsis">
- Package testing provides support for automated testing of Go packages.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="testing/iotest/">iotest</a>
- </td>
-
- <td class="pkg-synopsis">
- Package iotest implements Readers and Writers useful mainly for testing.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="testing/quick/">quick</a>
- </td>
-
- <td class="pkg-synopsis">
- Package quick implements utility functions to help with black box testing.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="text/">text</a>
- </td>
-
- <td class="pkg-synopsis">
-
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="text/scanner/">scanner</a>
- </td>
-
- <td class="pkg-synopsis">
- Package scanner provides a scanner and tokenizer for UTF-8-encoded text.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="text/tabwriter/">tabwriter</a>
- </td>
-
- <td class="pkg-synopsis">
- Package tabwriter implements a write filter (tabwriter.Writer) that translates tabbed columns in input into properly aligned text.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="text/template/">template</a>
- </td>
-
- <td class="pkg-synopsis">
- Package template implements data-driven templates for generating textual output.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 40px;">
- <a href="text/template/parse/">parse</a>
- </td>
-
- <td class="pkg-synopsis">
- Package parse builds parse trees for templates as defined by text/template and html/template.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="time/">time</a>
- </td>
-
- <td class="pkg-synopsis">
- Package time provides functionality for measuring and displaying time.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="time/tzdata/">tzdata</a>
- </td>
-
- <td class="pkg-synopsis">
- Package tzdata provides an embedded copy of the timezone database.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="unicode/">unicode</a>
- </td>
-
- <td class="pkg-synopsis">
- Package unicode provides data and functions to test some properties of Unicode code points.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="unicode/utf16/">utf16</a>
- </td>
-
- <td class="pkg-synopsis">
- Package utf16 implements encoding and decoding of UTF-16 sequences.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 20px;">
- <a href="unicode/utf8/">utf8</a>
- </td>
-
- <td class="pkg-synopsis">
- Package utf8 implements functions and constants to support text encoded in UTF-8.
- </td>
-
- </tr>
-
- <tr>
-
-
- <td class="pkg-name" style="padding-left: 0px;">
- <a href="unsafe/">unsafe</a>
- </td>
-
- <td class="pkg-synopsis">
- Package unsafe contains operations that step around the type safety of Go programs.
- </td>
-
- </tr>
-
- </table>
- </div> <!-- .pkg-dir -->
- </div> <!-- .expanded -->
- </div> <!-- #stdlib .toggleVisible -->
-
-
-
- <h2 id="other">Other packages</h2>
- <h3 id="subrepo">Sub-repositories</h3>
- <p>
- These packages are part of the Go Project but outside the main Go tree.
- They are developed under looser <a href="/doc/go1compat">compatibility requirements</a> than the Go core.
- Install them with "<a href="/cmd/go/#hdr-Download_and_install_packages_and_dependencies">go get</a>".
- </p>
- <ul>
- <li><a href="//pkg.go.dev/golang.org/x/benchmarks">benchmarks</a> — benchmarks to measure Go as it is developed.</li>
- <li><a href="//pkg.go.dev/golang.org/x/blog">blog</a> — <a href="//blog.golang.org">blog.golang.org</a>'s implementation.</li>
- <li><a href="//pkg.go.dev/golang.org/x/build">build</a> — <a href="//build.golang.org">build.golang.org</a>'s implementation.</li>
- <li><a href="//pkg.go.dev/golang.org/x/crypto">crypto</a> — additional cryptography packages.</li>
- <li><a href="//pkg.go.dev/golang.org/x/debug">debug</a> — an experimental debugger for Go.</li>
- <li><a href="//pkg.go.dev/golang.org/x/image">image</a> — additional imaging packages.</li>
- <li><a href="//pkg.go.dev/golang.org/x/mobile">mobile</a> — experimental support for Go on mobile platforms.</li>
- <li><a href="//pkg.go.dev/golang.org/x/net">net</a> — additional networking packages.</li>
- <li><a href="//pkg.go.dev/golang.org/x/perf">perf</a> — packages and tools for performance measurement, storage, and analysis.</li>
- <li><a href="//pkg.go.dev/golang.org/x/pkgsite">pkgsite</a> — home of the pkg.go.dev website.</li>
- <li><a href="//pkg.go.dev/golang.org/x/review">review</a> — a tool for working with Gerrit code reviews.</li>
- <li><a href="//pkg.go.dev/golang.org/x/sync">sync</a> — additional concurrency primitives.</li>
- <li><a href="//pkg.go.dev/golang.org/x/sys">sys</a> — packages for making system calls.</li>
- <li><a href="//pkg.go.dev/golang.org/x/text">text</a> — packages for working with text.</li>
- <li><a href="//pkg.go.dev/golang.org/x/time">time</a> — additional time packages.</li>
- <li><a href="//pkg.go.dev/golang.org/x/tools">tools</a> — godoc, goimports, gorename, and other tools.</li>
- <li><a href="//pkg.go.dev/golang.org/x/tour">tour</a> — <a href="//tour.golang.org">tour.golang.org</a>'s implementation.</li>
- <li><a href="//pkg.go.dev/golang.org/x/exp">exp</a> — experimental and deprecated packages (handle with care; may change without warning).</li>
- </ul>
-
- <h3 id="community">Community</h3>
- <p>
- These services can help you find Open Source packages provided by the community.
- </p>
- <ul>
- <li><a href="//pkg.go.dev">Pkg.go.dev</a> - the Go package discovery site.</li>
- <li><a href="/wiki/Projects">Projects at the Go Wiki</a> - a curated list of Go projects.</li>
- </ul>
-
-
-
-</div><!-- .container -->
-</main><!-- #page -->
-<footer>
- <div class="Footer Footer--wide">
- <img class="Footer-gopher" src="/lib/godoc/images/footer-gopher.jpg" alt="The Go Gopher">
- <ul class="Footer-links">
- <li class="Footer-link"><a href="/doc/copyright.html">Copyright</a></li>
- <li class="Footer-link"><a href="/doc/tos.html">Terms of Service</a></li>
- <li class="Footer-link"><a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a></li>
- <li class="Footer-link"><a href="http://golang.org/issues/new?title=x/website:" target="_blank" rel="noopener">Report a website issue</a></li>
- </ul>
- <a class="Footer-supportedBy" href="https://google.com">Supported by Google</a>
- </div>
-</footer>
-
-<script>
-(function() {
- var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
- ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
- var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
-})();
-</script>
-
-
--- a/domino/godoc/playground.js
+++ /dev/null
@@ -1,575 +1,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/*
-In the absence of any formal way to specify interfaces in JavaScript,
-here's a skeleton implementation of a playground transport.
-
- function Transport() {
- // Set up any transport state (eg, make a websocket connection).
- return {
- Run: function(body, output, options) {
- // Compile and run the program 'body' with 'options'.
- // Call the 'output' callback to display program output.
- return {
- Kill: function() {
- // Kill the running program.
- }
- };
- }
- };
- }
-
- // The output callback is called multiple times, and each time it is
- // passed an object of this form.
- var write = {
- Kind: 'string', // 'start', 'stdout', 'stderr', 'end'
- Body: 'string' // content of write or end status message
- }
-
- // The first call must be of Kind 'start' with no body.
- // Subsequent calls may be of Kind 'stdout' or 'stderr'
- // and must have a non-null Body string.
- // The final call should be of Kind 'end' with an optional
- // Body string, signifying a failure ("killed", for example).
-
- // The output callback must be of this form.
- // See PlaygroundOutput (below) for an implementation.
- function outputCallback(write) {
- }
-*/
-
-// HTTPTransport is the default transport.
-// enableVet enables running vet if a program was compiled and ran successfully.
-// If vet returned any errors, display them before the output of a program.
-function HTTPTransport(enableVet) {
- 'use strict';
-
- function playback(output, data) {
- // Backwards compatibility: default values do not affect the output.
- var events = data.Events || [];
- var errors = data.Errors || '';
- var status = data.Status || 0;
- var isTest = data.IsTest || false;
- var testsFailed = data.TestsFailed || 0;
-
- var timeout;
- output({ Kind: 'start' });
- function next() {
- if (!events || events.length === 0) {
- if (isTest) {
- if (testsFailed > 0) {
- output({
- Kind: 'system',
- Body:
- '\n' +
- testsFailed +
- ' test' +
- (testsFailed > 1 ? 's' : '') +
- ' failed.',
- });
- } else {
- output({ Kind: 'system', Body: '\nAll tests passed.' });
- }
- } else {
- if (status > 0) {
- output({ Kind: 'end', Body: 'status ' + status + '.' });
- } else {
- if (errors !== '') {
- // errors are displayed only in the case of timeout.
- output({ Kind: 'end', Body: errors + '.' });
- } else {
- output({ Kind: 'end' });
- }
- }
- }
- return;
- }
- var e = events.shift();
- if (e.Delay === 0) {
- output({ Kind: e.Kind, Body: e.Message });
- next();
- return;
- }
- timeout = setTimeout(function() {
- output({ Kind: e.Kind, Body: e.Message });
- next();
- }, e.Delay / 1000000);
- }
- next();
- return {
- Stop: function() {
- clearTimeout(timeout);
- },
- };
- }
-
- function error(output, msg) {
- output({ Kind: 'start' });
- output({ Kind: 'stderr', Body: msg });
- output({ Kind: 'end' });
- }
-
- function buildFailed(output, msg) {
- output({ Kind: 'start' });
- output({ Kind: 'stderr', Body: msg });
- output({ Kind: 'system', Body: '\nGo build failed.' });
- }
-
- var seq = 0;
- return {
- Run: function(body, output, options) {
- seq++;
- var cur = seq;
- var playing;
- $.ajax('/compile', {
- type: 'POST',
- data: { version: 2, body: body },
- dataType: 'json',
- success: function(data) {
- if (seq != cur) return;
- if (!data) return;
- if (playing != null) playing.Stop();
- if (data.Errors) {
- if (data.Errors === 'process took too long') {
- // Playback the output that was captured before the timeout.
- playing = playback(output, data);
- } else {
- buildFailed(output, data.Errors);
- }
- return;
- }
-
- if (!enableVet) {
- playing = playback(output, data);
- return;
- }
-
- $.ajax('/vet', {
- data: { body: body },
- type: 'POST',
- dataType: 'json',
- success: function(dataVet) {
- if (dataVet.Errors) {
- if (!data.Events) {
- data.Events = [];
- }
- // inject errors from the vet as the first events in the output
- data.Events.unshift({
- Message: 'Go vet exited.\n\n',
- Kind: 'system',
- Delay: 0,
- });
- data.Events.unshift({
- Message: dataVet.Errors,
- Kind: 'stderr',
- Delay: 0,
- });
- }
- playing = playback(output, data);
- },
- error: function() {
- playing = playback(output, data);
- },
- });
- },
- error: function() {
- error(output, 'Error communicating with remote server.');
- },
- });
- return {
- Kill: function() {
- if (playing != null) playing.Stop();
- output({ Kind: 'end', Body: 'killed' });
- },
- };
- },
- };
-}
-
-function SocketTransport() {
- 'use strict';
-
- var id = 0;
- var outputs = {};
- var started = {};
- var websocket;
- if (window.location.protocol == 'http:') {
- websocket = new WebSocket('ws://' + window.location.host + '/socket');
- } else if (window.location.protocol == 'https:') {
- websocket = new WebSocket('wss://' + window.location.host + '/socket');
- }
-
- websocket.onclose = function() {
- console.log('websocket connection closed');
- };
-
- websocket.onmessage = function(e) {
- var m = JSON.parse(e.data);
- var output = outputs[m.Id];
- if (output === null) return;
- if (!started[m.Id]) {
- output({ Kind: 'start' });
- started[m.Id] = true;
- }
- output({ Kind: m.Kind, Body: m.Body });
- };
-
- function send(m) {
- websocket.send(JSON.stringify(m));
- }
-
- return {
- Run: function(body, output, options) {
- var thisID = id + '';
- id++;
- outputs[thisID] = output;
- send({ Id: thisID, Kind: 'run', Body: body, Options: options });
- return {
- Kill: function() {
- send({ Id: thisID, Kind: 'kill' });
- },
- };
- },
- };
-}
-
-function PlaygroundOutput(el) {
- 'use strict';
-
- return function(write) {
- if (write.Kind == 'start') {
- el.innerHTML = '';
- return;
- }
-
- var cl = 'system';
- if (write.Kind == 'stdout' || write.Kind == 'stderr') cl = write.Kind;
-
- var m = write.Body;
- if (write.Kind == 'end') {
- m = '\nProgram exited' + (m ? ': ' + m : '.');
- }
-
- if (m.indexOf('IMAGE:') === 0) {
- // TODO(adg): buffer all writes before creating image
- var url = 'data:image/png;base64,' + m.substr(6);
- var img = document.createElement('img');
- img.src = url;
- el.appendChild(img);
- return;
- }
-
- // ^L clears the screen.
- var s = m.split('\x0c');
- if (s.length > 1) {
- el.innerHTML = '';
- m = s.pop();
- }
-
- m = m.replace(/&/g, '&');
- m = m.replace(/</g, '<');
- m = m.replace(/>/g, '>');
-
- var needScroll = el.scrollTop + el.offsetHeight == el.scrollHeight;
-
- var span = document.createElement('span');
- span.className = cl;
- span.innerHTML = m;
- el.appendChild(span);
-
- if (needScroll) el.scrollTop = el.scrollHeight - el.offsetHeight;
- };
-}
-
-(function() {
- function lineHighlight(error) {
- var regex = /prog.go:([0-9]+)/g;
- var r = regex.exec(error);
- while (r) {
- $('.lines div')
- .eq(r[1] - 1)
- .addClass('lineerror');
- r = regex.exec(error);
- }
- }
- function highlightOutput(wrappedOutput) {
- return function(write) {
- if (write.Body) lineHighlight(write.Body);
- wrappedOutput(write);
- };
- }
- function lineClear() {
- $('.lineerror').removeClass('lineerror');
- }
-
- // opts is an object with these keys
- // codeEl - code editor element
- // outputEl - program output element
- // runEl - run button element
- // fmtEl - fmt button element (optional)
- // fmtImportEl - fmt "imports" checkbox element (optional)
- // shareEl - share button element (optional)
- // shareURLEl - share URL text input element (optional)
- // shareRedirect - base URL to redirect to on share (optional)
- // toysEl - toys select element (optional)
- // enableHistory - enable using HTML5 history API (optional)
- // transport - playground transport to use (default is HTTPTransport)
- // enableShortcuts - whether to enable shortcuts (Ctrl+S/Cmd+S to save) (default is false)
- // enableVet - enable running vet and displaying its errors
- function playground(opts) {
- var code = $(opts.codeEl);
- var transport = opts['transport'] || new HTTPTransport(opts['enableVet']);
- var running;
-
- // autoindent helpers.
- function insertTabs(n) {
- // find the selection start and end
- var start = code[0].selectionStart;
- var end = code[0].selectionEnd;
- // split the textarea content into two, and insert n tabs
- var v = code[0].value;
- var u = v.substr(0, start);
- for (var i = 0; i < n; i++) {
- u += '\t';
- }
- u += v.substr(end);
- // set revised content
- code[0].value = u;
- // reset caret position after inserted tabs
- code[0].selectionStart = start + n;
- code[0].selectionEnd = start + n;
- }
- function autoindent(el) {
- var curpos = el.selectionStart;
- var tabs = 0;
- while (curpos > 0) {
- curpos--;
- if (el.value[curpos] == '\t') {
- tabs++;
- } else if (tabs > 0 || el.value[curpos] == '\n') {
- break;
- }
- }
- setTimeout(function() {
- insertTabs(tabs);
- }, 1);
- }
-
- // NOTE(cbro): e is a jQuery event, not a DOM event.
- function handleSaveShortcut(e) {
- if (e.isDefaultPrevented()) return false;
- if (!e.metaKey && !e.ctrlKey) return false;
- if (e.key != 'S' && e.key != 's') return false;
-
- e.preventDefault();
-
- // Share and save
- share(function(url) {
- window.location.href = url + '.go?download=true';
- });
-
- return true;
- }
-
- function keyHandler(e) {
- if (opts.enableShortcuts && handleSaveShortcut(e)) return;
-
- if (e.keyCode == 9 && !e.ctrlKey) {
- // tab (but not ctrl-tab)
- insertTabs(1);
- e.preventDefault();
- return false;
- }
- if (e.keyCode == 13) {
- // enter
- if (e.shiftKey) {
- // +shift
- run();
- e.preventDefault();
- return false;
- }
- if (e.ctrlKey) {
- // +control
- fmt();
- e.preventDefault();
- } else {
- autoindent(e.target);
- }
- }
- return true;
- }
- code.unbind('keydown').bind('keydown', keyHandler);
- var outdiv = $(opts.outputEl).empty();
- var output = $('<pre/>').appendTo(outdiv);
-
- function body() {
- return $(opts.codeEl).val();
- }
- function setBody(text) {
- $(opts.codeEl).val(text);
- }
- function origin(href) {
- return ('' + href)
- .split('/')
- .slice(0, 3)
- .join('/');
- }
-
- var pushedEmpty = window.location.pathname == '/';
- function inputChanged() {
- if (pushedEmpty) {
- return;
- }
- pushedEmpty = true;
- $(opts.shareURLEl).hide();
- window.history.pushState(null, '', '/');
- }
- function popState(e) {
- if (e === null) {
- return;
- }
- if (e && e.state && e.state.code) {
- setBody(e.state.code);
- }
- }
- var rewriteHistory = false;
- if (
- window.history &&
- window.history.pushState &&
- window.addEventListener &&
- opts.enableHistory
- ) {
- rewriteHistory = true;
- code[0].addEventListener('input', inputChanged);
- window.addEventListener('popstate', popState);
- }
-
- function setError(error) {
- if (running) running.Kill();
- lineClear();
- lineHighlight(error);
- output
- .empty()
- .addClass('error')
- .text(error);
- }
- function loading() {
- lineClear();
- if (running) running.Kill();
- output.removeClass('error').text('Waiting for remote server...');
- }
- function run() {
- loading();
- running = transport.Run(
- body(),
- highlightOutput(PlaygroundOutput(output[0]))
- );
- }
-
- function fmt() {
- loading();
- var data = { body: body() };
- if ($(opts.fmtImportEl).is(':checked')) {
- data['imports'] = 'true';
- }
- $.ajax('/fmt', {
- data: data,
- type: 'POST',
- dataType: 'json',
- success: function(data) {
- if (data.Error) {
- setError(data.Error);
- } else {
- setBody(data.Body);
- setError('');
- }
- },
- });
- }
-
- var shareURL; // jQuery element to show the shared URL.
- var sharing = false; // true if there is a pending request.
- var shareCallbacks = [];
- function share(opt_callback) {
- if (opt_callback) shareCallbacks.push(opt_callback);
-
- if (sharing) return;
- sharing = true;
-
- var sharingData = body();
- $.ajax('/share', {
- processData: false,
- data: sharingData,
- type: 'POST',
- contentType: 'text/plain; charset=utf-8',
- complete: function(xhr) {
- sharing = false;
- if (xhr.status != 200) {
- alert('Server error; try again.');
- return;
- }
- if (opts.shareRedirect) {
- window.location = opts.shareRedirect + xhr.responseText;
- }
- var path = '/p/' + xhr.responseText;
- var url = origin(window.location) + path;
-
- for (var i = 0; i < shareCallbacks.length; i++) {
- shareCallbacks[i](url);
- }
- shareCallbacks = [];
-
- if (shareURL) {
- shareURL
- .show()
- .val(url)
- .focus()
- .select();
-
- if (rewriteHistory) {
- var historyData = { code: sharingData };
- window.history.pushState(historyData, '', path);
- pushedEmpty = false;
- }
- }
- },
- });
- }
-
- $(opts.runEl).click(run);
- $(opts.fmtEl).click(fmt);
-
- if (
- opts.shareEl !== null &&
- (opts.shareURLEl !== null || opts.shareRedirect !== null)
- ) {
- if (opts.shareURLEl) {
- shareURL = $(opts.shareURLEl).hide();
- }
- $(opts.shareEl).click(function() {
- share();
- });
- }
-
- if (opts.toysEl !== null) {
- $(opts.toysEl).bind('change', function() {
- var toy = $(this).val();
- $.ajax('/doc/play/' + toy, {
- processData: false,
- type: 'GET',
- complete: function(xhr) {
- if (xhr.status != 200) {
- alert('Server error; try again.');
- return;
- }
- setBody(xhr.responseText);
- },
- });
- });
- }
- }
-
- window.playground = playground;
-})();
--- a/domino/jquery-3.5.1.js
+++ /dev/null
@@ -1,10872 +1,0 @@
-/*!
- * jQuery JavaScript Library v3.5.1
- * https://jquery.com/
- *
- * Includes Sizzle.js
- * https://sizzlejs.com/
- *
- * Copyright JS Foundation and other contributors
- * Released under the MIT license
- * https://jquery.org/license
- *
- * Date: 2020-05-04T22:49Z
- */
-( function( global, factory ) {
-
- "use strict";
-
- if ( typeof module === "object" && typeof module.exports === "object" ) {
-
- // For CommonJS and CommonJS-like environments where a proper `window`
- // is present, execute the factory and get jQuery.
- // For environments that do not have a `window` with a `document`
- // (such as Node.js), expose a factory as module.exports.
- // This accentuates the need for the creation of a real `window`.
- // e.g. var jQuery = require("jquery")(window);
- // See ticket #14549 for more info.
- module.exports = global.document ?
- factory( global, true ) :
- function( w ) {
- if ( !w.document ) {
- throw new Error( "jQuery requires a window with a document" );
- }
- return factory( w );
- };
- } else {
- factory( global );
- }
-
-// Pass this if window is not defined yet
-} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
-
-// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
-// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
-// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
-// enough that all such attempts are guarded in a try block.
-"use strict";
-
-var arr = [];
-
-var getProto = Object.getPrototypeOf;
-
-var slice = arr.slice;
-
-var flat = arr.flat ? function( array ) {
- return arr.flat.call( array );
-} : function( array ) {
- return arr.concat.apply( [], array );
-};
-
-
-var push = arr.push;
-
-var indexOf = arr.indexOf;
-
-var class2type = {};
-
-var toString = class2type.toString;
-
-var hasOwn = class2type.hasOwnProperty;
-
-var fnToString = hasOwn.toString;
-
-var ObjectFunctionString = fnToString.call( Object );
-
-var support = {};
-
-var isFunction = function isFunction( obj ) {
-
- // Support: Chrome <=57, Firefox <=52
- // In some browsers, typeof returns "function" for HTML <object> elements
- // (i.e., `typeof document.createElement( "object" ) === "function"`).
- // We don't want to classify *any* DOM node as a function.
- return typeof obj === "function" && typeof obj.nodeType !== "number";
- };
-
-
-var isWindow = function isWindow( obj ) {
- return obj != null && obj === obj.window;
- };
-
-
-var document = window.document;
-
-
-
- var preservedScriptAttributes = {
- type: true,
- src: true,
- nonce: true,
- noModule: true
- };
-
- function DOMEval( code, node, doc ) {
- doc = doc || document;
-
- var i, val,
- script = doc.createElement( "script" );
-
- script.text = code;
- if ( node ) {
- for ( i in preservedScriptAttributes ) {
-
- // Support: Firefox 64+, Edge 18+
- // Some browsers don't support the "nonce" property on scripts.
- // On the other hand, just using `getAttribute` is not enough as
- // the `nonce` attribute is reset to an empty string whenever it
- // becomes browsing-context connected.
- // See https://github.com/whatwg/html/issues/2369
- // See https://html.spec.whatwg.org/#nonce-attributes
- // The `node.getAttribute` check was added for the sake of
- // `jQuery.globalEval` so that it can fake a nonce-containing node
- // via an object.
- val = node[ i ] || node.getAttribute && node.getAttribute( i );
- if ( val ) {
- script.setAttribute( i, val );
- }
- }
- }
- doc.head.appendChild( script ).parentNode.removeChild( script );
- }
-
-
-function toType( obj ) {
- if ( obj == null ) {
- return obj + "";
- }
-
- // Support: Android <=2.3 only (functionish RegExp)
- return typeof obj === "object" || typeof obj === "function" ?
- class2type[ toString.call( obj ) ] || "object" :
- typeof obj;
-}
-/* global Symbol */
-// Defining this global in .eslintrc.json would create a danger of using the global
-// unguarded in another place, it seems safer to define global only for this module
-
-
-
-var
- version = "3.5.1",
-
- // Define a local copy of jQuery
- jQuery = function( selector, context ) {
-
- // The jQuery object is actually just the init constructor 'enhanced'
- // Need init if jQuery is called (just allow error to be thrown if not included)
- return new jQuery.fn.init( selector, context );
- };
-
-jQuery.fn = jQuery.prototype = {
-
- // The current version of jQuery being used
- jquery: version,
-
- constructor: jQuery,
-
- // The default length of a jQuery object is 0
- length: 0,
-
- toArray: function() {
- return slice.call( this );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
-
- // Return all the elements in a clean array
- if ( num == null ) {
- return slice.call( this );
- }
-
- // Return just the one element from the set
- return num < 0 ? this[ num + this.length ] : this[ num ];
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems ) {
-
- // Build a new jQuery matched element set
- var ret = jQuery.merge( this.constructor(), elems );
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- each: function( callback ) {
- return jQuery.each( this, callback );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map( this, function( elem, i ) {
- return callback.call( elem, i, elem );
- } ) );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ) );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- even: function() {
- return this.pushStack( jQuery.grep( this, function( _elem, i ) {
- return ( i + 1 ) % 2;
- } ) );
- },
-
- odd: function() {
- return this.pushStack( jQuery.grep( this, function( _elem, i ) {
- return i % 2;
- } ) );
- },
-
- eq: function( i ) {
- var len = this.length,
- j = +i + ( i < 0 ? len : 0 );
- return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
- },
-
- end: function() {
- return this.prevObject || this.constructor();
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: arr.sort,
- splice: arr.splice
-};
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[ 0 ] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
-
- // Skip the boolean and the target
- target = arguments[ i ] || {};
- i++;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !isFunction( target ) ) {
- target = {};
- }
-
- // Extend jQuery itself if only one argument is passed
- if ( i === length ) {
- target = this;
- i--;
- }
-
- for ( ; i < length; i++ ) {
-
- // Only deal with non-null/undefined values
- if ( ( options = arguments[ i ] ) != null ) {
-
- // Extend the base object
- for ( name in options ) {
- copy = options[ name ];
-
- // Prevent Object.prototype pollution
- // Prevent never-ending loop
- if ( name === "__proto__" || target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
- ( copyIsArray = Array.isArray( copy ) ) ) ) {
- src = target[ name ];
-
- // Ensure proper type for the source value
- if ( copyIsArray && !Array.isArray( src ) ) {
- clone = [];
- } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
- clone = {};
- } else {
- clone = src;
- }
- copyIsArray = false;
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend( {
-
- // Unique for each copy of jQuery on the page
- expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
-
- // Assume jQuery is ready without the ready module
- isReady: true,
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- noop: function() {},
-
- isPlainObject: function( obj ) {
- var proto, Ctor;
-
- // Detect obvious negatives
- // Use toString instead of jQuery.type to catch host objects
- if ( !obj || toString.call( obj ) !== "[object Object]" ) {
- return false;
- }
-
- proto = getProto( obj );
-
- // Objects with no prototype (e.g., `Object.create( null )`) are plain
- if ( !proto ) {
- return true;
- }
-
- // Objects with prototype are plain iff they were constructed by a global Object function
- Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
- return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
- },
-
- isEmptyObject: function( obj ) {
- var name;
-
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- // Evaluates a script in a provided context; falls back to the global one
- // if not specified.
- globalEval: function( code, options, doc ) {
- DOMEval( code, { nonce: options && options.nonce }, doc );
- },
-
- each: function( obj, callback ) {
- var length, i = 0;
-
- if ( isArrayLike( obj ) ) {
- length = obj.length;
- for ( ; i < length; i++ ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- }
-
- return obj;
- },
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var ret = results || [];
-
- if ( arr != null ) {
- if ( isArrayLike( Object( arr ) ) ) {
- jQuery.merge( ret,
- typeof arr === "string" ?
- [ arr ] : arr
- );
- } else {
- push.call( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- return arr == null ? -1 : indexOf.call( arr, elem, i );
- },
-
- // Support: Android <=4.0 only, PhantomJS 1 only
- // push.apply(_, arraylike) throws on ancient WebKit
- merge: function( first, second ) {
- var len = +second.length,
- j = 0,
- i = first.length;
-
- for ( ; j < len; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, invert ) {
- var callbackInverse,
- matches = [],
- i = 0,
- length = elems.length,
- callbackExpect = !invert;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- callbackInverse = !callback( elems[ i ], i );
- if ( callbackInverse !== callbackExpect ) {
- matches.push( elems[ i ] );
- }
- }
-
- return matches;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var length, value,
- i = 0,
- ret = [];
-
- // Go through the array, translating each of the items to their new values
- if ( isArrayLike( elems ) ) {
- length = elems.length;
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( i in elems ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
- }
-
- // Flatten any nested arrays
- return flat( ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // jQuery.support is not used in Core but other projects attach their
- // properties to it so it needs to exist.
- support: support
-} );
-
-if ( typeof Symbol === "function" ) {
- jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
-}
-
-// Populate the class2type map
-jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
-function( _i, name ) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-} );
-
-function isArrayLike( obj ) {
-
- // Support: real iOS 8.2 only (not reproducible in simulator)
- // `in` check used to prevent JIT error (gh-2145)
- // hasOwn isn't used here due to false negatives
- // regarding Nodelist length in IE
- var length = !!obj && "length" in obj && obj.length,
- type = toType( obj );
-
- if ( isFunction( obj ) || isWindow( obj ) ) {
- return false;
- }
-
- return type === "array" || length === 0 ||
- typeof length === "number" && length > 0 && ( length - 1 ) in obj;
-}
-var Sizzle =
-/*!
- * Sizzle CSS Selector Engine v2.3.5
- * https://sizzlejs.com/
- *
- * Copyright JS Foundation and other contributors
- * Released under the MIT license
- * https://js.foundation/
- *
- * Date: 2020-03-14
- */
-( function( window ) {
-var i,
- support,
- Expr,
- getText,
- isXML,
- tokenize,
- compile,
- select,
- outermostContext,
- sortInput,
- hasDuplicate,
-
- // Local document vars
- setDocument,
- document,
- docElem,
- documentIsHTML,
- rbuggyQSA,
- rbuggyMatches,
- matches,
- contains,
-
- // Instance-specific data
- expando = "sizzle" + 1 * new Date(),
- preferredDoc = window.document,
- dirruns = 0,
- done = 0,
- classCache = createCache(),
- tokenCache = createCache(),
- compilerCache = createCache(),
- nonnativeSelectorCache = createCache(),
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- }
- return 0;
- },
-
- // Instance methods
- hasOwn = ( {} ).hasOwnProperty,
- arr = [],
- pop = arr.pop,
- pushNative = arr.push,
- push = arr.push,
- slice = arr.slice,
-
- // Use a stripped-down indexOf as it's faster than native
- // https://jsperf.com/thor-indexof-vs-for/5
- indexOf = function( list, elem ) {
- var i = 0,
- len = list.length;
- for ( ; i < len; i++ ) {
- if ( list[ i ] === elem ) {
- return i;
- }
- }
- return -1;
- },
-
- booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
- "ismap|loop|multiple|open|readonly|required|scoped",
-
- // Regular expressions
-
- // http://www.w3.org/TR/css3-selectors/#whitespace
- whitespace = "[\\x20\\t\\r\\n\\f]",
-
- // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
- identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
- "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
-
- // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
- attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
-
- // Operator (capture 2)
- "*([*^$|!~]?=)" + whitespace +
-
- // "Attribute values must be CSS identifiers [capture 5]
- // or strings [capture 3 or capture 4]"
- "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
- whitespace + "*\\]",
-
- pseudos = ":(" + identifier + ")(?:\\((" +
-
- // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
- // 1. quoted (capture 3; capture 4 or capture 5)
- "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
-
- // 2. simple (capture 6)
- "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
-
- // 3. anything else (capture 2)
- ".*" +
- ")\\)|)",
-
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
- rwhitespace = new RegExp( whitespace + "+", "g" ),
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
- whitespace + "+$", "g" ),
-
- rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
- rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
- "*" ),
- rdescend = new RegExp( whitespace + "|>" ),
-
- rpseudo = new RegExp( pseudos ),
- ridentifier = new RegExp( "^" + identifier + "$" ),
-
- matchExpr = {
- "ID": new RegExp( "^#(" + identifier + ")" ),
- "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
- "TAG": new RegExp( "^(" + identifier + "|[*])" ),
- "ATTR": new RegExp( "^" + attributes ),
- "PSEUDO": new RegExp( "^" + pseudos ),
- "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
- whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
- whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
-
- // For use in libraries implementing .is()
- // We use this for POS matching in `select`
- "needsContext": new RegExp( "^" + whitespace +
- "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
- "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
- },
-
- rhtml = /HTML$/i,
- rinputs = /^(?:input|select|textarea|button)$/i,
- rheader = /^h\d$/i,
-
- rnative = /^[^{]+\{\s*\[native \w/,
-
- // Easily-parseable/retrievable ID or TAG or CLASS selectors
- rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
-
- rsibling = /[+~]/,
-
- // CSS escapes
- // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
- runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
- funescape = function( escape, nonHex ) {
- var high = "0x" + escape.slice( 1 ) - 0x10000;
-
- return nonHex ?
-
- // Strip the backslash prefix from a non-hex escape sequence
- nonHex :
-
- // Replace a hexadecimal escape sequence with the encoded Unicode code point
- // Support: IE <=11+
- // For values outside the Basic Multilingual Plane (BMP), manually construct a
- // surrogate pair
- high < 0 ?
- String.fromCharCode( high + 0x10000 ) :
- String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
- },
-
- // CSS string/identifier serialization
- // https://drafts.csswg.org/cssom/#common-serializing-idioms
- rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
- fcssescape = function( ch, asCodePoint ) {
- if ( asCodePoint ) {
-
- // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
- if ( ch === "\0" ) {
- return "\uFFFD";
- }
-
- // Control characters and (dependent upon position) numbers get escaped as code points
- return ch.slice( 0, -1 ) + "\\" +
- ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
- }
-
- // Other potentially-special ASCII characters get backslash-escaped
- return "\\" + ch;
- },
-
- // Used for iframes
- // See setDocument()
- // Removing the function wrapper causes a "Permission Denied"
- // error in IE
- unloadHandler = function() {
- setDocument();
- },
-
- inDisabledFieldset = addCombinator(
- function( elem ) {
- return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
- },
- { dir: "parentNode", next: "legend" }
- );
-
-// Optimize for push.apply( _, NodeList )
-try {
- push.apply(
- ( arr = slice.call( preferredDoc.childNodes ) ),
- preferredDoc.childNodes
- );
-
- // Support: Android<4.0
- // Detect silently failing push.apply
- // eslint-disable-next-line no-unused-expressions
- arr[ preferredDoc.childNodes.length ].nodeType;
-} catch ( e ) {
- push = { apply: arr.length ?
-
- // Leverage slice if possible
- function( target, els ) {
- pushNative.apply( target, slice.call( els ) );
- } :
-
- // Support: IE<9
- // Otherwise append directly
- function( target, els ) {
- var j = target.length,
- i = 0;
-
- // Can't trust NodeList.length
- while ( ( target[ j++ ] = els[ i++ ] ) ) {}
- target.length = j - 1;
- }
- };
-}
-
-function Sizzle( selector, context, results, seed ) {
- var m, i, elem, nid, match, groups, newSelector,
- newContext = context && context.ownerDocument,
-
- // nodeType defaults to 9, since context defaults to document
- nodeType = context ? context.nodeType : 9;
-
- results = results || [];
-
- // Return early from calls with invalid selector or context
- if ( typeof selector !== "string" || !selector ||
- nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
-
- return results;
- }
-
- // Try to shortcut find operations (as opposed to filters) in HTML documents
- if ( !seed ) {
- setDocument( context );
- context = context || document;
-
- if ( documentIsHTML ) {
-
- // If the selector is sufficiently simple, try using a "get*By*" DOM method
- // (excepting DocumentFragment context, where the methods don't exist)
- if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
-
- // ID selector
- if ( ( m = match[ 1 ] ) ) {
-
- // Document context
- if ( nodeType === 9 ) {
- if ( ( elem = context.getElementById( m ) ) ) {
-
- // Support: IE, Opera, Webkit
- // TODO: identify versions
- // getElementById can match elements by name instead of ID
- if ( elem.id === m ) {
- results.push( elem );
- return results;
- }
- } else {
- return results;
- }
-
- // Element context
- } else {
-
- // Support: IE, Opera, Webkit
- // TODO: identify versions
- // getElementById can match elements by name instead of ID
- if ( newContext && ( elem = newContext.getElementById( m ) ) &&
- contains( context, elem ) &&
- elem.id === m ) {
-
- results.push( elem );
- return results;
- }
- }
-
- // Type selector
- } else if ( match[ 2 ] ) {
- push.apply( results, context.getElementsByTagName( selector ) );
- return results;
-
- // Class selector
- } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
- context.getElementsByClassName ) {
-
- push.apply( results, context.getElementsByClassName( m ) );
- return results;
- }
- }
-
- // Take advantage of querySelectorAll
- if ( support.qsa &&
- !nonnativeSelectorCache[ selector + " " ] &&
- ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
-
- // Support: IE 8 only
- // Exclude object elements
- ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
-
- newSelector = selector;
- newContext = context;
-
- // qSA considers elements outside a scoping root when evaluating child or
- // descendant combinators, which is not what we want.
- // In such cases, we work around the behavior by prefixing every selector in the
- // list with an ID selector referencing the scope context.
- // The technique has to be used as well when a leading combinator is used
- // as such selectors are not recognized by querySelectorAll.
- // Thanks to Andrew Dupont for this technique.
- if ( nodeType === 1 &&
- ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
-
- // Expand context for sibling selectors
- newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
- context;
-
- // We can use :scope instead of the ID hack if the browser
- // supports it & if we're not changing the context.
- if ( newContext !== context || !support.scope ) {
-
- // Capture the context ID, setting it first if necessary
- if ( ( nid = context.getAttribute( "id" ) ) ) {
- nid = nid.replace( rcssescape, fcssescape );
- } else {
- context.setAttribute( "id", ( nid = expando ) );
- }
- }
-
- // Prefix every selector in the list
- groups = tokenize( selector );
- i = groups.length;
- while ( i-- ) {
- groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
- toSelector( groups[ i ] );
- }
- newSelector = groups.join( "," );
- }
-
- try {
- push.apply( results,
- newContext.querySelectorAll( newSelector )
- );
- return results;
- } catch ( qsaError ) {
- nonnativeSelectorCache( selector, true );
- } finally {
- if ( nid === expando ) {
- context.removeAttribute( "id" );
- }
- }
- }
- }
- }
-
- // All others
- return select( selector.replace( rtrim, "$1" ), context, results, seed );
-}
-
-/**
- * Create key-value caches of limited size
- * @returns {function(string, object)} Returns the Object data after storing it on itself with
- * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
- * deleting the oldest entry
- */
-function createCache() {
- var keys = [];
-
- function cache( key, value ) {
-
- // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
- if ( keys.push( key + " " ) > Expr.cacheLength ) {
-
- // Only keep the most recent entries
- delete cache[ keys.shift() ];
- }
- return ( cache[ key + " " ] = value );
- }
- return cache;
-}
-
-/**
- * Mark a function for special use by Sizzle
- * @param {Function} fn The function to mark
- */
-function markFunction( fn ) {
- fn[ expando ] = true;
- return fn;
-}
-
-/**
- * Support testing using an element
- * @param {Function} fn Passed the created element and returns a boolean result
- */
-function assert( fn ) {
- var el = document.createElement( "fieldset" );
-
- try {
- return !!fn( el );
- } catch ( e ) {
- return false;
- } finally {
-
- // Remove from its parent by default
- if ( el.parentNode ) {
- el.parentNode.removeChild( el );
- }
-
- // release memory in IE
- el = null;
- }
-}
-
-/**
- * Adds the same handler for all of the specified attrs
- * @param {String} attrs Pipe-separated list of attributes
- * @param {Function} handler The method that will be applied
- */
-function addHandle( attrs, handler ) {
- var arr = attrs.split( "|" ),
- i = arr.length;
-
- while ( i-- ) {
- Expr.attrHandle[ arr[ i ] ] = handler;
- }
-}
-
-/**
- * Checks document order of two siblings
- * @param {Element} a
- * @param {Element} b
- * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
- */
-function siblingCheck( a, b ) {
- var cur = b && a,
- diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
- a.sourceIndex - b.sourceIndex;
-
- // Use IE sourceIndex if available on both nodes
- if ( diff ) {
- return diff;
- }
-
- // Check if b follows a
- if ( cur ) {
- while ( ( cur = cur.nextSibling ) ) {
- if ( cur === b ) {
- return -1;
- }
- }
- }
-
- return a ? 1 : -1;
-}
-
-/**
- * Returns a function to use in pseudos for input types
- * @param {String} type
- */
-function createInputPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for buttons
- * @param {String} type
- */
-function createButtonPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return ( name === "input" || name === "button" ) && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for :enabled/:disabled
- * @param {Boolean} disabled true for :disabled; false for :enabled
- */
-function createDisabledPseudo( disabled ) {
-
- // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
- return function( elem ) {
-
- // Only certain elements can match :enabled or :disabled
- // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
- // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
- if ( "form" in elem ) {
-
- // Check for inherited disabledness on relevant non-disabled elements:
- // * listed form-associated elements in a disabled fieldset
- // https://html.spec.whatwg.org/multipage/forms.html#category-listed
- // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
- // * option elements in a disabled optgroup
- // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
- // All such elements have a "form" property.
- if ( elem.parentNode && elem.disabled === false ) {
-
- // Option elements defer to a parent optgroup if present
- if ( "label" in elem ) {
- if ( "label" in elem.parentNode ) {
- return elem.parentNode.disabled === disabled;
- } else {
- return elem.disabled === disabled;
- }
- }
-
- // Support: IE 6 - 11
- // Use the isDisabled shortcut property to check for disabled fieldset ancestors
- return elem.isDisabled === disabled ||
-
- // Where there is no isDisabled, check manually
- /* jshint -W018 */
- elem.isDisabled !== !disabled &&
- inDisabledFieldset( elem ) === disabled;
- }
-
- return elem.disabled === disabled;
-
- // Try to winnow out elements that can't be disabled before trusting the disabled property.
- // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
- // even exist on them, let alone have a boolean value.
- } else if ( "label" in elem ) {
- return elem.disabled === disabled;
- }
-
- // Remaining elements are neither :enabled nor :disabled
- return false;
- };
-}
-
-/**
- * Returns a function to use in pseudos for positionals
- * @param {Function} fn
- */
-function createPositionalPseudo( fn ) {
- return markFunction( function( argument ) {
- argument = +argument;
- return markFunction( function( seed, matches ) {
- var j,
- matchIndexes = fn( [], seed.length, argument ),
- i = matchIndexes.length;
-
- // Match elements found at the specified indexes
- while ( i-- ) {
- if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
- seed[ j ] = !( matches[ j ] = seed[ j ] );
- }
- }
- } );
- } );
-}
-
-/**
- * Checks a node for validity as a Sizzle context
- * @param {Element|Object=} context
- * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
- */
-function testContext( context ) {
- return context && typeof context.getElementsByTagName !== "undefined" && context;
-}
-
-// Expose support vars for convenience
-support = Sizzle.support = {};
-
-/**
- * Detects XML nodes
- * @param {Element|Object} elem An element or a document
- * @returns {Boolean} True iff elem is a non-HTML XML node
- */
-isXML = Sizzle.isXML = function( elem ) {
- var namespace = elem.namespaceURI,
- docElem = ( elem.ownerDocument || elem ).documentElement;
-
- // Support: IE <=8
- // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
- // https://bugs.jquery.com/ticket/4833
- return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
-};
-
-/**
- * Sets document-related variables once based on the current document
- * @param {Element|Object} [doc] An element or document object to use to set the document
- * @returns {Object} Returns the current document
- */
-setDocument = Sizzle.setDocument = function( node ) {
- var hasCompare, subWindow,
- doc = node ? node.ownerDocument || node : preferredDoc;
-
- // Return early if doc is invalid or already selected
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
- return document;
- }
-
- // Update global variables
- document = doc;
- docElem = document.documentElement;
- documentIsHTML = !isXML( document );
-
- // Support: IE 9 - 11+, Edge 12 - 18+
- // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( preferredDoc != document &&
- ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
-
- // Support: IE 11, Edge
- if ( subWindow.addEventListener ) {
- subWindow.addEventListener( "unload", unloadHandler, false );
-
- // Support: IE 9 - 10 only
- } else if ( subWindow.attachEvent ) {
- subWindow.attachEvent( "onunload", unloadHandler );
- }
- }
-
- // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
- // Safari 4 - 5 only, Opera <=11.6 - 12.x only
- // IE/Edge & older browsers don't support the :scope pseudo-class.
- // Support: Safari 6.0 only
- // Safari 6.0 supports :scope but it's an alias of :root there.
- support.scope = assert( function( el ) {
- docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
- return typeof el.querySelectorAll !== "undefined" &&
- !el.querySelectorAll( ":scope fieldset div" ).length;
- } );
-
- /* Attributes
- ---------------------------------------------------------------------- */
-
- // Support: IE<8
- // Verify that getAttribute really returns attributes and not properties
- // (excepting IE8 booleans)
- support.attributes = assert( function( el ) {
- el.className = "i";
- return !el.getAttribute( "className" );
- } );
-
- /* getElement(s)By*
- ---------------------------------------------------------------------- */
-
- // Check if getElementsByTagName("*") returns only elements
- support.getElementsByTagName = assert( function( el ) {
- el.appendChild( document.createComment( "" ) );
- return !el.getElementsByTagName( "*" ).length;
- } );
-
- // Support: IE<9
- support.getElementsByClassName = rnative.test( document.getElementsByClassName );
-
- // Support: IE<10
- // Check if getElementById returns elements by name
- // The broken getElementById methods don't pick up programmatically-set names,
- // so use a roundabout getElementsByName test
- support.getById = assert( function( el ) {
- docElem.appendChild( el ).id = expando;
- return !document.getElementsByName || !document.getElementsByName( expando ).length;
- } );
-
- // ID filter and find
- if ( support.getById ) {
- Expr.filter[ "ID" ] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- return elem.getAttribute( "id" ) === attrId;
- };
- };
- Expr.find[ "ID" ] = function( id, context ) {
- if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
- var elem = context.getElementById( id );
- return elem ? [ elem ] : [];
- }
- };
- } else {
- Expr.filter[ "ID" ] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- var node = typeof elem.getAttributeNode !== "undefined" &&
- elem.getAttributeNode( "id" );
- return node && node.value === attrId;
- };
- };
-
- // Support: IE 6 - 7 only
- // getElementById is not reliable as a find shortcut
- Expr.find[ "ID" ] = function( id, context ) {
- if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
- var node, i, elems,
- elem = context.getElementById( id );
-
- if ( elem ) {
-
- // Verify the id attribute
- node = elem.getAttributeNode( "id" );
- if ( node && node.value === id ) {
- return [ elem ];
- }
-
- // Fall back on getElementsByName
- elems = context.getElementsByName( id );
- i = 0;
- while ( ( elem = elems[ i++ ] ) ) {
- node = elem.getAttributeNode( "id" );
- if ( node && node.value === id ) {
- return [ elem ];
- }
- }
- }
-
- return [];
- }
- };
- }
-
- // Tag
- Expr.find[ "TAG" ] = support.getElementsByTagName ?
- function( tag, context ) {
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- return context.getElementsByTagName( tag );
-
- // DocumentFragment nodes don't have gEBTN
- } else if ( support.qsa ) {
- return context.querySelectorAll( tag );
- }
- } :
-
- function( tag, context ) {
- var elem,
- tmp = [],
- i = 0,
-
- // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
- results = context.getElementsByTagName( tag );
-
- // Filter out possible comments
- if ( tag === "*" ) {
- while ( ( elem = results[ i++ ] ) ) {
- if ( elem.nodeType === 1 ) {
- tmp.push( elem );
- }
- }
-
- return tmp;
- }
- return results;
- };
-
- // Class
- Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
- if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
- return context.getElementsByClassName( className );
- }
- };
-
- /* QSA/matchesSelector
- ---------------------------------------------------------------------- */
-
- // QSA and matchesSelector support
-
- // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
- rbuggyMatches = [];
-
- // qSa(:focus) reports false when true (Chrome 21)
- // We allow this because of a bug in IE8/9 that throws an error
- // whenever `document.activeElement` is accessed on an iframe
- // So, we allow :focus to pass through QSA all the time to avoid the IE error
- // See https://bugs.jquery.com/ticket/13378
- rbuggyQSA = [];
-
- if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
-
- // Build QSA regex
- // Regex strategy adopted from Diego Perini
- assert( function( el ) {
-
- var input;
-
- // Select is set to empty string on purpose
- // This is to test IE's treatment of not explicitly
- // setting a boolean content attribute,
- // since its presence should be enough
- // https://bugs.jquery.com/ticket/12359
- docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
- "<select id='" + expando + "-\r\\' msallowcapture=''>" +
- "<option selected=''></option></select>";
-
- // Support: IE8, Opera 11-12.16
- // Nothing should be selected when empty strings follow ^= or $= or *=
- // The test attribute must be unknown in Opera but "safe" for WinRT
- // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
- if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
- rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
- }
-
- // Support: IE8
- // Boolean attributes and "value" are not treated correctly
- if ( !el.querySelectorAll( "[selected]" ).length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
- }
-
- // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
- if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
- rbuggyQSA.push( "~=" );
- }
-
- // Support: IE 11+, Edge 15 - 18+
- // IE 11/Edge don't find elements on a `[name='']` query in some cases.
- // Adding a temporary attribute to the document before the selection works
- // around the issue.
- // Interestingly, IE 10 & older don't seem to have the issue.
- input = document.createElement( "input" );
- input.setAttribute( "name", "" );
- el.appendChild( input );
- if ( !el.querySelectorAll( "[name='']" ).length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
- whitespace + "*(?:''|\"\")" );
- }
-
- // Webkit/Opera - :checked should return selected option elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- // IE8 throws error here and will not see later tests
- if ( !el.querySelectorAll( ":checked" ).length ) {
- rbuggyQSA.push( ":checked" );
- }
-
- // Support: Safari 8+, iOS 8+
- // https://bugs.webkit.org/show_bug.cgi?id=136851
- // In-page `selector#id sibling-combinator selector` fails
- if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
- rbuggyQSA.push( ".#.+[+~]" );
- }
-
- // Support: Firefox <=3.6 - 5 only
- // Old Firefox doesn't throw on a badly-escaped identifier.
- el.querySelectorAll( "\\\f" );
- rbuggyQSA.push( "[\\r\\n\\f]" );
- } );
-
- assert( function( el ) {
- el.innerHTML = "<a href='' disabled='disabled'></a>" +
- "<select disabled='disabled'><option/></select>";
-
- // Support: Windows 8 Native Apps
- // The type and name attributes are restricted during .innerHTML assignment
- var input = document.createElement( "input" );
- input.setAttribute( "type", "hidden" );
- el.appendChild( input ).setAttribute( "name", "D" );
-
- // Support: IE8
- // Enforce case-sensitivity of name attribute
- if ( el.querySelectorAll( "[name=d]" ).length ) {
- rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
- }
-
- // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
- // IE8 throws error here and will not see later tests
- if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
- rbuggyQSA.push( ":enabled", ":disabled" );
- }
-
- // Support: IE9-11+
- // IE's :disabled selector does not pick up the children of disabled fieldsets
- docElem.appendChild( el ).disabled = true;
- if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
- rbuggyQSA.push( ":enabled", ":disabled" );
- }
-
- // Support: Opera 10 - 11 only
- // Opera 10-11 does not throw on post-comma invalid pseudos
- el.querySelectorAll( "*,:x" );
- rbuggyQSA.push( ",.*:" );
- } );
- }
-
- if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
- docElem.webkitMatchesSelector ||
- docElem.mozMatchesSelector ||
- docElem.oMatchesSelector ||
- docElem.msMatchesSelector ) ) ) ) {
-
- assert( function( el ) {
-
- // Check to see if it's possible to do matchesSelector
- // on a disconnected node (IE 9)
- support.disconnectedMatch = matches.call( el, "*" );
-
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( el, "[s!='']:x" );
- rbuggyMatches.push( "!=", pseudos );
- } );
- }
-
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
- rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
-
- /* Contains
- ---------------------------------------------------------------------- */
- hasCompare = rnative.test( docElem.compareDocumentPosition );
-
- // Element contains another
- // Purposefully self-exclusive
- // As in, an element does not contain itself
- contains = hasCompare || rnative.test( docElem.contains ) ?
- function( a, b ) {
- var adown = a.nodeType === 9 ? a.documentElement : a,
- bup = b && b.parentNode;
- return a === bup || !!( bup && bup.nodeType === 1 && (
- adown.contains ?
- adown.contains( bup ) :
- a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
- ) );
- } :
- function( a, b ) {
- if ( b ) {
- while ( ( b = b.parentNode ) ) {
- if ( b === a ) {
- return true;
- }
- }
- }
- return false;
- };
-
- /* Sorting
- ---------------------------------------------------------------------- */
-
- // Document order sorting
- sortOrder = hasCompare ?
- function( a, b ) {
-
- // Flag for duplicate removal
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- // Sort on method existence if only one input has compareDocumentPosition
- var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
- if ( compare ) {
- return compare;
- }
-
- // Calculate position if both inputs belong to the same document
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
- a.compareDocumentPosition( b ) :
-
- // Otherwise we know they are disconnected
- 1;
-
- // Disconnected nodes
- if ( compare & 1 ||
- ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
-
- // Choose the first element that is related to our preferred document
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( a == document || a.ownerDocument == preferredDoc &&
- contains( preferredDoc, a ) ) {
- return -1;
- }
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( b == document || b.ownerDocument == preferredDoc &&
- contains( preferredDoc, b ) ) {
- return 1;
- }
-
- // Maintain original order
- return sortInput ?
- ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
- 0;
- }
-
- return compare & 4 ? -1 : 1;
- } :
- function( a, b ) {
-
- // Exit early if the nodes are identical
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- var cur,
- i = 0,
- aup = a.parentNode,
- bup = b.parentNode,
- ap = [ a ],
- bp = [ b ];
-
- // Parentless nodes are either documents or disconnected
- if ( !aup || !bup ) {
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- /* eslint-disable eqeqeq */
- return a == document ? -1 :
- b == document ? 1 :
- /* eslint-enable eqeqeq */
- aup ? -1 :
- bup ? 1 :
- sortInput ?
- ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
- 0;
-
- // If the nodes are siblings, we can do a quick check
- } else if ( aup === bup ) {
- return siblingCheck( a, b );
- }
-
- // Otherwise we need full lists of their ancestors for comparison
- cur = a;
- while ( ( cur = cur.parentNode ) ) {
- ap.unshift( cur );
- }
- cur = b;
- while ( ( cur = cur.parentNode ) ) {
- bp.unshift( cur );
- }
-
- // Walk down the tree looking for a discrepancy
- while ( ap[ i ] === bp[ i ] ) {
- i++;
- }
-
- return i ?
-
- // Do a sibling check if the nodes have a common ancestor
- siblingCheck( ap[ i ], bp[ i ] ) :
-
- // Otherwise nodes in our document sort first
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- /* eslint-disable eqeqeq */
- ap[ i ] == preferredDoc ? -1 :
- bp[ i ] == preferredDoc ? 1 :
- /* eslint-enable eqeqeq */
- 0;
- };
-
- return document;
-};
-
-Sizzle.matches = function( expr, elements ) {
- return Sizzle( expr, null, null, elements );
-};
-
-Sizzle.matchesSelector = function( elem, expr ) {
- setDocument( elem );
-
- if ( support.matchesSelector && documentIsHTML &&
- !nonnativeSelectorCache[ expr + " " ] &&
- ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
- ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
-
- try {
- var ret = matches.call( elem, expr );
-
- // IE 9's matchesSelector returns false on disconnected nodes
- if ( ret || support.disconnectedMatch ||
-
- // As well, disconnected nodes are said to be in a document
- // fragment in IE 9
- elem.document && elem.document.nodeType !== 11 ) {
- return ret;
- }
- } catch ( e ) {
- nonnativeSelectorCache( expr, true );
- }
- }
-
- return Sizzle( expr, document, null, [ elem ] ).length > 0;
-};
-
-Sizzle.contains = function( context, elem ) {
-
- // Set document vars if needed
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( ( context.ownerDocument || context ) != document ) {
- setDocument( context );
- }
- return contains( context, elem );
-};
-
-Sizzle.attr = function( elem, name ) {
-
- // Set document vars if needed
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( ( elem.ownerDocument || elem ) != document ) {
- setDocument( elem );
- }
-
- var fn = Expr.attrHandle[ name.toLowerCase() ],
-
- // Don't get fooled by Object.prototype properties (jQuery #13807)
- val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
- fn( elem, name, !documentIsHTML ) :
- undefined;
-
- return val !== undefined ?
- val :
- support.attributes || !documentIsHTML ?
- elem.getAttribute( name ) :
- ( val = elem.getAttributeNode( name ) ) && val.specified ?
- val.value :
- null;
-};
-
-Sizzle.escape = function( sel ) {
- return ( sel + "" ).replace( rcssescape, fcssescape );
-};
-
-Sizzle.error = function( msg ) {
- throw new Error( "Syntax error, unrecognized expression: " + msg );
-};
-
-/**
- * Document sorting and removing duplicates
- * @param {ArrayLike} results
- */
-Sizzle.uniqueSort = function( results ) {
- var elem,
- duplicates = [],
- j = 0,
- i = 0;
-
- // Unless we *know* we can detect duplicates, assume their presence
- hasDuplicate = !support.detectDuplicates;
- sortInput = !support.sortStable && results.slice( 0 );
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- while ( ( elem = results[ i++ ] ) ) {
- if ( elem === results[ i ] ) {
- j = duplicates.push( i );
- }
- }
- while ( j-- ) {
- results.splice( duplicates[ j ], 1 );
- }
- }
-
- // Clear input after sorting to release objects
- // See https://github.com/jquery/sizzle/pull/225
- sortInput = null;
-
- return results;
-};
-
-/**
- * Utility function for retrieving the text value of an array of DOM nodes
- * @param {Array|Element} elem
- */
-getText = Sizzle.getText = function( elem ) {
- var node,
- ret = "",
- i = 0,
- nodeType = elem.nodeType;
-
- if ( !nodeType ) {
-
- // If no nodeType, this is expected to be an array
- while ( ( node = elem[ i++ ] ) ) {
-
- // Do not traverse comment nodes
- ret += getText( node );
- }
- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
-
- // Use textContent for elements
- // innerText usage removed for consistency of new lines (jQuery #11153)
- if ( typeof elem.textContent === "string" ) {
- return elem.textContent;
- } else {
-
- // Traverse its children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- ret += getText( elem );
- }
- }
- } else if ( nodeType === 3 || nodeType === 4 ) {
- return elem.nodeValue;
- }
-
- // Do not include comment or processing instruction nodes
-
- return ret;
-};
-
-Expr = Sizzle.selectors = {
-
- // Can be adjusted by the user
- cacheLength: 50,
-
- createPseudo: markFunction,
-
- match: matchExpr,
-
- attrHandle: {},
-
- find: {},
-
- relative: {
- ">": { dir: "parentNode", first: true },
- " ": { dir: "parentNode" },
- "+": { dir: "previousSibling", first: true },
- "~": { dir: "previousSibling" }
- },
-
- preFilter: {
- "ATTR": function( match ) {
- match[ 1 ] = match[ 1 ].replace( runescape, funescape );
-
- // Move the given value to match[3] whether quoted or unquoted
- match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
- match[ 5 ] || "" ).replace( runescape, funescape );
-
- if ( match[ 2 ] === "~=" ) {
- match[ 3 ] = " " + match[ 3 ] + " ";
- }
-
- return match.slice( 0, 4 );
- },
-
- "CHILD": function( match ) {
-
- /* matches from matchExpr["CHILD"]
- 1 type (only|nth|...)
- 2 what (child|of-type)
- 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
- 4 xn-component of xn+y argument ([+-]?\d*n|)
- 5 sign of xn-component
- 6 x of xn-component
- 7 sign of y-component
- 8 y of y-component
- */
- match[ 1 ] = match[ 1 ].toLowerCase();
-
- if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
-
- // nth-* requires argument
- if ( !match[ 3 ] ) {
- Sizzle.error( match[ 0 ] );
- }
-
- // numeric x and y parameters for Expr.filter.CHILD
- // remember that false/true cast respectively to 0/1
- match[ 4 ] = +( match[ 4 ] ?
- match[ 5 ] + ( match[ 6 ] || 1 ) :
- 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
- match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
-
- // other types prohibit arguments
- } else if ( match[ 3 ] ) {
- Sizzle.error( match[ 0 ] );
- }
-
- return match;
- },
-
- "PSEUDO": function( match ) {
- var excess,
- unquoted = !match[ 6 ] && match[ 2 ];
-
- if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
- return null;
- }
-
- // Accept quoted arguments as-is
- if ( match[ 3 ] ) {
- match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
-
- // Strip excess characters from unquoted arguments
- } else if ( unquoted && rpseudo.test( unquoted ) &&
-
- // Get excess from tokenize (recursively)
- ( excess = tokenize( unquoted, true ) ) &&
-
- // advance to the next closing parenthesis
- ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
-
- // excess is a negative index
- match[ 0 ] = match[ 0 ].slice( 0, excess );
- match[ 2 ] = unquoted.slice( 0, excess );
- }
-
- // Return only captures needed by the pseudo filter method (type and argument)
- return match.slice( 0, 3 );
- }
- },
-
- filter: {
-
- "TAG": function( nodeNameSelector ) {
- var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
- return nodeNameSelector === "*" ?
- function() {
- return true;
- } :
- function( elem ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
- };
- },
-
- "CLASS": function( className ) {
- var pattern = classCache[ className + " " ];
-
- return pattern ||
- ( pattern = new RegExp( "(^|" + whitespace +
- ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
- className, function( elem ) {
- return pattern.test(
- typeof elem.className === "string" && elem.className ||
- typeof elem.getAttribute !== "undefined" &&
- elem.getAttribute( "class" ) ||
- ""
- );
- } );
- },
-
- "ATTR": function( name, operator, check ) {
- return function( elem ) {
- var result = Sizzle.attr( elem, name );
-
- if ( result == null ) {
- return operator === "!=";
- }
- if ( !operator ) {
- return true;
- }
-
- result += "";
-
- /* eslint-disable max-len */
-
- return operator === "=" ? result === check :
- operator === "!=" ? result !== check :
- operator === "^=" ? check && result.indexOf( check ) === 0 :
- operator === "*=" ? check && result.indexOf( check ) > -1 :
- operator === "$=" ? check && result.slice( -check.length ) === check :
- operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
- operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
- false;
- /* eslint-enable max-len */
-
- };
- },
-
- "CHILD": function( type, what, _argument, first, last ) {
- var simple = type.slice( 0, 3 ) !== "nth",
- forward = type.slice( -4 ) !== "last",
- ofType = what === "of-type";
-
- return first === 1 && last === 0 ?
-
- // Shortcut for :nth-*(n)
- function( elem ) {
- return !!elem.parentNode;
- } :
-
- function( elem, _context, xml ) {
- var cache, uniqueCache, outerCache, node, nodeIndex, start,
- dir = simple !== forward ? "nextSibling" : "previousSibling",
- parent = elem.parentNode,
- name = ofType && elem.nodeName.toLowerCase(),
- useCache = !xml && !ofType,
- diff = false;
-
- if ( parent ) {
-
- // :(first|last|only)-(child|of-type)
- if ( simple ) {
- while ( dir ) {
- node = elem;
- while ( ( node = node[ dir ] ) ) {
- if ( ofType ?
- node.nodeName.toLowerCase() === name :
- node.nodeType === 1 ) {
-
- return false;
- }
- }
-
- // Reverse direction for :only-* (if we haven't yet done so)
- start = dir = type === "only" && !start && "nextSibling";
- }
- return true;
- }
-
- start = [ forward ? parent.firstChild : parent.lastChild ];
-
- // non-xml :nth-child(...) stores cache data on `parent`
- if ( forward && useCache ) {
-
- // Seek `elem` from a previously-cached index
-
- // ...in a gzip-friendly way
- node = parent;
- outerCache = node[ expando ] || ( node[ expando ] = {} );
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- ( outerCache[ node.uniqueID ] = {} );
-
- cache = uniqueCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex && cache[ 2 ];
- node = nodeIndex && parent.childNodes[ nodeIndex ];
-
- while ( ( node = ++nodeIndex && node && node[ dir ] ||
-
- // Fallback to seeking `elem` from the start
- ( diff = nodeIndex = 0 ) || start.pop() ) ) {
-
- // When found, cache indexes on `parent` and break
- if ( node.nodeType === 1 && ++diff && node === elem ) {
- uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
- break;
- }
- }
-
- } else {
-
- // Use previously-cached element index if available
- if ( useCache ) {
-
- // ...in a gzip-friendly way
- node = elem;
- outerCache = node[ expando ] || ( node[ expando ] = {} );
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- ( outerCache[ node.uniqueID ] = {} );
-
- cache = uniqueCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex;
- }
-
- // xml :nth-child(...)
- // or :nth-last-child(...) or :nth(-last)?-of-type(...)
- if ( diff === false ) {
-
- // Use the same loop as above to seek `elem` from the start
- while ( ( node = ++nodeIndex && node && node[ dir ] ||
- ( diff = nodeIndex = 0 ) || start.pop() ) ) {
-
- if ( ( ofType ?
- node.nodeName.toLowerCase() === name :
- node.nodeType === 1 ) &&
- ++diff ) {
-
- // Cache the index of each encountered element
- if ( useCache ) {
- outerCache = node[ expando ] ||
- ( node[ expando ] = {} );
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- ( outerCache[ node.uniqueID ] = {} );
-
- uniqueCache[ type ] = [ dirruns, diff ];
- }
-
- if ( node === elem ) {
- break;
- }
- }
- }
- }
- }
-
- // Incorporate the offset, then check against cycle size
- diff -= last;
- return diff === first || ( diff % first === 0 && diff / first >= 0 );
- }
- };
- },
-
- "PSEUDO": function( pseudo, argument ) {
-
- // pseudo-class names are case-insensitive
- // http://www.w3.org/TR/selectors/#pseudo-classes
- // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
- // Remember that setFilters inherits from pseudos
- var args,
- fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
- Sizzle.error( "unsupported pseudo: " + pseudo );
-
- // The user may use createPseudo to indicate that
- // arguments are needed to create the filter function
- // just as Sizzle does
- if ( fn[ expando ] ) {
- return fn( argument );
- }
-
- // But maintain support for old signatures
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
- markFunction( function( seed, matches ) {
- var idx,
- matched = fn( seed, argument ),
- i = matched.length;
- while ( i-- ) {
- idx = indexOf( seed, matched[ i ] );
- seed[ idx ] = !( matches[ idx ] = matched[ i ] );
- }
- } ) :
- function( elem ) {
- return fn( elem, 0, args );
- };
- }
-
- return fn;
- }
- },
-
- pseudos: {
-
- // Potentially complex pseudos
- "not": markFunction( function( selector ) {
-
- // Trim the selector passed to compile
- // to avoid treating leading and trailing
- // spaces as combinators
- var input = [],
- results = [],
- matcher = compile( selector.replace( rtrim, "$1" ) );
-
- return matcher[ expando ] ?
- markFunction( function( seed, matches, _context, xml ) {
- var elem,
- unmatched = matcher( seed, null, xml, [] ),
- i = seed.length;
-
- // Match elements unmatched by `matcher`
- while ( i-- ) {
- if ( ( elem = unmatched[ i ] ) ) {
- seed[ i ] = !( matches[ i ] = elem );
- }
- }
- } ) :
- function( elem, _context, xml ) {
- input[ 0 ] = elem;
- matcher( input, null, xml, results );
-
- // Don't keep the element (issue #299)
- input[ 0 ] = null;
- return !results.pop();
- };
- } ),
-
- "has": markFunction( function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- } ),
-
- "contains": markFunction( function( text ) {
- text = text.replace( runescape, funescape );
- return function( elem ) {
- return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
- };
- } ),
-
- // "Whether an element is represented by a :lang() selector
- // is based solely on the element's language value
- // being equal to the identifier C,
- // or beginning with the identifier C immediately followed by "-".
- // The matching of C against the element's language value is performed case-insensitively.
- // The identifier C does not have to be a valid language name."
- // http://www.w3.org/TR/selectors/#lang-pseudo
- "lang": markFunction( function( lang ) {
-
- // lang value must be a valid identifier
- if ( !ridentifier.test( lang || "" ) ) {
- Sizzle.error( "unsupported lang: " + lang );
- }
- lang = lang.replace( runescape, funescape ).toLowerCase();
- return function( elem ) {
- var elemLang;
- do {
- if ( ( elemLang = documentIsHTML ?
- elem.lang :
- elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
-
- elemLang = elemLang.toLowerCase();
- return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
- }
- } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
- return false;
- };
- } ),
-
- // Miscellaneous
- "target": function( elem ) {
- var hash = window.location && window.location.hash;
- return hash && hash.slice( 1 ) === elem.id;
- },
-
- "root": function( elem ) {
- return elem === docElem;
- },
-
- "focus": function( elem ) {
- return elem === document.activeElement &&
- ( !document.hasFocus || document.hasFocus() ) &&
- !!( elem.type || elem.href || ~elem.tabIndex );
- },
-
- // Boolean properties
- "enabled": createDisabledPseudo( false ),
- "disabled": createDisabledPseudo( true ),
-
- "checked": function( elem ) {
-
- // In CSS3, :checked should return both checked and selected elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- var nodeName = elem.nodeName.toLowerCase();
- return ( nodeName === "input" && !!elem.checked ) ||
- ( nodeName === "option" && !!elem.selected );
- },
-
- "selected": function( elem ) {
-
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- if ( elem.parentNode ) {
- // eslint-disable-next-line no-unused-expressions
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- // Contents
- "empty": function( elem ) {
-
- // http://www.w3.org/TR/selectors/#empty-pseudo
- // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
- // but not by others (comment: 8; processing instruction: 7; etc.)
- // nodeType < 6 works because attributes (2) do not appear as children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- if ( elem.nodeType < 6 ) {
- return false;
- }
- }
- return true;
- },
-
- "parent": function( elem ) {
- return !Expr.pseudos[ "empty" ]( elem );
- },
-
- // Element/input types
- "header": function( elem ) {
- return rheader.test( elem.nodeName );
- },
-
- "input": function( elem ) {
- return rinputs.test( elem.nodeName );
- },
-
- "button": function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === "button" || name === "button";
- },
-
- "text": function( elem ) {
- var attr;
- return elem.nodeName.toLowerCase() === "input" &&
- elem.type === "text" &&
-
- // Support: IE<8
- // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
- ( ( attr = elem.getAttribute( "type" ) ) == null ||
- attr.toLowerCase() === "text" );
- },
-
- // Position-in-collection
- "first": createPositionalPseudo( function() {
- return [ 0 ];
- } ),
-
- "last": createPositionalPseudo( function( _matchIndexes, length ) {
- return [ length - 1 ];
- } ),
-
- "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
- return [ argument < 0 ? argument + length : argument ];
- } ),
-
- "even": createPositionalPseudo( function( matchIndexes, length ) {
- var i = 0;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- "odd": createPositionalPseudo( function( matchIndexes, length ) {
- var i = 1;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
- var i = argument < 0 ?
- argument + length :
- argument > length ?
- length :
- argument;
- for ( ; --i >= 0; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; ++i < length; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } )
- }
-};
-
-Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
-
-// Add button/input type pseudos
-for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
- Expr.pseudos[ i ] = createInputPseudo( i );
-}
-for ( i in { submit: true, reset: true } ) {
- Expr.pseudos[ i ] = createButtonPseudo( i );
-}
-
-// Easy API for creating new setFilters
-function setFilters() {}
-setFilters.prototype = Expr.filters = Expr.pseudos;
-Expr.setFilters = new setFilters();
-
-tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
- var matched, match, tokens, type,
- soFar, groups, preFilters,
- cached = tokenCache[ selector + " " ];
-
- if ( cached ) {
- return parseOnly ? 0 : cached.slice( 0 );
- }
-
- soFar = selector;
- groups = [];
- preFilters = Expr.preFilter;
-
- while ( soFar ) {
-
- // Comma and first run
- if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
- if ( match ) {
-
- // Don't consume trailing commas as valid
- soFar = soFar.slice( match[ 0 ].length ) || soFar;
- }
- groups.push( ( tokens = [] ) );
- }
-
- matched = false;
-
- // Combinators
- if ( ( match = rcombinators.exec( soFar ) ) ) {
- matched = match.shift();
- tokens.push( {
- value: matched,
-
- // Cast descendant combinators to space
- type: match[ 0 ].replace( rtrim, " " )
- } );
- soFar = soFar.slice( matched.length );
- }
-
- // Filters
- for ( type in Expr.filter ) {
- if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
- ( match = preFilters[ type ]( match ) ) ) ) {
- matched = match.shift();
- tokens.push( {
- value: matched,
- type: type,
- matches: match
- } );
- soFar = soFar.slice( matched.length );
- }
- }
-
- if ( !matched ) {
- break;
- }
- }
-
- // Return the length of the invalid excess
- // if we're just parsing
- // Otherwise, throw an error or return tokens
- return parseOnly ?
- soFar.length :
- soFar ?
- Sizzle.error( selector ) :
-
- // Cache the tokens
- tokenCache( selector, groups ).slice( 0 );
-};
-
-function toSelector( tokens ) {
- var i = 0,
- len = tokens.length,
- selector = "";
- for ( ; i < len; i++ ) {
- selector += tokens[ i ].value;
- }
- return selector;
-}
-
-function addCombinator( matcher, combinator, base ) {
- var dir = combinator.dir,
- skip = combinator.next,
- key = skip || dir,
- checkNonElements = base && key === "parentNode",
- doneName = done++;
-
- return combinator.first ?
-
- // Check against closest ancestor/preceding element
- function( elem, context, xml ) {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- return matcher( elem, context, xml );
- }
- }
- return false;
- } :
-
- // Check against all ancestor/preceding elements
- function( elem, context, xml ) {
- var oldCache, uniqueCache, outerCache,
- newCache = [ dirruns, doneName ];
-
- // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
- if ( xml ) {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- if ( matcher( elem, context, xml ) ) {
- return true;
- }
- }
- }
- } else {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- outerCache = elem[ expando ] || ( elem[ expando ] = {} );
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ elem.uniqueID ] ||
- ( outerCache[ elem.uniqueID ] = {} );
-
- if ( skip && skip === elem.nodeName.toLowerCase() ) {
- elem = elem[ dir ] || elem;
- } else if ( ( oldCache = uniqueCache[ key ] ) &&
- oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
-
- // Assign to newCache so results back-propagate to previous elements
- return ( newCache[ 2 ] = oldCache[ 2 ] );
- } else {
-
- // Reuse newcache so results back-propagate to previous elements
- uniqueCache[ key ] = newCache;
-
- // A match means we're done; a fail means we have to keep checking
- if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
- return true;
- }
- }
- }
- }
- }
- return false;
- };
-}
-
-function elementMatcher( matchers ) {
- return matchers.length > 1 ?
- function( elem, context, xml ) {
- var i = matchers.length;
- while ( i-- ) {
- if ( !matchers[ i ]( elem, context, xml ) ) {
- return false;
- }
- }
- return true;
- } :
- matchers[ 0 ];
-}
-
-function multipleContexts( selector, contexts, results ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- Sizzle( selector, contexts[ i ], results );
- }
- return results;
-}
-
-function condense( unmatched, map, filter, context, xml ) {
- var elem,
- newUnmatched = [],
- i = 0,
- len = unmatched.length,
- mapped = map != null;
-
- for ( ; i < len; i++ ) {
- if ( ( elem = unmatched[ i ] ) ) {
- if ( !filter || filter( elem, context, xml ) ) {
- newUnmatched.push( elem );
- if ( mapped ) {
- map.push( i );
- }
- }
- }
- }
-
- return newUnmatched;
-}
-
-function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
- if ( postFilter && !postFilter[ expando ] ) {
- postFilter = setMatcher( postFilter );
- }
- if ( postFinder && !postFinder[ expando ] ) {
- postFinder = setMatcher( postFinder, postSelector );
- }
- return markFunction( function( seed, results, context, xml ) {
- var temp, i, elem,
- preMap = [],
- postMap = [],
- preexisting = results.length,
-
- // Get initial elements from seed or context
- elems = seed || multipleContexts(
- selector || "*",
- context.nodeType ? [ context ] : context,
- []
- ),
-
- // Prefilter to get matcher input, preserving a map for seed-results synchronization
- matcherIn = preFilter && ( seed || !selector ) ?
- condense( elems, preMap, preFilter, context, xml ) :
- elems,
-
- matcherOut = matcher ?
-
- // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
- postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-
- // ...intermediate processing is necessary
- [] :
-
- // ...otherwise use results directly
- results :
- matcherIn;
-
- // Find primary matches
- if ( matcher ) {
- matcher( matcherIn, matcherOut, context, xml );
- }
-
- // Apply postFilter
- if ( postFilter ) {
- temp = condense( matcherOut, postMap );
- postFilter( temp, [], context, xml );
-
- // Un-match failing elements by moving them back to matcherIn
- i = temp.length;
- while ( i-- ) {
- if ( ( elem = temp[ i ] ) ) {
- matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
- }
- }
- }
-
- if ( seed ) {
- if ( postFinder || preFilter ) {
- if ( postFinder ) {
-
- // Get the final matcherOut by condensing this intermediate into postFinder contexts
- temp = [];
- i = matcherOut.length;
- while ( i-- ) {
- if ( ( elem = matcherOut[ i ] ) ) {
-
- // Restore matcherIn since elem is not yet a final match
- temp.push( ( matcherIn[ i ] = elem ) );
- }
- }
- postFinder( null, ( matcherOut = [] ), temp, xml );
- }
-
- // Move matched elements from seed to results to keep them synchronized
- i = matcherOut.length;
- while ( i-- ) {
- if ( ( elem = matcherOut[ i ] ) &&
- ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
-
- seed[ temp ] = !( results[ temp ] = elem );
- }
- }
- }
-
- // Add elements to results, through postFinder if defined
- } else {
- matcherOut = condense(
- matcherOut === results ?
- matcherOut.splice( preexisting, matcherOut.length ) :
- matcherOut
- );
- if ( postFinder ) {
- postFinder( null, results, matcherOut, xml );
- } else {
- push.apply( results, matcherOut );
- }
- }
- } );
-}
-
-function matcherFromTokens( tokens ) {
- var checkContext, matcher, j,
- len = tokens.length,
- leadingRelative = Expr.relative[ tokens[ 0 ].type ],
- implicitRelative = leadingRelative || Expr.relative[ " " ],
- i = leadingRelative ? 1 : 0,
-
- // The foundational matcher ensures that elements are reachable from top-level context(s)
- matchContext = addCombinator( function( elem ) {
- return elem === checkContext;
- }, implicitRelative, true ),
- matchAnyContext = addCombinator( function( elem ) {
- return indexOf( checkContext, elem ) > -1;
- }, implicitRelative, true ),
- matchers = [ function( elem, context, xml ) {
- var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
- ( checkContext = context ).nodeType ?
- matchContext( elem, context, xml ) :
- matchAnyContext( elem, context, xml ) );
-
- // Avoid hanging onto element (issue #299)
- checkContext = null;
- return ret;
- } ];
-
- for ( ; i < len; i++ ) {
- if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
- matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
- } else {
- matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
-
- // Return special upon seeing a positional matcher
- if ( matcher[ expando ] ) {
-
- // Find the next relative operator (if any) for proper handling
- j = ++i;
- for ( ; j < len; j++ ) {
- if ( Expr.relative[ tokens[ j ].type ] ) {
- break;
- }
- }
- return setMatcher(
- i > 1 && elementMatcher( matchers ),
- i > 1 && toSelector(
-
- // If the preceding token was a descendant combinator, insert an implicit any-element `*`
- tokens
- .slice( 0, i - 1 )
- .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
- ).replace( rtrim, "$1" ),
- matcher,
- i < j && matcherFromTokens( tokens.slice( i, j ) ),
- j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
- j < len && toSelector( tokens )
- );
- }
- matchers.push( matcher );
- }
- }
-
- return elementMatcher( matchers );
-}
-
-function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
- var bySet = setMatchers.length > 0,
- byElement = elementMatchers.length > 0,
- superMatcher = function( seed, context, xml, results, outermost ) {
- var elem, j, matcher,
- matchedCount = 0,
- i = "0",
- unmatched = seed && [],
- setMatched = [],
- contextBackup = outermostContext,
-
- // We must always have either seed elements or outermost context
- elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
-
- // Use integer dirruns iff this is the outermost matcher
- dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
- len = elems.length;
-
- if ( outermost ) {
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- outermostContext = context == document || context || outermost;
- }
-
- // Add elements passing elementMatchers directly to results
- // Support: IE<9, Safari
- // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
- for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
- if ( byElement && elem ) {
- j = 0;
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( !context && elem.ownerDocument != document ) {
- setDocument( elem );
- xml = !documentIsHTML;
- }
- while ( ( matcher = elementMatchers[ j++ ] ) ) {
- if ( matcher( elem, context || document, xml ) ) {
- results.push( elem );
- break;
- }
- }
- if ( outermost ) {
- dirruns = dirrunsUnique;
- }
- }
-
- // Track unmatched elements for set filters
- if ( bySet ) {
-
- // They will have gone through all possible matchers
- if ( ( elem = !matcher && elem ) ) {
- matchedCount--;
- }
-
- // Lengthen the array for every element, matched or not
- if ( seed ) {
- unmatched.push( elem );
- }
- }
- }
-
- // `i` is now the count of elements visited above, and adding it to `matchedCount`
- // makes the latter nonnegative.
- matchedCount += i;
-
- // Apply set filters to unmatched elements
- // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
- // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
- // no element matchers and no seed.
- // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
- // case, which will result in a "00" `matchedCount` that differs from `i` but is also
- // numerically zero.
- if ( bySet && i !== matchedCount ) {
- j = 0;
- while ( ( matcher = setMatchers[ j++ ] ) ) {
- matcher( unmatched, setMatched, context, xml );
- }
-
- if ( seed ) {
-
- // Reintegrate element matches to eliminate the need for sorting
- if ( matchedCount > 0 ) {
- while ( i-- ) {
- if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
- setMatched[ i ] = pop.call( results );
- }
- }
- }
-
- // Discard index placeholder values to get only actual matches
- setMatched = condense( setMatched );
- }
-
- // Add matches to results
- push.apply( results, setMatched );
-
- // Seedless set matches succeeding multiple successful matchers stipulate sorting
- if ( outermost && !seed && setMatched.length > 0 &&
- ( matchedCount + setMatchers.length ) > 1 ) {
-
- Sizzle.uniqueSort( results );
- }
- }
-
- // Override manipulation of globals by nested matchers
- if ( outermost ) {
- dirruns = dirrunsUnique;
- outermostContext = contextBackup;
- }
-
- return unmatched;
- };
-
- return bySet ?
- markFunction( superMatcher ) :
- superMatcher;
-}
-
-compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
- var i,
- setMatchers = [],
- elementMatchers = [],
- cached = compilerCache[ selector + " " ];
-
- if ( !cached ) {
-
- // Generate a function of recursive functions that can be used to check each element
- if ( !match ) {
- match = tokenize( selector );
- }
- i = match.length;
- while ( i-- ) {
- cached = matcherFromTokens( match[ i ] );
- if ( cached[ expando ] ) {
- setMatchers.push( cached );
- } else {
- elementMatchers.push( cached );
- }
- }
-
- // Cache the compiled function
- cached = compilerCache(
- selector,
- matcherFromGroupMatchers( elementMatchers, setMatchers )
- );
-
- // Save selector and tokenization
- cached.selector = selector;
- }
- return cached;
-};
-
-/**
- * A low-level selection function that works with Sizzle's compiled
- * selector functions
- * @param {String|Function} selector A selector or a pre-compiled
- * selector function built with Sizzle.compile
- * @param {Element} context
- * @param {Array} [results]
- * @param {Array} [seed] A set of elements to match against
- */
-select = Sizzle.select = function( selector, context, results, seed ) {
- var i, tokens, token, type, find,
- compiled = typeof selector === "function" && selector,
- match = !seed && tokenize( ( selector = compiled.selector || selector ) );
-
- results = results || [];
-
- // Try to minimize operations if there is only one selector in the list and no seed
- // (the latter of which guarantees us context)
- if ( match.length === 1 ) {
-
- // Reduce context if the leading compound selector is an ID
- tokens = match[ 0 ] = match[ 0 ].slice( 0 );
- if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
- context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
-
- context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
- .replace( runescape, funescape ), context ) || [] )[ 0 ];
- if ( !context ) {
- return results;
-
- // Precompiled matchers will still verify ancestry, so step up a level
- } else if ( compiled ) {
- context = context.parentNode;
- }
-
- selector = selector.slice( tokens.shift().value.length );
- }
-
- // Fetch a seed set for right-to-left matching
- i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
- while ( i-- ) {
- token = tokens[ i ];
-
- // Abort if we hit a combinator
- if ( Expr.relative[ ( type = token.type ) ] ) {
- break;
- }
- if ( ( find = Expr.find[ type ] ) ) {
-
- // Search, expanding context for leading sibling combinators
- if ( ( seed = find(
- token.matches[ 0 ].replace( runescape, funescape ),
- rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
- context
- ) ) ) {
-
- // If seed is empty or no tokens remain, we can return early
- tokens.splice( i, 1 );
- selector = seed.length && toSelector( tokens );
- if ( !selector ) {
- push.apply( results, seed );
- return results;
- }
-
- break;
- }
- }
- }
- }
-
- // Compile and execute a filtering function if one is not provided
- // Provide `match` to avoid retokenization if we modified the selector above
- ( compiled || compile( selector, match ) )(
- seed,
- context,
- !documentIsHTML,
- results,
- !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
- );
- return results;
-};
-
-// One-time assignments
-
-// Sort stability
-support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
-
-// Support: Chrome 14-35+
-// Always assume duplicates if they aren't passed to the comparison function
-support.detectDuplicates = !!hasDuplicate;
-
-// Initialize against the default document
-setDocument();
-
-// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
-// Detached nodes confoundingly follow *each other*
-support.sortDetached = assert( function( el ) {
-
- // Should return 1, but returns 4 (following)
- return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
-} );
-
-// Support: IE<8
-// Prevent attribute/property "interpolation"
-// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !assert( function( el ) {
- el.innerHTML = "<a href='#'></a>";
- return el.firstChild.getAttribute( "href" ) === "#";
-} ) ) {
- addHandle( "type|href|height|width", function( elem, name, isXML ) {
- if ( !isXML ) {
- return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
- }
- } );
-}
-
-// Support: IE<9
-// Use defaultValue in place of getAttribute("value")
-if ( !support.attributes || !assert( function( el ) {
- el.innerHTML = "<input/>";
- el.firstChild.setAttribute( "value", "" );
- return el.firstChild.getAttribute( "value" ) === "";
-} ) ) {
- addHandle( "value", function( elem, _name, isXML ) {
- if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
- return elem.defaultValue;
- }
- } );
-}
-
-// Support: IE<9
-// Use getAttributeNode to fetch booleans when getAttribute lies
-if ( !assert( function( el ) {
- return el.getAttribute( "disabled" ) == null;
-} ) ) {
- addHandle( booleans, function( elem, name, isXML ) {
- var val;
- if ( !isXML ) {
- return elem[ name ] === true ? name.toLowerCase() :
- ( val = elem.getAttributeNode( name ) ) && val.specified ?
- val.value :
- null;
- }
- } );
-}
-
-return Sizzle;
-
-} )( window );
-
-
-
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-
-// Deprecated
-jQuery.expr[ ":" ] = jQuery.expr.pseudos;
-jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-jQuery.escapeSelector = Sizzle.escape;
-
-
-
-
-var dir = function( elem, dir, until ) {
- var matched = [],
- truncate = until !== undefined;
-
- while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
- if ( elem.nodeType === 1 ) {
- if ( truncate && jQuery( elem ).is( until ) ) {
- break;
- }
- matched.push( elem );
- }
- }
- return matched;
-};
-
-
-var siblings = function( n, elem ) {
- var matched = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- matched.push( n );
- }
- }
-
- return matched;
-};
-
-
-var rneedsContext = jQuery.expr.match.needsContext;
-
-
-
-function nodeName( elem, name ) {
-
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
-
-};
-var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
-
-
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, not ) {
- if ( isFunction( qualifier ) ) {
- return jQuery.grep( elements, function( elem, i ) {
- return !!qualifier.call( elem, i, elem ) !== not;
- } );
- }
-
- // Single element
- if ( qualifier.nodeType ) {
- return jQuery.grep( elements, function( elem ) {
- return ( elem === qualifier ) !== not;
- } );
- }
-
- // Arraylike of elements (jQuery, arguments, Array)
- if ( typeof qualifier !== "string" ) {
- return jQuery.grep( elements, function( elem ) {
- return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
- } );
- }
-
- // Filtered directly for both simple and complex selectors
- return jQuery.filter( qualifier, elements, not );
-}
-
-jQuery.filter = function( expr, elems, not ) {
- var elem = elems[ 0 ];
-
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- if ( elems.length === 1 && elem.nodeType === 1 ) {
- return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
- }
-
- return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
- return elem.nodeType === 1;
- } ) );
-};
-
-jQuery.fn.extend( {
- find: function( selector ) {
- var i, ret,
- len = this.length,
- self = this;
-
- if ( typeof selector !== "string" ) {
- return this.pushStack( jQuery( selector ).filter( function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- } ) );
- }
-
- ret = this.pushStack( [] );
-
- for ( i = 0; i < len; i++ ) {
- jQuery.find( selector, self[ i ], ret );
- }
-
- return len > 1 ? jQuery.uniqueSort( ret ) : ret;
- },
- filter: function( selector ) {
- return this.pushStack( winnow( this, selector || [], false ) );
- },
- not: function( selector ) {
- return this.pushStack( winnow( this, selector || [], true ) );
- },
- is: function( selector ) {
- return !!winnow(
- this,
-
- // If this is a positional/relative selector, check membership in the returned set
- // so $("p:first").is("p:last") won't return true for a doc with two "p".
- typeof selector === "string" && rneedsContext.test( selector ) ?
- jQuery( selector ) :
- selector || [],
- false
- ).length;
- }
-} );
-
-
-// Initialize a jQuery object
-
-
-// A central reference to the root jQuery(document)
-var rootjQuery,
-
- // A simple way to check for HTML strings
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
- // Strict HTML recognition (#11290: must start with <)
- // Shortcut simple #id case for speed
- rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
-
- init = jQuery.fn.init = function( selector, context, root ) {
- var match, elem;
-
- // HANDLE: $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // Method init() accepts an alternate rootjQuery
- // so migrate can support jQuery.sub (gh-2101)
- root = root || rootjQuery;
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector[ 0 ] === "<" &&
- selector[ selector.length - 1 ] === ">" &&
- selector.length >= 3 ) {
-
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && ( match[ 1 ] || !context ) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[ 1 ] ) {
- context = context instanceof jQuery ? context[ 0 ] : context;
-
- // Option to run scripts is true for back-compat
- // Intentionally let the error be thrown if parseHTML is not present
- jQuery.merge( this, jQuery.parseHTML(
- match[ 1 ],
- context && context.nodeType ? context.ownerDocument || context : document,
- true
- ) );
-
- // HANDLE: $(html, props)
- if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
- for ( match in context ) {
-
- // Properties of context are called as methods if possible
- if ( isFunction( this[ match ] ) ) {
- this[ match ]( context[ match ] );
-
- // ...and otherwise set as attributes
- } else {
- this.attr( match, context[ match ] );
- }
- }
- }
-
- return this;
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[ 2 ] );
-
- if ( elem ) {
-
- // Inject the element directly into the jQuery object
- this[ 0 ] = elem;
- this.length = 1;
- }
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || root ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(DOMElement)
- } else if ( selector.nodeType ) {
- this[ 0 ] = selector;
- this.length = 1;
- return this;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( isFunction( selector ) ) {
- return root.ready !== undefined ?
- root.ready( selector ) :
-
- // Execute immediately if ready is not present
- selector( jQuery );
- }
-
- return jQuery.makeArray( selector, this );
- };
-
-// Give the init function the jQuery prototype for later instantiation
-init.prototype = jQuery.fn;
-
-// Initialize central reference
-rootjQuery = jQuery( document );
-
-
-var rparentsprev = /^(?:parents|prev(?:Until|All))/,
-
- // Methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.fn.extend( {
- has: function( target ) {
- var targets = jQuery( target, this ),
- l = targets.length;
-
- return this.filter( function() {
- var i = 0;
- for ( ; i < l; i++ ) {
- if ( jQuery.contains( this, targets[ i ] ) ) {
- return true;
- }
- }
- } );
- },
-
- closest: function( selectors, context ) {
- var cur,
- i = 0,
- l = this.length,
- matched = [],
- targets = typeof selectors !== "string" && jQuery( selectors );
-
- // Positional selectors never match, since there's no _selection_ context
- if ( !rneedsContext.test( selectors ) ) {
- for ( ; i < l; i++ ) {
- for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
-
- // Always skip document fragments
- if ( cur.nodeType < 11 && ( targets ?
- targets.index( cur ) > -1 :
-
- // Don't pass non-elements to Sizzle
- cur.nodeType === 1 &&
- jQuery.find.matchesSelector( cur, selectors ) ) ) {
-
- matched.push( cur );
- break;
- }
- }
- }
- }
-
- return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
- },
-
- // Determine the position of an element within the set
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
- }
-
- // Index in selector
- if ( typeof elem === "string" ) {
- return indexOf.call( jQuery( elem ), this[ 0 ] );
- }
-
- // Locate the position of the desired element
- return indexOf.call( this,
-
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[ 0 ] : elem
- );
- },
-
- add: function( selector, context ) {
- return this.pushStack(
- jQuery.uniqueSort(
- jQuery.merge( this.get(), jQuery( selector, context ) )
- )
- );
- },
-
- addBack: function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter( selector )
- );
- }
-} );
-
-function sibling( cur, dir ) {
- while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
- return cur;
-}
-
-jQuery.each( {
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, _i, until ) {
- return dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return sibling( elem, "nextSibling" );
- },
- prev: function( elem ) {
- return sibling( elem, "previousSibling" );
- },
- nextAll: function( elem ) {
- return dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, _i, until ) {
- return dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, _i, until ) {
- return dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return siblings( ( elem.parentNode || {} ).firstChild, elem );
- },
- children: function( elem ) {
- return siblings( elem.firstChild );
- },
- contents: function( elem ) {
- if ( elem.contentDocument != null &&
-
- // Support: IE 11+
- // <object> elements with no `data` attribute has an object
- // `contentDocument` with a `null` prototype.
- getProto( elem.contentDocument ) ) {
-
- return elem.contentDocument;
- }
-
- // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
- // Treat the template element as a regular one in browsers that
- // don't support it.
- if ( nodeName( elem, "template" ) ) {
- elem = elem.content || elem;
- }
-
- return jQuery.merge( [], elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var matched = jQuery.map( this, fn, until );
-
- if ( name.slice( -5 ) !== "Until" ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- matched = jQuery.filter( selector, matched );
- }
-
- if ( this.length > 1 ) {
-
- // Remove duplicates
- if ( !guaranteedUnique[ name ] ) {
- jQuery.uniqueSort( matched );
- }
-
- // Reverse order for parents* and prev-derivatives
- if ( rparentsprev.test( name ) ) {
- matched.reverse();
- }
- }
-
- return this.pushStack( matched );
- };
-} );
-var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
-
-
-
-// Convert String-formatted options into Object-formatted ones
-function createOptions( options ) {
- var object = {};
- jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
- object[ flag ] = true;
- } );
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * options: an optional list of space-separated options that will change how
- * the callback list behaves or a more traditional option object
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible options:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( options ) {
-
- // Convert options from String-formatted to Object-formatted if needed
- // (we check in cache first)
- options = typeof options === "string" ?
- createOptions( options ) :
- jQuery.extend( {}, options );
-
- var // Flag to know if list is currently firing
- firing,
-
- // Last fire value for non-forgettable lists
- memory,
-
- // Flag to know if list was already fired
- fired,
-
- // Flag to prevent firing
- locked,
-
- // Actual callback list
- list = [],
-
- // Queue of execution data for repeatable lists
- queue = [],
-
- // Index of currently firing callback (modified by add/remove as needed)
- firingIndex = -1,
-
- // Fire callbacks
- fire = function() {
-
- // Enforce single-firing
- locked = locked || options.once;
-
- // Execute callbacks for all pending executions,
- // respecting firingIndex overrides and runtime changes
- fired = firing = true;
- for ( ; queue.length; firingIndex = -1 ) {
- memory = queue.shift();
- while ( ++firingIndex < list.length ) {
-
- // Run callback and check for early termination
- if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
- options.stopOnFalse ) {
-
- // Jump to end and forget the data so .add doesn't re-fire
- firingIndex = list.length;
- memory = false;
- }
- }
- }
-
- // Forget the data if we're done with it
- if ( !options.memory ) {
- memory = false;
- }
-
- firing = false;
-
- // Clean up if we're done firing for good
- if ( locked ) {
-
- // Keep an empty list if we have data for future add calls
- if ( memory ) {
- list = [];
-
- // Otherwise, this object is spent
- } else {
- list = "";
- }
- }
- },
-
- // Actual Callbacks object
- self = {
-
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
-
- // If we have memory from a past run, we should fire after adding
- if ( memory && !firing ) {
- firingIndex = list.length - 1;
- queue.push( memory );
- }
-
- ( function add( args ) {
- jQuery.each( args, function( _, arg ) {
- if ( isFunction( arg ) ) {
- if ( !options.unique || !self.has( arg ) ) {
- list.push( arg );
- }
- } else if ( arg && arg.length && toType( arg ) !== "string" ) {
-
- // Inspect recursively
- add( arg );
- }
- } );
- } )( arguments );
-
- if ( memory && !firing ) {
- fire();
- }
- }
- return this;
- },
-
- // Remove a callback from the list
- remove: function() {
- jQuery.each( arguments, function( _, arg ) {
- var index;
- while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
- list.splice( index, 1 );
-
- // Handle firing indexes
- if ( index <= firingIndex ) {
- firingIndex--;
- }
- }
- } );
- return this;
- },
-
- // Check if a given callback is in the list.
- // If no argument is given, return whether or not list has callbacks attached.
- has: function( fn ) {
- return fn ?
- jQuery.inArray( fn, list ) > -1 :
- list.length > 0;
- },
-
- // Remove all callbacks from the list
- empty: function() {
- if ( list ) {
- list = [];
- }
- return this;
- },
-
- // Disable .fire and .add
- // Abort any current/pending executions
- // Clear all callbacks and values
- disable: function() {
- locked = queue = [];
- list = memory = "";
- return this;
- },
- disabled: function() {
- return !list;
- },
-
- // Disable .fire
- // Also disable .add unless we have memory (since it would have no effect)
- // Abort any pending executions
- lock: function() {
- locked = queue = [];
- if ( !memory && !firing ) {
- list = memory = "";
- }
- return this;
- },
- locked: function() {
- return !!locked;
- },
-
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- if ( !locked ) {
- args = args || [];
- args = [ context, args.slice ? args.slice() : args ];
- queue.push( args );
- if ( !firing ) {
- fire();
- }
- }
- return this;
- },
-
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
-
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!fired;
- }
- };
-
- return self;
-};
-
-
-function Identity( v ) {
- return v;
-}
-function Thrower( ex ) {
- throw ex;
-}
-
-function adoptValue( value, resolve, reject, noValue ) {
- var method;
-
- try {
-
- // Check for promise aspect first to privilege synchronous behavior
- if ( value && isFunction( ( method = value.promise ) ) ) {
- method.call( value ).done( resolve ).fail( reject );
-
- // Other thenables
- } else if ( value && isFunction( ( method = value.then ) ) ) {
- method.call( value, resolve, reject );
-
- // Other non-thenables
- } else {
-
- // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
- // * false: [ value ].slice( 0 ) => resolve( value )
- // * true: [ value ].slice( 1 ) => resolve()
- resolve.apply( undefined, [ value ].slice( noValue ) );
- }
-
- // For Promises/A+, convert exceptions into rejections
- // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
- // Deferred#then to conditionally suppress rejection.
- } catch ( value ) {
-
- // Support: Android 4.0 only
- // Strict mode functions invoked without .call/.apply get global-object context
- reject.apply( undefined, [ value ] );
- }
-}
-
-jQuery.extend( {
-
- Deferred: function( func ) {
- var tuples = [
-
- // action, add listener, callbacks,
- // ... .then handlers, argument index, [final state]
- [ "notify", "progress", jQuery.Callbacks( "memory" ),
- jQuery.Callbacks( "memory" ), 2 ],
- [ "resolve", "done", jQuery.Callbacks( "once memory" ),
- jQuery.Callbacks( "once memory" ), 0, "resolved" ],
- [ "reject", "fail", jQuery.Callbacks( "once memory" ),
- jQuery.Callbacks( "once memory" ), 1, "rejected" ]
- ],
- state = "pending",
- promise = {
- state: function() {
- return state;
- },
- always: function() {
- deferred.done( arguments ).fail( arguments );
- return this;
- },
- "catch": function( fn ) {
- return promise.then( null, fn );
- },
-
- // Keep pipe for back-compat
- pipe: function( /* fnDone, fnFail, fnProgress */ ) {
- var fns = arguments;
-
- return jQuery.Deferred( function( newDefer ) {
- jQuery.each( tuples, function( _i, tuple ) {
-
- // Map tuples (progress, done, fail) to arguments (done, fail, progress)
- var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
-
- // deferred.progress(function() { bind to newDefer or newDefer.notify })
- // deferred.done(function() { bind to newDefer or newDefer.resolve })
- // deferred.fail(function() { bind to newDefer or newDefer.reject })
- deferred[ tuple[ 1 ] ]( function() {
- var returned = fn && fn.apply( this, arguments );
- if ( returned && isFunction( returned.promise ) ) {
- returned.promise()
- .progress( newDefer.notify )
- .done( newDefer.resolve )
- .fail( newDefer.reject );
- } else {
- newDefer[ tuple[ 0 ] + "With" ](
- this,
- fn ? [ returned ] : arguments
- );
- }
- } );
- } );
- fns = null;
- } ).promise();
- },
- then: function( onFulfilled, onRejected, onProgress ) {
- var maxDepth = 0;
- function resolve( depth, deferred, handler, special ) {
- return function() {
- var that = this,
- args = arguments,
- mightThrow = function() {
- var returned, then;
-
- // Support: Promises/A+ section 2.3.3.3.3
- // https://promisesaplus.com/#point-59
- // Ignore double-resolution attempts
- if ( depth < maxDepth ) {
- return;
- }
-
- returned = handler.apply( that, args );
-
- // Support: Promises/A+ section 2.3.1
- // https://promisesaplus.com/#point-48
- if ( returned === deferred.promise() ) {
- throw new TypeError( "Thenable self-resolution" );
- }
-
- // Support: Promises/A+ sections 2.3.3.1, 3.5
- // https://promisesaplus.com/#point-54
- // https://promisesaplus.com/#point-75
- // Retrieve `then` only once
- then = returned &&
-
- // Support: Promises/A+ section 2.3.4
- // https://promisesaplus.com/#point-64
- // Only check objects and functions for thenability
- ( typeof returned === "object" ||
- typeof returned === "function" ) &&
- returned.then;
-
- // Handle a returned thenable
- if ( isFunction( then ) ) {
-
- // Special processors (notify) just wait for resolution
- if ( special ) {
- then.call(
- returned,
- resolve( maxDepth, deferred, Identity, special ),
- resolve( maxDepth, deferred, Thrower, special )
- );
-
- // Normal processors (resolve) also hook into progress
- } else {
-
- // ...and disregard older resolution values
- maxDepth++;
-
- then.call(
- returned,
- resolve( maxDepth, deferred, Identity, special ),
- resolve( maxDepth, deferred, Thrower, special ),
- resolve( maxDepth, deferred, Identity,
- deferred.notifyWith )
- );
- }
-
- // Handle all other returned values
- } else {
-
- // Only substitute handlers pass on context
- // and multiple values (non-spec behavior)
- if ( handler !== Identity ) {
- that = undefined;
- args = [ returned ];
- }
-
- // Process the value(s)
- // Default process is resolve
- ( special || deferred.resolveWith )( that, args );
- }
- },
-
- // Only normal processors (resolve) catch and reject exceptions
- process = special ?
- mightThrow :
- function() {
- try {
- mightThrow();
- } catch ( e ) {
-
- if ( jQuery.Deferred.exceptionHook ) {
- jQuery.Deferred.exceptionHook( e,
- process.stackTrace );
- }
-
- // Support: Promises/A+ section 2.3.3.3.4.1
- // https://promisesaplus.com/#point-61
- // Ignore post-resolution exceptions
- if ( depth + 1 >= maxDepth ) {
-
- // Only substitute handlers pass on context
- // and multiple values (non-spec behavior)
- if ( handler !== Thrower ) {
- that = undefined;
- args = [ e ];
- }
-
- deferred.rejectWith( that, args );
- }
- }
- };
-
- // Support: Promises/A+ section 2.3.3.3.1
- // https://promisesaplus.com/#point-57
- // Re-resolve promises immediately to dodge false rejection from
- // subsequent errors
- if ( depth ) {
- process();
- } else {
-
- // Call an optional hook to record the stack, in case of exception
- // since it's otherwise lost when execution goes async
- if ( jQuery.Deferred.getStackHook ) {
- process.stackTrace = jQuery.Deferred.getStackHook();
- }
- window.setTimeout( process );
- }
- };
- }
-
- return jQuery.Deferred( function( newDefer ) {
-
- // progress_handlers.add( ... )
- tuples[ 0 ][ 3 ].add(
- resolve(
- 0,
- newDefer,
- isFunction( onProgress ) ?
- onProgress :
- Identity,
- newDefer.notifyWith
- )
- );
-
- // fulfilled_handlers.add( ... )
- tuples[ 1 ][ 3 ].add(
- resolve(
- 0,
- newDefer,
- isFunction( onFulfilled ) ?
- onFulfilled :
- Identity
- )
- );
-
- // rejected_handlers.add( ... )
- tuples[ 2 ][ 3 ].add(
- resolve(
- 0,
- newDefer,
- isFunction( onRejected ) ?
- onRejected :
- Thrower
- )
- );
- } ).promise();
- },
-
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- return obj != null ? jQuery.extend( obj, promise ) : promise;
- }
- },
- deferred = {};
-
- // Add list-specific methods
- jQuery.each( tuples, function( i, tuple ) {
- var list = tuple[ 2 ],
- stateString = tuple[ 5 ];
-
- // promise.progress = list.add
- // promise.done = list.add
- // promise.fail = list.add
- promise[ tuple[ 1 ] ] = list.add;
-
- // Handle state
- if ( stateString ) {
- list.add(
- function() {
-
- // state = "resolved" (i.e., fulfilled)
- // state = "rejected"
- state = stateString;
- },
-
- // rejected_callbacks.disable
- // fulfilled_callbacks.disable
- tuples[ 3 - i ][ 2 ].disable,
-
- // rejected_handlers.disable
- // fulfilled_handlers.disable
- tuples[ 3 - i ][ 3 ].disable,
-
- // progress_callbacks.lock
- tuples[ 0 ][ 2 ].lock,
-
- // progress_handlers.lock
- tuples[ 0 ][ 3 ].lock
- );
- }
-
- // progress_handlers.fire
- // fulfilled_handlers.fire
- // rejected_handlers.fire
- list.add( tuple[ 3 ].fire );
-
- // deferred.notify = function() { deferred.notifyWith(...) }
- // deferred.resolve = function() { deferred.resolveWith(...) }
- // deferred.reject = function() { deferred.rejectWith(...) }
- deferred[ tuple[ 0 ] ] = function() {
- deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
- return this;
- };
-
- // deferred.notifyWith = list.fireWith
- // deferred.resolveWith = list.fireWith
- // deferred.rejectWith = list.fireWith
- deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
- } );
-
- // Make the deferred a promise
- promise.promise( deferred );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( singleValue ) {
- var
-
- // count of uncompleted subordinates
- remaining = arguments.length,
-
- // count of unprocessed arguments
- i = remaining,
-
- // subordinate fulfillment data
- resolveContexts = Array( i ),
- resolveValues = slice.call( arguments ),
-
- // the master Deferred
- master = jQuery.Deferred(),
-
- // subordinate callback factory
- updateFunc = function( i ) {
- return function( value ) {
- resolveContexts[ i ] = this;
- resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
- if ( !( --remaining ) ) {
- master.resolveWith( resolveContexts, resolveValues );
- }
- };
- };
-
- // Single- and empty arguments are adopted like Promise.resolve
- if ( remaining <= 1 ) {
- adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
- !remaining );
-
- // Use .then() to unwrap secondary thenables (cf. gh-3000)
- if ( master.state() === "pending" ||
- isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
-
- return master.then();
- }
- }
-
- // Multiple arguments are aggregated like Promise.all array elements
- while ( i-- ) {
- adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
- }
-
- return master.promise();
- }
-} );
-
-
-// These usually indicate a programmer mistake during development,
-// warn about them ASAP rather than swallowing them by default.
-var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
-
-jQuery.Deferred.exceptionHook = function( error, stack ) {
-
- // Support: IE 8 - 9 only
- // Console exists when dev tools are open, which can happen at any time
- if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
- window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
- }
-};
-
-
-
-
-jQuery.readyException = function( error ) {
- window.setTimeout( function() {
- throw error;
- } );
-};
-
-
-
-
-// The deferred used on DOM ready
-var readyList = jQuery.Deferred();
-
-jQuery.fn.ready = function( fn ) {
-
- readyList
- .then( fn )
-
- // Wrap jQuery.readyException in a function so that the lookup
- // happens at the time of error handling instead of callback
- // registration.
- .catch( function( error ) {
- jQuery.readyException( error );
- } );
-
- return this;
-};
-
-jQuery.extend( {
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
- }
-} );
-
-jQuery.ready.then = readyList.then;
-
-// The ready event handler and self cleanup method
-function completed() {
- document.removeEventListener( "DOMContentLoaded", completed );
- window.removeEventListener( "load", completed );
- jQuery.ready();
-}
-
-// Catch cases where $(document).ready() is called
-// after the browser event has already occurred.
-// Support: IE <=9 - 10 only
-// Older IE sometimes signals "interactive" too soon
-if ( document.readyState === "complete" ||
- ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
-
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- window.setTimeout( jQuery.ready );
-
-} else {
-
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", completed );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", completed );
-}
-
-
-
-
-// Multifunctional method to get and set values of a collection
-// The value/s can optionally be executed if it's a function
-var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
- var i = 0,
- len = elems.length,
- bulk = key == null;
-
- // Sets many values
- if ( toType( key ) === "object" ) {
- chainable = true;
- for ( i in key ) {
- access( elems, fn, i, key[ i ], true, emptyGet, raw );
- }
-
- // Sets one value
- } else if ( value !== undefined ) {
- chainable = true;
-
- if ( !isFunction( value ) ) {
- raw = true;
- }
-
- if ( bulk ) {
-
- // Bulk operations run against the entire set
- if ( raw ) {
- fn.call( elems, value );
- fn = null;
-
- // ...except when executing function values
- } else {
- bulk = fn;
- fn = function( elem, _key, value ) {
- return bulk.call( jQuery( elem ), value );
- };
- }
- }
-
- if ( fn ) {
- for ( ; i < len; i++ ) {
- fn(
- elems[ i ], key, raw ?
- value :
- value.call( elems[ i ], i, fn( elems[ i ], key ) )
- );
- }
- }
- }
-
- if ( chainable ) {
- return elems;
- }
-
- // Gets
- if ( bulk ) {
- return fn.call( elems );
- }
-
- return len ? fn( elems[ 0 ], key ) : emptyGet;
-};
-
-
-// Matches dashed string for camelizing
-var rmsPrefix = /^-ms-/,
- rdashAlpha = /-([a-z])/g;
-
-// Used by camelCase as callback to replace()
-function fcamelCase( _all, letter ) {
- return letter.toUpperCase();
-}
-
-// Convert dashed to camelCase; used by the css and data modules
-// Support: IE <=9 - 11, Edge 12 - 15
-// Microsoft forgot to hump their vendor prefix (#9572)
-function camelCase( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
-}
-var acceptData = function( owner ) {
-
- // Accepts only:
- // - Node
- // - Node.ELEMENT_NODE
- // - Node.DOCUMENT_NODE
- // - Object
- // - Any
- return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
-};
-
-
-
-
-function Data() {
- this.expando = jQuery.expando + Data.uid++;
-}
-
-Data.uid = 1;
-
-Data.prototype = {
-
- cache: function( owner ) {
-
- // Check if the owner object already has a cache
- var value = owner[ this.expando ];
-
- // If not, create one
- if ( !value ) {
- value = {};
-
- // We can accept data for non-element nodes in modern browsers,
- // but we should not, see #8335.
- // Always return an empty object.
- if ( acceptData( owner ) ) {
-
- // If it is a node unlikely to be stringify-ed or looped over
- // use plain assignment
- if ( owner.nodeType ) {
- owner[ this.expando ] = value;
-
- // Otherwise secure it in a non-enumerable property
- // configurable must be true to allow the property to be
- // deleted when data is removed
- } else {
- Object.defineProperty( owner, this.expando, {
- value: value,
- configurable: true
- } );
- }
- }
- }
-
- return value;
- },
- set: function( owner, data, value ) {
- var prop,
- cache = this.cache( owner );
-
- // Handle: [ owner, key, value ] args
- // Always use camelCase key (gh-2257)
- if ( typeof data === "string" ) {
- cache[ camelCase( data ) ] = value;
-
- // Handle: [ owner, { properties } ] args
- } else {
-
- // Copy the properties one-by-one to the cache object
- for ( prop in data ) {
- cache[ camelCase( prop ) ] = data[ prop ];
- }
- }
- return cache;
- },
- get: function( owner, key ) {
- return key === undefined ?
- this.cache( owner ) :
-
- // Always use camelCase key (gh-2257)
- owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
- },
- access: function( owner, key, value ) {
-
- // In cases where either:
- //
- // 1. No key was specified
- // 2. A string key was specified, but no value provided
- //
- // Take the "read" path and allow the get method to determine
- // which value to return, respectively either:
- //
- // 1. The entire cache object
- // 2. The data stored at the key
- //
- if ( key === undefined ||
- ( ( key && typeof key === "string" ) && value === undefined ) ) {
-
- return this.get( owner, key );
- }
-
- // When the key is not a string, or both a key and value
- // are specified, set or extend (existing objects) with either:
- //
- // 1. An object of properties
- // 2. A key and value
- //
- this.set( owner, key, value );
-
- // Since the "set" path can have two possible entry points
- // return the expected data based on which path was taken[*]
- return value !== undefined ? value : key;
- },
- remove: function( owner, key ) {
- var i,
- cache = owner[ this.expando ];
-
- if ( cache === undefined ) {
- return;
- }
-
- if ( key !== undefined ) {
-
- // Support array or space separated string of keys
- if ( Array.isArray( key ) ) {
-
- // If key is an array of keys...
- // We always set camelCase keys, so remove that.
- key = key.map( camelCase );
- } else {
- key = camelCase( key );
-
- // If a key with the spaces exists, use it.
- // Otherwise, create an array by matching non-whitespace
- key = key in cache ?
- [ key ] :
- ( key.match( rnothtmlwhite ) || [] );
- }
-
- i = key.length;
-
- while ( i-- ) {
- delete cache[ key[ i ] ];
- }
- }
-
- // Remove the expando if there's no more data
- if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
-
- // Support: Chrome <=35 - 45
- // Webkit & Blink performance suffers when deleting properties
- // from DOM nodes, so set to undefined instead
- // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
- if ( owner.nodeType ) {
- owner[ this.expando ] = undefined;
- } else {
- delete owner[ this.expando ];
- }
- }
- },
- hasData: function( owner ) {
- var cache = owner[ this.expando ];
- return cache !== undefined && !jQuery.isEmptyObject( cache );
- }
-};
-var dataPriv = new Data();
-
-var dataUser = new Data();
-
-
-
-// Implementation Summary
-//
-// 1. Enforce API surface and semantic compatibility with 1.9.x branch
-// 2. Improve the module's maintainability by reducing the storage
-// paths to a single mechanism.
-// 3. Use the same single mechanism to support "private" and "user" data.
-// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
-// 5. Avoid exposing implementation details on user objects (eg. expando properties)
-// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
-
-var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
- rmultiDash = /[A-Z]/g;
-
-function getData( data ) {
- if ( data === "true" ) {
- return true;
- }
-
- if ( data === "false" ) {
- return false;
- }
-
- if ( data === "null" ) {
- return null;
- }
-
- // Only convert to a number if it doesn't change the string
- if ( data === +data + "" ) {
- return +data;
- }
-
- if ( rbrace.test( data ) ) {
- return JSON.parse( data );
- }
-
- return data;
-}
-
-function dataAttr( elem, key, data ) {
- var name;
-
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
- name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = getData( data );
- } catch ( e ) {}
-
- // Make sure we set the data so it isn't changed later
- dataUser.set( elem, key, data );
- } else {
- data = undefined;
- }
- }
- return data;
-}
-
-jQuery.extend( {
- hasData: function( elem ) {
- return dataUser.hasData( elem ) || dataPriv.hasData( elem );
- },
-
- data: function( elem, name, data ) {
- return dataUser.access( elem, name, data );
- },
-
- removeData: function( elem, name ) {
- dataUser.remove( elem, name );
- },
-
- // TODO: Now that all calls to _data and _removeData have been replaced
- // with direct calls to dataPriv methods, these can be deprecated.
- _data: function( elem, name, data ) {
- return dataPriv.access( elem, name, data );
- },
-
- _removeData: function( elem, name ) {
- dataPriv.remove( elem, name );
- }
-} );
-
-jQuery.fn.extend( {
- data: function( key, value ) {
- var i, name, data,
- elem = this[ 0 ],
- attrs = elem && elem.attributes;
-
- // Gets all values
- if ( key === undefined ) {
- if ( this.length ) {
- data = dataUser.get( elem );
-
- if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
- i = attrs.length;
- while ( i-- ) {
-
- // Support: IE 11 only
- // The attrs elements can be null (#14894)
- if ( attrs[ i ] ) {
- name = attrs[ i ].name;
- if ( name.indexOf( "data-" ) === 0 ) {
- name = camelCase( name.slice( 5 ) );
- dataAttr( elem, name, data[ name ] );
- }
- }
- }
- dataPriv.set( elem, "hasDataAttrs", true );
- }
- }
-
- return data;
- }
-
- // Sets multiple values
- if ( typeof key === "object" ) {
- return this.each( function() {
- dataUser.set( this, key );
- } );
- }
-
- return access( this, function( value ) {
- var data;
-
- // The calling jQuery object (element matches) is not empty
- // (and therefore has an element appears at this[ 0 ]) and the
- // `value` parameter was not undefined. An empty jQuery object
- // will result in `undefined` for elem = this[ 0 ] which will
- // throw an exception if an attempt to read a data cache is made.
- if ( elem && value === undefined ) {
-
- // Attempt to get data from the cache
- // The key will always be camelCased in Data
- data = dataUser.get( elem, key );
- if ( data !== undefined ) {
- return data;
- }
-
- // Attempt to "discover" the data in
- // HTML5 custom data-* attrs
- data = dataAttr( elem, key );
- if ( data !== undefined ) {
- return data;
- }
-
- // We tried really hard, but the data doesn't exist.
- return;
- }
-
- // Set the data...
- this.each( function() {
-
- // We always store the camelCased key
- dataUser.set( this, key, value );
- } );
- }, null, value, arguments.length > 1, null, true );
- },
-
- removeData: function( key ) {
- return this.each( function() {
- dataUser.remove( this, key );
- } );
- }
-} );
-
-
-jQuery.extend( {
- queue: function( elem, type, data ) {
- var queue;
-
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- queue = dataPriv.get( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !queue || Array.isArray( data ) ) {
- queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
- } else {
- queue.push( data );
- }
- }
- return queue || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- startLength = queue.length,
- fn = queue.shift(),
- hooks = jQuery._queueHooks( elem, type ),
- next = function() {
- jQuery.dequeue( elem, type );
- };
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- startLength--;
- }
-
- if ( fn ) {
-
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- // Clear up the last queue stop function
- delete hooks.stop;
- fn.call( elem, next, hooks );
- }
-
- if ( !startLength && hooks ) {
- hooks.empty.fire();
- }
- },
-
- // Not public - generate a queueHooks object, or return the current one
- _queueHooks: function( elem, type ) {
- var key = type + "queueHooks";
- return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
- empty: jQuery.Callbacks( "once memory" ).add( function() {
- dataPriv.remove( elem, [ type + "queue", key ] );
- } )
- } );
- }
-} );
-
-jQuery.fn.extend( {
- queue: function( type, data ) {
- var setter = 2;
-
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- setter--;
- }
-
- if ( arguments.length < setter ) {
- return jQuery.queue( this[ 0 ], type );
- }
-
- return data === undefined ?
- this :
- this.each( function() {
- var queue = jQuery.queue( this, type, data );
-
- // Ensure a hooks for this queue
- jQuery._queueHooks( this, type );
-
- if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- } );
- },
- dequeue: function( type ) {
- return this.each( function() {
- jQuery.dequeue( this, type );
- } );
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
-
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, obj ) {
- var tmp,
- count = 1,
- defer = jQuery.Deferred(),
- elements = this,
- i = this.length,
- resolve = function() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- };
-
- if ( typeof type !== "string" ) {
- obj = type;
- type = undefined;
- }
- type = type || "fx";
-
- while ( i-- ) {
- tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
- if ( tmp && tmp.empty ) {
- count++;
- tmp.empty.add( resolve );
- }
- }
- resolve();
- return defer.promise( obj );
- }
-} );
-var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
-
-var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
-
-
-var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
-
-var documentElement = document.documentElement;
-
-
-
- var isAttached = function( elem ) {
- return jQuery.contains( elem.ownerDocument, elem );
- },
- composed = { composed: true };
-
- // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
- // Check attachment across shadow DOM boundaries when possible (gh-3504)
- // Support: iOS 10.0-10.2 only
- // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
- // leading to errors. We need to check for `getRootNode`.
- if ( documentElement.getRootNode ) {
- isAttached = function( elem ) {
- return jQuery.contains( elem.ownerDocument, elem ) ||
- elem.getRootNode( composed ) === elem.ownerDocument;
- };
- }
-var isHiddenWithinTree = function( elem, el ) {
-
- // isHiddenWithinTree might be called from jQuery#filter function;
- // in that case, element will be second argument
- elem = el || elem;
-
- // Inline style trumps all
- return elem.style.display === "none" ||
- elem.style.display === "" &&
-
- // Otherwise, check computed style
- // Support: Firefox <=43 - 45
- // Disconnected elements can have computed display: none, so first confirm that elem is
- // in the document.
- isAttached( elem ) &&
-
- jQuery.css( elem, "display" ) === "none";
- };
-
-
-
-function adjustCSS( elem, prop, valueParts, tween ) {
- var adjusted, scale,
- maxIterations = 20,
- currentValue = tween ?
- function() {
- return tween.cur();
- } :
- function() {
- return jQuery.css( elem, prop, "" );
- },
- initial = currentValue(),
- unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
-
- // Starting value computation is required for potential unit mismatches
- initialInUnit = elem.nodeType &&
- ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
- rcssNum.exec( jQuery.css( elem, prop ) );
-
- if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
-
- // Support: Firefox <=54
- // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
- initial = initial / 2;
-
- // Trust units reported by jQuery.css
- unit = unit || initialInUnit[ 3 ];
-
- // Iteratively approximate from a nonzero starting point
- initialInUnit = +initial || 1;
-
- while ( maxIterations-- ) {
-
- // Evaluate and update our best guess (doubling guesses that zero out).
- // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
- jQuery.style( elem, prop, initialInUnit + unit );
- if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
- maxIterations = 0;
- }
- initialInUnit = initialInUnit / scale;
-
- }
-
- initialInUnit = initialInUnit * 2;
- jQuery.style( elem, prop, initialInUnit + unit );
-
- // Make sure we update the tween properties later on
- valueParts = valueParts || [];
- }
-
- if ( valueParts ) {
- initialInUnit = +initialInUnit || +initial || 0;
-
- // Apply relative offset (+=/-=) if specified
- adjusted = valueParts[ 1 ] ?
- initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
- +valueParts[ 2 ];
- if ( tween ) {
- tween.unit = unit;
- tween.start = initialInUnit;
- tween.end = adjusted;
- }
- }
- return adjusted;
-}
-
-
-var defaultDisplayMap = {};
-
-function getDefaultDisplay( elem ) {
- var temp,
- doc = elem.ownerDocument,
- nodeName = elem.nodeName,
- display = defaultDisplayMap[ nodeName ];
-
- if ( display ) {
- return display;
- }
-
- temp = doc.body.appendChild( doc.createElement( nodeName ) );
- display = jQuery.css( temp, "display" );
-
- temp.parentNode.removeChild( temp );
-
- if ( display === "none" ) {
- display = "block";
- }
- defaultDisplayMap[ nodeName ] = display;
-
- return display;
-}
-
-function showHide( elements, show ) {
- var display, elem,
- values = [],
- index = 0,
- length = elements.length;
-
- // Determine new display value for elements that need to change
- for ( ; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
-
- display = elem.style.display;
- if ( show ) {
-
- // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
- // check is required in this first loop unless we have a nonempty display value (either
- // inline or about-to-be-restored)
- if ( display === "none" ) {
- values[ index ] = dataPriv.get( elem, "display" ) || null;
- if ( !values[ index ] ) {
- elem.style.display = "";
- }
- }
- if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
- values[ index ] = getDefaultDisplay( elem );
- }
- } else {
- if ( display !== "none" ) {
- values[ index ] = "none";
-
- // Remember what we're overwriting
- dataPriv.set( elem, "display", display );
- }
- }
- }
-
- // Set the display of the elements in a second loop to avoid constant reflow
- for ( index = 0; index < length; index++ ) {
- if ( values[ index ] != null ) {
- elements[ index ].style.display = values[ index ];
- }
- }
-
- return elements;
-}
-
-jQuery.fn.extend( {
- show: function() {
- return showHide( this, true );
- },
- hide: function() {
- return showHide( this );
- },
- toggle: function( state ) {
- if ( typeof state === "boolean" ) {
- return state ? this.show() : this.hide();
- }
-
- return this.each( function() {
- if ( isHiddenWithinTree( this ) ) {
- jQuery( this ).show();
- } else {
- jQuery( this ).hide();
- }
- } );
- }
-} );
-var rcheckableType = ( /^(?:checkbox|radio)$/i );
-
-var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
-
-var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
-
-
-
-( function() {
- var fragment = document.createDocumentFragment(),
- div = fragment.appendChild( document.createElement( "div" ) ),
- input = document.createElement( "input" );
-
- // Support: Android 4.0 - 4.3 only
- // Check state lost if the name is set (#11217)
- // Support: Windows Web Apps (WWA)
- // `name` and `type` must use .setAttribute for WWA (#14901)
- input.setAttribute( "type", "radio" );
- input.setAttribute( "checked", "checked" );
- input.setAttribute( "name", "t" );
-
- div.appendChild( input );
-
- // Support: Android <=4.1 only
- // Older WebKit doesn't clone checked state correctly in fragments
- support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Support: IE <=11 only
- // Make sure textarea (and checkbox) defaultValue is properly cloned
- div.innerHTML = "<textarea>x</textarea>";
- support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
-
- // Support: IE <=9 only
- // IE <=9 replaces <option> tags with their contents when inserted outside of
- // the select element.
- div.innerHTML = "<option></option>";
- support.option = !!div.lastChild;
-} )();
-
-
-// We have to close these tags to support XHTML (#13200)
-var wrapMap = {
-
- // XHTML parsers do not magically insert elements in the
- // same way that tag soup parsers do. So we cannot shorten
- // this by omitting <tbody> or other required elements.
- thead: [ 1, "<table>", "</table>" ],
- col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
- tr: [ 2, "<table><tbody>", "</tbody></table>" ],
- td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
-
- _default: [ 0, "", "" ]
-};
-
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-// Support: IE <=9 only
-if ( !support.option ) {
- wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
-}
-
-
-function getAll( context, tag ) {
-
- // Support: IE <=9 - 11 only
- // Use typeof to avoid zero-argument method invocation on host objects (#15151)
- var ret;
-
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- ret = context.getElementsByTagName( tag || "*" );
-
- } else if ( typeof context.querySelectorAll !== "undefined" ) {
- ret = context.querySelectorAll( tag || "*" );
-
- } else {
- ret = [];
- }
-
- if ( tag === undefined || tag && nodeName( context, tag ) ) {
- return jQuery.merge( [ context ], ret );
- }
-
- return ret;
-}
-
-
-// Mark scripts as having already been evaluated
-function setGlobalEval( elems, refElements ) {
- var i = 0,
- l = elems.length;
-
- for ( ; i < l; i++ ) {
- dataPriv.set(
- elems[ i ],
- "globalEval",
- !refElements || dataPriv.get( refElements[ i ], "globalEval" )
- );
- }
-}
-
-
-var rhtml = /<|&#?\w+;/;
-
-function buildFragment( elems, context, scripts, selection, ignored ) {
- var elem, tmp, tag, wrap, attached, j,
- fragment = context.createDocumentFragment(),
- nodes = [],
- i = 0,
- l = elems.length;
-
- for ( ; i < l; i++ ) {
- elem = elems[ i ];
-
- if ( elem || elem === 0 ) {
-
- // Add nodes directly
- if ( toType( elem ) === "object" ) {
-
- // Support: Android <=4.0 only, PhantomJS 1 only
- // push.apply(_, arraylike) throws on ancient WebKit
- jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
-
- // Convert non-html into a text node
- } else if ( !rhtml.test( elem ) ) {
- nodes.push( context.createTextNode( elem ) );
-
- // Convert html into DOM nodes
- } else {
- tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
-
- // Deserialize a standard representation
- tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
- wrap = wrapMap[ tag ] || wrapMap._default;
- tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
-
- // Descend through wrappers to the right content
- j = wrap[ 0 ];
- while ( j-- ) {
- tmp = tmp.lastChild;
- }
-
- // Support: Android <=4.0 only, PhantomJS 1 only
- // push.apply(_, arraylike) throws on ancient WebKit
- jQuery.merge( nodes, tmp.childNodes );
-
- // Remember the top-level container
- tmp = fragment.firstChild;
-
- // Ensure the created nodes are orphaned (#12392)
- tmp.textContent = "";
- }
- }
- }
-
- // Remove wrapper from fragment
- fragment.textContent = "";
-
- i = 0;
- while ( ( elem = nodes[ i++ ] ) ) {
-
- // Skip elements already in the context collection (trac-4087)
- if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
- if ( ignored ) {
- ignored.push( elem );
- }
- continue;
- }
-
- attached = isAttached( elem );
-
- // Append to fragment
- tmp = getAll( fragment.appendChild( elem ), "script" );
-
- // Preserve script evaluation history
- if ( attached ) {
- setGlobalEval( tmp );
- }
-
- // Capture executables
- if ( scripts ) {
- j = 0;
- while ( ( elem = tmp[ j++ ] ) ) {
- if ( rscriptType.test( elem.type || "" ) ) {
- scripts.push( elem );
- }
- }
- }
- }
-
- return fragment;
-}
-
-
-var
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
- rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
-
-function returnTrue() {
- return true;
-}
-
-function returnFalse() {
- return false;
-}
-
-// Support: IE <=9 - 11+
-// focus() and blur() are asynchronous, except when they are no-op.
-// So expect focus to be synchronous when the element is already active,
-// and blur to be synchronous when the element is not already active.
-// (focus and blur are always synchronous in other supported browsers,
-// this just defines when we can count on it).
-function expectSync( elem, type ) {
- return ( elem === safeActiveElement() ) === ( type === "focus" );
-}
-
-// Support: IE <=9 only
-// Accessing document.activeElement can throw unexpectedly
-// https://bugs.jquery.com/ticket/13393
-function safeActiveElement() {
- try {
- return document.activeElement;
- } catch ( err ) { }
-}
-
-function on( elem, types, selector, data, fn, one ) {
- var origFn, type;
-
- // Types can be a map of types/handlers
- if ( typeof types === "object" ) {
-
- // ( types-Object, selector, data )
- if ( typeof selector !== "string" ) {
-
- // ( types-Object, data )
- data = data || selector;
- selector = undefined;
- }
- for ( type in types ) {
- on( elem, type, selector, data, types[ type ], one );
- }
- return elem;
- }
-
- if ( data == null && fn == null ) {
-
- // ( types, fn )
- fn = selector;
- data = selector = undefined;
- } else if ( fn == null ) {
- if ( typeof selector === "string" ) {
-
- // ( types, selector, fn )
- fn = data;
- data = undefined;
- } else {
-
- // ( types, data, fn )
- fn = data;
- data = selector;
- selector = undefined;
- }
- }
- if ( fn === false ) {
- fn = returnFalse;
- } else if ( !fn ) {
- return elem;
- }
-
- if ( one === 1 ) {
- origFn = fn;
- fn = function( event ) {
-
- // Can use an empty set, since event contains the info
- jQuery().off( event );
- return origFn.apply( this, arguments );
- };
-
- // Use same guid so caller can remove using origFn
- fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
- }
- return elem.each( function() {
- jQuery.event.add( this, types, fn, data, selector );
- } );
-}
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- global: {},
-
- add: function( elem, types, handler, data, selector ) {
-
- var handleObjIn, eventHandle, tmp,
- events, t, handleObj,
- special, handlers, type, namespaces, origType,
- elemData = dataPriv.get( elem );
-
- // Only attach events to objects that accept data
- if ( !acceptData( elem ) ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- selector = handleObjIn.selector;
- }
-
- // Ensure that invalid selectors throw exceptions at attach time
- // Evaluate against documentElement in case elem is a non-element node (e.g., document)
- if ( selector ) {
- jQuery.find.matchesSelector( documentElement, selector );
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- if ( !( events = elemData.events ) ) {
- events = elemData.events = Object.create( null );
- }
- if ( !( eventHandle = elemData.handle ) ) {
- eventHandle = elemData.handle = function( e ) {
-
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
- jQuery.event.dispatch.apply( elem, arguments ) : undefined;
- };
- }
-
- // Handle multiple events separated by a space
- types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[ t ] ) || [];
- type = origType = tmp[ 1 ];
- namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
-
- // There *must* be a type, no attaching namespace-only handlers
- if ( !type ) {
- continue;
- }
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend( {
- type: type,
- origType: origType,
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
- namespace: namespaces.join( "." )
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- if ( !( handlers = events[ type ] ) ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener if the special events handler returns false
- if ( !special.setup ||
- special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
-
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- },
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
-
- var j, origCount, tmp,
- events, t, handleObj,
- special, handlers, type, namespaces, origType,
- elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
-
- if ( !elemData || !( events = elemData.events ) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[ t ] ) || [];
- type = origType = tmp[ 1 ];
- namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector ? special.delegateType : special.bindType ) || type;
- handlers = events[ type ] || [];
- tmp = tmp[ 2 ] &&
- new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
-
- // Remove matching events
- origCount = j = handlers.length;
- while ( j-- ) {
- handleObj = handlers[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !tmp || tmp.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector ||
- selector === "**" && handleObj.selector ) ) {
- handlers.splice( j, 1 );
-
- if ( handleObj.selector ) {
- handlers.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( origCount && !handlers.length ) {
- if ( !special.teardown ||
- special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
-
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove data and the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- dataPriv.remove( elem, "handle events" );
- }
- },
-
- dispatch: function( nativeEvent ) {
-
- var i, j, ret, matched, handleObj, handlerQueue,
- args = new Array( arguments.length ),
-
- // Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( nativeEvent ),
-
- handlers = (
- dataPriv.get( this, "events" ) || Object.create( null )
- )[ event.type ] || [],
- special = jQuery.event.special[ event.type ] || {};
-
- // Use the fix-ed jQuery.Event rather than the (read-only) native event
- args[ 0 ] = event;
-
- for ( i = 1; i < arguments.length; i++ ) {
- args[ i ] = arguments[ i ];
- }
-
- event.delegateTarget = this;
-
- // Call the preDispatch hook for the mapped type, and let it bail if desired
- if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
- return;
- }
-
- // Determine handlers
- handlerQueue = jQuery.event.handlers.call( this, event, handlers );
-
- // Run delegates first; they may want to stop propagation beneath us
- i = 0;
- while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
- event.currentTarget = matched.elem;
-
- j = 0;
- while ( ( handleObj = matched.handlers[ j++ ] ) &&
- !event.isImmediatePropagationStopped() ) {
-
- // If the event is namespaced, then each handler is only invoked if it is
- // specially universal or its namespaces are a superset of the event's.
- if ( !event.rnamespace || handleObj.namespace === false ||
- event.rnamespace.test( handleObj.namespace ) ) {
-
- event.handleObj = handleObj;
- event.data = handleObj.data;
-
- ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
- handleObj.handler ).apply( matched.elem, args );
-
- if ( ret !== undefined ) {
- if ( ( event.result = ret ) === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- }
- }
- }
-
- // Call the postDispatch hook for the mapped type
- if ( special.postDispatch ) {
- special.postDispatch.call( this, event );
- }
-
- return event.result;
- },
-
- handlers: function( event, handlers ) {
- var i, handleObj, sel, matchedHandlers, matchedSelectors,
- handlerQueue = [],
- delegateCount = handlers.delegateCount,
- cur = event.target;
-
- // Find delegate handlers
- if ( delegateCount &&
-
- // Support: IE <=9
- // Black-hole SVG <use> instance trees (trac-13180)
- cur.nodeType &&
-
- // Support: Firefox <=42
- // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
- // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
- // Support: IE 11 only
- // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
- !( event.type === "click" && event.button >= 1 ) ) {
-
- for ( ; cur !== this; cur = cur.parentNode || this ) {
-
- // Don't check non-elements (#13208)
- // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
- if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
- matchedHandlers = [];
- matchedSelectors = {};
- for ( i = 0; i < delegateCount; i++ ) {
- handleObj = handlers[ i ];
-
- // Don't conflict with Object.prototype properties (#13203)
- sel = handleObj.selector + " ";
-
- if ( matchedSelectors[ sel ] === undefined ) {
- matchedSelectors[ sel ] = handleObj.needsContext ?
- jQuery( sel, this ).index( cur ) > -1 :
- jQuery.find( sel, this, null, [ cur ] ).length;
- }
- if ( matchedSelectors[ sel ] ) {
- matchedHandlers.push( handleObj );
- }
- }
- if ( matchedHandlers.length ) {
- handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
- }
- }
- }
- }
-
- // Add the remaining (directly-bound) handlers
- cur = this;
- if ( delegateCount < handlers.length ) {
- handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
- }
-
- return handlerQueue;
- },
-
- addProp: function( name, hook ) {
- Object.defineProperty( jQuery.Event.prototype, name, {
- enumerable: true,
- configurable: true,
-
- get: isFunction( hook ) ?
- function() {
- if ( this.originalEvent ) {
- return hook( this.originalEvent );
- }
- } :
- function() {
- if ( this.originalEvent ) {
- return this.originalEvent[ name ];
- }
- },
-
- set: function( value ) {
- Object.defineProperty( this, name, {
- enumerable: true,
- configurable: true,
- writable: true,
- value: value
- } );
- }
- } );
- },
-
- fix: function( originalEvent ) {
- return originalEvent[ jQuery.expando ] ?
- originalEvent :
- new jQuery.Event( originalEvent );
- },
-
- special: {
- load: {
-
- // Prevent triggered image.load events from bubbling to window.load
- noBubble: true
- },
- click: {
-
- // Utilize native event to ensure correct state for checkable inputs
- setup: function( data ) {
-
- // For mutual compressibility with _default, replace `this` access with a local var.
- // `|| data` is dead code meant only to preserve the variable through minification.
- var el = this || data;
-
- // Claim the first handler
- if ( rcheckableType.test( el.type ) &&
- el.click && nodeName( el, "input" ) ) {
-
- // dataPriv.set( el, "click", ... )
- leverageNative( el, "click", returnTrue );
- }
-
- // Return false to allow normal processing in the caller
- return false;
- },
- trigger: function( data ) {
-
- // For mutual compressibility with _default, replace `this` access with a local var.
- // `|| data` is dead code meant only to preserve the variable through minification.
- var el = this || data;
-
- // Force setup before triggering a click
- if ( rcheckableType.test( el.type ) &&
- el.click && nodeName( el, "input" ) ) {
-
- leverageNative( el, "click" );
- }
-
- // Return non-false to allow normal event-path propagation
- return true;
- },
-
- // For cross-browser consistency, suppress native .click() on links
- // Also prevent it if we're currently inside a leveraged native-event stack
- _default: function( event ) {
- var target = event.target;
- return rcheckableType.test( target.type ) &&
- target.click && nodeName( target, "input" ) &&
- dataPriv.get( target, "click" ) ||
- nodeName( target, "a" );
- }
- },
-
- beforeunload: {
- postDispatch: function( event ) {
-
- // Support: Firefox 20+
- // Firefox doesn't alert if the returnValue field is not set.
- if ( event.result !== undefined && event.originalEvent ) {
- event.originalEvent.returnValue = event.result;
- }
- }
- }
- }
-};
-
-// Ensure the presence of an event listener that handles manually-triggered
-// synthetic events by interrupting progress until reinvoked in response to
-// *native* events that it fires directly, ensuring that state changes have
-// already occurred before other listeners are invoked.
-function leverageNative( el, type, expectSync ) {
-
- // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
- if ( !expectSync ) {
- if ( dataPriv.get( el, type ) === undefined ) {
- jQuery.event.add( el, type, returnTrue );
- }
- return;
- }
-
- // Register the controller as a special universal handler for all event namespaces
- dataPriv.set( el, type, false );
- jQuery.event.add( el, type, {
- namespace: false,
- handler: function( event ) {
- var notAsync, result,
- saved = dataPriv.get( this, type );
-
- if ( ( event.isTrigger & 1 ) && this[ type ] ) {
-
- // Interrupt processing of the outer synthetic .trigger()ed event
- // Saved data should be false in such cases, but might be a leftover capture object
- // from an async native handler (gh-4350)
- if ( !saved.length ) {
-
- // Store arguments for use when handling the inner native event
- // There will always be at least one argument (an event object), so this array
- // will not be confused with a leftover capture object.
- saved = slice.call( arguments );
- dataPriv.set( this, type, saved );
-
- // Trigger the native event and capture its result
- // Support: IE <=9 - 11+
- // focus() and blur() are asynchronous
- notAsync = expectSync( this, type );
- this[ type ]();
- result = dataPriv.get( this, type );
- if ( saved !== result || notAsync ) {
- dataPriv.set( this, type, false );
- } else {
- result = {};
- }
- if ( saved !== result ) {
-
- // Cancel the outer synthetic event
- event.stopImmediatePropagation();
- event.preventDefault();
- return result.value;
- }
-
- // If this is an inner synthetic event for an event with a bubbling surrogate
- // (focus or blur), assume that the surrogate already propagated from triggering the
- // native event and prevent that from happening again here.
- // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
- // bubbling surrogate propagates *after* the non-bubbling base), but that seems
- // less bad than duplication.
- } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
- event.stopPropagation();
- }
-
- // If this is a native event triggered above, everything is now in order
- // Fire an inner synthetic event with the original arguments
- } else if ( saved.length ) {
-
- // ...and capture the result
- dataPriv.set( this, type, {
- value: jQuery.event.trigger(
-
- // Support: IE <=9 - 11+
- // Extend with the prototype to reset the above stopImmediatePropagation()
- jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
- saved.slice( 1 ),
- this
- )
- } );
-
- // Abort handling of the native event
- event.stopImmediatePropagation();
- }
- }
- } );
-}
-
-jQuery.removeEvent = function( elem, type, handle ) {
-
- // This "if" is needed for plain objects
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle );
- }
-};
-
-jQuery.Event = function( src, props ) {
-
- // Allow instantiation without the 'new' keyword
- if ( !( this instanceof jQuery.Event ) ) {
- return new jQuery.Event( src, props );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
-
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = src.defaultPrevented ||
- src.defaultPrevented === undefined &&
-
- // Support: Android <=2.3 only
- src.returnValue === false ?
- returnTrue :
- returnFalse;
-
- // Create target properties
- // Support: Safari <=6 - 7 only
- // Target should not be a text node (#504, #13143)
- this.target = ( src.target && src.target.nodeType === 3 ) ?
- src.target.parentNode :
- src.target;
-
- this.currentTarget = src.currentTarget;
- this.relatedTarget = src.relatedTarget;
-
- // Event type
- } else {
- this.type = src;
- }
-
- // Put explicitly provided properties onto the event object
- if ( props ) {
- jQuery.extend( this, props );
- }
-
- // Create a timestamp if incoming event doesn't have one
- this.timeStamp = src && src.timeStamp || Date.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
- constructor: jQuery.Event,
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse,
- isSimulated: false,
-
- preventDefault: function() {
- var e = this.originalEvent;
-
- this.isDefaultPrevented = returnTrue;
-
- if ( e && !this.isSimulated ) {
- e.preventDefault();
- }
- },
- stopPropagation: function() {
- var e = this.originalEvent;
-
- this.isPropagationStopped = returnTrue;
-
- if ( e && !this.isSimulated ) {
- e.stopPropagation();
- }
- },
- stopImmediatePropagation: function() {
- var e = this.originalEvent;
-
- this.isImmediatePropagationStopped = returnTrue;
-
- if ( e && !this.isSimulated ) {
- e.stopImmediatePropagation();
- }
-
- this.stopPropagation();
- }
-};
-
-// Includes all common event props including KeyEvent and MouseEvent specific props
-jQuery.each( {
- altKey: true,
- bubbles: true,
- cancelable: true,
- changedTouches: true,
- ctrlKey: true,
- detail: true,
- eventPhase: true,
- metaKey: true,
- pageX: true,
- pageY: true,
- shiftKey: true,
- view: true,
- "char": true,
- code: true,
- charCode: true,
- key: true,
- keyCode: true,
- button: true,
- buttons: true,
- clientX: true,
- clientY: true,
- offsetX: true,
- offsetY: true,
- pointerId: true,
- pointerType: true,
- screenX: true,
- screenY: true,
- targetTouches: true,
- toElement: true,
- touches: true,
-
- which: function( event ) {
- var button = event.button;
-
- // Add which for key events
- if ( event.which == null && rkeyEvent.test( event.type ) ) {
- return event.charCode != null ? event.charCode : event.keyCode;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
- if ( button & 1 ) {
- return 1;
- }
-
- if ( button & 2 ) {
- return 3;
- }
-
- if ( button & 4 ) {
- return 2;
- }
-
- return 0;
- }
-
- return event.which;
- }
-}, jQuery.event.addProp );
-
-jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
- jQuery.event.special[ type ] = {
-
- // Utilize native event if possible so blur/focus sequence is correct
- setup: function() {
-
- // Claim the first handler
- // dataPriv.set( this, "focus", ... )
- // dataPriv.set( this, "blur", ... )
- leverageNative( this, type, expectSync );
-
- // Return false to allow normal processing in the caller
- return false;
- },
- trigger: function() {
-
- // Force setup before trigger
- leverageNative( this, type );
-
- // Return non-false to allow normal event-path propagation
- return true;
- },
-
- delegateType: delegateType
- };
-} );
-
-// Create mouseenter/leave events using mouseover/out and event-time checks
-// so that event delegation works in jQuery.
-// Do the same for pointerenter/pointerleave and pointerover/pointerout
-//
-// Support: Safari 7 only
-// Safari sends mouseenter too often; see:
-// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
-// for the description of the bug (it existed in older Chrome versions as well).
-jQuery.each( {
- mouseenter: "mouseover",
- mouseleave: "mouseout",
- pointerenter: "pointerover",
- pointerleave: "pointerout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- delegateType: fix,
- bindType: fix,
-
- handle: function( event ) {
- var ret,
- target = this,
- related = event.relatedTarget,
- handleObj = event.handleObj;
-
- // For mouseenter/leave call the handler if related is outside the target.
- // NB: No relatedTarget if the mouse left/entered the browser window
- if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
- event.type = handleObj.origType;
- ret = handleObj.handler.apply( this, arguments );
- event.type = fix;
- }
- return ret;
- }
- };
-} );
-
-jQuery.fn.extend( {
-
- on: function( types, selector, data, fn ) {
- return on( this, types, selector, data, fn );
- },
- one: function( types, selector, data, fn ) {
- return on( this, types, selector, data, fn, 1 );
- },
- off: function( types, selector, fn ) {
- var handleObj, type;
- if ( types && types.preventDefault && types.handleObj ) {
-
- // ( event ) dispatched jQuery.Event
- handleObj = types.handleObj;
- jQuery( types.delegateTarget ).off(
- handleObj.namespace ?
- handleObj.origType + "." + handleObj.namespace :
- handleObj.origType,
- handleObj.selector,
- handleObj.handler
- );
- return this;
- }
- if ( typeof types === "object" ) {
-
- // ( types-object [, selector] )
- for ( type in types ) {
- this.off( type, selector, types[ type ] );
- }
- return this;
- }
- if ( selector === false || typeof selector === "function" ) {
-
- // ( types [, fn] )
- fn = selector;
- selector = undefined;
- }
- if ( fn === false ) {
- fn = returnFalse;
- }
- return this.each( function() {
- jQuery.event.remove( this, types, fn, selector );
- } );
- }
-} );
-
-
-var
-
- // Support: IE <=10 - 11, Edge 12 - 13 only
- // In IE/Edge using regex groups here causes severe slowdowns.
- // See https://connect.microsoft.com/IE/feedback/details/1736512/
- rnoInnerhtml = /<script|<style|<link/i,
-
- // checked="checked" or checked
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
- rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
-
-// Prefer a tbody over its parent table for containing new rows
-function manipulationTarget( elem, content ) {
- if ( nodeName( elem, "table" ) &&
- nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
-
- return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
- }
-
- return elem;
-}
-
-// Replace/restore the type attribute of script elements for safe DOM manipulation
-function disableScript( elem ) {
- elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
- return elem;
-}
-function restoreScript( elem ) {
- if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
- elem.type = elem.type.slice( 5 );
- } else {
- elem.removeAttribute( "type" );
- }
-
- return elem;
-}
-
-function cloneCopyEvent( src, dest ) {
- var i, l, type, pdataOld, udataOld, udataCur, events;
-
- if ( dest.nodeType !== 1 ) {
- return;
- }
-
- // 1. Copy private data: events, handlers, etc.
- if ( dataPriv.hasData( src ) ) {
- pdataOld = dataPriv.get( src );
- events = pdataOld.events;
-
- if ( events ) {
- dataPriv.remove( dest, "handle events" );
-
- for ( type in events ) {
- for ( i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ] );
- }
- }
- }
- }
-
- // 2. Copy user data
- if ( dataUser.hasData( src ) ) {
- udataOld = dataUser.access( src );
- udataCur = jQuery.extend( {}, udataOld );
-
- dataUser.set( dest, udataCur );
- }
-}
-
-// Fix IE bugs, see support tests
-function fixInput( src, dest ) {
- var nodeName = dest.nodeName.toLowerCase();
-
- // Fails to persist the checked state of a cloned checkbox or radio button.
- if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
- dest.checked = src.checked;
-
- // Fails to return the selected option to the default selected state when cloning options
- } else if ( nodeName === "input" || nodeName === "textarea" ) {
- dest.defaultValue = src.defaultValue;
- }
-}
-
-function domManip( collection, args, callback, ignored ) {
-
- // Flatten any nested arrays
- args = flat( args );
-
- var fragment, first, scripts, hasScripts, node, doc,
- i = 0,
- l = collection.length,
- iNoClone = l - 1,
- value = args[ 0 ],
- valueIsFunction = isFunction( value );
-
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( valueIsFunction ||
- ( l > 1 && typeof value === "string" &&
- !support.checkClone && rchecked.test( value ) ) ) {
- return collection.each( function( index ) {
- var self = collection.eq( index );
- if ( valueIsFunction ) {
- args[ 0 ] = value.call( this, index, self.html() );
- }
- domManip( self, args, callback, ignored );
- } );
- }
-
- if ( l ) {
- fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
- first = fragment.firstChild;
-
- if ( fragment.childNodes.length === 1 ) {
- fragment = first;
- }
-
- // Require either new content or an interest in ignored elements to invoke the callback
- if ( first || ignored ) {
- scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
- hasScripts = scripts.length;
-
- // Use the original fragment for the last item
- // instead of the first because it can end up
- // being emptied incorrectly in certain situations (#8070).
- for ( ; i < l; i++ ) {
- node = fragment;
-
- if ( i !== iNoClone ) {
- node = jQuery.clone( node, true, true );
-
- // Keep references to cloned scripts for later restoration
- if ( hasScripts ) {
-
- // Support: Android <=4.0 only, PhantomJS 1 only
- // push.apply(_, arraylike) throws on ancient WebKit
- jQuery.merge( scripts, getAll( node, "script" ) );
- }
- }
-
- callback.call( collection[ i ], node, i );
- }
-
- if ( hasScripts ) {
- doc = scripts[ scripts.length - 1 ].ownerDocument;
-
- // Reenable scripts
- jQuery.map( scripts, restoreScript );
-
- // Evaluate executable scripts on first document insertion
- for ( i = 0; i < hasScripts; i++ ) {
- node = scripts[ i ];
- if ( rscriptType.test( node.type || "" ) &&
- !dataPriv.access( node, "globalEval" ) &&
- jQuery.contains( doc, node ) ) {
-
- if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
-
- // Optional AJAX dependency, but won't run scripts if not present
- if ( jQuery._evalUrl && !node.noModule ) {
- jQuery._evalUrl( node.src, {
- nonce: node.nonce || node.getAttribute( "nonce" )
- }, doc );
- }
- } else {
- DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
- }
- }
- }
- }
- }
- }
-
- return collection;
-}
-
-function remove( elem, selector, keepData ) {
- var node,
- nodes = selector ? jQuery.filter( selector, elem ) : elem,
- i = 0;
-
- for ( ; ( node = nodes[ i ] ) != null; i++ ) {
- if ( !keepData && node.nodeType === 1 ) {
- jQuery.cleanData( getAll( node ) );
- }
-
- if ( node.parentNode ) {
- if ( keepData && isAttached( node ) ) {
- setGlobalEval( getAll( node, "script" ) );
- }
- node.parentNode.removeChild( node );
- }
- }
-
- return elem;
-}
-
-jQuery.extend( {
- htmlPrefilter: function( html ) {
- return html;
- },
-
- clone: function( elem, dataAndEvents, deepDataAndEvents ) {
- var i, l, srcElements, destElements,
- clone = elem.cloneNode( true ),
- inPage = isAttached( elem );
-
- // Fix IE cloning issues
- if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
- !jQuery.isXMLDoc( elem ) ) {
-
- // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
- destElements = getAll( clone );
- srcElements = getAll( elem );
-
- for ( i = 0, l = srcElements.length; i < l; i++ ) {
- fixInput( srcElements[ i ], destElements[ i ] );
- }
- }
-
- // Copy the events from the original to the clone
- if ( dataAndEvents ) {
- if ( deepDataAndEvents ) {
- srcElements = srcElements || getAll( elem );
- destElements = destElements || getAll( clone );
-
- for ( i = 0, l = srcElements.length; i < l; i++ ) {
- cloneCopyEvent( srcElements[ i ], destElements[ i ] );
- }
- } else {
- cloneCopyEvent( elem, clone );
- }
- }
-
- // Preserve script evaluation history
- destElements = getAll( clone, "script" );
- if ( destElements.length > 0 ) {
- setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
- }
-
- // Return the cloned set
- return clone;
- },
-
- cleanData: function( elems ) {
- var data, elem, type,
- special = jQuery.event.special,
- i = 0;
-
- for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
- if ( acceptData( elem ) ) {
- if ( ( data = elem[ dataPriv.expando ] ) ) {
- if ( data.events ) {
- for ( type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
-
- // This is a shortcut to avoid jQuery.event.remove's overhead
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- }
-
- // Support: Chrome <=35 - 45+
- // Assign undefined instead of using delete, see Data#remove
- elem[ dataPriv.expando ] = undefined;
- }
- if ( elem[ dataUser.expando ] ) {
-
- // Support: Chrome <=35 - 45+
- // Assign undefined instead of using delete, see Data#remove
- elem[ dataUser.expando ] = undefined;
- }
- }
- }
- }
-} );
-
-jQuery.fn.extend( {
- detach: function( selector ) {
- return remove( this, selector, true );
- },
-
- remove: function( selector ) {
- return remove( this, selector );
- },
-
- text: function( value ) {
- return access( this, function( value ) {
- return value === undefined ?
- jQuery.text( this ) :
- this.empty().each( function() {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- this.textContent = value;
- }
- } );
- }, null, value, arguments.length );
- },
-
- append: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.appendChild( elem );
- }
- } );
- },
-
- prepend: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.insertBefore( elem, target.firstChild );
- }
- } );
- },
-
- before: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this );
- }
- } );
- },
-
- after: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- }
- } );
- },
-
- empty: function() {
- var elem,
- i = 0;
-
- for ( ; ( elem = this[ i ] ) != null; i++ ) {
- if ( elem.nodeType === 1 ) {
-
- // Prevent memory leaks
- jQuery.cleanData( getAll( elem, false ) );
-
- // Remove any remaining nodes
- elem.textContent = "";
- }
- }
-
- return this;
- },
-
- clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
-
- return this.map( function() {
- return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
- } );
- },
-
- html: function( value ) {
- return access( this, function( value ) {
- var elem = this[ 0 ] || {},
- i = 0,
- l = this.length;
-
- if ( value === undefined && elem.nodeType === 1 ) {
- return elem.innerHTML;
- }
-
- // See if we can take a shortcut and just use innerHTML
- if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
- !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
-
- value = jQuery.htmlPrefilter( value );
-
- try {
- for ( ; i < l; i++ ) {
- elem = this[ i ] || {};
-
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem, false ) );
- elem.innerHTML = value;
- }
- }
-
- elem = 0;
-
- // If using innerHTML throws an exception, use the fallback method
- } catch ( e ) {}
- }
-
- if ( elem ) {
- this.empty().append( value );
- }
- }, null, value, arguments.length );
- },
-
- replaceWith: function() {
- var ignored = [];
-
- // Make the changes, replacing each non-ignored context element with the new content
- return domManip( this, arguments, function( elem ) {
- var parent = this.parentNode;
-
- if ( jQuery.inArray( this, ignored ) < 0 ) {
- jQuery.cleanData( getAll( this ) );
- if ( parent ) {
- parent.replaceChild( elem, this );
- }
- }
-
- // Force callback invocation
- }, ignored );
- }
-} );
-
-jQuery.each( {
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
-}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var elems,
- ret = [],
- insert = jQuery( selector ),
- last = insert.length - 1,
- i = 0;
-
- for ( ; i <= last; i++ ) {
- elems = i === last ? this : this.clone( true );
- jQuery( insert[ i ] )[ original ]( elems );
-
- // Support: Android <=4.0 only, PhantomJS 1 only
- // .get() because push.apply(_, arraylike) throws on ancient WebKit
- push.apply( ret, elems.get() );
- }
-
- return this.pushStack( ret );
- };
-} );
-var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
-
-var getStyles = function( elem ) {
-
- // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
- // IE throws on elements created in popups
- // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
- var view = elem.ownerDocument.defaultView;
-
- if ( !view || !view.opener ) {
- view = window;
- }
-
- return view.getComputedStyle( elem );
- };
-
-var swap = function( elem, options, callback ) {
- var ret, name,
- old = {};
-
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- ret = callback.call( elem );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
-
- return ret;
-};
-
-
-var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
-
-
-
-( function() {
-
- // Executing both pixelPosition & boxSizingReliable tests require only one layout
- // so they're executed at the same time to save the second computation.
- function computeStyleTests() {
-
- // This is a singleton, we need to execute it only once
- if ( !div ) {
- return;
- }
-
- container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
- "margin-top:1px;padding:0;border:0";
- div.style.cssText =
- "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
- "margin:auto;border:1px;padding:1px;" +
- "width:60%;top:1%";
- documentElement.appendChild( container ).appendChild( div );
-
- var divStyle = window.getComputedStyle( div );
- pixelPositionVal = divStyle.top !== "1%";
-
- // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
- reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
-
- // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
- // Some styles come back with percentage values, even though they shouldn't
- div.style.right = "60%";
- pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
-
- // Support: IE 9 - 11 only
- // Detect misreporting of content dimensions for box-sizing:border-box elements
- boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
-
- // Support: IE 9 only
- // Detect overflow:scroll screwiness (gh-3699)
- // Support: Chrome <=64
- // Don't get tricked when zoom affects offsetWidth (gh-4029)
- div.style.position = "absolute";
- scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
-
- documentElement.removeChild( container );
-
- // Nullify the div so it wouldn't be stored in the memory and
- // it will also be a sign that checks already performed
- div = null;
- }
-
- function roundPixelMeasures( measure ) {
- return Math.round( parseFloat( measure ) );
- }
-
- var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
- reliableTrDimensionsVal, reliableMarginLeftVal,
- container = document.createElement( "div" ),
- div = document.createElement( "div" );
-
- // Finish early in limited (non-browser) environments
- if ( !div.style ) {
- return;
- }
-
- // Support: IE <=9 - 11 only
- // Style of cloned element affects source element cloned (#8908)
- div.style.backgroundClip = "content-box";
- div.cloneNode( true ).style.backgroundClip = "";
- support.clearCloneStyle = div.style.backgroundClip === "content-box";
-
- jQuery.extend( support, {
- boxSizingReliable: function() {
- computeStyleTests();
- return boxSizingReliableVal;
- },
- pixelBoxStyles: function() {
- computeStyleTests();
- return pixelBoxStylesVal;
- },
- pixelPosition: function() {
- computeStyleTests();
- return pixelPositionVal;
- },
- reliableMarginLeft: function() {
- computeStyleTests();
- return reliableMarginLeftVal;
- },
- scrollboxSize: function() {
- computeStyleTests();
- return scrollboxSizeVal;
- },
-
- // Support: IE 9 - 11+, Edge 15 - 18+
- // IE/Edge misreport `getComputedStyle` of table rows with width/height
- // set in CSS while `offset*` properties report correct values.
- // Behavior in IE 9 is more subtle than in newer versions & it passes
- // some versions of this test; make sure not to make it pass there!
- reliableTrDimensions: function() {
- var table, tr, trChild, trStyle;
- if ( reliableTrDimensionsVal == null ) {
- table = document.createElement( "table" );
- tr = document.createElement( "tr" );
- trChild = document.createElement( "div" );
-
- table.style.cssText = "position:absolute;left:-11111px";
- tr.style.height = "1px";
- trChild.style.height = "9px";
-
- documentElement
- .appendChild( table )
- .appendChild( tr )
- .appendChild( trChild );
-
- trStyle = window.getComputedStyle( tr );
- reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
-
- documentElement.removeChild( table );
- }
- return reliableTrDimensionsVal;
- }
- } );
-} )();
-
-
-function curCSS( elem, name, computed ) {
- var width, minWidth, maxWidth, ret,
-
- // Support: Firefox 51+
- // Retrieving style before computed somehow
- // fixes an issue with getting wrong values
- // on detached elements
- style = elem.style;
-
- computed = computed || getStyles( elem );
-
- // getPropertyValue is needed for:
- // .css('filter') (IE 9 only, #12537)
- // .css('--customProperty) (#3144)
- if ( computed ) {
- ret = computed.getPropertyValue( name ) || computed[ name ];
-
- if ( ret === "" && !isAttached( elem ) ) {
- ret = jQuery.style( elem, name );
- }
-
- // A tribute to the "awesome hack by Dean Edwards"
- // Android Browser returns percentage for some values,
- // but width seems to be reliably pixels.
- // This is against the CSSOM draft spec:
- // https://drafts.csswg.org/cssom/#resolved-values
- if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
-
- // Remember the original values
- width = style.width;
- minWidth = style.minWidth;
- maxWidth = style.maxWidth;
-
- // Put in the new values to get a computed value out
- style.minWidth = style.maxWidth = style.width = ret;
- ret = computed.width;
-
- // Revert the changed values
- style.width = width;
- style.minWidth = minWidth;
- style.maxWidth = maxWidth;
- }
- }
-
- return ret !== undefined ?
-
- // Support: IE <=9 - 11 only
- // IE returns zIndex value as an integer.
- ret + "" :
- ret;
-}
-
-
-function addGetHookIf( conditionFn, hookFn ) {
-
- // Define the hook, we'll check on the first run if it's really needed.
- return {
- get: function() {
- if ( conditionFn() ) {
-
- // Hook not needed (or it's not possible to use it due
- // to missing dependency), remove it.
- delete this.get;
- return;
- }
-
- // Hook needed; redefine it so that the support test is not executed again.
- return ( this.get = hookFn ).apply( this, arguments );
- }
- };
-}
-
-
-var cssPrefixes = [ "Webkit", "Moz", "ms" ],
- emptyStyle = document.createElement( "div" ).style,
- vendorProps = {};
-
-// Return a vendor-prefixed property or undefined
-function vendorPropName( name ) {
-
- // Check for vendor prefixed names
- var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
- i = cssPrefixes.length;
-
- while ( i-- ) {
- name = cssPrefixes[ i ] + capName;
- if ( name in emptyStyle ) {
- return name;
- }
- }
-}
-
-// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
-function finalPropName( name ) {
- var final = jQuery.cssProps[ name ] || vendorProps[ name ];
-
- if ( final ) {
- return final;
- }
- if ( name in emptyStyle ) {
- return name;
- }
- return vendorProps[ name ] = vendorPropName( name ) || name;
-}
-
-
-var
-
- // Swappable if display is none or starts with table
- // except "table", "table-cell", or "table-caption"
- // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
- rdisplayswap = /^(none|table(?!-c[ea]).+)/,
- rcustomProp = /^--/,
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssNormalTransform = {
- letterSpacing: "0",
- fontWeight: "400"
- };
-
-function setPositiveNumber( _elem, value, subtract ) {
-
- // Any relative (+/-) values have already been
- // normalized at this point
- var matches = rcssNum.exec( value );
- return matches ?
-
- // Guard against undefined "subtract", e.g., when used as in cssHooks
- Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
- value;
-}
-
-function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
- var i = dimension === "width" ? 1 : 0,
- extra = 0,
- delta = 0;
-
- // Adjustment may not be necessary
- if ( box === ( isBorderBox ? "border" : "content" ) ) {
- return 0;
- }
-
- for ( ; i < 4; i += 2 ) {
-
- // Both box models exclude margin
- if ( box === "margin" ) {
- delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
- }
-
- // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
- if ( !isBorderBox ) {
-
- // Add padding
- delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
-
- // For "border" or "margin", add border
- if ( box !== "padding" ) {
- delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
-
- // But still keep track of it otherwise
- } else {
- extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
-
- // If we get here with a border-box (content + padding + border), we're seeking "content" or
- // "padding" or "margin"
- } else {
-
- // For "content", subtract padding
- if ( box === "content" ) {
- delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
- }
-
- // For "content" or "padding", subtract border
- if ( box !== "margin" ) {
- delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
- }
- }
-
- // Account for positive content-box scroll gutter when requested by providing computedVal
- if ( !isBorderBox && computedVal >= 0 ) {
-
- // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
- // Assuming integer scroll gutter, subtract the rest and round down
- delta += Math.max( 0, Math.ceil(
- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
- computedVal -
- delta -
- extra -
- 0.5
-
- // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
- // Use an explicit zero to avoid NaN (gh-3964)
- ) ) || 0;
- }
-
- return delta;
-}
-
-function getWidthOrHeight( elem, dimension, extra ) {
-
- // Start with computed style
- var styles = getStyles( elem ),
-
- // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
- // Fake content-box until we know it's needed to know the true value.
- boxSizingNeeded = !support.boxSizingReliable() || extra,
- isBorderBox = boxSizingNeeded &&
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
- valueIsBorderBox = isBorderBox,
-
- val = curCSS( elem, dimension, styles ),
- offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
-
- // Support: Firefox <=54
- // Return a confounding non-pixel value or feign ignorance, as appropriate.
- if ( rnumnonpx.test( val ) ) {
- if ( !extra ) {
- return val;
- }
- val = "auto";
- }
-
-
- // Support: IE 9 - 11 only
- // Use offsetWidth/offsetHeight for when box sizing is unreliable.
- // In those cases, the computed value can be trusted to be border-box.
- if ( ( !support.boxSizingReliable() && isBorderBox ||
-
- // Support: IE 10 - 11+, Edge 15 - 18+
- // IE/Edge misreport `getComputedStyle` of table rows with width/height
- // set in CSS while `offset*` properties report correct values.
- // Interestingly, in some cases IE 9 doesn't suffer from this issue.
- !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
-
- // Fall back to offsetWidth/offsetHeight when value is "auto"
- // This happens for inline elements with no explicit setting (gh-3571)
- val === "auto" ||
-
- // Support: Android <=4.1 - 4.3 only
- // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
- !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
-
- // Make sure the element is visible & connected
- elem.getClientRects().length ) {
-
- isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
-
- // Where available, offsetWidth/offsetHeight approximate border box dimensions.
- // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
- // retrieved value as a content box dimension.
- valueIsBorderBox = offsetProp in elem;
- if ( valueIsBorderBox ) {
- val = elem[ offsetProp ];
- }
- }
-
- // Normalize "" and auto
- val = parseFloat( val ) || 0;
-
- // Adjust for the element's box model
- return ( val +
- boxModelAdjustment(
- elem,
- dimension,
- extra || ( isBorderBox ? "border" : "content" ),
- valueIsBorderBox,
- styles,
-
- // Provide the current computed size to request scroll gutter calculation (gh-3589)
- val
- )
- ) + "px";
-}
-
-jQuery.extend( {
-
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
-
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity" );
- return ret === "" ? "1" : ret;
- }
- }
- }
- },
-
- // Don't automatically add "px" to these possibly-unitless properties
- cssNumber: {
- "animationIterationCount": true,
- "columnCount": true,
- "fillOpacity": true,
- "flexGrow": true,
- "flexShrink": true,
- "fontWeight": true,
- "gridArea": true,
- "gridColumn": true,
- "gridColumnEnd": true,
- "gridColumnStart": true,
- "gridRow": true,
- "gridRowEnd": true,
- "gridRowStart": true,
- "lineHeight": true,
- "opacity": true,
- "order": true,
- "orphans": true,
- "widows": true,
- "zIndex": true,
- "zoom": true
- },
-
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {},
-
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
-
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
-
- // Make sure that we're working with the right name
- var ret, type, hooks,
- origName = camelCase( name ),
- isCustomProp = rcustomProp.test( name ),
- style = elem.style;
-
- // Make sure that we're working with the right name. We don't
- // want to query the value if it is a CSS custom property
- // since they are user-defined.
- if ( !isCustomProp ) {
- name = finalPropName( origName );
- }
-
- // Gets hook for the prefixed version, then unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // Check if we're setting a value
- if ( value !== undefined ) {
- type = typeof value;
-
- // Convert "+=" or "-=" to relative numbers (#7345)
- if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
- value = adjustCSS( elem, name, ret );
-
- // Fixes bug #9237
- type = "number";
- }
-
- // Make sure that null and NaN values aren't set (#7116)
- if ( value == null || value !== value ) {
- return;
- }
-
- // If a number was passed in, add the unit (except for certain CSS properties)
- // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
- // "px" to a few hardcoded values.
- if ( type === "number" && !isCustomProp ) {
- value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
- }
-
- // background-* props affect original clone's values
- if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
- style[ name ] = "inherit";
- }
-
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !( "set" in hooks ) ||
- ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
-
- if ( isCustomProp ) {
- style.setProperty( name, value );
- } else {
- style[ name ] = value;
- }
- }
-
- } else {
-
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks &&
- ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
-
- return ret;
- }
-
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
-
- css: function( elem, name, extra, styles ) {
- var val, num, hooks,
- origName = camelCase( name ),
- isCustomProp = rcustomProp.test( name );
-
- // Make sure that we're working with the right name. We don't
- // want to modify the value if it is a CSS custom property
- // since they are user-defined.
- if ( !isCustomProp ) {
- name = finalPropName( origName );
- }
-
- // Try prefixed name followed by the unprefixed name
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks ) {
- val = hooks.get( elem, true, extra );
- }
-
- // Otherwise, if a way to get the computed value exists, use that
- if ( val === undefined ) {
- val = curCSS( elem, name, styles );
- }
-
- // Convert "normal" to computed value
- if ( val === "normal" && name in cssNormalTransform ) {
- val = cssNormalTransform[ name ];
- }
-
- // Make numeric if forced or a qualifier was provided and val looks numeric
- if ( extra === "" || extra ) {
- num = parseFloat( val );
- return extra === true || isFinite( num ) ? num || 0 : val;
- }
-
- return val;
- }
-} );
-
-jQuery.each( [ "height", "width" ], function( _i, dimension ) {
- jQuery.cssHooks[ dimension ] = {
- get: function( elem, computed, extra ) {
- if ( computed ) {
-
- // Certain elements can have dimension info if we invisibly show them
- // but it must have a current display style that would benefit
- return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
-
- // Support: Safari 8+
- // Table columns in Safari have non-zero offsetWidth & zero
- // getBoundingClientRect().width unless display is changed.
- // Support: IE <=11 only
- // Running getBoundingClientRect on a disconnected node
- // in IE throws an error.
- ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
- swap( elem, cssShow, function() {
- return getWidthOrHeight( elem, dimension, extra );
- } ) :
- getWidthOrHeight( elem, dimension, extra );
- }
- },
-
- set: function( elem, value, extra ) {
- var matches,
- styles = getStyles( elem ),
-
- // Only read styles.position if the test has a chance to fail
- // to avoid forcing a reflow.
- scrollboxSizeBuggy = !support.scrollboxSize() &&
- styles.position === "absolute",
-
- // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
- boxSizingNeeded = scrollboxSizeBuggy || extra,
- isBorderBox = boxSizingNeeded &&
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
- subtract = extra ?
- boxModelAdjustment(
- elem,
- dimension,
- extra,
- isBorderBox,
- styles
- ) :
- 0;
-
- // Account for unreliable border-box dimensions by comparing offset* to computed and
- // faking a content-box to get border and padding (gh-3699)
- if ( isBorderBox && scrollboxSizeBuggy ) {
- subtract -= Math.ceil(
- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
- parseFloat( styles[ dimension ] ) -
- boxModelAdjustment( elem, dimension, "border", false, styles ) -
- 0.5
- );
- }
-
- // Convert to pixels if value adjustment is needed
- if ( subtract && ( matches = rcssNum.exec( value ) ) &&
- ( matches[ 3 ] || "px" ) !== "px" ) {
-
- elem.style[ dimension ] = value;
- value = jQuery.css( elem, dimension );
- }
-
- return setPositiveNumber( elem, value, subtract );
- }
- };
-} );
-
-jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
- function( elem, computed ) {
- if ( computed ) {
- return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
- elem.getBoundingClientRect().left -
- swap( elem, { marginLeft: 0 }, function() {
- return elem.getBoundingClientRect().left;
- } )
- ) + "px";
- }
- }
-);
-
-// These hooks are used by animate to expand properties
-jQuery.each( {
- margin: "",
- padding: "",
- border: "Width"
-}, function( prefix, suffix ) {
- jQuery.cssHooks[ prefix + suffix ] = {
- expand: function( value ) {
- var i = 0,
- expanded = {},
-
- // Assumes a single number if not a string
- parts = typeof value === "string" ? value.split( " " ) : [ value ];
-
- for ( ; i < 4; i++ ) {
- expanded[ prefix + cssExpand[ i ] + suffix ] =
- parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
- }
-
- return expanded;
- }
- };
-
- if ( prefix !== "margin" ) {
- jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
- }
-} );
-
-jQuery.fn.extend( {
- css: function( name, value ) {
- return access( this, function( elem, name, value ) {
- var styles, len,
- map = {},
- i = 0;
-
- if ( Array.isArray( name ) ) {
- styles = getStyles( elem );
- len = name.length;
-
- for ( ; i < len; i++ ) {
- map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
- }
-
- return map;
- }
-
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- }, name, value, arguments.length > 1 );
- }
-} );
-
-
-function Tween( elem, options, prop, end, easing ) {
- return new Tween.prototype.init( elem, options, prop, end, easing );
-}
-jQuery.Tween = Tween;
-
-Tween.prototype = {
- constructor: Tween,
- init: function( elem, options, prop, end, easing, unit ) {
- this.elem = elem;
- this.prop = prop;
- this.easing = easing || jQuery.easing._default;
- this.options = options;
- this.start = this.now = this.cur();
- this.end = end;
- this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
- },
- cur: function() {
- var hooks = Tween.propHooks[ this.prop ];
-
- return hooks && hooks.get ?
- hooks.get( this ) :
- Tween.propHooks._default.get( this );
- },
- run: function( percent ) {
- var eased,
- hooks = Tween.propHooks[ this.prop ];
-
- if ( this.options.duration ) {
- this.pos = eased = jQuery.easing[ this.easing ](
- percent, this.options.duration * percent, 0, 1, this.options.duration
- );
- } else {
- this.pos = eased = percent;
- }
- this.now = ( this.end - this.start ) * eased + this.start;
-
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- if ( hooks && hooks.set ) {
- hooks.set( this );
- } else {
- Tween.propHooks._default.set( this );
- }
- return this;
- }
-};
-
-Tween.prototype.init.prototype = Tween.prototype;
-
-Tween.propHooks = {
- _default: {
- get: function( tween ) {
- var result;
-
- // Use a property on the element directly when it is not a DOM element,
- // or when there is no matching style property that exists.
- if ( tween.elem.nodeType !== 1 ||
- tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
- return tween.elem[ tween.prop ];
- }
-
- // Passing an empty string as a 3rd parameter to .css will automatically
- // attempt a parseFloat and fallback to a string if the parse fails.
- // Simple values such as "10px" are parsed to Float;
- // complex values such as "rotate(1rad)" are returned as-is.
- result = jQuery.css( tween.elem, tween.prop, "" );
-
- // Empty strings, null, undefined and "auto" are converted to 0.
- return !result || result === "auto" ? 0 : result;
- },
- set: function( tween ) {
-
- // Use step hook for back compat.
- // Use cssHook if its there.
- // Use .style if available and use plain properties where available.
- if ( jQuery.fx.step[ tween.prop ] ) {
- jQuery.fx.step[ tween.prop ]( tween );
- } else if ( tween.elem.nodeType === 1 && (
- jQuery.cssHooks[ tween.prop ] ||
- tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
- jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
- } else {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- }
-};
-
-// Support: IE <=9 only
-// Panic based approach to setting things on disconnected nodes
-Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
- set: function( tween ) {
- if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
-};
-
-jQuery.easing = {
- linear: function( p ) {
- return p;
- },
- swing: function( p ) {
- return 0.5 - Math.cos( p * Math.PI ) / 2;
- },
- _default: "swing"
-};
-
-jQuery.fx = Tween.prototype.init;
-
-// Back compat <1.8 extension point
-jQuery.fx.step = {};
-
-
-
-
-var
- fxNow, inProgress,
- rfxtypes = /^(?:toggle|show|hide)$/,
- rrun = /queueHooks$/;
-
-function schedule() {
- if ( inProgress ) {
- if ( document.hidden === false && window.requestAnimationFrame ) {
- window.requestAnimationFrame( schedule );
- } else {
- window.setTimeout( schedule, jQuery.fx.interval );
- }
-
- jQuery.fx.tick();
- }
-}
-
-// Animations created synchronously will run synchronously
-function createFxNow() {
- window.setTimeout( function() {
- fxNow = undefined;
- } );
- return ( fxNow = Date.now() );
-}
-
-// Generate parameters to create a standard animation
-function genFx( type, includeWidth ) {
- var which,
- i = 0,
- attrs = { height: type };
-
- // If we include width, step value is 1 to do all cssExpand values,
- // otherwise step value is 2 to skip over Left and Right
- includeWidth = includeWidth ? 1 : 0;
- for ( ; i < 4; i += 2 - includeWidth ) {
- which = cssExpand[ i ];
- attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
- }
-
- if ( includeWidth ) {
- attrs.opacity = attrs.width = type;
- }
-
- return attrs;
-}
-
-function createTween( value, prop, animation ) {
- var tween,
- collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
- index = 0,
- length = collection.length;
- for ( ; index < length; index++ ) {
- if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
-
- // We're done with this property
- return tween;
- }
- }
-}
-
-function defaultPrefilter( elem, props, opts ) {
- var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
- isBox = "width" in props || "height" in props,
- anim = this,
- orig = {},
- style = elem.style,
- hidden = elem.nodeType && isHiddenWithinTree( elem ),
- dataShow = dataPriv.get( elem, "fxshow" );
-
- // Queue-skipping animations hijack the fx hooks
- if ( !opts.queue ) {
- hooks = jQuery._queueHooks( elem, "fx" );
- if ( hooks.unqueued == null ) {
- hooks.unqueued = 0;
- oldfire = hooks.empty.fire;
- hooks.empty.fire = function() {
- if ( !hooks.unqueued ) {
- oldfire();
- }
- };
- }
- hooks.unqueued++;
-
- anim.always( function() {
-
- // Ensure the complete handler is called before this completes
- anim.always( function() {
- hooks.unqueued--;
- if ( !jQuery.queue( elem, "fx" ).length ) {
- hooks.empty.fire();
- }
- } );
- } );
- }
-
- // Detect show/hide animations
- for ( prop in props ) {
- value = props[ prop ];
- if ( rfxtypes.test( value ) ) {
- delete props[ prop ];
- toggle = toggle || value === "toggle";
- if ( value === ( hidden ? "hide" : "show" ) ) {
-
- // Pretend to be hidden if this is a "show" and
- // there is still data from a stopped show/hide
- if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
- hidden = true;
-
- // Ignore all other no-op show/hide data
- } else {
- continue;
- }
- }
- orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
- }
- }
-
- // Bail out if this is a no-op like .hide().hide()
- propTween = !jQuery.isEmptyObject( props );
- if ( !propTween && jQuery.isEmptyObject( orig ) ) {
- return;
- }
-
- // Restrict "overflow" and "display" styles during box animations
- if ( isBox && elem.nodeType === 1 ) {
-
- // Support: IE <=9 - 11, Edge 12 - 15
- // Record all 3 overflow attributes because IE does not infer the shorthand
- // from identically-valued overflowX and overflowY and Edge just mirrors
- // the overflowX value there.
- opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
-
- // Identify a display type, preferring old show/hide data over the CSS cascade
- restoreDisplay = dataShow && dataShow.display;
- if ( restoreDisplay == null ) {
- restoreDisplay = dataPriv.get( elem, "display" );
- }
- display = jQuery.css( elem, "display" );
- if ( display === "none" ) {
- if ( restoreDisplay ) {
- display = restoreDisplay;
- } else {
-
- // Get nonempty value(s) by temporarily forcing visibility
- showHide( [ elem ], true );
- restoreDisplay = elem.style.display || restoreDisplay;
- display = jQuery.css( elem, "display" );
- showHide( [ elem ] );
- }
- }
-
- // Animate inline elements as inline-block
- if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
- if ( jQuery.css( elem, "float" ) === "none" ) {
-
- // Restore the original display value at the end of pure show/hide animations
- if ( !propTween ) {
- anim.done( function() {
- style.display = restoreDisplay;
- } );
- if ( restoreDisplay == null ) {
- display = style.display;
- restoreDisplay = display === "none" ? "" : display;
- }
- }
- style.display = "inline-block";
- }
- }
- }
-
- if ( opts.overflow ) {
- style.overflow = "hidden";
- anim.always( function() {
- style.overflow = opts.overflow[ 0 ];
- style.overflowX = opts.overflow[ 1 ];
- style.overflowY = opts.overflow[ 2 ];
- } );
- }
-
- // Implement show/hide animations
- propTween = false;
- for ( prop in orig ) {
-
- // General show/hide setup for this element animation
- if ( !propTween ) {
- if ( dataShow ) {
- if ( "hidden" in dataShow ) {
- hidden = dataShow.hidden;
- }
- } else {
- dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
- }
-
- // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
- if ( toggle ) {
- dataShow.hidden = !hidden;
- }
-
- // Show elements before animating them
- if ( hidden ) {
- showHide( [ elem ], true );
- }
-
- /* eslint-disable no-loop-func */
-
- anim.done( function() {
-
- /* eslint-enable no-loop-func */
-
- // The final step of a "hide" animation is actually hiding the element
- if ( !hidden ) {
- showHide( [ elem ] );
- }
- dataPriv.remove( elem, "fxshow" );
- for ( prop in orig ) {
- jQuery.style( elem, prop, orig[ prop ] );
- }
- } );
- }
-
- // Per-property setup
- propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
- if ( !( prop in dataShow ) ) {
- dataShow[ prop ] = propTween.start;
- if ( hidden ) {
- propTween.end = propTween.start;
- propTween.start = 0;
- }
- }
- }
-}
-
-function propFilter( props, specialEasing ) {
- var index, name, easing, value, hooks;
-
- // camelCase, specialEasing and expand cssHook pass
- for ( index in props ) {
- name = camelCase( index );
- easing = specialEasing[ name ];
- value = props[ index ];
- if ( Array.isArray( value ) ) {
- easing = value[ 1 ];
- value = props[ index ] = value[ 0 ];
- }
-
- if ( index !== name ) {
- props[ name ] = value;
- delete props[ index ];
- }
-
- hooks = jQuery.cssHooks[ name ];
- if ( hooks && "expand" in hooks ) {
- value = hooks.expand( value );
- delete props[ name ];
-
- // Not quite $.extend, this won't overwrite existing keys.
- // Reusing 'index' because we have the correct "name"
- for ( index in value ) {
- if ( !( index in props ) ) {
- props[ index ] = value[ index ];
- specialEasing[ index ] = easing;
- }
- }
- } else {
- specialEasing[ name ] = easing;
- }
- }
-}
-
-function Animation( elem, properties, options ) {
- var result,
- stopped,
- index = 0,
- length = Animation.prefilters.length,
- deferred = jQuery.Deferred().always( function() {
-
- // Don't match elem in the :animated selector
- delete tick.elem;
- } ),
- tick = function() {
- if ( stopped ) {
- return false;
- }
- var currentTime = fxNow || createFxNow(),
- remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
-
- // Support: Android 2.3 only
- // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
- temp = remaining / animation.duration || 0,
- percent = 1 - temp,
- index = 0,
- length = animation.tweens.length;
-
- for ( ; index < length; index++ ) {
- animation.tweens[ index ].run( percent );
- }
-
- deferred.notifyWith( elem, [ animation, percent, remaining ] );
-
- // If there's more to do, yield
- if ( percent < 1 && length ) {
- return remaining;
- }
-
- // If this was an empty animation, synthesize a final progress notification
- if ( !length ) {
- deferred.notifyWith( elem, [ animation, 1, 0 ] );
- }
-
- // Resolve the animation and report its conclusion
- deferred.resolveWith( elem, [ animation ] );
- return false;
- },
- animation = deferred.promise( {
- elem: elem,
- props: jQuery.extend( {}, properties ),
- opts: jQuery.extend( true, {
- specialEasing: {},
- easing: jQuery.easing._default
- }, options ),
- originalProperties: properties,
- originalOptions: options,
- startTime: fxNow || createFxNow(),
- duration: options.duration,
- tweens: [],
- createTween: function( prop, end ) {
- var tween = jQuery.Tween( elem, animation.opts, prop, end,
- animation.opts.specialEasing[ prop ] || animation.opts.easing );
- animation.tweens.push( tween );
- return tween;
- },
- stop: function( gotoEnd ) {
- var index = 0,
-
- // If we are going to the end, we want to run all the tweens
- // otherwise we skip this part
- length = gotoEnd ? animation.tweens.length : 0;
- if ( stopped ) {
- return this;
- }
- stopped = true;
- for ( ; index < length; index++ ) {
- animation.tweens[ index ].run( 1 );
- }
-
- // Resolve when we played the last frame; otherwise, reject
- if ( gotoEnd ) {
- deferred.notifyWith( elem, [ animation, 1, 0 ] );
- deferred.resolveWith( elem, [ animation, gotoEnd ] );
- } else {
- deferred.rejectWith( elem, [ animation, gotoEnd ] );
- }
- return this;
- }
- } ),
- props = animation.props;
-
- propFilter( props, animation.opts.specialEasing );
-
- for ( ; index < length; index++ ) {
- result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
- if ( result ) {
- if ( isFunction( result.stop ) ) {
- jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
- result.stop.bind( result );
- }
- return result;
- }
- }
-
- jQuery.map( props, createTween, animation );
-
- if ( isFunction( animation.opts.start ) ) {
- animation.opts.start.call( elem, animation );
- }
-
- // Attach callbacks from options
- animation
- .progress( animation.opts.progress )
- .done( animation.opts.done, animation.opts.complete )
- .fail( animation.opts.fail )
- .always( animation.opts.always );
-
- jQuery.fx.timer(
- jQuery.extend( tick, {
- elem: elem,
- anim: animation,
- queue: animation.opts.queue
- } )
- );
-
- return animation;
-}
-
-jQuery.Animation = jQuery.extend( Animation, {
-
- tweeners: {
- "*": [ function( prop, value ) {
- var tween = this.createTween( prop, value );
- adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
- return tween;
- } ]
- },
-
- tweener: function( props, callback ) {
- if ( isFunction( props ) ) {
- callback = props;
- props = [ "*" ];
- } else {
- props = props.match( rnothtmlwhite );
- }
-
- var prop,
- index = 0,
- length = props.length;
-
- for ( ; index < length; index++ ) {
- prop = props[ index ];
- Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
- Animation.tweeners[ prop ].unshift( callback );
- }
- },
-
- prefilters: [ defaultPrefilter ],
-
- prefilter: function( callback, prepend ) {
- if ( prepend ) {
- Animation.prefilters.unshift( callback );
- } else {
- Animation.prefilters.push( callback );
- }
- }
-} );
-
-jQuery.speed = function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
- complete: fn || !fn && easing ||
- isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !isFunction( easing ) && easing
- };
-
- // Go to the end state if fx are off
- if ( jQuery.fx.off ) {
- opt.duration = 0;
-
- } else {
- if ( typeof opt.duration !== "number" ) {
- if ( opt.duration in jQuery.fx.speeds ) {
- opt.duration = jQuery.fx.speeds[ opt.duration ];
-
- } else {
- opt.duration = jQuery.fx.speeds._default;
- }
- }
- }
-
- // Normalize opt.queue - true/undefined/null -> "fx"
- if ( opt.queue == null || opt.queue === true ) {
- opt.queue = "fx";
- }
-
- // Queueing
- opt.old = opt.complete;
-
- opt.complete = function() {
- if ( isFunction( opt.old ) ) {
- opt.old.call( this );
- }
-
- if ( opt.queue ) {
- jQuery.dequeue( this, opt.queue );
- }
- };
-
- return opt;
-};
-
-jQuery.fn.extend( {
- fadeTo: function( speed, to, easing, callback ) {
-
- // Show any hidden elements after setting opacity to 0
- return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
-
- // Animate to the value specified
- .end().animate( { opacity: to }, speed, easing, callback );
- },
- animate: function( prop, speed, easing, callback ) {
- var empty = jQuery.isEmptyObject( prop ),
- optall = jQuery.speed( speed, easing, callback ),
- doAnimation = function() {
-
- // Operate on a copy of prop so per-property easing won't be lost
- var anim = Animation( this, jQuery.extend( {}, prop ), optall );
-
- // Empty animations, or finishing resolves immediately
- if ( empty || dataPriv.get( this, "finish" ) ) {
- anim.stop( true );
- }
- };
- doAnimation.finish = doAnimation;
-
- return empty || optall.queue === false ?
- this.each( doAnimation ) :
- this.queue( optall.queue, doAnimation );
- },
- stop: function( type, clearQueue, gotoEnd ) {
- var stopQueue = function( hooks ) {
- var stop = hooks.stop;
- delete hooks.stop;
- stop( gotoEnd );
- };
-
- if ( typeof type !== "string" ) {
- gotoEnd = clearQueue;
- clearQueue = type;
- type = undefined;
- }
- if ( clearQueue ) {
- this.queue( type || "fx", [] );
- }
-
- return this.each( function() {
- var dequeue = true,
- index = type != null && type + "queueHooks",
- timers = jQuery.timers,
- data = dataPriv.get( this );
-
- if ( index ) {
- if ( data[ index ] && data[ index ].stop ) {
- stopQueue( data[ index ] );
- }
- } else {
- for ( index in data ) {
- if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
- stopQueue( data[ index ] );
- }
- }
- }
-
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this &&
- ( type == null || timers[ index ].queue === type ) ) {
-
- timers[ index ].anim.stop( gotoEnd );
- dequeue = false;
- timers.splice( index, 1 );
- }
- }
-
- // Start the next in the queue if the last step wasn't forced.
- // Timers currently will call their complete callbacks, which
- // will dequeue but only if they were gotoEnd.
- if ( dequeue || !gotoEnd ) {
- jQuery.dequeue( this, type );
- }
- } );
- },
- finish: function( type ) {
- if ( type !== false ) {
- type = type || "fx";
- }
- return this.each( function() {
- var index,
- data = dataPriv.get( this ),
- queue = data[ type + "queue" ],
- hooks = data[ type + "queueHooks" ],
- timers = jQuery.timers,
- length = queue ? queue.length : 0;
-
- // Enable finishing flag on private data
- data.finish = true;
-
- // Empty the queue first
- jQuery.queue( this, type, [] );
-
- if ( hooks && hooks.stop ) {
- hooks.stop.call( this, true );
- }
-
- // Look for any active animations, and finish them
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
- timers[ index ].anim.stop( true );
- timers.splice( index, 1 );
- }
- }
-
- // Look for any animations in the old queue and finish them
- for ( index = 0; index < length; index++ ) {
- if ( queue[ index ] && queue[ index ].finish ) {
- queue[ index ].finish.call( this );
- }
- }
-
- // Turn off finishing flag
- delete data.finish;
- } );
- }
-} );
-
-jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
- var cssFn = jQuery.fn[ name ];
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return speed == null || typeof speed === "boolean" ?
- cssFn.apply( this, arguments ) :
- this.animate( genFx( name, true ), speed, easing, callback );
- };
-} );
-
-// Generate shortcuts for custom animations
-jQuery.each( {
- slideDown: genFx( "show" ),
- slideUp: genFx( "hide" ),
- slideToggle: genFx( "toggle" ),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
-} );
-
-jQuery.timers = [];
-jQuery.fx.tick = function() {
- var timer,
- i = 0,
- timers = jQuery.timers;
-
- fxNow = Date.now();
-
- for ( ; i < timers.length; i++ ) {
- timer = timers[ i ];
-
- // Run the timer and safely remove it when done (allowing for external removal)
- if ( !timer() && timers[ i ] === timer ) {
- timers.splice( i--, 1 );
- }
- }
-
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
- fxNow = undefined;
-};
-
-jQuery.fx.timer = function( timer ) {
- jQuery.timers.push( timer );
- jQuery.fx.start();
-};
-
-jQuery.fx.interval = 13;
-jQuery.fx.start = function() {
- if ( inProgress ) {
- return;
- }
-
- inProgress = true;
- schedule();
-};
-
-jQuery.fx.stop = function() {
- inProgress = null;
-};
-
-jQuery.fx.speeds = {
- slow: 600,
- fast: 200,
-
- // Default speed
- _default: 400
-};
-
-
-// Based off of the plugin by Clint Helfers, with permission.
-// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
-jQuery.fn.delay = function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = window.setTimeout( next, time );
- hooks.stop = function() {
- window.clearTimeout( timeout );
- };
- } );
-};
-
-
-( function() {
- var input = document.createElement( "input" ),
- select = document.createElement( "select" ),
- opt = select.appendChild( document.createElement( "option" ) );
-
- input.type = "checkbox";
-
- // Support: Android <=4.3 only
- // Default value for a checkbox should be "on"
- support.checkOn = input.value !== "";
-
- // Support: IE <=11 only
- // Must access selectedIndex to make default options select
- support.optSelected = opt.selected;
-
- // Support: IE <=11 only
- // An input loses its value after becoming a radio
- input = document.createElement( "input" );
- input.value = "t";
- input.type = "radio";
- support.radioValue = input.value === "t";
-} )();
-
-
-var boolHook,
- attrHandle = jQuery.expr.attrHandle;
-
-jQuery.fn.extend( {
- attr: function( name, value ) {
- return access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each( function() {
- jQuery.removeAttr( this, name );
- } );
- }
-} );
-
-jQuery.extend( {
- attr: function( elem, name, value ) {
- var ret, hooks,
- nType = elem.nodeType;
-
- // Don't get/set attributes on text, comment and attribute nodes
- if ( nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === "undefined" ) {
- return jQuery.prop( elem, name, value );
- }
-
- // Attribute hooks are determined by the lowercase version
- // Grab necessary hook if one is defined
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
- hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
- ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
- }
-
- if ( value !== undefined ) {
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
- return;
- }
-
- if ( hooks && "set" in hooks &&
- ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
- return ret;
- }
-
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
- return ret;
- }
-
- ret = jQuery.find.attr( elem, name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ? undefined : ret;
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !support.radioValue && value === "radio" &&
- nodeName( elem, "input" ) ) {
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- },
-
- removeAttr: function( elem, value ) {
- var name,
- i = 0,
-
- // Attribute names can contain non-HTML whitespace characters
- // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
- attrNames = value && value.match( rnothtmlwhite );
-
- if ( attrNames && elem.nodeType === 1 ) {
- while ( ( name = attrNames[ i++ ] ) ) {
- elem.removeAttribute( name );
- }
- }
- }
-} );
-
-// Hooks for boolean attributes
-boolHook = {
- set: function( elem, value, name ) {
- if ( value === false ) {
-
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- elem.setAttribute( name, name );
- }
- return name;
- }
-};
-
-jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
- var getter = attrHandle[ name ] || jQuery.find.attr;
-
- attrHandle[ name ] = function( elem, name, isXML ) {
- var ret, handle,
- lowercaseName = name.toLowerCase();
-
- if ( !isXML ) {
-
- // Avoid an infinite loop by temporarily removing this function from the getter
- handle = attrHandle[ lowercaseName ];
- attrHandle[ lowercaseName ] = ret;
- ret = getter( elem, name, isXML ) != null ?
- lowercaseName :
- null;
- attrHandle[ lowercaseName ] = handle;
- }
- return ret;
- };
-} );
-
-
-
-
-var rfocusable = /^(?:input|select|textarea|button)$/i,
- rclickable = /^(?:a|area)$/i;
-
-jQuery.fn.extend( {
- prop: function( name, value ) {
- return access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- return this.each( function() {
- delete this[ jQuery.propFix[ name ] || name ];
- } );
- }
-} );
-
-jQuery.extend( {
- prop: function( elem, name, value ) {
- var ret, hooks,
- nType = elem.nodeType;
-
- // Don't get/set properties on text, comment and attribute nodes
- if ( nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
-
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks &&
- ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
- return ret;
- }
-
- return ( elem[ name ] = value );
- }
-
- if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
- return ret;
- }
-
- return elem[ name ];
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
-
- // Support: IE <=9 - 11 only
- // elem.tabIndex doesn't always return the
- // correct value when it hasn't been explicitly set
- // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- // Use proper attribute retrieval(#12072)
- var tabindex = jQuery.find.attr( elem, "tabindex" );
-
- if ( tabindex ) {
- return parseInt( tabindex, 10 );
- }
-
- if (
- rfocusable.test( elem.nodeName ) ||
- rclickable.test( elem.nodeName ) &&
- elem.href
- ) {
- return 0;
- }
-
- return -1;
- }
- }
- },
-
- propFix: {
- "for": "htmlFor",
- "class": "className"
- }
-} );
-
-// Support: IE <=11 only
-// Accessing the selectedIndex property
-// forces the browser to respect setting selected
-// on the option
-// The getter ensures a default option is selected
-// when in an optgroup
-// eslint rule "no-unused-expressions" is disabled for this code
-// since it considers such accessions noop
-if ( !support.optSelected ) {
- jQuery.propHooks.selected = {
- get: function( elem ) {
-
- /* eslint no-unused-expressions: "off" */
-
- var parent = elem.parentNode;
- if ( parent && parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- return null;
- },
- set: function( elem ) {
-
- /* eslint no-unused-expressions: "off" */
-
- var parent = elem.parentNode;
- if ( parent ) {
- parent.selectedIndex;
-
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- }
- };
-}
-
-jQuery.each( [
- "tabIndex",
- "readOnly",
- "maxLength",
- "cellSpacing",
- "cellPadding",
- "rowSpan",
- "colSpan",
- "useMap",
- "frameBorder",
- "contentEditable"
-], function() {
- jQuery.propFix[ this.toLowerCase() ] = this;
-} );
-
-
-
-
- // Strip and collapse whitespace according to HTML spec
- // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
- function stripAndCollapse( value ) {
- var tokens = value.match( rnothtmlwhite ) || [];
- return tokens.join( " " );
- }
-
-
-function getClass( elem ) {
- return elem.getAttribute && elem.getAttribute( "class" ) || "";
-}
-
-function classesToArray( value ) {
- if ( Array.isArray( value ) ) {
- return value;
- }
- if ( typeof value === "string" ) {
- return value.match( rnothtmlwhite ) || [];
- }
- return [];
-}
-
-jQuery.fn.extend( {
- addClass: function( value ) {
- var classes, elem, cur, curValue, clazz, j, finalValue,
- i = 0;
-
- if ( isFunction( value ) ) {
- return this.each( function( j ) {
- jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
- } );
- }
-
- classes = classesToArray( value );
-
- if ( classes.length ) {
- while ( ( elem = this[ i++ ] ) ) {
- curValue = getClass( elem );
- cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
-
- if ( cur ) {
- j = 0;
- while ( ( clazz = classes[ j++ ] ) ) {
- if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
- cur += clazz + " ";
- }
- }
-
- // Only assign if different to avoid unneeded rendering.
- finalValue = stripAndCollapse( cur );
- if ( curValue !== finalValue ) {
- elem.setAttribute( "class", finalValue );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classes, elem, cur, curValue, clazz, j, finalValue,
- i = 0;
-
- if ( isFunction( value ) ) {
- return this.each( function( j ) {
- jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
- } );
- }
-
- if ( !arguments.length ) {
- return this.attr( "class", "" );
- }
-
- classes = classesToArray( value );
-
- if ( classes.length ) {
- while ( ( elem = this[ i++ ] ) ) {
- curValue = getClass( elem );
-
- // This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
-
- if ( cur ) {
- j = 0;
- while ( ( clazz = classes[ j++ ] ) ) {
-
- // Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
- cur = cur.replace( " " + clazz + " ", " " );
- }
- }
-
- // Only assign if different to avoid unneeded rendering.
- finalValue = stripAndCollapse( cur );
- if ( curValue !== finalValue ) {
- elem.setAttribute( "class", finalValue );
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isValidValue = type === "string" || Array.isArray( value );
-
- if ( typeof stateVal === "boolean" && isValidValue ) {
- return stateVal ? this.addClass( value ) : this.removeClass( value );
- }
-
- if ( isFunction( value ) ) {
- return this.each( function( i ) {
- jQuery( this ).toggleClass(
- value.call( this, i, getClass( this ), stateVal ),
- stateVal
- );
- } );
- }
-
- return this.each( function() {
- var className, i, self, classNames;
-
- if ( isValidValue ) {
-
- // Toggle individual class names
- i = 0;
- self = jQuery( this );
- classNames = classesToArray( value );
-
- while ( ( className = classNames[ i++ ] ) ) {
-
- // Check each className given, space separated list
- if ( self.hasClass( className ) ) {
- self.removeClass( className );
- } else {
- self.addClass( className );
- }
- }
-
- // Toggle whole class name
- } else if ( value === undefined || type === "boolean" ) {
- className = getClass( this );
- if ( className ) {
-
- // Store className if set
- dataPriv.set( this, "__className__", className );
- }
-
- // If the element has a class name or if we're passed `false`,
- // then remove the whole classname (if there was one, the above saved it).
- // Otherwise bring back whatever was previously saved (if anything),
- // falling back to the empty string if nothing was stored.
- if ( this.setAttribute ) {
- this.setAttribute( "class",
- className || value === false ?
- "" :
- dataPriv.get( this, "__className__" ) || ""
- );
- }
- }
- } );
- },
-
- hasClass: function( selector ) {
- var className, elem,
- i = 0;
-
- className = " " + selector + " ";
- while ( ( elem = this[ i++ ] ) ) {
- if ( elem.nodeType === 1 &&
- ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
- return true;
- }
- }
-
- return false;
- }
-} );
-
-
-
-
-var rreturn = /\r/g;
-
-jQuery.fn.extend( {
- val: function( value ) {
- var hooks, ret, valueIsFunction,
- elem = this[ 0 ];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] ||
- jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if ( hooks &&
- "get" in hooks &&
- ( ret = hooks.get( elem, "value" ) ) !== undefined
- ) {
- return ret;
- }
-
- ret = elem.value;
-
- // Handle most common string cases
- if ( typeof ret === "string" ) {
- return ret.replace( rreturn, "" );
- }
-
- // Handle cases where value is null/undef or number
- return ret == null ? "" : ret;
- }
-
- return;
- }
-
- valueIsFunction = isFunction( value );
-
- return this.each( function( i ) {
- var val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( valueIsFunction ) {
- val = value.call( this, i, jQuery( this ).val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
-
- } else if ( typeof val === "number" ) {
- val += "";
-
- } else if ( Array.isArray( val ) ) {
- val = jQuery.map( val, function( value ) {
- return value == null ? "" : value + "";
- } );
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- } );
- }
-} );
-
-jQuery.extend( {
- valHooks: {
- option: {
- get: function( elem ) {
-
- var val = jQuery.find.attr( elem, "value" );
- return val != null ?
- val :
-
- // Support: IE <=10 - 11 only
- // option.text throws exceptions (#14686, #14858)
- // Strip and collapse whitespace
- // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
- stripAndCollapse( jQuery.text( elem ) );
- }
- },
- select: {
- get: function( elem ) {
- var value, option, i,
- options = elem.options,
- index = elem.selectedIndex,
- one = elem.type === "select-one",
- values = one ? null : [],
- max = one ? index + 1 : options.length;
-
- if ( index < 0 ) {
- i = max;
-
- } else {
- i = one ? index : 0;
- }
-
- // Loop through all the selected options
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // Support: IE <=9 only
- // IE8-9 doesn't update selected after form reset (#2551)
- if ( ( option.selected || i === index ) &&
-
- // Don't return options that are disabled or in a disabled optgroup
- !option.disabled &&
- ( !option.parentNode.disabled ||
- !nodeName( option.parentNode, "optgroup" ) ) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var optionSet, option,
- options = elem.options,
- values = jQuery.makeArray( value ),
- i = options.length;
-
- while ( i-- ) {
- option = options[ i ];
-
- /* eslint-disable no-cond-assign */
-
- if ( option.selected =
- jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
- ) {
- optionSet = true;
- }
-
- /* eslint-enable no-cond-assign */
- }
-
- // Force browsers to behave consistently when non-matching value is set
- if ( !optionSet ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- }
-} );
-
-// Radios and checkboxes getter/setter
-jQuery.each( [ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- set: function( elem, value ) {
- if ( Array.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
- }
- }
- };
- if ( !support.checkOn ) {
- jQuery.valHooks[ this ].get = function( elem ) {
- return elem.getAttribute( "value" ) === null ? "on" : elem.value;
- };
- }
-} );
-
-
-
-
-// Return jQuery for attributes-only inclusion
-
-
-support.focusin = "onfocusin" in window;
-
-
-var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- stopPropagationCallback = function( e ) {
- e.stopPropagation();
- };
-
-jQuery.extend( jQuery.event, {
-
- trigger: function( event, data, elem, onlyHandlers ) {
-
- var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
- eventPath = [ elem || document ],
- type = hasOwn.call( event, "type" ) ? event.type : event,
- namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
-
- cur = lastElement = tmp = elem = elem || document;
-
- // Don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf( "." ) > -1 ) {
-
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split( "." );
- type = namespaces.shift();
- namespaces.sort();
- }
- ontype = type.indexOf( ":" ) < 0 && "on" + type;
-
- // Caller can pass in a jQuery.Event object, Object, or just an event type string
- event = event[ jQuery.expando ] ?
- event :
- new jQuery.Event( type, typeof event === "object" && event );
-
- // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
- event.isTrigger = onlyHandlers ? 2 : 3;
- event.namespace = namespaces.join( "." );
- event.rnamespace = event.namespace ?
- new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
- null;
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data == null ?
- [ event ] :
- jQuery.makeArray( data, [ event ] );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- if ( !rfocusMorph.test( bubbleType + type ) ) {
- cur = cur.parentNode;
- }
- for ( ; cur; cur = cur.parentNode ) {
- eventPath.push( cur );
- tmp = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( tmp === ( elem.ownerDocument || document ) ) {
- eventPath.push( tmp.defaultView || tmp.parentWindow || window );
- }
- }
-
- // Fire handlers on the event path
- i = 0;
- while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
- lastElement = cur;
- event.type = i > 1 ?
- bubbleType :
- special.bindType || type;
-
- // jQuery handler
- handle = (
- dataPriv.get( cur, "events" ) || Object.create( null )
- )[ event.type ] &&
- dataPriv.get( cur, "handle" );
- if ( handle ) {
- handle.apply( cur, data );
- }
-
- // Native handler
- handle = ontype && cur[ ontype ];
- if ( handle && handle.apply && acceptData( cur ) ) {
- event.result = handle.apply( cur, data );
- if ( event.result === false ) {
- event.preventDefault();
- }
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if ( ( !special._default ||
- special._default.apply( eventPath.pop(), data ) === false ) &&
- acceptData( elem ) ) {
-
- // Call a native DOM method on the target with the same name as the event.
- // Don't do default actions on window, that's where global variables be (#6170)
- if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
-
- // Don't re-trigger an onFOO event when we call its FOO() method
- tmp = elem[ ontype ];
-
- if ( tmp ) {
- elem[ ontype ] = null;
- }
-
- // Prevent re-triggering of the same event, since we already bubbled it above
- jQuery.event.triggered = type;
-
- if ( event.isPropagationStopped() ) {
- lastElement.addEventListener( type, stopPropagationCallback );
- }
-
- elem[ type ]();
-
- if ( event.isPropagationStopped() ) {
- lastElement.removeEventListener( type, stopPropagationCallback );
- }
-
- jQuery.event.triggered = undefined;
-
- if ( tmp ) {
- elem[ ontype ] = tmp;
- }
- }
- }
- }
-
- return event.result;
- },
-
- // Piggyback on a donor event to simulate a different one
- // Used only for `focus(in | out)` events
- simulate: function( type, elem, event ) {
- var e = jQuery.extend(
- new jQuery.Event(),
- event,
- {
- type: type,
- isSimulated: true
- }
- );
-
- jQuery.event.trigger( e, null, elem );
- }
-
-} );
-
-jQuery.fn.extend( {
-
- trigger: function( type, data ) {
- return this.each( function() {
- jQuery.event.trigger( type, data, this );
- } );
- },
- triggerHandler: function( type, data ) {
- var elem = this[ 0 ];
- if ( elem ) {
- return jQuery.event.trigger( type, data, elem, true );
- }
- }
-} );
-
-
-// Support: Firefox <=44
-// Firefox doesn't have focus(in | out) events
-// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
-//
-// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
-// focus(in | out) events fire after focus & blur events,
-// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
-// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
-if ( !support.focusin ) {
- jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
- // Attach a single capturing handler on the document while someone wants focusin/focusout
- var handler = function( event ) {
- jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
- };
-
- jQuery.event.special[ fix ] = {
- setup: function() {
-
- // Handle: regular nodes (via `this.ownerDocument`), window
- // (via `this.document`) & document (via `this`).
- var doc = this.ownerDocument || this.document || this,
- attaches = dataPriv.access( doc, fix );
-
- if ( !attaches ) {
- doc.addEventListener( orig, handler, true );
- }
- dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
- },
- teardown: function() {
- var doc = this.ownerDocument || this.document || this,
- attaches = dataPriv.access( doc, fix ) - 1;
-
- if ( !attaches ) {
- doc.removeEventListener( orig, handler, true );
- dataPriv.remove( doc, fix );
-
- } else {
- dataPriv.access( doc, fix, attaches );
- }
- }
- };
- } );
-}
-var location = window.location;
-
-var nonce = { guid: Date.now() };
-
-var rquery = ( /\?/ );
-
-
-
-// Cross-browser xml parsing
-jQuery.parseXML = function( data ) {
- var xml;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
-
- // Support: IE 9 - 11 only
- // IE throws on parseFromString with invalid input.
- try {
- xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
- } catch ( e ) {
- xml = undefined;
- }
-
- if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
-};
-
-
-var
- rbracket = /\[\]$/,
- rCRLF = /\r?\n/g,
- rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
- rsubmittable = /^(?:input|select|textarea|keygen)/i;
-
-function buildParams( prefix, obj, traditional, add ) {
- var name;
-
- if ( Array.isArray( obj ) ) {
-
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
-
- // Treat each array item as a scalar.
- add( prefix, v );
-
- } else {
-
- // Item is non-scalar (array or object), encode its numeric index.
- buildParams(
- prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
- v,
- traditional,
- add
- );
- }
- } );
-
- } else if ( !traditional && toType( obj ) === "object" ) {
-
- // Serialize object item.
- for ( name in obj ) {
- buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
- }
-
- } else {
-
- // Serialize scalar item.
- add( prefix, obj );
- }
-}
-
-// Serialize an array of form elements or a set of
-// key/values into a query string
-jQuery.param = function( a, traditional ) {
- var prefix,
- s = [],
- add = function( key, valueOrFunction ) {
-
- // If value is a function, invoke it and use its return value
- var value = isFunction( valueOrFunction ) ?
- valueOrFunction() :
- valueOrFunction;
-
- s[ s.length ] = encodeURIComponent( key ) + "=" +
- encodeURIComponent( value == null ? "" : value );
- };
-
- if ( a == null ) {
- return "";
- }
-
- // If an array was passed in, assume that it is an array of form elements.
- if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
-
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- } );
-
- } else {
-
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( prefix in a ) {
- buildParams( prefix, a[ prefix ], traditional, add );
- }
- }
-
- // Return the resulting serialization
- return s.join( "&" );
-};
-
-jQuery.fn.extend( {
- serialize: function() {
- return jQuery.param( this.serializeArray() );
- },
- serializeArray: function() {
- return this.map( function() {
-
- // Can add propHook for "elements" to filter or add form elements
- var elements = jQuery.prop( this, "elements" );
- return elements ? jQuery.makeArray( elements ) : this;
- } )
- .filter( function() {
- var type = this.type;
-
- // Use .is( ":disabled" ) so that fieldset[disabled] works
- return this.name && !jQuery( this ).is( ":disabled" ) &&
- rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
- ( this.checked || !rcheckableType.test( type ) );
- } )
- .map( function( _i, elem ) {
- var val = jQuery( this ).val();
-
- if ( val == null ) {
- return null;
- }
-
- if ( Array.isArray( val ) ) {
- return jQuery.map( val, function( val ) {
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- } );
- }
-
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- } ).get();
- }
-} );
-
-
-var
- r20 = /%20/g,
- rhash = /#.*$/,
- rantiCache = /([?&])_=[^&]*/,
- rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
-
- // #7653, #8125, #8152: local protocol detection
- rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
- rnoContent = /^(?:GET|HEAD)$/,
- rprotocol = /^\/\//,
-
- /* Prefilters
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
- * 2) These are called:
- * - BEFORE asking for a transport
- * - AFTER param serialization (s.data is a string if s.processData is true)
- * 3) key is the dataType
- * 4) the catchall symbol "*" can be used
- * 5) execution will start with transport dataType and THEN continue down to "*" if needed
- */
- prefilters = {},
-
- /* Transports bindings
- * 1) key is the dataType
- * 2) the catchall symbol "*" can be used
- * 3) selection will start with transport dataType and THEN go to "*" if needed
- */
- transports = {},
-
- // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
- allTypes = "*/".concat( "*" ),
-
- // Anchor tag for parsing the document origin
- originAnchor = document.createElement( "a" );
- originAnchor.href = location.href;
-
-// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
-function addToPrefiltersOrTransports( structure ) {
-
- // dataTypeExpression is optional and defaults to "*"
- return function( dataTypeExpression, func ) {
-
- if ( typeof dataTypeExpression !== "string" ) {
- func = dataTypeExpression;
- dataTypeExpression = "*";
- }
-
- var dataType,
- i = 0,
- dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
-
- if ( isFunction( func ) ) {
-
- // For each dataType in the dataTypeExpression
- while ( ( dataType = dataTypes[ i++ ] ) ) {
-
- // Prepend if requested
- if ( dataType[ 0 ] === "+" ) {
- dataType = dataType.slice( 1 ) || "*";
- ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
-
- // Otherwise append
- } else {
- ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
- }
- }
- }
- };
-}
-
-// Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
-
- var inspected = {},
- seekingTransport = ( structure === transports );
-
- function inspect( dataType ) {
- var selected;
- inspected[ dataType ] = true;
- jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
- var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
- if ( typeof dataTypeOrTransport === "string" &&
- !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
-
- options.dataTypes.unshift( dataTypeOrTransport );
- inspect( dataTypeOrTransport );
- return false;
- } else if ( seekingTransport ) {
- return !( selected = dataTypeOrTransport );
- }
- } );
- return selected;
- }
-
- return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
-}
-
-// A special extend for ajax options
-// that takes "flat" options (not to be deep extended)
-// Fixes #9887
-function ajaxExtend( target, src ) {
- var key, deep,
- flatOptions = jQuery.ajaxSettings.flatOptions || {};
-
- for ( key in src ) {
- if ( src[ key ] !== undefined ) {
- ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
- }
- }
- if ( deep ) {
- jQuery.extend( true, target, deep );
- }
-
- return target;
-}
-
-/* Handles responses to an ajax request:
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
-function ajaxHandleResponses( s, jqXHR, responses ) {
-
- var ct, type, finalDataType, firstDataType,
- contents = s.contents,
- dataTypes = s.dataTypes;
-
- // Remove auto dataType and get content-type in the process
- while ( dataTypes[ 0 ] === "*" ) {
- dataTypes.shift();
- if ( ct === undefined ) {
- ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
- }
- }
-
- // Check if we're dealing with a known content-type
- if ( ct ) {
- for ( type in contents ) {
- if ( contents[ type ] && contents[ type ].test( ct ) ) {
- dataTypes.unshift( type );
- break;
- }
- }
- }
-
- // Check to see if we have a response for the expected dataType
- if ( dataTypes[ 0 ] in responses ) {
- finalDataType = dataTypes[ 0 ];
- } else {
-
- // Try convertible dataTypes
- for ( type in responses ) {
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
- finalDataType = type;
- break;
- }
- if ( !firstDataType ) {
- firstDataType = type;
- }
- }
-
- // Or just use first one
- finalDataType = finalDataType || firstDataType;
- }
-
- // If we found a dataType
- // We add the dataType to the list if needed
- // and return the corresponding response
- if ( finalDataType ) {
- if ( finalDataType !== dataTypes[ 0 ] ) {
- dataTypes.unshift( finalDataType );
- }
- return responses[ finalDataType ];
- }
-}
-
-/* Chain conversions given the request and the original response
- * Also sets the responseXXX fields on the jqXHR instance
- */
-function ajaxConvert( s, response, jqXHR, isSuccess ) {
- var conv2, current, conv, tmp, prev,
- converters = {},
-
- // Work with a copy of dataTypes in case we need to modify it for conversion
- dataTypes = s.dataTypes.slice();
-
- // Create converters map with lowercased keys
- if ( dataTypes[ 1 ] ) {
- for ( conv in s.converters ) {
- converters[ conv.toLowerCase() ] = s.converters[ conv ];
- }
- }
-
- current = dataTypes.shift();
-
- // Convert to each sequential dataType
- while ( current ) {
-
- if ( s.responseFields[ current ] ) {
- jqXHR[ s.responseFields[ current ] ] = response;
- }
-
- // Apply the dataFilter if provided
- if ( !prev && isSuccess && s.dataFilter ) {
- response = s.dataFilter( response, s.dataType );
- }
-
- prev = current;
- current = dataTypes.shift();
-
- if ( current ) {
-
- // There's only work to do if current dataType is non-auto
- if ( current === "*" ) {
-
- current = prev;
-
- // Convert response if prev dataType is non-auto and differs from current
- } else if ( prev !== "*" && prev !== current ) {
-
- // Seek a direct converter
- conv = converters[ prev + " " + current ] || converters[ "* " + current ];
-
- // If none found, seek a pair
- if ( !conv ) {
- for ( conv2 in converters ) {
-
- // If conv2 outputs current
- tmp = conv2.split( " " );
- if ( tmp[ 1 ] === current ) {
-
- // If prev can be converted to accepted input
- conv = converters[ prev + " " + tmp[ 0 ] ] ||
- converters[ "* " + tmp[ 0 ] ];
- if ( conv ) {
-
- // Condense equivalence converters
- if ( conv === true ) {
- conv = converters[ conv2 ];
-
- // Otherwise, insert the intermediate dataType
- } else if ( converters[ conv2 ] !== true ) {
- current = tmp[ 0 ];
- dataTypes.unshift( tmp[ 1 ] );
- }
- break;
- }
- }
- }
- }
-
- // Apply converter (if not an equivalence)
- if ( conv !== true ) {
-
- // Unless errors are allowed to bubble, catch and return them
- if ( conv && s.throws ) {
- response = conv( response );
- } else {
- try {
- response = conv( response );
- } catch ( e ) {
- return {
- state: "parsererror",
- error: conv ? e : "No conversion from " + prev + " to " + current
- };
- }
- }
- }
- }
- }
- }
-
- return { state: "success", data: response };
-}
-
-jQuery.extend( {
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {},
-
- ajaxSettings: {
- url: location.href,
- type: "GET",
- isLocal: rlocalProtocol.test( location.protocol ),
- global: true,
- processData: true,
- async: true,
- contentType: "application/x-www-form-urlencoded; charset=UTF-8",
-
- /*
- timeout: 0,
- data: null,
- dataType: null,
- username: null,
- password: null,
- cache: null,
- throws: false,
- traditional: false,
- headers: {},
- */
-
- accepts: {
- "*": allTypes,
- text: "text/plain",
- html: "text/html",
- xml: "application/xml, text/xml",
- json: "application/json, text/javascript"
- },
-
- contents: {
- xml: /\bxml\b/,
- html: /\bhtml/,
- json: /\bjson\b/
- },
-
- responseFields: {
- xml: "responseXML",
- text: "responseText",
- json: "responseJSON"
- },
-
- // Data converters
- // Keys separate source (or catchall "*") and destination types with a single space
- converters: {
-
- // Convert anything to text
- "* text": String,
-
- // Text to html (true = no transformation)
- "text html": true,
-
- // Evaluate text as a json expression
- "text json": JSON.parse,
-
- // Parse text as xml
- "text xml": jQuery.parseXML
- },
-
- // For options that shouldn't be deep extended:
- // you can add your own custom options here if
- // and when you create one that shouldn't be
- // deep extended (see ajaxExtend)
- flatOptions: {
- url: true,
- context: true
- }
- },
-
- // Creates a full fledged settings object into target
- // with both ajaxSettings and settings fields.
- // If target is omitted, writes into ajaxSettings.
- ajaxSetup: function( target, settings ) {
- return settings ?
-
- // Building a settings object
- ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
-
- // Extending ajaxSettings
- ajaxExtend( jQuery.ajaxSettings, target );
- },
-
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
- ajaxTransport: addToPrefiltersOrTransports( transports ),
-
- // Main method
- ajax: function( url, options ) {
-
- // If url is an object, simulate pre-1.5 signature
- if ( typeof url === "object" ) {
- options = url;
- url = undefined;
- }
-
- // Force options to be an object
- options = options || {};
-
- var transport,
-
- // URL without anti-cache param
- cacheURL,
-
- // Response headers
- responseHeadersString,
- responseHeaders,
-
- // timeout handle
- timeoutTimer,
-
- // Url cleanup var
- urlAnchor,
-
- // Request state (becomes false upon send and true upon completion)
- completed,
-
- // To know if global events are to be dispatched
- fireGlobals,
-
- // Loop variable
- i,
-
- // uncached part of the url
- uncached,
-
- // Create the final options object
- s = jQuery.ajaxSetup( {}, options ),
-
- // Callbacks context
- callbackContext = s.context || s,
-
- // Context for global events is callbackContext if it is a DOM node or jQuery collection
- globalEventContext = s.context &&
- ( callbackContext.nodeType || callbackContext.jquery ) ?
- jQuery( callbackContext ) :
- jQuery.event,
-
- // Deferreds
- deferred = jQuery.Deferred(),
- completeDeferred = jQuery.Callbacks( "once memory" ),
-
- // Status-dependent callbacks
- statusCode = s.statusCode || {},
-
- // Headers (they are sent all at once)
- requestHeaders = {},
- requestHeadersNames = {},
-
- // Default abort message
- strAbort = "canceled",
-
- // Fake xhr
- jqXHR = {
- readyState: 0,
-
- // Builds headers hashtable if needed
- getResponseHeader: function( key ) {
- var match;
- if ( completed ) {
- if ( !responseHeaders ) {
- responseHeaders = {};
- while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
- responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
- ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
- .concat( match[ 2 ] );
- }
- }
- match = responseHeaders[ key.toLowerCase() + " " ];
- }
- return match == null ? null : match.join( ", " );
- },
-
- // Raw string
- getAllResponseHeaders: function() {
- return completed ? responseHeadersString : null;
- },
-
- // Caches the header
- setRequestHeader: function( name, value ) {
- if ( completed == null ) {
- name = requestHeadersNames[ name.toLowerCase() ] =
- requestHeadersNames[ name.toLowerCase() ] || name;
- requestHeaders[ name ] = value;
- }
- return this;
- },
-
- // Overrides response content-type header
- overrideMimeType: function( type ) {
- if ( completed == null ) {
- s.mimeType = type;
- }
- return this;
- },
-
- // Status-dependent callbacks
- statusCode: function( map ) {
- var code;
- if ( map ) {
- if ( completed ) {
-
- // Execute the appropriate callbacks
- jqXHR.always( map[ jqXHR.status ] );
- } else {
-
- // Lazy-add the new callbacks in a way that preserves old ones
- for ( code in map ) {
- statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
- }
- }
- }
- return this;
- },
-
- // Cancel the request
- abort: function( statusText ) {
- var finalText = statusText || strAbort;
- if ( transport ) {
- transport.abort( finalText );
- }
- done( 0, finalText );
- return this;
- }
- };
-
- // Attach deferreds
- deferred.promise( jqXHR );
-
- // Add protocol if not provided (prefilters might expect it)
- // Handle falsy url in the settings object (#10093: consistency with old signature)
- // We also use the url parameter if available
- s.url = ( ( url || s.url || location.href ) + "" )
- .replace( rprotocol, location.protocol + "//" );
-
- // Alias method option to type as per ticket #12004
- s.type = options.method || options.type || s.method || s.type;
-
- // Extract dataTypes list
- s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
-
- // A cross-domain request is in order when the origin doesn't match the current origin.
- if ( s.crossDomain == null ) {
- urlAnchor = document.createElement( "a" );
-
- // Support: IE <=8 - 11, Edge 12 - 15
- // IE throws exception on accessing the href property if url is malformed,
- // e.g. http://example.com:80x/
- try {
- urlAnchor.href = s.url;
-
- // Support: IE <=8 - 11 only
- // Anchor's host property isn't correctly set when s.url is relative
- urlAnchor.href = urlAnchor.href;
- s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
- urlAnchor.protocol + "//" + urlAnchor.host;
- } catch ( e ) {
-
- // If there is an error parsing the URL, assume it is crossDomain,
- // it can be rejected by the transport if it is invalid
- s.crossDomain = true;
- }
- }
-
- // Convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
-
- // Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
-
- // If request was aborted inside a prefilter, stop there
- if ( completed ) {
- return jqXHR;
- }
-
- // We can fire global events as of now if asked to
- // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
- fireGlobals = jQuery.event && s.global;
-
- // Watch for a new set of requests
- if ( fireGlobals && jQuery.active++ === 0 ) {
- jQuery.event.trigger( "ajaxStart" );
- }
-
- // Uppercase the type
- s.type = s.type.toUpperCase();
-
- // Determine if request has content
- s.hasContent = !rnoContent.test( s.type );
-
- // Save the URL in case we're toying with the If-Modified-Since
- // and/or If-None-Match header later on
- // Remove hash to simplify url manipulation
- cacheURL = s.url.replace( rhash, "" );
-
- // More options handling for requests with no content
- if ( !s.hasContent ) {
-
- // Remember the hash so we can put it back
- uncached = s.url.slice( cacheURL.length );
-
- // If data is available and should be processed, append data to url
- if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
- cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
-
- // #9682: remove data so that it's not used in an eventual retry
- delete s.data;
- }
-
- // Add or update anti-cache param if needed
- if ( s.cache === false ) {
- cacheURL = cacheURL.replace( rantiCache, "$1" );
- uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
- uncached;
- }
-
- // Put hash and anti-cache on the URL that will be requested (gh-1732)
- s.url = cacheURL + uncached;
-
- // Change '%20' to '+' if this is encoded form body content (gh-2658)
- } else if ( s.data && s.processData &&
- ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
- s.data = s.data.replace( r20, "+" );
- }
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( jQuery.lastModified[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
- }
- if ( jQuery.etag[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
- }
- }
-
- // Set the correct header, if data is being sent
- if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- jqXHR.setRequestHeader( "Content-Type", s.contentType );
- }
-
- // Set the Accepts header for the server, depending on the dataType
- jqXHR.setRequestHeader(
- "Accept",
- s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
- s.accepts[ s.dataTypes[ 0 ] ] +
- ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
- s.accepts[ "*" ]
- );
-
- // Check for headers option
- for ( i in s.headers ) {
- jqXHR.setRequestHeader( i, s.headers[ i ] );
- }
-
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend &&
- ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
-
- // Abort if not done already and return
- return jqXHR.abort();
- }
-
- // Aborting is no longer a cancellation
- strAbort = "abort";
-
- // Install callbacks on deferreds
- completeDeferred.add( s.complete );
- jqXHR.done( s.success );
- jqXHR.fail( s.error );
-
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
-
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- jqXHR.readyState = 1;
-
- // Send global event
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
- }
-
- // If request was aborted inside ajaxSend, stop there
- if ( completed ) {
- return jqXHR;
- }
-
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = window.setTimeout( function() {
- jqXHR.abort( "timeout" );
- }, s.timeout );
- }
-
- try {
- completed = false;
- transport.send( requestHeaders, done );
- } catch ( e ) {
-
- // Rethrow post-completion exceptions
- if ( completed ) {
- throw e;
- }
-
- // Propagate others as results
- done( -1, e );
- }
- }
-
- // Callback for when everything is done
- function done( status, nativeStatusText, responses, headers ) {
- var isSuccess, success, error, response, modified,
- statusText = nativeStatusText;
-
- // Ignore repeat invocations
- if ( completed ) {
- return;
- }
-
- completed = true;
-
- // Clear timeout if it exists
- if ( timeoutTimer ) {
- window.clearTimeout( timeoutTimer );
- }
-
- // Dereference transport for early garbage collection
- // (no matter how long the jqXHR object will be used)
- transport = undefined;
-
- // Cache response headers
- responseHeadersString = headers || "";
-
- // Set readyState
- jqXHR.readyState = status > 0 ? 4 : 0;
-
- // Determine if successful
- isSuccess = status >= 200 && status < 300 || status === 304;
-
- // Get response data
- if ( responses ) {
- response = ajaxHandleResponses( s, jqXHR, responses );
- }
-
- // Use a noop converter for missing script
- if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
- s.converters[ "text script" ] = function() {};
- }
-
- // Convert no matter what (that way responseXXX fields are always set)
- response = ajaxConvert( s, response, jqXHR, isSuccess );
-
- // If successful, handle type chaining
- if ( isSuccess ) {
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- modified = jqXHR.getResponseHeader( "Last-Modified" );
- if ( modified ) {
- jQuery.lastModified[ cacheURL ] = modified;
- }
- modified = jqXHR.getResponseHeader( "etag" );
- if ( modified ) {
- jQuery.etag[ cacheURL ] = modified;
- }
- }
-
- // if no content
- if ( status === 204 || s.type === "HEAD" ) {
- statusText = "nocontent";
-
- // if not modified
- } else if ( status === 304 ) {
- statusText = "notmodified";
-
- // If we have data, let's convert it
- } else {
- statusText = response.state;
- success = response.data;
- error = response.error;
- isSuccess = !error;
- }
- } else {
-
- // Extract error from statusText and normalize for non-aborts
- error = statusText;
- if ( status || !statusText ) {
- statusText = "error";
- if ( status < 0 ) {
- status = 0;
- }
- }
- }
-
- // Set data for the fake xhr object
- jqXHR.status = status;
- jqXHR.statusText = ( nativeStatusText || statusText ) + "";
-
- // Success/Error
- if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
- } else {
- deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
- }
-
- // Status-dependent callbacks
- jqXHR.statusCode( statusCode );
- statusCode = undefined;
-
- if ( fireGlobals ) {
- globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
- [ jqXHR, s, isSuccess ? success : error ] );
- }
-
- // Complete
- completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
-
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
-
- // Handle the global AJAX counter
- if ( !( --jQuery.active ) ) {
- jQuery.event.trigger( "ajaxStop" );
- }
- }
- }
-
- return jqXHR;
- },
-
- getJSON: function( url, data, callback ) {
- return jQuery.get( url, data, callback, "json" );
- },
-
- getScript: function( url, callback ) {
- return jQuery.get( url, undefined, callback, "script" );
- }
-} );
-
-jQuery.each( [ "get", "post" ], function( _i, method ) {
- jQuery[ method ] = function( url, data, callback, type ) {
-
- // Shift arguments if data argument was omitted
- if ( isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = undefined;
- }
-
- // The url can be an options object (which then must have .url)
- return jQuery.ajax( jQuery.extend( {
- url: url,
- type: method,
- dataType: type,
- data: data,
- success: callback
- }, jQuery.isPlainObject( url ) && url ) );
- };
-} );
-
-jQuery.ajaxPrefilter( function( s ) {
- var i;
- for ( i in s.headers ) {
- if ( i.toLowerCase() === "content-type" ) {
- s.contentType = s.headers[ i ] || "";
- }
- }
-} );
-
-
-jQuery._evalUrl = function( url, options, doc ) {
- return jQuery.ajax( {
- url: url,
-
- // Make this explicit, since user can override this through ajaxSetup (#11264)
- type: "GET",
- dataType: "script",
- cache: true,
- async: false,
- global: false,
-
- // Only evaluate the response if it is successful (gh-4126)
- // dataFilter is not invoked for failure responses, so using it instead
- // of the default converter is kludgy but it works.
- converters: {
- "text script": function() {}
- },
- dataFilter: function( response ) {
- jQuery.globalEval( response, options, doc );
- }
- } );
-};
-
-
-jQuery.fn.extend( {
- wrapAll: function( html ) {
- var wrap;
-
- if ( this[ 0 ] ) {
- if ( isFunction( html ) ) {
- html = html.call( this[ 0 ] );
- }
-
- // The elements to wrap the target around
- wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
-
- if ( this[ 0 ].parentNode ) {
- wrap.insertBefore( this[ 0 ] );
- }
-
- wrap.map( function() {
- var elem = this;
-
- while ( elem.firstElementChild ) {
- elem = elem.firstElementChild;
- }
-
- return elem;
- } ).append( this );
- }
-
- return this;
- },
-
- wrapInner: function( html ) {
- if ( isFunction( html ) ) {
- return this.each( function( i ) {
- jQuery( this ).wrapInner( html.call( this, i ) );
- } );
- }
-
- return this.each( function() {
- var self = jQuery( this ),
- contents = self.contents();
-
- if ( contents.length ) {
- contents.wrapAll( html );
-
- } else {
- self.append( html );
- }
- } );
- },
-
- wrap: function( html ) {
- var htmlIsFunction = isFunction( html );
-
- return this.each( function( i ) {
- jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
- } );
- },
-
- unwrap: function( selector ) {
- this.parent( selector ).not( "body" ).each( function() {
- jQuery( this ).replaceWith( this.childNodes );
- } );
- return this;
- }
-} );
-
-
-jQuery.expr.pseudos.hidden = function( elem ) {
- return !jQuery.expr.pseudos.visible( elem );
-};
-jQuery.expr.pseudos.visible = function( elem ) {
- return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
-};
-
-
-
-
-jQuery.ajaxSettings.xhr = function() {
- try {
- return new window.XMLHttpRequest();
- } catch ( e ) {}
-};
-
-var xhrSuccessStatus = {
-
- // File protocol always yields status code 0, assume 200
- 0: 200,
-
- // Support: IE <=9 only
- // #1450: sometimes IE returns 1223 when it should be 204
- 1223: 204
- },
- xhrSupported = jQuery.ajaxSettings.xhr();
-
-support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
-support.ajax = xhrSupported = !!xhrSupported;
-
-jQuery.ajaxTransport( function( options ) {
- var callback, errorCallback;
-
- // Cross domain only allowed if supported through XMLHttpRequest
- if ( support.cors || xhrSupported && !options.crossDomain ) {
- return {
- send: function( headers, complete ) {
- var i,
- xhr = options.xhr();
-
- xhr.open(
- options.type,
- options.url,
- options.async,
- options.username,
- options.password
- );
-
- // Apply custom fields if provided
- if ( options.xhrFields ) {
- for ( i in options.xhrFields ) {
- xhr[ i ] = options.xhrFields[ i ];
- }
- }
-
- // Override mime type if needed
- if ( options.mimeType && xhr.overrideMimeType ) {
- xhr.overrideMimeType( options.mimeType );
- }
-
- // X-Requested-With header
- // For cross-domain requests, seeing as conditions for a preflight are
- // akin to a jigsaw puzzle, we simply never set it to be sure.
- // (it can always be set on a per-request basis or even using ajaxSetup)
- // For same-domain requests, won't change header if already provided.
- if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
- headers[ "X-Requested-With" ] = "XMLHttpRequest";
- }
-
- // Set headers
- for ( i in headers ) {
- xhr.setRequestHeader( i, headers[ i ] );
- }
-
- // Callback
- callback = function( type ) {
- return function() {
- if ( callback ) {
- callback = errorCallback = xhr.onload =
- xhr.onerror = xhr.onabort = xhr.ontimeout =
- xhr.onreadystatechange = null;
-
- if ( type === "abort" ) {
- xhr.abort();
- } else if ( type === "error" ) {
-
- // Support: IE <=9 only
- // On a manual native abort, IE9 throws
- // errors on any property access that is not readyState
- if ( typeof xhr.status !== "number" ) {
- complete( 0, "error" );
- } else {
- complete(
-
- // File: protocol always yields status 0; see #8605, #14207
- xhr.status,
- xhr.statusText
- );
- }
- } else {
- complete(
- xhrSuccessStatus[ xhr.status ] || xhr.status,
- xhr.statusText,
-
- // Support: IE <=9 only
- // IE9 has no XHR2 but throws on binary (trac-11426)
- // For XHR2 non-text, let the caller handle it (gh-2498)
- ( xhr.responseType || "text" ) !== "text" ||
- typeof xhr.responseText !== "string" ?
- { binary: xhr.response } :
- { text: xhr.responseText },
- xhr.getAllResponseHeaders()
- );
- }
- }
- };
- };
-
- // Listen to events
- xhr.onload = callback();
- errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
-
- // Support: IE 9 only
- // Use onreadystatechange to replace onabort
- // to handle uncaught aborts
- if ( xhr.onabort !== undefined ) {
- xhr.onabort = errorCallback;
- } else {
- xhr.onreadystatechange = function() {
-
- // Check readyState before timeout as it changes
- if ( xhr.readyState === 4 ) {
-
- // Allow onerror to be called first,
- // but that will not handle a native abort
- // Also, save errorCallback to a variable
- // as xhr.onerror cannot be accessed
- window.setTimeout( function() {
- if ( callback ) {
- errorCallback();
- }
- } );
- }
- };
- }
-
- // Create the abort callback
- callback = callback( "abort" );
-
- try {
-
- // Do send the request (this may raise an exception)
- xhr.send( options.hasContent && options.data || null );
- } catch ( e ) {
-
- // #14683: Only rethrow if this hasn't been notified as an error yet
- if ( callback ) {
- throw e;
- }
- }
- },
-
- abort: function() {
- if ( callback ) {
- callback();
- }
- }
- };
- }
-} );
-
-
-
-
-// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
-jQuery.ajaxPrefilter( function( s ) {
- if ( s.crossDomain ) {
- s.contents.script = false;
- }
-} );
-
-// Install script dataType
-jQuery.ajaxSetup( {
- accepts: {
- script: "text/javascript, application/javascript, " +
- "application/ecmascript, application/x-ecmascript"
- },
- contents: {
- script: /\b(?:java|ecma)script\b/
- },
- converters: {
- "text script": function( text ) {
- jQuery.globalEval( text );
- return text;
- }
- }
-} );
-
-// Handle cache's special case and crossDomain
-jQuery.ajaxPrefilter( "script", function( s ) {
- if ( s.cache === undefined ) {
- s.cache = false;
- }
- if ( s.crossDomain ) {
- s.type = "GET";
- }
-} );
-
-// Bind script tag hack transport
-jQuery.ajaxTransport( "script", function( s ) {
-
- // This transport only deals with cross domain or forced-by-attrs requests
- if ( s.crossDomain || s.scriptAttrs ) {
- var script, callback;
- return {
- send: function( _, complete ) {
- script = jQuery( "<script>" )
- .attr( s.scriptAttrs || {} )
- .prop( { charset: s.scriptCharset, src: s.url } )
- .on( "load error", callback = function( evt ) {
- script.remove();
- callback = null;
- if ( evt ) {
- complete( evt.type === "error" ? 404 : 200, evt.type );
- }
- } );
-
- // Use native DOM manipulation to avoid our domManip AJAX trickery
- document.head.appendChild( script[ 0 ] );
- },
- abort: function() {
- if ( callback ) {
- callback();
- }
- }
- };
- }
-} );
-
-
-
-
-var oldCallbacks = [],
- rjsonp = /(=)\?(?=&|$)|\?\?/;
-
-// Default jsonp settings
-jQuery.ajaxSetup( {
- jsonp: "callback",
- jsonpCallback: function() {
- var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
- this[ callback ] = true;
- return callback;
- }
-} );
-
-// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
-
- var callbackName, overwritten, responseContainer,
- jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
- "url" :
- typeof s.data === "string" &&
- ( s.contentType || "" )
- .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
- rjsonp.test( s.data ) && "data"
- );
-
- // Handle iff the expected data type is "jsonp" or we have a parameter to set
- if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
-
- // Get callback name, remembering preexisting value associated with it
- callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
- s.jsonpCallback() :
- s.jsonpCallback;
-
- // Insert callback into url or form data
- if ( jsonProp ) {
- s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
- } else if ( s.jsonp !== false ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
- }
-
- // Use data converter to retrieve json after script execution
- s.converters[ "script json" ] = function() {
- if ( !responseContainer ) {
- jQuery.error( callbackName + " was not called" );
- }
- return responseContainer[ 0 ];
- };
-
- // Force json dataType
- s.dataTypes[ 0 ] = "json";
-
- // Install callback
- overwritten = window[ callbackName ];
- window[ callbackName ] = function() {
- responseContainer = arguments;
- };
-
- // Clean-up function (fires after converters)
- jqXHR.always( function() {
-
- // If previous value didn't exist - remove it
- if ( overwritten === undefined ) {
- jQuery( window ).removeProp( callbackName );
-
- // Otherwise restore preexisting value
- } else {
- window[ callbackName ] = overwritten;
- }
-
- // Save back as free
- if ( s[ callbackName ] ) {
-
- // Make sure that re-using the options doesn't screw things around
- s.jsonpCallback = originalSettings.jsonpCallback;
-
- // Save the callback name for future use
- oldCallbacks.push( callbackName );
- }
-
- // Call if it was a function and we have a response
- if ( responseContainer && isFunction( overwritten ) ) {
- overwritten( responseContainer[ 0 ] );
- }
-
- responseContainer = overwritten = undefined;
- } );
-
- // Delegate to script
- return "script";
- }
-} );
-
-
-
-
-// Support: Safari 8 only
-// In Safari 8 documents created via document.implementation.createHTMLDocument
-// collapse sibling forms: the second one becomes a child of the first one.
-// Because of that, this security measure has to be disabled in Safari 8.
-// https://bugs.webkit.org/show_bug.cgi?id=137337
-support.createHTMLDocument = ( function() {
- var body = document.implementation.createHTMLDocument( "" ).body;
- body.innerHTML = "<form></form><form></form>";
- return body.childNodes.length === 2;
-} )();
-
-
-// Argument "data" should be string of html
-// context (optional): If specified, the fragment will be created in this context,
-// defaults to document
-// keepScripts (optional): If true, will include scripts passed in the html string
-jQuery.parseHTML = function( data, context, keepScripts ) {
- if ( typeof data !== "string" ) {
- return [];
- }
- if ( typeof context === "boolean" ) {
- keepScripts = context;
- context = false;
- }
-
- var base, parsed, scripts;
-
- if ( !context ) {
-
- // Stop scripts or inline event handlers from being executed immediately
- // by using document.implementation
- if ( support.createHTMLDocument ) {
- context = document.implementation.createHTMLDocument( "" );
-
- // Set the base href for the created document
- // so any parsed elements with URLs
- // are based on the document's URL (gh-2965)
- base = context.createElement( "base" );
- base.href = document.location.href;
- context.head.appendChild( base );
- } else {
- context = document;
- }
- }
-
- parsed = rsingleTag.exec( data );
- scripts = !keepScripts && [];
-
- // Single tag
- if ( parsed ) {
- return [ context.createElement( parsed[ 1 ] ) ];
- }
-
- parsed = buildFragment( [ data ], context, scripts );
-
- if ( scripts && scripts.length ) {
- jQuery( scripts ).remove();
- }
-
- return jQuery.merge( [], parsed.childNodes );
-};
-
-
-/**
- * Load a url into a page
- */
-jQuery.fn.load = function( url, params, callback ) {
- var selector, type, response,
- self = this,
- off = url.indexOf( " " );
-
- if ( off > -1 ) {
- selector = stripAndCollapse( url.slice( off ) );
- url = url.slice( 0, off );
- }
-
- // If it's a function
- if ( isFunction( params ) ) {
-
- // We assume that it's the callback
- callback = params;
- params = undefined;
-
- // Otherwise, build a param string
- } else if ( params && typeof params === "object" ) {
- type = "POST";
- }
-
- // If we have elements to modify, make the request
- if ( self.length > 0 ) {
- jQuery.ajax( {
- url: url,
-
- // If "type" variable is undefined, then "GET" method will be used.
- // Make value of this field explicit since
- // user can override it through ajaxSetup method
- type: type || "GET",
- dataType: "html",
- data: params
- } ).done( function( responseText ) {
-
- // Save response for use in complete callback
- response = arguments;
-
- self.html( selector ?
-
- // If a selector was specified, locate the right elements in a dummy div
- // Exclude scripts to avoid IE 'Permission Denied' errors
- jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
-
- // Otherwise use the full result
- responseText );
-
- // If the request succeeds, this function gets "data", "status", "jqXHR"
- // but they are ignored because response was set above.
- // If it fails, this function gets "jqXHR", "status", "error"
- } ).always( callback && function( jqXHR, status ) {
- self.each( function() {
- callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
- } );
- } );
- }
-
- return this;
-};
-
-
-
-
-jQuery.expr.pseudos.animated = function( elem ) {
- return jQuery.grep( jQuery.timers, function( fn ) {
- return elem === fn.elem;
- } ).length;
-};
-
-
-
-
-jQuery.offset = {
- setOffset: function( elem, options, i ) {
- var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
- position = jQuery.css( elem, "position" ),
- curElem = jQuery( elem ),
- props = {};
-
- // Set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
-
- curOffset = curElem.offset();
- curCSSTop = jQuery.css( elem, "top" );
- curCSSLeft = jQuery.css( elem, "left" );
- calculatePosition = ( position === "absolute" || position === "fixed" ) &&
- ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
-
- // Need to be able to calculate position if either
- // top or left is auto and position is either absolute or fixed
- if ( calculatePosition ) {
- curPosition = curElem.position();
- curTop = curPosition.top;
- curLeft = curPosition.left;
-
- } else {
- curTop = parseFloat( curCSSTop ) || 0;
- curLeft = parseFloat( curCSSLeft ) || 0;
- }
-
- if ( isFunction( options ) ) {
-
- // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
- options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
- }
-
- if ( options.top != null ) {
- props.top = ( options.top - curOffset.top ) + curTop;
- }
- if ( options.left != null ) {
- props.left = ( options.left - curOffset.left ) + curLeft;
- }
-
- if ( "using" in options ) {
- options.using.call( elem, props );
-
- } else {
- if ( typeof props.top === "number" ) {
- props.top += "px";
- }
- if ( typeof props.left === "number" ) {
- props.left += "px";
- }
- curElem.css( props );
- }
- }
-};
-
-jQuery.fn.extend( {
-
- // offset() relates an element's border box to the document origin
- offset: function( options ) {
-
- // Preserve chaining for setter
- if ( arguments.length ) {
- return options === undefined ?
- this :
- this.each( function( i ) {
- jQuery.offset.setOffset( this, options, i );
- } );
- }
-
- var rect, win,
- elem = this[ 0 ];
-
- if ( !elem ) {
- return;
- }
-
- // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
- // Support: IE <=11 only
- // Running getBoundingClientRect on a
- // disconnected node in IE throws an error
- if ( !elem.getClientRects().length ) {
- return { top: 0, left: 0 };
- }
-
- // Get document-relative position by adding viewport scroll to viewport-relative gBCR
- rect = elem.getBoundingClientRect();
- win = elem.ownerDocument.defaultView;
- return {
- top: rect.top + win.pageYOffset,
- left: rect.left + win.pageXOffset
- };
- },
-
- // position() relates an element's margin box to its offset parent's padding box
- // This corresponds to the behavior of CSS absolute positioning
- position: function() {
- if ( !this[ 0 ] ) {
- return;
- }
-
- var offsetParent, offset, doc,
- elem = this[ 0 ],
- parentOffset = { top: 0, left: 0 };
-
- // position:fixed elements are offset from the viewport, which itself always has zero offset
- if ( jQuery.css( elem, "position" ) === "fixed" ) {
-
- // Assume position:fixed implies availability of getBoundingClientRect
- offset = elem.getBoundingClientRect();
-
- } else {
- offset = this.offset();
-
- // Account for the *real* offset parent, which can be the document or its root element
- // when a statically positioned element is identified
- doc = elem.ownerDocument;
- offsetParent = elem.offsetParent || doc.documentElement;
- while ( offsetParent &&
- ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
- jQuery.css( offsetParent, "position" ) === "static" ) {
-
- offsetParent = offsetParent.parentNode;
- }
- if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
-
- // Incorporate borders into its offset, since they are outside its content origin
- parentOffset = jQuery( offsetParent ).offset();
- parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
- parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
- }
- }
-
- // Subtract parent offsets and element margins
- return {
- top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
- left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
- };
- },
-
- // This method will return documentElement in the following cases:
- // 1) For the element inside the iframe without offsetParent, this method will return
- // documentElement of the parent window
- // 2) For the hidden or detached element
- // 3) For body or html element, i.e. in case of the html node - it will return itself
- //
- // but those exceptions were never presented as a real life use-cases
- // and might be considered as more preferable results.
- //
- // This logic, however, is not guaranteed and can change at any point in the future
- offsetParent: function() {
- return this.map( function() {
- var offsetParent = this.offsetParent;
-
- while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
- offsetParent = offsetParent.offsetParent;
- }
-
- return offsetParent || documentElement;
- } );
- }
-} );
-
-// Create scrollLeft and scrollTop methods
-jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
- var top = "pageYOffset" === prop;
-
- jQuery.fn[ method ] = function( val ) {
- return access( this, function( elem, method, val ) {
-
- // Coalesce documents and windows
- var win;
- if ( isWindow( elem ) ) {
- win = elem;
- } else if ( elem.nodeType === 9 ) {
- win = elem.defaultView;
- }
-
- if ( val === undefined ) {
- return win ? win[ prop ] : elem[ method ];
- }
-
- if ( win ) {
- win.scrollTo(
- !top ? val : win.pageXOffset,
- top ? val : win.pageYOffset
- );
-
- } else {
- elem[ method ] = val;
- }
- }, method, val, arguments.length );
- };
-} );
-
-// Support: Safari <=7 - 9.1, Chrome <=37 - 49
-// Add the top/left cssHooks using jQuery.fn.position
-// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
-// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
-// getComputedStyle returns percent when specified for top/left/bottom/right;
-// rather than make the css module depend on the offset module, just check for it here
-jQuery.each( [ "top", "left" ], function( _i, prop ) {
- jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
- function( elem, computed ) {
- if ( computed ) {
- computed = curCSS( elem, prop );
-
- // If curCSS returns percentage, fallback to offset
- return rnumnonpx.test( computed ) ?
- jQuery( elem ).position()[ prop ] + "px" :
- computed;
- }
- }
- );
-} );
-
-
-// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
-jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
- jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
- function( defaultExtra, funcName ) {
-
- // Margin is only for outerHeight, outerWidth
- jQuery.fn[ funcName ] = function( margin, value ) {
- var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
- extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
-
- return access( this, function( elem, type, value ) {
- var doc;
-
- if ( isWindow( elem ) ) {
-
- // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
- return funcName.indexOf( "outer" ) === 0 ?
- elem[ "inner" + name ] :
- elem.document.documentElement[ "client" + name ];
- }
-
- // Get document width or height
- if ( elem.nodeType === 9 ) {
- doc = elem.documentElement;
-
- // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
- // whichever is greatest
- return Math.max(
- elem.body[ "scroll" + name ], doc[ "scroll" + name ],
- elem.body[ "offset" + name ], doc[ "offset" + name ],
- doc[ "client" + name ]
- );
- }
-
- return value === undefined ?
-
- // Get width or height on the element, requesting but not forcing parseFloat
- jQuery.css( elem, type, extra ) :
-
- // Set width or height on the element
- jQuery.style( elem, type, value, extra );
- }, type, chainable ? margin : undefined, chainable );
- };
- } );
-} );
-
-
-jQuery.each( [
- "ajaxStart",
- "ajaxStop",
- "ajaxComplete",
- "ajaxError",
- "ajaxSuccess",
- "ajaxSend"
-], function( _i, type ) {
- jQuery.fn[ type ] = function( fn ) {
- return this.on( type, fn );
- };
-} );
-
-
-
-
-jQuery.fn.extend( {
-
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
-
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ?
- this.off( selector, "**" ) :
- this.off( types, selector || "**", fn );
- },
-
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-} );
-
-jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup contextmenu" ).split( " " ),
- function( _i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- return arguments.length > 0 ?
- this.on( name, null, data, fn ) :
- this.trigger( name );
- };
- } );
-
-
-
-
-// Support: Android <=4.0 only
-// Make sure we trim BOM and NBSP
-var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
-
-// Bind a function to a context, optionally partially applying any
-// arguments.
-// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
-// However, it is not slated for removal any time soon
-jQuery.proxy = function( fn, context ) {
- var tmp, args, proxy;
-
- if ( typeof context === "string" ) {
- tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- args = slice.call( arguments, 2 );
- proxy = function() {
- return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || jQuery.guid++;
-
- return proxy;
-};
-
-jQuery.holdReady = function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
-};
-jQuery.isArray = Array.isArray;
-jQuery.parseJSON = JSON.parse;
-jQuery.nodeName = nodeName;
-jQuery.isFunction = isFunction;
-jQuery.isWindow = isWindow;
-jQuery.camelCase = camelCase;
-jQuery.type = toType;
-
-jQuery.now = Date.now;
-
-jQuery.isNumeric = function( obj ) {
-
- // As of jQuery 3.0, isNumeric is limited to
- // strings and numbers (primitives or objects)
- // that can be coerced to finite numbers (gh-2662)
- var type = jQuery.type( obj );
- return ( type === "number" || type === "string" ) &&
-
- // parseFloat NaNs numeric-cast false positives ("")
- // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
- // subtraction forces infinities to NaN
- !isNaN( obj - parseFloat( obj ) );
-};
-
-jQuery.trim = function( text ) {
- return text == null ?
- "" :
- ( text + "" ).replace( rtrim, "" );
-};
-
-
-
-// Register as a named AMD module, since jQuery can be concatenated with other
-// files that may use define, but not via a proper concatenation script that
-// understands anonymous AMD modules. A named AMD is safest and most robust
-// way to register. Lowercase jquery is used because AMD module names are
-// derived from file names, and jQuery is normally delivered in a lowercase
-// file name. Do this after creating the global so that if an AMD module wants
-// to call noConflict to hide this version of jQuery, it will work.
-
-// Note that for maximum portability, libraries that are not jQuery should
-// declare themselves as anonymous modules, and avoid setting a global if an
-// AMD loader is present. jQuery is a special case. For more information, see
-// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
-
-if ( typeof define === "function" && define.amd ) {
- define( "jquery", [], function() {
- return jQuery;
- } );
-}
-
-
-
-
-var
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$;
-
-jQuery.noConflict = function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
-};
-
-// Expose jQuery and $ identifiers, even in AMD
-// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
-// and CommonJS for browser emulators (#13566)
-if ( typeof noGlobal === "undefined" ) {
- window.jQuery = window.$ = jQuery;
-}
-
-
-
-
-return jQuery;
-} );
--- a/domino/jqueryui/jquery-1.12.4.js
+++ /dev/null
@@ -1,11008 +1,0 @@
-/*!
- * jQuery JavaScript Library v1.12.4
- * http://jquery.com/
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license
- * http://jquery.org/license
- *
- * Date: 2016-05-20T17:17Z
- */
-
-(function( global, factory ) {
-
- if ( typeof module === "object" && typeof module.exports === "object" ) {
- // For CommonJS and CommonJS-like environments where a proper `window`
- // is present, execute the factory and get jQuery.
- // For environments that do not have a `window` with a `document`
- // (such as Node.js), expose a factory as module.exports.
- // This accentuates the need for the creation of a real `window`.
- // e.g. var jQuery = require("jquery")(window);
- // See ticket #14549 for more info.
- module.exports = global.document ?
- factory( global, true ) :
- function( w ) {
- if ( !w.document ) {
- throw new Error( "jQuery requires a window with a document" );
- }
- return factory( w );
- };
- } else {
- factory( global );
- }
-
-// Pass this if window is not defined yet
-}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
-
-// Support: Firefox 18+
-// Can't be in strict mode, several libs including ASP.NET trace
-// the stack via arguments.caller.callee and Firefox dies if
-// you try to trace through "use strict" call chains. (#13335)
-//"use strict";
-var deletedIds = [];
-
-var document = window.document;
-
-var slice = deletedIds.slice;
-
-var concat = deletedIds.concat;
-
-var push = deletedIds.push;
-
-var indexOf = deletedIds.indexOf;
-
-var class2type = {};
-
-var toString = class2type.toString;
-
-var hasOwn = class2type.hasOwnProperty;
-
-var support = {};
-
-
-
-var
- version = "1.12.4",
-
- // Define a local copy of jQuery
- jQuery = function( selector, context ) {
-
- // The jQuery object is actually just the init constructor 'enhanced'
- // Need init if jQuery is called (just allow error to be thrown if not included)
- return new jQuery.fn.init( selector, context );
- },
-
- // Support: Android<4.1, IE<9
- // Make sure we trim BOM and NBSP
- rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
-
- // Matches dashed string for camelizing
- rmsPrefix = /^-ms-/,
- rdashAlpha = /-([\da-z])/gi,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return letter.toUpperCase();
- };
-
-jQuery.fn = jQuery.prototype = {
-
- // The current version of jQuery being used
- jquery: version,
-
- constructor: jQuery,
-
- // Start with an empty selector
- selector: "",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- toArray: function() {
- return slice.call( this );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num != null ?
-
- // Return just the one element from the set
- ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
-
- // Return all the elements in a clean array
- slice.call( this );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems ) {
-
- // Build a new jQuery matched element set
- var ret = jQuery.merge( this.constructor(), elems );
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
- ret.context = this.context;
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- each: function( callback ) {
- return jQuery.each( this, callback );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map( this, function( elem, i ) {
- return callback.call( elem, i, elem );
- } ) );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ) );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- eq: function( i ) {
- var len = this.length,
- j = +i + ( i < 0 ? len : 0 );
- return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
- },
-
- end: function() {
- return this.prevObject || this.constructor();
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: deletedIds.sort,
- splice: deletedIds.splice
-};
-
-jQuery.extend = jQuery.fn.extend = function() {
- var src, copyIsArray, copy, name, options, clone,
- target = arguments[ 0 ] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
-
- // skip the boolean and the target
- target = arguments[ i ] || {};
- i++;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( i === length ) {
- target = this;
- i--;
- }
-
- for ( ; i < length; i++ ) {
-
- // Only deal with non-null/undefined values
- if ( ( options = arguments[ i ] ) != null ) {
-
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
- ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
-
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray( src ) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject( src ) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend( {
-
- // Unique for each copy of jQuery on the page
- expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
-
- // Assume jQuery is ready without the ready module
- isReady: true,
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- noop: function() {},
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type( obj ) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type( obj ) === "array";
- },
-
- isWindow: function( obj ) {
- /* jshint eqeqeq: false */
- return obj != null && obj == obj.window;
- },
-
- isNumeric: function( obj ) {
-
- // parseFloat NaNs numeric-cast false positives (null|true|false|"")
- // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
- // subtraction forces infinities to NaN
- // adding 1 corrects loss of precision from parseFloat (#15100)
- var realStringObj = obj && obj.toString();
- return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
- },
-
- isEmptyObject: function( obj ) {
- var name;
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- isPlainObject: function( obj ) {
- var key;
-
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
-
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call( obj, "constructor" ) &&
- !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
- return false;
- }
- } catch ( e ) {
-
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Support: IE<9
- // Handle iteration over inherited properties before own properties.
- if ( !support.ownFirst ) {
- for ( key in obj ) {
- return hasOwn.call( obj, key );
- }
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- for ( key in obj ) {}
-
- return key === undefined || hasOwn.call( obj, key );
- },
-
- type: function( obj ) {
- if ( obj == null ) {
- return obj + "";
- }
- return typeof obj === "object" || typeof obj === "function" ?
- class2type[ toString.call( obj ) ] || "object" :
- typeof obj;
- },
-
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && jQuery.trim( data ) ) {
-
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
- },
-
- each: function( obj, callback ) {
- var length, i = 0;
-
- if ( isArrayLike( obj ) ) {
- length = obj.length;
- for ( ; i < length; i++ ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- }
-
- return obj;
- },
-
- // Support: Android<4.1, IE<9
- trim: function( text ) {
- return text == null ?
- "" :
- ( text + "" ).replace( rtrim, "" );
- },
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var ret = results || [];
-
- if ( arr != null ) {
- if ( isArrayLike( Object( arr ) ) ) {
- jQuery.merge( ret,
- typeof arr === "string" ?
- [ arr ] : arr
- );
- } else {
- push.call( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- var len;
-
- if ( arr ) {
- if ( indexOf ) {
- return indexOf.call( arr, elem, i );
- }
-
- len = arr.length;
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
-
- for ( ; i < len; i++ ) {
-
- // Skip accessing in sparse arrays
- if ( i in arr && arr[ i ] === elem ) {
- return i;
- }
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var len = +second.length,
- j = 0,
- i = first.length;
-
- while ( j < len ) {
- first[ i++ ] = second[ j++ ];
- }
-
- // Support: IE<9
- // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
- if ( len !== len ) {
- while ( second[ j ] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, invert ) {
- var callbackInverse,
- matches = [],
- i = 0,
- length = elems.length,
- callbackExpect = !invert;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- callbackInverse = !callback( elems[ i ], i );
- if ( callbackInverse !== callbackExpect ) {
- matches.push( elems[ i ] );
- }
- }
-
- return matches;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var length, value,
- i = 0,
- ret = [];
-
- // Go through the array, translating each of the items to their new values
- if ( isArrayLike( elems ) ) {
- length = elems.length;
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( i in elems ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
- }
-
- // Flatten any nested arrays
- return concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- var args, proxy, tmp;
-
- if ( typeof context === "string" ) {
- tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- args = slice.call( arguments, 2 );
- proxy = function() {
- return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || jQuery.guid++;
-
- return proxy;
- },
-
- now: function() {
- return +( new Date() );
- },
-
- // jQuery.support is not used in Core but other projects attach their
- // properties to it so it needs to exist.
- support: support
-} );
-
-// JSHint would error on this code due to the Symbol not being defined in ES5.
-// Defining this global in .jshintrc would create a danger of using the global
-// unguarded in another place, it seems safer to just disable JSHint for these
-// three lines.
-/* jshint ignore: start */
-if ( typeof Symbol === "function" ) {
- jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
-}
-/* jshint ignore: end */
-
-// Populate the class2type map
-jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
-function( i, name ) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-} );
-
-function isArrayLike( obj ) {
-
- // Support: iOS 8.2 (not reproducible in simulator)
- // `in` check used to prevent JIT error (gh-2145)
- // hasOwn isn't used here due to false negatives
- // regarding Nodelist length in IE
- var length = !!obj && "length" in obj && obj.length,
- type = jQuery.type( obj );
-
- if ( type === "function" || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- return type === "array" || length === 0 ||
- typeof length === "number" && length > 0 && ( length - 1 ) in obj;
-}
-var Sizzle =
-/*!
- * Sizzle CSS Selector Engine v2.2.1
- * http://sizzlejs.com/
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license
- * http://jquery.org/license
- *
- * Date: 2015-10-17
- */
-(function( window ) {
-
-var i,
- support,
- Expr,
- getText,
- isXML,
- tokenize,
- compile,
- select,
- outermostContext,
- sortInput,
- hasDuplicate,
-
- // Local document vars
- setDocument,
- document,
- docElem,
- documentIsHTML,
- rbuggyQSA,
- rbuggyMatches,
- matches,
- contains,
-
- // Instance-specific data
- expando = "sizzle" + 1 * new Date(),
- preferredDoc = window.document,
- dirruns = 0,
- done = 0,
- classCache = createCache(),
- tokenCache = createCache(),
- compilerCache = createCache(),
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- }
- return 0;
- },
-
- // General-purpose constants
- MAX_NEGATIVE = 1 << 31,
-
- // Instance methods
- hasOwn = ({}).hasOwnProperty,
- arr = [],
- pop = arr.pop,
- push_native = arr.push,
- push = arr.push,
- slice = arr.slice,
- // Use a stripped-down indexOf as it's faster than native
- // http://jsperf.com/thor-indexof-vs-for/5
- indexOf = function( list, elem ) {
- var i = 0,
- len = list.length;
- for ( ; i < len; i++ ) {
- if ( list[i] === elem ) {
- return i;
- }
- }
- return -1;
- },
-
- booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
-
- // Regular expressions
-
- // http://www.w3.org/TR/css3-selectors/#whitespace
- whitespace = "[\\x20\\t\\r\\n\\f]",
-
- // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
- identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
-
- // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
- attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
- // Operator (capture 2)
- "*([*^$|!~]?=)" + whitespace +
- // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
- "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
- "*\\]",
-
- pseudos = ":(" + identifier + ")(?:\\((" +
- // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
- // 1. quoted (capture 3; capture 4 or capture 5)
- "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
- // 2. simple (capture 6)
- "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
- // 3. anything else (capture 2)
- ".*" +
- ")\\)|)",
-
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
- rwhitespace = new RegExp( whitespace + "+", "g" ),
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
-
- rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
- rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
-
- rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
-
- rpseudo = new RegExp( pseudos ),
- ridentifier = new RegExp( "^" + identifier + "$" ),
-
- matchExpr = {
- "ID": new RegExp( "^#(" + identifier + ")" ),
- "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
- "TAG": new RegExp( "^(" + identifier + "|[*])" ),
- "ATTR": new RegExp( "^" + attributes ),
- "PSEUDO": new RegExp( "^" + pseudos ),
- "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
- "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
- "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
- // For use in libraries implementing .is()
- // We use this for POS matching in `select`
- "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
- whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
- },
-
- rinputs = /^(?:input|select|textarea|button)$/i,
- rheader = /^h\d$/i,
-
- rnative = /^[^{]+\{\s*\[native \w/,
-
- // Easily-parseable/retrievable ID or TAG or CLASS selectors
- rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
-
- rsibling = /[+~]/,
- rescape = /'|\\/g,
-
- // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
- runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
- funescape = function( _, escaped, escapedWhitespace ) {
- var high = "0x" + escaped - 0x10000;
- // NaN means non-codepoint
- // Support: Firefox<24
- // Workaround erroneous numeric interpretation of +"0x"
- return high !== high || escapedWhitespace ?
- escaped :
- high < 0 ?
- // BMP codepoint
- String.fromCharCode( high + 0x10000 ) :
- // Supplemental Plane codepoint (surrogate pair)
- String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
- },
-
- // Used for iframes
- // See setDocument()
- // Removing the function wrapper causes a "Permission Denied"
- // error in IE
- unloadHandler = function() {
- setDocument();
- };
-
-// Optimize for push.apply( _, NodeList )
-try {
- push.apply(
- (arr = slice.call( preferredDoc.childNodes )),
- preferredDoc.childNodes
- );
- // Support: Android<4.0
- // Detect silently failing push.apply
- arr[ preferredDoc.childNodes.length ].nodeType;
-} catch ( e ) {
- push = { apply: arr.length ?
-
- // Leverage slice if possible
- function( target, els ) {
- push_native.apply( target, slice.call(els) );
- } :
-
- // Support: IE<9
- // Otherwise append directly
- function( target, els ) {
- var j = target.length,
- i = 0;
- // Can't trust NodeList.length
- while ( (target[j++] = els[i++]) ) {}
- target.length = j - 1;
- }
- };
-}
-
-function Sizzle( selector, context, results, seed ) {
- var m, i, elem, nid, nidselect, match, groups, newSelector,
- newContext = context && context.ownerDocument,
-
- // nodeType defaults to 9, since context defaults to document
- nodeType = context ? context.nodeType : 9;
-
- results = results || [];
-
- // Return early from calls with invalid selector or context
- if ( typeof selector !== "string" || !selector ||
- nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
-
- return results;
- }
-
- // Try to shortcut find operations (as opposed to filters) in HTML documents
- if ( !seed ) {
-
- if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
- setDocument( context );
- }
- context = context || document;
-
- if ( documentIsHTML ) {
-
- // If the selector is sufficiently simple, try using a "get*By*" DOM method
- // (excepting DocumentFragment context, where the methods don't exist)
- if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
-
- // ID selector
- if ( (m = match[1]) ) {
-
- // Document context
- if ( nodeType === 9 ) {
- if ( (elem = context.getElementById( m )) ) {
-
- // Support: IE, Opera, Webkit
- // TODO: identify versions
- // getElementById can match elements by name instead of ID
- if ( elem.id === m ) {
- results.push( elem );
- return results;
- }
- } else {
- return results;
- }
-
- // Element context
- } else {
-
- // Support: IE, Opera, Webkit
- // TODO: identify versions
- // getElementById can match elements by name instead of ID
- if ( newContext && (elem = newContext.getElementById( m )) &&
- contains( context, elem ) &&
- elem.id === m ) {
-
- results.push( elem );
- return results;
- }
- }
-
- // Type selector
- } else if ( match[2] ) {
- push.apply( results, context.getElementsByTagName( selector ) );
- return results;
-
- // Class selector
- } else if ( (m = match[3]) && support.getElementsByClassName &&
- context.getElementsByClassName ) {
-
- push.apply( results, context.getElementsByClassName( m ) );
- return results;
- }
- }
-
- // Take advantage of querySelectorAll
- if ( support.qsa &&
- !compilerCache[ selector + " " ] &&
- (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
-
- if ( nodeType !== 1 ) {
- newContext = context;
- newSelector = selector;
-
- // qSA looks outside Element context, which is not what we want
- // Thanks to Andrew Dupont for this workaround technique
- // Support: IE <=8
- // Exclude object elements
- } else if ( context.nodeName.toLowerCase() !== "object" ) {
-
- // Capture the context ID, setting it first if necessary
- if ( (nid = context.getAttribute( "id" )) ) {
- nid = nid.replace( rescape, "\\$&" );
- } else {
- context.setAttribute( "id", (nid = expando) );
- }
-
- // Prefix every selector in the list
- groups = tokenize( selector );
- i = groups.length;
- nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
- while ( i-- ) {
- groups[i] = nidselect + " " + toSelector( groups[i] );
- }
- newSelector = groups.join( "," );
-
- // Expand context for sibling selectors
- newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
- context;
- }
-
- if ( newSelector ) {
- try {
- push.apply( results,
- newContext.querySelectorAll( newSelector )
- );
- return results;
- } catch ( qsaError ) {
- } finally {
- if ( nid === expando ) {
- context.removeAttribute( "id" );
- }
- }
- }
- }
- }
- }
-
- // All others
- return select( selector.replace( rtrim, "$1" ), context, results, seed );
-}
-
-/**
- * Create key-value caches of limited size
- * @returns {function(string, object)} Returns the Object data after storing it on itself with
- * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
- * deleting the oldest entry
- */
-function createCache() {
- var keys = [];
-
- function cache( key, value ) {
- // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
- if ( keys.push( key + " " ) > Expr.cacheLength ) {
- // Only keep the most recent entries
- delete cache[ keys.shift() ];
- }
- return (cache[ key + " " ] = value);
- }
- return cache;
-}
-
-/**
- * Mark a function for special use by Sizzle
- * @param {Function} fn The function to mark
- */
-function markFunction( fn ) {
- fn[ expando ] = true;
- return fn;
-}
-
-/**
- * Support testing using an element
- * @param {Function} fn Passed the created div and expects a boolean result
- */
-function assert( fn ) {
- var div = document.createElement("div");
-
- try {
- return !!fn( div );
- } catch (e) {
- return false;
- } finally {
- // Remove from its parent by default
- if ( div.parentNode ) {
- div.parentNode.removeChild( div );
- }
- // release memory in IE
- div = null;
- }
-}
-
-/**
- * Adds the same handler for all of the specified attrs
- * @param {String} attrs Pipe-separated list of attributes
- * @param {Function} handler The method that will be applied
- */
-function addHandle( attrs, handler ) {
- var arr = attrs.split("|"),
- i = arr.length;
-
- while ( i-- ) {
- Expr.attrHandle[ arr[i] ] = handler;
- }
-}
-
-/**
- * Checks document order of two siblings
- * @param {Element} a
- * @param {Element} b
- * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
- */
-function siblingCheck( a, b ) {
- var cur = b && a,
- diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
- ( ~b.sourceIndex || MAX_NEGATIVE ) -
- ( ~a.sourceIndex || MAX_NEGATIVE );
-
- // Use IE sourceIndex if available on both nodes
- if ( diff ) {
- return diff;
- }
-
- // Check if b follows a
- if ( cur ) {
- while ( (cur = cur.nextSibling) ) {
- if ( cur === b ) {
- return -1;
- }
- }
- }
-
- return a ? 1 : -1;
-}
-
-/**
- * Returns a function to use in pseudos for input types
- * @param {String} type
- */
-function createInputPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for buttons
- * @param {String} type
- */
-function createButtonPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return (name === "input" || name === "button") && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for positionals
- * @param {Function} fn
- */
-function createPositionalPseudo( fn ) {
- return markFunction(function( argument ) {
- argument = +argument;
- return markFunction(function( seed, matches ) {
- var j,
- matchIndexes = fn( [], seed.length, argument ),
- i = matchIndexes.length;
-
- // Match elements found at the specified indexes
- while ( i-- ) {
- if ( seed[ (j = matchIndexes[i]) ] ) {
- seed[j] = !(matches[j] = seed[j]);
- }
- }
- });
- });
-}
-
-/**
- * Checks a node for validity as a Sizzle context
- * @param {Element|Object=} context
- * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
- */
-function testContext( context ) {
- return context && typeof context.getElementsByTagName !== "undefined" && context;
-}
-
-// Expose support vars for convenience
-support = Sizzle.support = {};
-
-/**
- * Detects XML nodes
- * @param {Element|Object} elem An element or a document
- * @returns {Boolean} True iff elem is a non-HTML XML node
- */
-isXML = Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = elem && (elem.ownerDocument || elem).documentElement;
- return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-/**
- * Sets document-related variables once based on the current document
- * @param {Element|Object} [doc] An element or document object to use to set the document
- * @returns {Object} Returns the current document
- */
-setDocument = Sizzle.setDocument = function( node ) {
- var hasCompare, parent,
- doc = node ? node.ownerDocument || node : preferredDoc;
-
- // Return early if doc is invalid or already selected
- if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
- return document;
- }
-
- // Update global variables
- document = doc;
- docElem = document.documentElement;
- documentIsHTML = !isXML( document );
-
- // Support: IE 9-11, Edge
- // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
- if ( (parent = document.defaultView) && parent.top !== parent ) {
- // Support: IE 11
- if ( parent.addEventListener ) {
- parent.addEventListener( "unload", unloadHandler, false );
-
- // Support: IE 9 - 10 only
- } else if ( parent.attachEvent ) {
- parent.attachEvent( "onunload", unloadHandler );
- }
- }
-
- /* Attributes
- ---------------------------------------------------------------------- */
-
- // Support: IE<8
- // Verify that getAttribute really returns attributes and not properties
- // (excepting IE8 booleans)
- support.attributes = assert(function( div ) {
- div.className = "i";
- return !div.getAttribute("className");
- });
-
- /* getElement(s)By*
- ---------------------------------------------------------------------- */
-
- // Check if getElementsByTagName("*") returns only elements
- support.getElementsByTagName = assert(function( div ) {
- div.appendChild( document.createComment("") );
- return !div.getElementsByTagName("*").length;
- });
-
- // Support: IE<9
- support.getElementsByClassName = rnative.test( document.getElementsByClassName );
-
- // Support: IE<10
- // Check if getElementById returns elements by name
- // The broken getElementById methods don't pick up programatically-set names,
- // so use a roundabout getElementsByName test
- support.getById = assert(function( div ) {
- docElem.appendChild( div ).id = expando;
- return !document.getElementsByName || !document.getElementsByName( expando ).length;
- });
-
- // ID find and filter
- if ( support.getById ) {
- Expr.find["ID"] = function( id, context ) {
- if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
- var m = context.getElementById( id );
- return m ? [ m ] : [];
- }
- };
- Expr.filter["ID"] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- return elem.getAttribute("id") === attrId;
- };
- };
- } else {
- // Support: IE6/7
- // getElementById is not reliable as a find shortcut
- delete Expr.find["ID"];
-
- Expr.filter["ID"] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- var node = typeof elem.getAttributeNode !== "undefined" &&
- elem.getAttributeNode("id");
- return node && node.value === attrId;
- };
- };
- }
-
- // Tag
- Expr.find["TAG"] = support.getElementsByTagName ?
- function( tag, context ) {
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- return context.getElementsByTagName( tag );
-
- // DocumentFragment nodes don't have gEBTN
- } else if ( support.qsa ) {
- return context.querySelectorAll( tag );
- }
- } :
-
- function( tag, context ) {
- var elem,
- tmp = [],
- i = 0,
- // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
- results = context.getElementsByTagName( tag );
-
- // Filter out possible comments
- if ( tag === "*" ) {
- while ( (elem = results[i++]) ) {
- if ( elem.nodeType === 1 ) {
- tmp.push( elem );
- }
- }
-
- return tmp;
- }
- return results;
- };
-
- // Class
- Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
- if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
- return context.getElementsByClassName( className );
- }
- };
-
- /* QSA/matchesSelector
- ---------------------------------------------------------------------- */
-
- // QSA and matchesSelector support
-
- // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
- rbuggyMatches = [];
-
- // qSa(:focus) reports false when true (Chrome 21)
- // We allow this because of a bug in IE8/9 that throws an error
- // whenever `document.activeElement` is accessed on an iframe
- // So, we allow :focus to pass through QSA all the time to avoid the IE error
- // See http://bugs.jquery.com/ticket/13378
- rbuggyQSA = [];
-
- if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
- // Build QSA regex
- // Regex strategy adopted from Diego Perini
- assert(function( div ) {
- // Select is set to empty string on purpose
- // This is to test IE's treatment of not explicitly
- // setting a boolean content attribute,
- // since its presence should be enough
- // http://bugs.jquery.com/ticket/12359
- docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
- "<select id='" + expando + "-\r\\' msallowcapture=''>" +
- "<option selected=''></option></select>";
-
- // Support: IE8, Opera 11-12.16
- // Nothing should be selected when empty strings follow ^= or $= or *=
- // The test attribute must be unknown in Opera but "safe" for WinRT
- // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
- if ( div.querySelectorAll("[msallowcapture^='']").length ) {
- rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
- }
-
- // Support: IE8
- // Boolean attributes and "value" are not treated correctly
- if ( !div.querySelectorAll("[selected]").length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
- }
-
- // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
- if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
- rbuggyQSA.push("~=");
- }
-
- // Webkit/Opera - :checked should return selected option elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- // IE8 throws error here and will not see later tests
- if ( !div.querySelectorAll(":checked").length ) {
- rbuggyQSA.push(":checked");
- }
-
- // Support: Safari 8+, iOS 8+
- // https://bugs.webkit.org/show_bug.cgi?id=136851
- // In-page `selector#id sibing-combinator selector` fails
- if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
- rbuggyQSA.push(".#.+[+~]");
- }
- });
-
- assert(function( div ) {
- // Support: Windows 8 Native Apps
- // The type and name attributes are restricted during .innerHTML assignment
- var input = document.createElement("input");
- input.setAttribute( "type", "hidden" );
- div.appendChild( input ).setAttribute( "name", "D" );
-
- // Support: IE8
- // Enforce case-sensitivity of name attribute
- if ( div.querySelectorAll("[name=d]").length ) {
- rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
- }
-
- // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
- // IE8 throws error here and will not see later tests
- if ( !div.querySelectorAll(":enabled").length ) {
- rbuggyQSA.push( ":enabled", ":disabled" );
- }
-
- // Opera 10-11 does not throw on post-comma invalid pseudos
- div.querySelectorAll("*,:x");
- rbuggyQSA.push(",.*:");
- });
- }
-
- if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
- docElem.webkitMatchesSelector ||
- docElem.mozMatchesSelector ||
- docElem.oMatchesSelector ||
- docElem.msMatchesSelector) )) ) {
-
- assert(function( div ) {
- // Check to see if it's possible to do matchesSelector
- // on a disconnected node (IE 9)
- support.disconnectedMatch = matches.call( div, "div" );
-
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( div, "[s!='']:x" );
- rbuggyMatches.push( "!=", pseudos );
- });
- }
-
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
- rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
-
- /* Contains
- ---------------------------------------------------------------------- */
- hasCompare = rnative.test( docElem.compareDocumentPosition );
-
- // Element contains another
- // Purposefully self-exclusive
- // As in, an element does not contain itself
- contains = hasCompare || rnative.test( docElem.contains ) ?
- function( a, b ) {
- var adown = a.nodeType === 9 ? a.documentElement : a,
- bup = b && b.parentNode;
- return a === bup || !!( bup && bup.nodeType === 1 && (
- adown.contains ?
- adown.contains( bup ) :
- a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
- ));
- } :
- function( a, b ) {
- if ( b ) {
- while ( (b = b.parentNode) ) {
- if ( b === a ) {
- return true;
- }
- }
- }
- return false;
- };
-
- /* Sorting
- ---------------------------------------------------------------------- */
-
- // Document order sorting
- sortOrder = hasCompare ?
- function( a, b ) {
-
- // Flag for duplicate removal
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- // Sort on method existence if only one input has compareDocumentPosition
- var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
- if ( compare ) {
- return compare;
- }
-
- // Calculate position if both inputs belong to the same document
- compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
- a.compareDocumentPosition( b ) :
-
- // Otherwise we know they are disconnected
- 1;
-
- // Disconnected nodes
- if ( compare & 1 ||
- (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
-
- // Choose the first element that is related to our preferred document
- if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
- return -1;
- }
- if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
- return 1;
- }
-
- // Maintain original order
- return sortInput ?
- ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
- 0;
- }
-
- return compare & 4 ? -1 : 1;
- } :
- function( a, b ) {
- // Exit early if the nodes are identical
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- var cur,
- i = 0,
- aup = a.parentNode,
- bup = b.parentNode,
- ap = [ a ],
- bp = [ b ];
-
- // Parentless nodes are either documents or disconnected
- if ( !aup || !bup ) {
- return a === document ? -1 :
- b === document ? 1 :
- aup ? -1 :
- bup ? 1 :
- sortInput ?
- ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
- 0;
-
- // If the nodes are siblings, we can do a quick check
- } else if ( aup === bup ) {
- return siblingCheck( a, b );
- }
-
- // Otherwise we need full lists of their ancestors for comparison
- cur = a;
- while ( (cur = cur.parentNode) ) {
- ap.unshift( cur );
- }
- cur = b;
- while ( (cur = cur.parentNode) ) {
- bp.unshift( cur );
- }
-
- // Walk down the tree looking for a discrepancy
- while ( ap[i] === bp[i] ) {
- i++;
- }
-
- return i ?
- // Do a sibling check if the nodes have a common ancestor
- siblingCheck( ap[i], bp[i] ) :
-
- // Otherwise nodes in our document sort first
- ap[i] === preferredDoc ? -1 :
- bp[i] === preferredDoc ? 1 :
- 0;
- };
-
- return document;
-};
-
-Sizzle.matches = function( expr, elements ) {
- return Sizzle( expr, null, null, elements );
-};
-
-Sizzle.matchesSelector = function( elem, expr ) {
- // Set document vars if needed
- if ( ( elem.ownerDocument || elem ) !== document ) {
- setDocument( elem );
- }
-
- // Make sure that attribute selectors are quoted
- expr = expr.replace( rattributeQuotes, "='$1']" );
-
- if ( support.matchesSelector && documentIsHTML &&
- !compilerCache[ expr + " " ] &&
- ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
- ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
-
- try {
- var ret = matches.call( elem, expr );
-
- // IE 9's matchesSelector returns false on disconnected nodes
- if ( ret || support.disconnectedMatch ||
- // As well, disconnected nodes are said to be in a document
- // fragment in IE 9
- elem.document && elem.document.nodeType !== 11 ) {
- return ret;
- }
- } catch (e) {}
- }
-
- return Sizzle( expr, document, null, [ elem ] ).length > 0;
-};
-
-Sizzle.contains = function( context, elem ) {
- // Set document vars if needed
- if ( ( context.ownerDocument || context ) !== document ) {
- setDocument( context );
- }
- return contains( context, elem );
-};
-
-Sizzle.attr = function( elem, name ) {
- // Set document vars if needed
- if ( ( elem.ownerDocument || elem ) !== document ) {
- setDocument( elem );
- }
-
- var fn = Expr.attrHandle[ name.toLowerCase() ],
- // Don't get fooled by Object.prototype properties (jQuery #13807)
- val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
- fn( elem, name, !documentIsHTML ) :
- undefined;
-
- return val !== undefined ?
- val :
- support.attributes || !documentIsHTML ?
- elem.getAttribute( name ) :
- (val = elem.getAttributeNode(name)) && val.specified ?
- val.value :
- null;
-};
-
-Sizzle.error = function( msg ) {
- throw new Error( "Syntax error, unrecognized expression: " + msg );
-};
-
-/**
- * Document sorting and removing duplicates
- * @param {ArrayLike} results
- */
-Sizzle.uniqueSort = function( results ) {
- var elem,
- duplicates = [],
- j = 0,
- i = 0;
-
- // Unless we *know* we can detect duplicates, assume their presence
- hasDuplicate = !support.detectDuplicates;
- sortInput = !support.sortStable && results.slice( 0 );
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- while ( (elem = results[i++]) ) {
- if ( elem === results[ i ] ) {
- j = duplicates.push( i );
- }
- }
- while ( j-- ) {
- results.splice( duplicates[ j ], 1 );
- }
- }
-
- // Clear input after sorting to release objects
- // See https://github.com/jquery/sizzle/pull/225
- sortInput = null;
-
- return results;
-};
-
-/**
- * Utility function for retrieving the text value of an array of DOM nodes
- * @param {Array|Element} elem
- */
-getText = Sizzle.getText = function( elem ) {
- var node,
- ret = "",
- i = 0,
- nodeType = elem.nodeType;
-
- if ( !nodeType ) {
- // If no nodeType, this is expected to be an array
- while ( (node = elem[i++]) ) {
- // Do not traverse comment nodes
- ret += getText( node );
- }
- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
- // Use textContent for elements
- // innerText usage removed for consistency of new lines (jQuery #11153)
- if ( typeof elem.textContent === "string" ) {
- return elem.textContent;
- } else {
- // Traverse its children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- ret += getText( elem );
- }
- }
- } else if ( nodeType === 3 || nodeType === 4 ) {
- return elem.nodeValue;
- }
- // Do not include comment or processing instruction nodes
-
- return ret;
-};
-
-Expr = Sizzle.selectors = {
-
- // Can be adjusted by the user
- cacheLength: 50,
-
- createPseudo: markFunction,
-
- match: matchExpr,
-
- attrHandle: {},
-
- find: {},
-
- relative: {
- ">": { dir: "parentNode", first: true },
- " ": { dir: "parentNode" },
- "+": { dir: "previousSibling", first: true },
- "~": { dir: "previousSibling" }
- },
-
- preFilter: {
- "ATTR": function( match ) {
- match[1] = match[1].replace( runescape, funescape );
-
- // Move the given value to match[3] whether quoted or unquoted
- match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
-
- if ( match[2] === "~=" ) {
- match[3] = " " + match[3] + " ";
- }
-
- return match.slice( 0, 4 );
- },
-
- "CHILD": function( match ) {
- /* matches from matchExpr["CHILD"]
- 1 type (only|nth|...)
- 2 what (child|of-type)
- 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
- 4 xn-component of xn+y argument ([+-]?\d*n|)
- 5 sign of xn-component
- 6 x of xn-component
- 7 sign of y-component
- 8 y of y-component
- */
- match[1] = match[1].toLowerCase();
-
- if ( match[1].slice( 0, 3 ) === "nth" ) {
- // nth-* requires argument
- if ( !match[3] ) {
- Sizzle.error( match[0] );
- }
-
- // numeric x and y parameters for Expr.filter.CHILD
- // remember that false/true cast respectively to 0/1
- match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
- match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
-
- // other types prohibit arguments
- } else if ( match[3] ) {
- Sizzle.error( match[0] );
- }
-
- return match;
- },
-
- "PSEUDO": function( match ) {
- var excess,
- unquoted = !match[6] && match[2];
-
- if ( matchExpr["CHILD"].test( match[0] ) ) {
- return null;
- }
-
- // Accept quoted arguments as-is
- if ( match[3] ) {
- match[2] = match[4] || match[5] || "";
-
- // Strip excess characters from unquoted arguments
- } else if ( unquoted && rpseudo.test( unquoted ) &&
- // Get excess from tokenize (recursively)
- (excess = tokenize( unquoted, true )) &&
- // advance to the next closing parenthesis
- (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
-
- // excess is a negative index
- match[0] = match[0].slice( 0, excess );
- match[2] = unquoted.slice( 0, excess );
- }
-
- // Return only captures needed by the pseudo filter method (type and argument)
- return match.slice( 0, 3 );
- }
- },
-
- filter: {
-
- "TAG": function( nodeNameSelector ) {
- var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
- return nodeNameSelector === "*" ?
- function() { return true; } :
- function( elem ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
- };
- },
-
- "CLASS": function( className ) {
- var pattern = classCache[ className + " " ];
-
- return pattern ||
- (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
- classCache( className, function( elem ) {
- return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
- });
- },
-
- "ATTR": function( name, operator, check ) {
- return function( elem ) {
- var result = Sizzle.attr( elem, name );
-
- if ( result == null ) {
- return operator === "!=";
- }
- if ( !operator ) {
- return true;
- }
-
- result += "";
-
- return operator === "=" ? result === check :
- operator === "!=" ? result !== check :
- operator === "^=" ? check && result.indexOf( check ) === 0 :
- operator === "*=" ? check && result.indexOf( check ) > -1 :
- operator === "$=" ? check && result.slice( -check.length ) === check :
- operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
- operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
- false;
- };
- },
-
- "CHILD": function( type, what, argument, first, last ) {
- var simple = type.slice( 0, 3 ) !== "nth",
- forward = type.slice( -4 ) !== "last",
- ofType = what === "of-type";
-
- return first === 1 && last === 0 ?
-
- // Shortcut for :nth-*(n)
- function( elem ) {
- return !!elem.parentNode;
- } :
-
- function( elem, context, xml ) {
- var cache, uniqueCache, outerCache, node, nodeIndex, start,
- dir = simple !== forward ? "nextSibling" : "previousSibling",
- parent = elem.parentNode,
- name = ofType && elem.nodeName.toLowerCase(),
- useCache = !xml && !ofType,
- diff = false;
-
- if ( parent ) {
-
- // :(first|last|only)-(child|of-type)
- if ( simple ) {
- while ( dir ) {
- node = elem;
- while ( (node = node[ dir ]) ) {
- if ( ofType ?
- node.nodeName.toLowerCase() === name :
- node.nodeType === 1 ) {
-
- return false;
- }
- }
- // Reverse direction for :only-* (if we haven't yet done so)
- start = dir = type === "only" && !start && "nextSibling";
- }
- return true;
- }
-
- start = [ forward ? parent.firstChild : parent.lastChild ];
-
- // non-xml :nth-child(...) stores cache data on `parent`
- if ( forward && useCache ) {
-
- // Seek `elem` from a previously-cached index
-
- // ...in a gzip-friendly way
- node = parent;
- outerCache = node[ expando ] || (node[ expando ] = {});
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- (outerCache[ node.uniqueID ] = {});
-
- cache = uniqueCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex && cache[ 2 ];
- node = nodeIndex && parent.childNodes[ nodeIndex ];
-
- while ( (node = ++nodeIndex && node && node[ dir ] ||
-
- // Fallback to seeking `elem` from the start
- (diff = nodeIndex = 0) || start.pop()) ) {
-
- // When found, cache indexes on `parent` and break
- if ( node.nodeType === 1 && ++diff && node === elem ) {
- uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
- break;
- }
- }
-
- } else {
- // Use previously-cached element index if available
- if ( useCache ) {
- // ...in a gzip-friendly way
- node = elem;
- outerCache = node[ expando ] || (node[ expando ] = {});
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- (outerCache[ node.uniqueID ] = {});
-
- cache = uniqueCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex;
- }
-
- // xml :nth-child(...)
- // or :nth-last-child(...) or :nth(-last)?-of-type(...)
- if ( diff === false ) {
- // Use the same loop as above to seek `elem` from the start
- while ( (node = ++nodeIndex && node && node[ dir ] ||
- (diff = nodeIndex = 0) || start.pop()) ) {
-
- if ( ( ofType ?
- node.nodeName.toLowerCase() === name :
- node.nodeType === 1 ) &&
- ++diff ) {
-
- // Cache the index of each encountered element
- if ( useCache ) {
- outerCache = node[ expando ] || (node[ expando ] = {});
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ node.uniqueID ] ||
- (outerCache[ node.uniqueID ] = {});
-
- uniqueCache[ type ] = [ dirruns, diff ];
- }
-
- if ( node === elem ) {
- break;
- }
- }
- }
- }
- }
-
- // Incorporate the offset, then check against cycle size
- diff -= last;
- return diff === first || ( diff % first === 0 && diff / first >= 0 );
- }
- };
- },
-
- "PSEUDO": function( pseudo, argument ) {
- // pseudo-class names are case-insensitive
- // http://www.w3.org/TR/selectors/#pseudo-classes
- // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
- // Remember that setFilters inherits from pseudos
- var args,
- fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
- Sizzle.error( "unsupported pseudo: " + pseudo );
-
- // The user may use createPseudo to indicate that
- // arguments are needed to create the filter function
- // just as Sizzle does
- if ( fn[ expando ] ) {
- return fn( argument );
- }
-
- // But maintain support for old signatures
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
- markFunction(function( seed, matches ) {
- var idx,
- matched = fn( seed, argument ),
- i = matched.length;
- while ( i-- ) {
- idx = indexOf( seed, matched[i] );
- seed[ idx ] = !( matches[ idx ] = matched[i] );
- }
- }) :
- function( elem ) {
- return fn( elem, 0, args );
- };
- }
-
- return fn;
- }
- },
-
- pseudos: {
- // Potentially complex pseudos
- "not": markFunction(function( selector ) {
- // Trim the selector passed to compile
- // to avoid treating leading and trailing
- // spaces as combinators
- var input = [],
- results = [],
- matcher = compile( selector.replace( rtrim, "$1" ) );
-
- return matcher[ expando ] ?
- markFunction(function( seed, matches, context, xml ) {
- var elem,
- unmatched = matcher( seed, null, xml, [] ),
- i = seed.length;
-
- // Match elements unmatched by `matcher`
- while ( i-- ) {
- if ( (elem = unmatched[i]) ) {
- seed[i] = !(matches[i] = elem);
- }
- }
- }) :
- function( elem, context, xml ) {
- input[0] = elem;
- matcher( input, null, xml, results );
- // Don't keep the element (issue #299)
- input[0] = null;
- return !results.pop();
- };
- }),
-
- "has": markFunction(function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- }),
-
- "contains": markFunction(function( text ) {
- text = text.replace( runescape, funescape );
- return function( elem ) {
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
- };
- }),
-
- // "Whether an element is represented by a :lang() selector
- // is based solely on the element's language value
- // being equal to the identifier C,
- // or beginning with the identifier C immediately followed by "-".
- // The matching of C against the element's language value is performed case-insensitively.
- // The identifier C does not have to be a valid language name."
- // http://www.w3.org/TR/selectors/#lang-pseudo
- "lang": markFunction( function( lang ) {
- // lang value must be a valid identifier
- if ( !ridentifier.test(lang || "") ) {
- Sizzle.error( "unsupported lang: " + lang );
- }
- lang = lang.replace( runescape, funescape ).toLowerCase();
- return function( elem ) {
- var elemLang;
- do {
- if ( (elemLang = documentIsHTML ?
- elem.lang :
- elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
-
- elemLang = elemLang.toLowerCase();
- return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
- }
- } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
- return false;
- };
- }),
-
- // Miscellaneous
- "target": function( elem ) {
- var hash = window.location && window.location.hash;
- return hash && hash.slice( 1 ) === elem.id;
- },
-
- "root": function( elem ) {
- return elem === docElem;
- },
-
- "focus": function( elem ) {
- return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
- },
-
- // Boolean properties
- "enabled": function( elem ) {
- return elem.disabled === false;
- },
-
- "disabled": function( elem ) {
- return elem.disabled === true;
- },
-
- "checked": function( elem ) {
- // In CSS3, :checked should return both checked and selected elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- var nodeName = elem.nodeName.toLowerCase();
- return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
- },
-
- "selected": function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- if ( elem.parentNode ) {
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- // Contents
- "empty": function( elem ) {
- // http://www.w3.org/TR/selectors/#empty-pseudo
- // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
- // but not by others (comment: 8; processing instruction: 7; etc.)
- // nodeType < 6 works because attributes (2) do not appear as children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- if ( elem.nodeType < 6 ) {
- return false;
- }
- }
- return true;
- },
-
- "parent": function( elem ) {
- return !Expr.pseudos["empty"]( elem );
- },
-
- // Element/input types
- "header": function( elem ) {
- return rheader.test( elem.nodeName );
- },
-
- "input": function( elem ) {
- return rinputs.test( elem.nodeName );
- },
-
- "button": function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === "button" || name === "button";
- },
-
- "text": function( elem ) {
- var attr;
- return elem.nodeName.toLowerCase() === "input" &&
- elem.type === "text" &&
-
- // Support: IE<8
- // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
- ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
- },
-
- // Position-in-collection
- "first": createPositionalPseudo(function() {
- return [ 0 ];
- }),
-
- "last": createPositionalPseudo(function( matchIndexes, length ) {
- return [ length - 1 ];
- }),
-
- "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
- return [ argument < 0 ? argument + length : argument ];
- }),
-
- "even": createPositionalPseudo(function( matchIndexes, length ) {
- var i = 0;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "odd": createPositionalPseudo(function( matchIndexes, length ) {
- var i = 1;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; --i >= 0; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; ++i < length; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- })
- }
-};
-
-Expr.pseudos["nth"] = Expr.pseudos["eq"];
-
-// Add button/input type pseudos
-for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
- Expr.pseudos[ i ] = createInputPseudo( i );
-}
-for ( i in { submit: true, reset: true } ) {
- Expr.pseudos[ i ] = createButtonPseudo( i );
-}
-
-// Easy API for creating new setFilters
-function setFilters() {}
-setFilters.prototype = Expr.filters = Expr.pseudos;
-Expr.setFilters = new setFilters();
-
-tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
- var matched, match, tokens, type,
- soFar, groups, preFilters,
- cached = tokenCache[ selector + " " ];
-
- if ( cached ) {
- return parseOnly ? 0 : cached.slice( 0 );
- }
-
- soFar = selector;
- groups = [];
- preFilters = Expr.preFilter;
-
- while ( soFar ) {
-
- // Comma and first run
- if ( !matched || (match = rcomma.exec( soFar )) ) {
- if ( match ) {
- // Don't consume trailing commas as valid
- soFar = soFar.slice( match[0].length ) || soFar;
- }
- groups.push( (tokens = []) );
- }
-
- matched = false;
-
- // Combinators
- if ( (match = rcombinators.exec( soFar )) ) {
- matched = match.shift();
- tokens.push({
- value: matched,
- // Cast descendant combinators to space
- type: match[0].replace( rtrim, " " )
- });
- soFar = soFar.slice( matched.length );
- }
-
- // Filters
- for ( type in Expr.filter ) {
- if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
- (match = preFilters[ type ]( match ))) ) {
- matched = match.shift();
- tokens.push({
- value: matched,
- type: type,
- matches: match
- });
- soFar = soFar.slice( matched.length );
- }
- }
-
- if ( !matched ) {
- break;
- }
- }
-
- // Return the length of the invalid excess
- // if we're just parsing
- // Otherwise, throw an error or return tokens
- return parseOnly ?
- soFar.length :
- soFar ?
- Sizzle.error( selector ) :
- // Cache the tokens
- tokenCache( selector, groups ).slice( 0 );
-};
-
-function toSelector( tokens ) {
- var i = 0,
- len = tokens.length,
- selector = "";
- for ( ; i < len; i++ ) {
- selector += tokens[i].value;
- }
- return selector;
-}
-
-function addCombinator( matcher, combinator, base ) {
- var dir = combinator.dir,
- checkNonElements = base && dir === "parentNode",
- doneName = done++;
-
- return combinator.first ?
- // Check against closest ancestor/preceding element
- function( elem, context, xml ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- return matcher( elem, context, xml );
- }
- }
- } :
-
- // Check against all ancestor/preceding elements
- function( elem, context, xml ) {
- var oldCache, uniqueCache, outerCache,
- newCache = [ dirruns, doneName ];
-
- // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
- if ( xml ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- if ( matcher( elem, context, xml ) ) {
- return true;
- }
- }
- }
- } else {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- outerCache = elem[ expando ] || (elem[ expando ] = {});
-
- // Support: IE <9 only
- // Defend against cloned attroperties (jQuery gh-1709)
- uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
-
- if ( (oldCache = uniqueCache[ dir ]) &&
- oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
-
- // Assign to newCache so results back-propagate to previous elements
- return (newCache[ 2 ] = oldCache[ 2 ]);
- } else {
- // Reuse newcache so results back-propagate to previous elements
- uniqueCache[ dir ] = newCache;
-
- // A match means we're done; a fail means we have to keep checking
- if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
- return true;
- }
- }
- }
- }
- }
- };
-}
-
-function elementMatcher( matchers ) {
- return matchers.length > 1 ?
- function( elem, context, xml ) {
- var i = matchers.length;
- while ( i-- ) {
- if ( !matchers[i]( elem, context, xml ) ) {
- return false;
- }
- }
- return true;
- } :
- matchers[0];
-}
-
-function multipleContexts( selector, contexts, results ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- Sizzle( selector, contexts[i], results );
- }
- return results;
-}
-
-function condense( unmatched, map, filter, context, xml ) {
- var elem,
- newUnmatched = [],
- i = 0,
- len = unmatched.length,
- mapped = map != null;
-
- for ( ; i < len; i++ ) {
- if ( (elem = unmatched[i]) ) {
- if ( !filter || filter( elem, context, xml ) ) {
- newUnmatched.push( elem );
- if ( mapped ) {
- map.push( i );
- }
- }
- }
- }
-
- return newUnmatched;
-}
-
-function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
- if ( postFilter && !postFilter[ expando ] ) {
- postFilter = setMatcher( postFilter );
- }
- if ( postFinder && !postFinder[ expando ] ) {
- postFinder = setMatcher( postFinder, postSelector );
- }
- return markFunction(function( seed, results, context, xml ) {
- var temp, i, elem,
- preMap = [],
- postMap = [],
- preexisting = results.length,
-
- // Get initial elements from seed or context
- elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
-
- // Prefilter to get matcher input, preserving a map for seed-results synchronization
- matcherIn = preFilter && ( seed || !selector ) ?
- condense( elems, preMap, preFilter, context, xml ) :
- elems,
-
- matcherOut = matcher ?
- // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
- postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-
- // ...intermediate processing is necessary
- [] :
-
- // ...otherwise use results directly
- results :
- matcherIn;
-
- // Find primary matches
- if ( matcher ) {
- matcher( matcherIn, matcherOut, context, xml );
- }
-
- // Apply postFilter
- if ( postFilter ) {
- temp = condense( matcherOut, postMap );
- postFilter( temp, [], context, xml );
-
- // Un-match failing elements by moving them back to matcherIn
- i = temp.length;
- while ( i-- ) {
- if ( (elem = temp[i]) ) {
- matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
- }
- }
- }
-
- if ( seed ) {
- if ( postFinder || preFilter ) {
- if ( postFinder ) {
- // Get the final matcherOut by condensing this intermediate into postFinder contexts
- temp = [];
- i = matcherOut.length;
- while ( i-- ) {
- if ( (elem = matcherOut[i]) ) {
- // Restore matcherIn since elem is not yet a final match
- temp.push( (matcherIn[i] = elem) );
- }
- }
- postFinder( null, (matcherOut = []), temp, xml );
- }
-
- // Move matched elements from seed to results to keep them synchronized
- i = matcherOut.length;
- while ( i-- ) {
- if ( (elem = matcherOut[i]) &&
- (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
-
- seed[temp] = !(results[temp] = elem);
- }
- }
- }
-
- // Add elements to results, through postFinder if defined
- } else {
- matcherOut = condense(
- matcherOut === results ?
- matcherOut.splice( preexisting, matcherOut.length ) :
- matcherOut
- );
- if ( postFinder ) {
- postFinder( null, results, matcherOut, xml );
- } else {
- push.apply( results, matcherOut );
- }
- }
- });
-}
-
-function matcherFromTokens( tokens ) {
- var checkContext, matcher, j,
- len = tokens.length,
- leadingRelative = Expr.relative[ tokens[0].type ],
- implicitRelative = leadingRelative || Expr.relative[" "],
- i = leadingRelative ? 1 : 0,
-
- // The foundational matcher ensures that elements are reachable from top-level context(s)
- matchContext = addCombinator( function( elem ) {
- return elem === checkContext;
- }, implicitRelative, true ),
- matchAnyContext = addCombinator( function( elem ) {
- return indexOf( checkContext, elem ) > -1;
- }, implicitRelative, true ),
- matchers = [ function( elem, context, xml ) {
- var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
- (checkContext = context).nodeType ?
- matchContext( elem, context, xml ) :
- matchAnyContext( elem, context, xml ) );
- // Avoid hanging onto element (issue #299)
- checkContext = null;
- return ret;
- } ];
-
- for ( ; i < len; i++ ) {
- if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
- matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
- } else {
- matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
-
- // Return special upon seeing a positional matcher
- if ( matcher[ expando ] ) {
- // Find the next relative operator (if any) for proper handling
- j = ++i;
- for ( ; j < len; j++ ) {
- if ( Expr.relative[ tokens[j].type ] ) {
- break;
- }
- }
- return setMatcher(
- i > 1 && elementMatcher( matchers ),
- i > 1 && toSelector(
- // If the preceding token was a descendant combinator, insert an implicit any-element `*`
- tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
- ).replace( rtrim, "$1" ),
- matcher,
- i < j && matcherFromTokens( tokens.slice( i, j ) ),
- j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
- j < len && toSelector( tokens )
- );
- }
- matchers.push( matcher );
- }
- }
-
- return elementMatcher( matchers );
-}
-
-function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
- var bySet = setMatchers.length > 0,
- byElement = elementMatchers.length > 0,
- superMatcher = function( seed, context, xml, results, outermost ) {
- var elem, j, matcher,
- matchedCount = 0,
- i = "0",
- unmatched = seed && [],
- setMatched = [],
- contextBackup = outermostContext,
- // We must always have either seed elements or outermost context
- elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
- // Use integer dirruns iff this is the outermost matcher
- dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
- len = elems.length;
-
- if ( outermost ) {
- outermostContext = context === document || context || outermost;
- }
-
- // Add elements passing elementMatchers directly to results
- // Support: IE<9, Safari
- // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
- for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
- if ( byElement && elem ) {
- j = 0;
- if ( !context && elem.ownerDocument !== document ) {
- setDocument( elem );
- xml = !documentIsHTML;
- }
- while ( (matcher = elementMatchers[j++]) ) {
- if ( matcher( elem, context || document, xml) ) {
- results.push( elem );
- break;
- }
- }
- if ( outermost ) {
- dirruns = dirrunsUnique;
- }
- }
-
- // Track unmatched elements for set filters
- if ( bySet ) {
- // They will have gone through all possible matchers
- if ( (elem = !matcher && elem) ) {
- matchedCount--;
- }
-
- // Lengthen the array for every element, matched or not
- if ( seed ) {
- unmatched.push( elem );
- }
- }
- }
-
- // `i` is now the count of elements visited above, and adding it to `matchedCount`
- // makes the latter nonnegative.
- matchedCount += i;
-
- // Apply set filters to unmatched elements
- // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
- // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
- // no element matchers and no seed.
- // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
- // case, which will result in a "00" `matchedCount` that differs from `i` but is also
- // numerically zero.
- if ( bySet && i !== matchedCount ) {
- j = 0;
- while ( (matcher = setMatchers[j++]) ) {
- matcher( unmatched, setMatched, context, xml );
- }
-
- if ( seed ) {
- // Reintegrate element matches to eliminate the need for sorting
- if ( matchedCount > 0 ) {
- while ( i-- ) {
- if ( !(unmatched[i] || setMatched[i]) ) {
- setMatched[i] = pop.call( results );
- }
- }
- }
-
- // Discard index placeholder values to get only actual matches
- setMatched = condense( setMatched );
- }
-
- // Add matches to results
- push.apply( results, setMatched );
-
- // Seedless set matches succeeding multiple successful matchers stipulate sorting
- if ( outermost && !seed && setMatched.length > 0 &&
- ( matchedCount + setMatchers.length ) > 1 ) {
-
- Sizzle.uniqueSort( results );
- }
- }
-
- // Override manipulation of globals by nested matchers
- if ( outermost ) {
- dirruns = dirrunsUnique;
- outermostContext = contextBackup;
- }
-
- return unmatched;
- };
-
- return bySet ?
- markFunction( superMatcher ) :
- superMatcher;
-}
-
-compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
- var i,
- setMatchers = [],
- elementMatchers = [],
- cached = compilerCache[ selector + " " ];
-
- if ( !cached ) {
- // Generate a function of recursive functions that can be used to check each element
- if ( !match ) {
- match = tokenize( selector );
- }
- i = match.length;
- while ( i-- ) {
- cached = matcherFromTokens( match[i] );
- if ( cached[ expando ] ) {
- setMatchers.push( cached );
- } else {
- elementMatchers.push( cached );
- }
- }
-
- // Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
-
- // Save selector and tokenization
- cached.selector = selector;
- }
- return cached;
-};
-
-/**
- * A low-level selection function that works with Sizzle's compiled
- * selector functions
- * @param {String|Function} selector A selector or a pre-compiled
- * selector function built with Sizzle.compile
- * @param {Element} context
- * @param {Array} [results]
- * @param {Array} [seed] A set of elements to match against
- */
-select = Sizzle.select = function( selector, context, results, seed ) {
- var i, tokens, token, type, find,
- compiled = typeof selector === "function" && selector,
- match = !seed && tokenize( (selector = compiled.selector || selector) );
-
- results = results || [];
-
- // Try to minimize operations if there is only one selector in the list and no seed
- // (the latter of which guarantees us context)
- if ( match.length === 1 ) {
-
- // Reduce context if the leading compound selector is an ID
- tokens = match[0] = match[0].slice( 0 );
- if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
- support.getById && context.nodeType === 9 && documentIsHTML &&
- Expr.relative[ tokens[1].type ] ) {
-
- context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
- if ( !context ) {
- return results;
-
- // Precompiled matchers will still verify ancestry, so step up a level
- } else if ( compiled ) {
- context = context.parentNode;
- }
-
- selector = selector.slice( tokens.shift().value.length );
- }
-
- // Fetch a seed set for right-to-left matching
- i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
- while ( i-- ) {
- token = tokens[i];
-
- // Abort if we hit a combinator
- if ( Expr.relative[ (type = token.type) ] ) {
- break;
- }
- if ( (find = Expr.find[ type ]) ) {
- // Search, expanding context for leading sibling combinators
- if ( (seed = find(
- token.matches[0].replace( runescape, funescape ),
- rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
- )) ) {
-
- // If seed is empty or no tokens remain, we can return early
- tokens.splice( i, 1 );
- selector = seed.length && toSelector( tokens );
- if ( !selector ) {
- push.apply( results, seed );
- return results;
- }
-
- break;
- }
- }
- }
- }
-
- // Compile and execute a filtering function if one is not provided
- // Provide `match` to avoid retokenization if we modified the selector above
- ( compiled || compile( selector, match ) )(
- seed,
- context,
- !documentIsHTML,
- results,
- !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
- );
- return results;
-};
-
-// One-time assignments
-
-// Sort stability
-support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
-
-// Support: Chrome 14-35+
-// Always assume duplicates if they aren't passed to the comparison function
-support.detectDuplicates = !!hasDuplicate;
-
-// Initialize against the default document
-setDocument();
-
-// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
-// Detached nodes confoundingly follow *each other*
-support.sortDetached = assert(function( div1 ) {
- // Should return 1, but returns 4 (following)
- return div1.compareDocumentPosition( document.createElement("div") ) & 1;
-});
-
-// Support: IE<8
-// Prevent attribute/property "interpolation"
-// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !assert(function( div ) {
- div.innerHTML = "<a href='#'></a>";
- return div.firstChild.getAttribute("href") === "#" ;
-}) ) {
- addHandle( "type|href|height|width", function( elem, name, isXML ) {
- if ( !isXML ) {
- return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
- }
- });
-}
-
-// Support: IE<9
-// Use defaultValue in place of getAttribute("value")
-if ( !support.attributes || !assert(function( div ) {
- div.innerHTML = "<input/>";
- div.firstChild.setAttribute( "value", "" );
- return div.firstChild.getAttribute( "value" ) === "";
-}) ) {
- addHandle( "value", function( elem, name, isXML ) {
- if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
- return elem.defaultValue;
- }
- });
-}
-
-// Support: IE<9
-// Use getAttributeNode to fetch booleans when getAttribute lies
-if ( !assert(function( div ) {
- return div.getAttribute("disabled") == null;
-}) ) {
- addHandle( booleans, function( elem, name, isXML ) {
- var val;
- if ( !isXML ) {
- return elem[ name ] === true ? name.toLowerCase() :
- (val = elem.getAttributeNode( name )) && val.specified ?
- val.value :
- null;
- }
- });
-}
-
-return Sizzle;
-
-})( window );
-
-
-
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[ ":" ] = jQuery.expr.pseudos;
-jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-
-
-
-var dir = function( elem, dir, until ) {
- var matched = [],
- truncate = until !== undefined;
-
- while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
- if ( elem.nodeType === 1 ) {
- if ( truncate && jQuery( elem ).is( until ) ) {
- break;
- }
- matched.push( elem );
- }
- }
- return matched;
-};
-
-
-var siblings = function( n, elem ) {
- var matched = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- matched.push( n );
- }
- }
-
- return matched;
-};
-
-
-var rneedsContext = jQuery.expr.match.needsContext;
-
-var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
-
-
-
-var risSimple = /^.[^:#\[\.,]*$/;
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, not ) {
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep( elements, function( elem, i ) {
- /* jshint -W018 */
- return !!qualifier.call( elem, i, elem ) !== not;
- } );
-
- }
-
- if ( qualifier.nodeType ) {
- return jQuery.grep( elements, function( elem ) {
- return ( elem === qualifier ) !== not;
- } );
-
- }
-
- if ( typeof qualifier === "string" ) {
- if ( risSimple.test( qualifier ) ) {
- return jQuery.filter( qualifier, elements, not );
- }
-
- qualifier = jQuery.filter( qualifier, elements );
- }
-
- return jQuery.grep( elements, function( elem ) {
- return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
- } );
-}
-
-jQuery.filter = function( expr, elems, not ) {
- var elem = elems[ 0 ];
-
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- return elems.length === 1 && elem.nodeType === 1 ?
- jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
- jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
- return elem.nodeType === 1;
- } ) );
-};
-
-jQuery.fn.extend( {
- find: function( selector ) {
- var i,
- ret = [],
- self = this,
- len = self.length;
-
- if ( typeof selector !== "string" ) {
- return this.pushStack( jQuery( selector ).filter( function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- } ) );
- }
-
- for ( i = 0; i < len; i++ ) {
- jQuery.find( selector, self[ i ], ret );
- }
-
- // Needed because $( selector, context ) becomes $( context ).find( selector )
- ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
- ret.selector = this.selector ? this.selector + " " + selector : selector;
- return ret;
- },
- filter: function( selector ) {
- return this.pushStack( winnow( this, selector || [], false ) );
- },
- not: function( selector ) {
- return this.pushStack( winnow( this, selector || [], true ) );
- },
- is: function( selector ) {
- return !!winnow(
- this,
-
- // If this is a positional/relative selector, check membership in the returned set
- // so $("p:first").is("p:last") won't return true for a doc with two "p".
- typeof selector === "string" && rneedsContext.test( selector ) ?
- jQuery( selector ) :
- selector || [],
- false
- ).length;
- }
-} );
-
-
-// Initialize a jQuery object
-
-
-// A central reference to the root jQuery(document)
-var rootjQuery,
-
- // A simple way to check for HTML strings
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
- // Strict HTML recognition (#11290: must start with <)
- rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
-
- init = jQuery.fn.init = function( selector, context, root ) {
- var match, elem;
-
- // HANDLE: $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // init accepts an alternate rootjQuery
- // so migrate can support jQuery.sub (gh-2101)
- root = root || rootjQuery;
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector.charAt( 0 ) === "<" &&
- selector.charAt( selector.length - 1 ) === ">" &&
- selector.length >= 3 ) {
-
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && ( match[ 1 ] || !context ) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[ 1 ] ) {
- context = context instanceof jQuery ? context[ 0 ] : context;
-
- // scripts is true for back-compat
- // Intentionally let the error be thrown if parseHTML is not present
- jQuery.merge( this, jQuery.parseHTML(
- match[ 1 ],
- context && context.nodeType ? context.ownerDocument || context : document,
- true
- ) );
-
- // HANDLE: $(html, props)
- if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
- for ( match in context ) {
-
- // Properties of context are called as methods if possible
- if ( jQuery.isFunction( this[ match ] ) ) {
- this[ match ]( context[ match ] );
-
- // ...and otherwise set as attributes
- } else {
- this.attr( match, context[ match ] );
- }
- }
- }
-
- return this;
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[ 2 ] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
-
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[ 2 ] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[ 0 ] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || root ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(DOMElement)
- } else if ( selector.nodeType ) {
- this.context = this[ 0 ] = selector;
- this.length = 1;
- return this;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return typeof root.ready !== "undefined" ?
- root.ready( selector ) :
-
- // Execute immediately if ready is not present
- selector( jQuery );
- }
-
- if ( selector.selector !== undefined ) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- };
-
-// Give the init function the jQuery prototype for later instantiation
-init.prototype = jQuery.fn;
-
-// Initialize central reference
-rootjQuery = jQuery( document );
-
-
-var rparentsprev = /^(?:parents|prev(?:Until|All))/,
-
- // methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.fn.extend( {
- has: function( target ) {
- var i,
- targets = jQuery( target, this ),
- len = targets.length;
-
- return this.filter( function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( this, targets[ i ] ) ) {
- return true;
- }
- }
- } );
- },
-
- closest: function( selectors, context ) {
- var cur,
- i = 0,
- l = this.length,
- matched = [],
- pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
- jQuery( selectors, context || this.context ) :
- 0;
-
- for ( ; i < l; i++ ) {
- for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
-
- // Always skip document fragments
- if ( cur.nodeType < 11 && ( pos ?
- pos.index( cur ) > -1 :
-
- // Don't pass non-elements to Sizzle
- cur.nodeType === 1 &&
- jQuery.find.matchesSelector( cur, selectors ) ) ) {
-
- matched.push( cur );
- break;
- }
- }
- }
-
- return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
- },
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
- }
-
- // index in selector
- if ( typeof elem === "string" ) {
- return jQuery.inArray( this[ 0 ], jQuery( elem ) );
- }
-
- // Locate the position of the desired element
- return jQuery.inArray(
-
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[ 0 ] : elem, this );
- },
-
- add: function( selector, context ) {
- return this.pushStack(
- jQuery.uniqueSort(
- jQuery.merge( this.get(), jQuery( selector, context ) )
- )
- );
- },
-
- addBack: function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter( selector )
- );
- }
-} );
-
-function sibling( cur, dir ) {
- do {
- cur = cur[ dir ];
- } while ( cur && cur.nodeType !== 1 );
-
- return cur;
-}
-
-jQuery.each( {
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return sibling( elem, "nextSibling" );
- },
- prev: function( elem ) {
- return sibling( elem, "previousSibling" );
- },
- nextAll: function( elem ) {
- return dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return siblings( ( elem.parentNode || {} ).firstChild, elem );
- },
- children: function( elem ) {
- return siblings( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.merge( [], elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until );
-
- if ( name.slice( -5 ) !== "Until" ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
-
- if ( this.length > 1 ) {
-
- // Remove duplicates
- if ( !guaranteedUnique[ name ] ) {
- ret = jQuery.uniqueSort( ret );
- }
-
- // Reverse order for parents* and prev-derivatives
- if ( rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
- }
-
- return this.pushStack( ret );
- };
-} );
-var rnotwhite = ( /\S+/g );
-
-
-
-// Convert String-formatted options into Object-formatted ones
-function createOptions( options ) {
- var object = {};
- jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
- object[ flag ] = true;
- } );
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * options: an optional list of space-separated options that will change how
- * the callback list behaves or a more traditional option object
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible options:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( options ) {
-
- // Convert options from String-formatted to Object-formatted if needed
- // (we check in cache first)
- options = typeof options === "string" ?
- createOptions( options ) :
- jQuery.extend( {}, options );
-
- var // Flag to know if list is currently firing
- firing,
-
- // Last fire value for non-forgettable lists
- memory,
-
- // Flag to know if list was already fired
- fired,
-
- // Flag to prevent firing
- locked,
-
- // Actual callback list
- list = [],
-
- // Queue of execution data for repeatable lists
- queue = [],
-
- // Index of currently firing callback (modified by add/remove as needed)
- firingIndex = -1,
-
- // Fire callbacks
- fire = function() {
-
- // Enforce single-firing
- locked = options.once;
-
- // Execute callbacks for all pending executions,
- // respecting firingIndex overrides and runtime changes
- fired = firing = true;
- for ( ; queue.length; firingIndex = -1 ) {
- memory = queue.shift();
- while ( ++firingIndex < list.length ) {
-
- // Run callback and check for early termination
- if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
- options.stopOnFalse ) {
-
- // Jump to end and forget the data so .add doesn't re-fire
- firingIndex = list.length;
- memory = false;
- }
- }
- }
-
- // Forget the data if we're done with it
- if ( !options.memory ) {
- memory = false;
- }
-
- firing = false;
-
- // Clean up if we're done firing for good
- if ( locked ) {
-
- // Keep an empty list if we have data for future add calls
- if ( memory ) {
- list = [];
-
- // Otherwise, this object is spent
- } else {
- list = "";
- }
- }
- },
-
- // Actual Callbacks object
- self = {
-
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
-
- // If we have memory from a past run, we should fire after adding
- if ( memory && !firing ) {
- firingIndex = list.length - 1;
- queue.push( memory );
- }
-
- ( function add( args ) {
- jQuery.each( args, function( _, arg ) {
- if ( jQuery.isFunction( arg ) ) {
- if ( !options.unique || !self.has( arg ) ) {
- list.push( arg );
- }
- } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
-
- // Inspect recursively
- add( arg );
- }
- } );
- } )( arguments );
-
- if ( memory && !firing ) {
- fire();
- }
- }
- return this;
- },
-
- // Remove a callback from the list
- remove: function() {
- jQuery.each( arguments, function( _, arg ) {
- var index;
- while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
- list.splice( index, 1 );
-
- // Handle firing indexes
- if ( index <= firingIndex ) {
- firingIndex--;
- }
- }
- } );
- return this;
- },
-
- // Check if a given callback is in the list.
- // If no argument is given, return whether or not list has callbacks attached.
- has: function( fn ) {
- return fn ?
- jQuery.inArray( fn, list ) > -1 :
- list.length > 0;
- },
-
- // Remove all callbacks from the list
- empty: function() {
- if ( list ) {
- list = [];
- }
- return this;
- },
-
- // Disable .fire and .add
- // Abort any current/pending executions
- // Clear all callbacks and values
- disable: function() {
- locked = queue = [];
- list = memory = "";
- return this;
- },
- disabled: function() {
- return !list;
- },
-
- // Disable .fire
- // Also disable .add unless we have memory (since it would have no effect)
- // Abort any pending executions
- lock: function() {
- locked = true;
- if ( !memory ) {
- self.disable();
- }
- return this;
- },
- locked: function() {
- return !!locked;
- },
-
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- if ( !locked ) {
- args = args || [];
- args = [ context, args.slice ? args.slice() : args ];
- queue.push( args );
- if ( !firing ) {
- fire();
- }
- }
- return this;
- },
-
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
-
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!fired;
- }
- };
-
- return self;
-};
-
-
-jQuery.extend( {
-
- Deferred: function( func ) {
- var tuples = [
-
- // action, add listener, listener list, final state
- [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
- [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
- [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
- ],
- state = "pending",
- promise = {
- state: function() {
- return state;
- },
- always: function() {
- deferred.done( arguments ).fail( arguments );
- return this;
- },
- then: function( /* fnDone, fnFail, fnProgress */ ) {
- var fns = arguments;
- return jQuery.Deferred( function( newDefer ) {
- jQuery.each( tuples, function( i, tuple ) {
- var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
-
- // deferred[ done | fail | progress ] for forwarding actions to newDefer
- deferred[ tuple[ 1 ] ]( function() {
- var returned = fn && fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise()
- .progress( newDefer.notify )
- .done( newDefer.resolve )
- .fail( newDefer.reject );
- } else {
- newDefer[ tuple[ 0 ] + "With" ](
- this === promise ? newDefer.promise() : this,
- fn ? [ returned ] : arguments
- );
- }
- } );
- } );
- fns = null;
- } ).promise();
- },
-
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- return obj != null ? jQuery.extend( obj, promise ) : promise;
- }
- },
- deferred = {};
-
- // Keep pipe for back-compat
- promise.pipe = promise.then;
-
- // Add list-specific methods
- jQuery.each( tuples, function( i, tuple ) {
- var list = tuple[ 2 ],
- stateString = tuple[ 3 ];
-
- // promise[ done | fail | progress ] = list.add
- promise[ tuple[ 1 ] ] = list.add;
-
- // Handle state
- if ( stateString ) {
- list.add( function() {
-
- // state = [ resolved | rejected ]
- state = stateString;
-
- // [ reject_list | resolve_list ].disable; progress_list.lock
- }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
- }
-
- // deferred[ resolve | reject | notify ]
- deferred[ tuple[ 0 ] ] = function() {
- deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
- return this;
- };
- deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
- } );
-
- // Make the deferred a promise
- promise.promise( deferred );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( subordinate /* , ..., subordinateN */ ) {
- var i = 0,
- resolveValues = slice.call( arguments ),
- length = resolveValues.length,
-
- // the count of uncompleted subordinates
- remaining = length !== 1 ||
- ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
-
- // the master Deferred.
- // If resolveValues consist of only a single Deferred, just use that.
- deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
-
- // Update function for both resolve and progress values
- updateFunc = function( i, contexts, values ) {
- return function( value ) {
- contexts[ i ] = this;
- values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
- if ( values === progressValues ) {
- deferred.notifyWith( contexts, values );
-
- } else if ( !( --remaining ) ) {
- deferred.resolveWith( contexts, values );
- }
- };
- },
-
- progressValues, progressContexts, resolveContexts;
-
- // add listeners to Deferred subordinates; treat others as resolved
- if ( length > 1 ) {
- progressValues = new Array( length );
- progressContexts = new Array( length );
- resolveContexts = new Array( length );
- for ( ; i < length; i++ ) {
- if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
- resolveValues[ i ].promise()
- .progress( updateFunc( i, progressContexts, progressValues ) )
- .done( updateFunc( i, resolveContexts, resolveValues ) )
- .fail( deferred.reject );
- } else {
- --remaining;
- }
- }
- }
-
- // if we're not waiting on anything, resolve the master
- if ( !remaining ) {
- deferred.resolveWith( resolveContexts, resolveValues );
- }
-
- return deferred.promise();
- }
-} );
-
-
-// The deferred used on DOM ready
-var readyList;
-
-jQuery.fn.ready = function( fn ) {
-
- // Add the callback
- jQuery.ready.promise().done( fn );
-
- return this;
-};
-
-jQuery.extend( {
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.triggerHandler ) {
- jQuery( document ).triggerHandler( "ready" );
- jQuery( document ).off( "ready" );
- }
- }
-} );
-
-/**
- * Clean-up method for dom ready events
- */
-function detach() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", completed );
- window.removeEventListener( "load", completed );
-
- } else {
- document.detachEvent( "onreadystatechange", completed );
- window.detachEvent( "onload", completed );
- }
-}
-
-/**
- * The ready event handler and self cleanup method
- */
-function completed() {
-
- // readyState === "complete" is good enough for us to call the dom ready in oldIE
- if ( document.addEventListener ||
- window.event.type === "load" ||
- document.readyState === "complete" ) {
-
- detach();
- jQuery.ready();
- }
-}
-
-jQuery.ready.promise = function( obj ) {
- if ( !readyList ) {
-
- readyList = jQuery.Deferred();
-
- // Catch cases where $(document).ready() is called
- // after the browser event has already occurred.
- // Support: IE6-10
- // Older IE sometimes signals "interactive" too soon
- if ( document.readyState === "complete" ||
- ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
-
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- window.setTimeout( jQuery.ready );
-
- // Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
-
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", completed );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", completed );
-
- // If IE event model is used
- } else {
-
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", completed );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", completed );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch ( e ) {}
-
- if ( top && top.doScroll ) {
- ( function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
-
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll( "left" );
- } catch ( e ) {
- return window.setTimeout( doScrollCheck, 50 );
- }
-
- // detach all dom ready events
- detach();
-
- // and execute any waiting functions
- jQuery.ready();
- }
- } )();
- }
- }
- }
- return readyList.promise( obj );
-};
-
-// Kick off the DOM ready check even if the user does not
-jQuery.ready.promise();
-
-
-
-
-// Support: IE<9
-// Iteration over object's inherited properties before its own
-var i;
-for ( i in jQuery( support ) ) {
- break;
-}
-support.ownFirst = i === "0";
-
-// Note: most support tests are defined in their respective modules.
-// false until the test is run
-support.inlineBlockNeedsLayout = false;
-
-// Execute ASAP in case we need to set body.style.zoom
-jQuery( function() {
-
- // Minified: var a,b,c,d
- var val, div, body, container;
-
- body = document.getElementsByTagName( "body" )[ 0 ];
- if ( !body || !body.style ) {
-
- // Return for frameset docs that don't have a body
- return;
- }
-
- // Setup
- div = document.createElement( "div" );
- container = document.createElement( "div" );
- container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
- body.appendChild( container ).appendChild( div );
-
- if ( typeof div.style.zoom !== "undefined" ) {
-
- // Support: IE<8
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
-
- support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
- if ( val ) {
-
- // Prevent IE 6 from affecting layout for positioned elements #11048
- // Prevent IE from shrinking the body in IE 7 mode #12869
- // Support: IE<8
- body.style.zoom = 1;
- }
- }
-
- body.removeChild( container );
-} );
-
-
-( function() {
- var div = document.createElement( "div" );
-
- // Support: IE<9
- support.deleteExpando = true;
- try {
- delete div.test;
- } catch ( e ) {
- support.deleteExpando = false;
- }
-
- // Null elements to avoid leaks in IE.
- div = null;
-} )();
-var acceptData = function( elem ) {
- var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
- nodeType = +elem.nodeType || 1;
-
- // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
- return nodeType !== 1 && nodeType !== 9 ?
- false :
-
- // Nodes accept data unless otherwise specified; rejection can be conditional
- !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
-};
-
-
-
-
-var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
- rmultiDash = /([A-Z])/g;
-
-function dataAttr( elem, key, data ) {
-
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
-
- // Only convert to a number if it doesn't change the string
- +data + "" === data ? +data :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch ( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-// checks a cache object for emptiness
-function isEmptyDataObject( obj ) {
- var name;
- for ( name in obj ) {
-
- // if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
- continue;
- }
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-
-function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !acceptData( elem ) ) {
- return;
- }
-
- var ret, thisCache,
- internalKey = jQuery.expando,
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
- data === undefined && typeof name === "string" ) {
- return;
- }
-
- if ( !id ) {
-
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
- } else {
- id = internalKey;
- }
- }
-
- if ( !cache[ id ] ) {
-
- // Avoid exposing jQuery metadata on plain JS objects when the object
- // is serialized using JSON.stringify
- cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ] = jQuery.extend( cache[ id ], name );
- } else {
- cache[ id ].data = jQuery.extend( cache[ id ].data, name );
- }
- }
-
- thisCache = cache[ id ];
-
- // jQuery data() is stored in a separate object inside the object's internal data
- // cache in order to avoid key collisions between internal data and user-defined
- // data.
- if ( !pvt ) {
- if ( !thisCache.data ) {
- thisCache.data = {};
- }
-
- thisCache = thisCache.data;
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( typeof name === "string" ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
-}
-
-function internalRemoveData( elem, name, pvt ) {
- if ( !acceptData( elem ) ) {
- return;
- }
-
- var thisCache, i,
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ] : cache[ id ].data;
-
- if ( thisCache ) {
-
- // Support array or space separated string names for data keys
- if ( !jQuery.isArray( name ) ) {
-
- // try the string as a key before any manipulation
- if ( name in thisCache ) {
- name = [ name ];
- } else {
-
- // split the camel cased version by spaces unless a key with the spaces exists
- name = jQuery.camelCase( name );
- if ( name in thisCache ) {
- name = [ name ];
- } else {
- name = name.split( " " );
- }
- }
- } else {
-
- // If "name" is an array of keys...
- // When data is initially created, via ("key", "val") signature,
- // keys will be converted to camelCase.
- // Since there is no way to tell _how_ a key was added, remove
- // both plain key and camelCase key. #12786
- // This will only penalize the array argument path.
- name = name.concat( jQuery.map( name, jQuery.camelCase ) );
- }
-
- i = name.length;
- while ( i-- ) {
- delete thisCache[ name[ i ] ];
- }
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( !pvt ) {
- delete cache[ id ].data;
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject( cache[ id ] ) ) {
- return;
- }
- }
-
- // Destroy the cache
- if ( isNode ) {
- jQuery.cleanData( [ elem ], true );
-
- // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
- /* jshint eqeqeq: false */
- } else if ( support.deleteExpando || cache != cache.window ) {
- /* jshint eqeqeq: true */
- delete cache[ id ];
-
- // When all else fails, undefined
- } else {
- cache[ id ] = undefined;
- }
-}
-
-jQuery.extend( {
- cache: {},
-
- // The following elements (space-suffixed to avoid Object.prototype collisions)
- // throw uncatchable exceptions if you attempt to set expando properties
- noData: {
- "applet ": true,
- "embed ": true,
-
- // ...but Flash objects (which have this classid) *can* handle expandos
- "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data ) {
- return internalData( elem, name, data );
- },
-
- removeData: function( elem, name ) {
- return internalRemoveData( elem, name );
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return internalData( elem, name, data, true );
- },
-
- _removeData: function( elem, name ) {
- return internalRemoveData( elem, name, true );
- }
-} );
-
-jQuery.fn.extend( {
- data: function( key, value ) {
- var i, name, data,
- elem = this[ 0 ],
- attrs = elem && elem.attributes;
-
- // Special expections of .data basically thwart jQuery.access,
- // so implement the relevant behavior ourselves
-
- // Gets all values
- if ( key === undefined ) {
- if ( this.length ) {
- data = jQuery.data( elem );
-
- if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
- i = attrs.length;
- while ( i-- ) {
-
- // Support: IE11+
- // The attrs elements can be null (#14894)
- if ( attrs[ i ] ) {
- name = attrs[ i ].name;
- if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.slice( 5 ) );
- dataAttr( elem, name, data[ name ] );
- }
- }
- }
- jQuery._data( elem, "parsedAttrs", true );
- }
- }
-
- return data;
- }
-
- // Sets multiple values
- if ( typeof key === "object" ) {
- return this.each( function() {
- jQuery.data( this, key );
- } );
- }
-
- return arguments.length > 1 ?
-
- // Sets one value
- this.each( function() {
- jQuery.data( this, key, value );
- } ) :
-
- // Gets one value
- // Try to fetch any internally stored data first
- elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
- },
-
- removeData: function( key ) {
- return this.each( function() {
- jQuery.removeData( this, key );
- } );
- }
-} );
-
-
-jQuery.extend( {
- queue: function( elem, type, data ) {
- var queue;
-
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- queue = jQuery._data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !queue || jQuery.isArray( data ) ) {
- queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
- } else {
- queue.push( data );
- }
- }
- return queue || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- startLength = queue.length,
- fn = queue.shift(),
- hooks = jQuery._queueHooks( elem, type ),
- next = function() {
- jQuery.dequeue( elem, type );
- };
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- startLength--;
- }
-
- if ( fn ) {
-
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- // clear up the last queue stop function
- delete hooks.stop;
- fn.call( elem, next, hooks );
- }
-
- if ( !startLength && hooks ) {
- hooks.empty.fire();
- }
- },
-
- // not intended for public consumption - generates a queueHooks object,
- // or returns the current one
- _queueHooks: function( elem, type ) {
- var key = type + "queueHooks";
- return jQuery._data( elem, key ) || jQuery._data( elem, key, {
- empty: jQuery.Callbacks( "once memory" ).add( function() {
- jQuery._removeData( elem, type + "queue" );
- jQuery._removeData( elem, key );
- } )
- } );
- }
-} );
-
-jQuery.fn.extend( {
- queue: function( type, data ) {
- var setter = 2;
-
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- setter--;
- }
-
- if ( arguments.length < setter ) {
- return jQuery.queue( this[ 0 ], type );
- }
-
- return data === undefined ?
- this :
- this.each( function() {
- var queue = jQuery.queue( this, type, data );
-
- // ensure a hooks for this queue
- jQuery._queueHooks( this, type );
-
- if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- } );
- },
- dequeue: function( type ) {
- return this.each( function() {
- jQuery.dequeue( this, type );
- } );
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
-
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, obj ) {
- var tmp,
- count = 1,
- defer = jQuery.Deferred(),
- elements = this,
- i = this.length,
- resolve = function() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- };
-
- if ( typeof type !== "string" ) {
- obj = type;
- type = undefined;
- }
- type = type || "fx";
-
- while ( i-- ) {
- tmp = jQuery._data( elements[ i ], type + "queueHooks" );
- if ( tmp && tmp.empty ) {
- count++;
- tmp.empty.add( resolve );
- }
- }
- resolve();
- return defer.promise( obj );
- }
-} );
-
-
-( function() {
- var shrinkWrapBlocksVal;
-
- support.shrinkWrapBlocks = function() {
- if ( shrinkWrapBlocksVal != null ) {
- return shrinkWrapBlocksVal;
- }
-
- // Will be changed later if needed.
- shrinkWrapBlocksVal = false;
-
- // Minified: var b,c,d
- var div, body, container;
-
- body = document.getElementsByTagName( "body" )[ 0 ];
- if ( !body || !body.style ) {
-
- // Test fired too early or in an unsupported environment, exit.
- return;
- }
-
- // Setup
- div = document.createElement( "div" );
- container = document.createElement( "div" );
- container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
- body.appendChild( container ).appendChild( div );
-
- // Support: IE6
- // Check if elements with layout shrink-wrap their children
- if ( typeof div.style.zoom !== "undefined" ) {
-
- // Reset CSS: box-sizing; display; margin; border
- div.style.cssText =
-
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
- "box-sizing:content-box;display:block;margin:0;border:0;" +
- "padding:1px;width:1px;zoom:1";
- div.appendChild( document.createElement( "div" ) ).style.width = "5px";
- shrinkWrapBlocksVal = div.offsetWidth !== 3;
- }
-
- body.removeChild( container );
-
- return shrinkWrapBlocksVal;
- };
-
-} )();
-var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
-
-var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
-
-
-var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
-
-var isHidden = function( elem, el ) {
-
- // isHidden might be called from jQuery#filter function;
- // in that case, element will be second argument
- elem = el || elem;
- return jQuery.css( elem, "display" ) === "none" ||
- !jQuery.contains( elem.ownerDocument, elem );
- };
-
-
-
-function adjustCSS( elem, prop, valueParts, tween ) {
- var adjusted,
- scale = 1,
- maxIterations = 20,
- currentValue = tween ?
- function() { return tween.cur(); } :
- function() { return jQuery.css( elem, prop, "" ); },
- initial = currentValue(),
- unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
-
- // Starting value computation is required for potential unit mismatches
- initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
- rcssNum.exec( jQuery.css( elem, prop ) );
-
- if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
-
- // Trust units reported by jQuery.css
- unit = unit || initialInUnit[ 3 ];
-
- // Make sure we update the tween properties later on
- valueParts = valueParts || [];
-
- // Iteratively approximate from a nonzero starting point
- initialInUnit = +initial || 1;
-
- do {
-
- // If previous iteration zeroed out, double until we get *something*.
- // Use string for doubling so we don't accidentally see scale as unchanged below
- scale = scale || ".5";
-
- // Adjust and apply
- initialInUnit = initialInUnit / scale;
- jQuery.style( elem, prop, initialInUnit + unit );
-
- // Update scale, tolerating zero or NaN from tween.cur()
- // Break the loop if scale is unchanged or perfect, or if we've just had enough.
- } while (
- scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
- );
- }
-
- if ( valueParts ) {
- initialInUnit = +initialInUnit || +initial || 0;
-
- // Apply relative offset (+=/-=) if specified
- adjusted = valueParts[ 1 ] ?
- initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
- +valueParts[ 2 ];
- if ( tween ) {
- tween.unit = unit;
- tween.start = initialInUnit;
- tween.end = adjusted;
- }
- }
- return adjusted;
-}
-
-
-// Multifunctional method to get and set values of a collection
-// The value/s can optionally be executed if it's a function
-var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
- var i = 0,
- length = elems.length,
- bulk = key == null;
-
- // Sets many values
- if ( jQuery.type( key ) === "object" ) {
- chainable = true;
- for ( i in key ) {
- access( elems, fn, i, key[ i ], true, emptyGet, raw );
- }
-
- // Sets one value
- } else if ( value !== undefined ) {
- chainable = true;
-
- if ( !jQuery.isFunction( value ) ) {
- raw = true;
- }
-
- if ( bulk ) {
-
- // Bulk operations run against the entire set
- if ( raw ) {
- fn.call( elems, value );
- fn = null;
-
- // ...except when executing function values
- } else {
- bulk = fn;
- fn = function( elem, key, value ) {
- return bulk.call( jQuery( elem ), value );
- };
- }
- }
-
- if ( fn ) {
- for ( ; i < length; i++ ) {
- fn(
- elems[ i ],
- key,
- raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
- );
- }
- }
- }
-
- return chainable ?
- elems :
-
- // Gets
- bulk ?
- fn.call( elems ) :
- length ? fn( elems[ 0 ], key ) : emptyGet;
-};
-var rcheckableType = ( /^(?:checkbox|radio)$/i );
-
-var rtagName = ( /<([\w:-]+)/ );
-
-var rscriptType = ( /^$|\/(?:java|ecma)script/i );
-
-var rleadingWhitespace = ( /^\s+/ );
-
-var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
- "details|dialog|figcaption|figure|footer|header|hgroup|main|" +
- "mark|meter|nav|output|picture|progress|section|summary|template|time|video";
-
-
-
-function createSafeFragment( document ) {
- var list = nodeNames.split( "|" ),
- safeFrag = document.createDocumentFragment();
-
- if ( safeFrag.createElement ) {
- while ( list.length ) {
- safeFrag.createElement(
- list.pop()
- );
- }
- }
- return safeFrag;
-}
-
-
-( function() {
- var div = document.createElement( "div" ),
- fragment = document.createDocumentFragment(),
- input = document.createElement( "input" );
-
- // Setup
- div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
-
- // IE strips leading whitespace when .innerHTML is used
- support.leadingWhitespace = div.firstChild.nodeType === 3;
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- support.tbody = !div.getElementsByTagName( "tbody" ).length;
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
-
- // Makes sure cloning an html5 element does not cause problems
- // Where outerHTML is undefined, this still works
- support.html5Clone =
- document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- input.type = "checkbox";
- input.checked = true;
- fragment.appendChild( input );
- support.appendChecked = input.checked;
-
- // Make sure textarea (and checkbox) defaultValue is properly cloned
- // Support: IE6-IE11+
- div.innerHTML = "<textarea>x</textarea>";
- support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
-
- // #11217 - WebKit loses check when the name is after the checked attribute
- fragment.appendChild( div );
-
- // Support: Windows Web Apps (WWA)
- // `name` and `type` must use .setAttribute for WWA (#14901)
- input = document.createElement( "input" );
- input.setAttribute( "type", "radio" );
- input.setAttribute( "checked", "checked" );
- input.setAttribute( "name", "t" );
-
- div.appendChild( input );
-
- // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
- // old WebKit doesn't clone checked state correctly in fragments
- support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Support: IE<9
- // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
- support.noCloneEvent = !!div.addEventListener;
-
- // Support: IE<9
- // Since attributes and properties are the same in IE,
- // cleanData must set properties to undefined rather than use removeAttribute
- div[ jQuery.expando ] = 1;
- support.attributes = !div.getAttribute( jQuery.expando );
-} )();
-
-
-// We have to close these tags to support XHTML (#13200)
-var wrapMap = {
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
- legend: [ 1, "<fieldset>", "</fieldset>" ],
- area: [ 1, "<map>", "</map>" ],
-
- // Support: IE8
- param: [ 1, "<object>", "</object>" ],
- thead: [ 1, "<table>", "</table>" ],
- tr: [ 2, "<table><tbody>", "</tbody></table>" ],
- col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
- td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
-
- // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
- // unless wrapped in a div with non-breaking characters in front of it.
- _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
-};
-
-// Support: IE8-IE9
-wrapMap.optgroup = wrapMap.option;
-
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-
-function getAll( context, tag ) {
- var elems, elem,
- i = 0,
- found = typeof context.getElementsByTagName !== "undefined" ?
- context.getElementsByTagName( tag || "*" ) :
- typeof context.querySelectorAll !== "undefined" ?
- context.querySelectorAll( tag || "*" ) :
- undefined;
-
- if ( !found ) {
- for ( found = [], elems = context.childNodes || context;
- ( elem = elems[ i ] ) != null;
- i++
- ) {
- if ( !tag || jQuery.nodeName( elem, tag ) ) {
- found.push( elem );
- } else {
- jQuery.merge( found, getAll( elem, tag ) );
- }
- }
- }
-
- return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
- jQuery.merge( [ context ], found ) :
- found;
-}
-
-
-// Mark scripts as having already been evaluated
-function setGlobalEval( elems, refElements ) {
- var elem,
- i = 0;
- for ( ; ( elem = elems[ i ] ) != null; i++ ) {
- jQuery._data(
- elem,
- "globalEval",
- !refElements || jQuery._data( refElements[ i ], "globalEval" )
- );
- }
-}
-
-
-var rhtml = /<|&#?\w+;/,
- rtbody = /<tbody/i;
-
-function fixDefaultChecked( elem ) {
- if ( rcheckableType.test( elem.type ) ) {
- elem.defaultChecked = elem.checked;
- }
-}
-
-function buildFragment( elems, context, scripts, selection, ignored ) {
- var j, elem, contains,
- tmp, tag, tbody, wrap,
- l = elems.length,
-
- // Ensure a safe fragment
- safe = createSafeFragment( context ),
-
- nodes = [],
- i = 0;
-
- for ( ; i < l; i++ ) {
- elem = elems[ i ];
-
- if ( elem || elem === 0 ) {
-
- // Add nodes directly
- if ( jQuery.type( elem ) === "object" ) {
- jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
-
- // Convert non-html into a text node
- } else if ( !rhtml.test( elem ) ) {
- nodes.push( context.createTextNode( elem ) );
-
- // Convert html into DOM nodes
- } else {
- tmp = tmp || safe.appendChild( context.createElement( "div" ) );
-
- // Deserialize a standard representation
- tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
- wrap = wrapMap[ tag ] || wrapMap._default;
-
- tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
-
- // Descend through wrappers to the right content
- j = wrap[ 0 ];
- while ( j-- ) {
- tmp = tmp.lastChild;
- }
-
- // Manually add leading whitespace removed by IE
- if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
- }
-
- // Remove IE's autoinserted <tbody> from table fragments
- if ( !support.tbody ) {
-
- // String was a <table>, *may* have spurious <tbody>
- elem = tag === "table" && !rtbody.test( elem ) ?
- tmp.firstChild :
-
- // String was a bare <thead> or <tfoot>
- wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
- tmp :
- 0;
-
- j = elem && elem.childNodes.length;
- while ( j-- ) {
- if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
- !tbody.childNodes.length ) {
-
- elem.removeChild( tbody );
- }
- }
- }
-
- jQuery.merge( nodes, tmp.childNodes );
-
- // Fix #12392 for WebKit and IE > 9
- tmp.textContent = "";
-
- // Fix #12392 for oldIE
- while ( tmp.firstChild ) {
- tmp.removeChild( tmp.firstChild );
- }
-
- // Remember the top-level container for proper cleanup
- tmp = safe.lastChild;
- }
- }
- }
-
- // Fix #11356: Clear elements from fragment
- if ( tmp ) {
- safe.removeChild( tmp );
- }
-
- // Reset defaultChecked for any radios and checkboxes
- // about to be appended to the DOM in IE 6/7 (#8060)
- if ( !support.appendChecked ) {
- jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
- }
-
- i = 0;
- while ( ( elem = nodes[ i++ ] ) ) {
-
- // Skip elements already in the context collection (trac-4087)
- if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
- if ( ignored ) {
- ignored.push( elem );
- }
-
- continue;
- }
-
- contains = jQuery.contains( elem.ownerDocument, elem );
-
- // Append to fragment
- tmp = getAll( safe.appendChild( elem ), "script" );
-
- // Preserve script evaluation history
- if ( contains ) {
- setGlobalEval( tmp );
- }
-
- // Capture executables
- if ( scripts ) {
- j = 0;
- while ( ( elem = tmp[ j++ ] ) ) {
- if ( rscriptType.test( elem.type || "" ) ) {
- scripts.push( elem );
- }
- }
- }
- }
-
- tmp = null;
-
- return safe;
-}
-
-
-( function() {
- var i, eventName,
- div = document.createElement( "div" );
-
- // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
- for ( i in { submit: true, change: true, focusin: true } ) {
- eventName = "on" + i;
-
- if ( !( support[ i ] = eventName in window ) ) {
-
- // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
- div.setAttribute( eventName, "t" );
- support[ i ] = div.attributes[ eventName ].expando === false;
- }
- }
-
- // Null elements to avoid leaks in IE.
- div = null;
-} )();
-
-
-var rformElems = /^(?:input|select|textarea)$/i,
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
-
-function returnTrue() {
- return true;
-}
-
-function returnFalse() {
- return false;
-}
-
-// Support: IE9
-// See #13393 for more info
-function safeActiveElement() {
- try {
- return document.activeElement;
- } catch ( err ) { }
-}
-
-function on( elem, types, selector, data, fn, one ) {
- var origFn, type;
-
- // Types can be a map of types/handlers
- if ( typeof types === "object" ) {
-
- // ( types-Object, selector, data )
- if ( typeof selector !== "string" ) {
-
- // ( types-Object, data )
- data = data || selector;
- selector = undefined;
- }
- for ( type in types ) {
- on( elem, type, selector, data, types[ type ], one );
- }
- return elem;
- }
-
- if ( data == null && fn == null ) {
-
- // ( types, fn )
- fn = selector;
- data = selector = undefined;
- } else if ( fn == null ) {
- if ( typeof selector === "string" ) {
-
- // ( types, selector, fn )
- fn = data;
- data = undefined;
- } else {
-
- // ( types, data, fn )
- fn = data;
- data = selector;
- selector = undefined;
- }
- }
- if ( fn === false ) {
- fn = returnFalse;
- } else if ( !fn ) {
- return elem;
- }
-
- if ( one === 1 ) {
- origFn = fn;
- fn = function( event ) {
-
- // Can use an empty set, since event contains the info
- jQuery().off( event );
- return origFn.apply( this, arguments );
- };
-
- // Use same guid so caller can remove using origFn
- fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
- }
- return elem.each( function() {
- jQuery.event.add( this, types, fn, data, selector );
- } );
-}
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- global: {},
-
- add: function( elem, types, handler, data, selector ) {
- var tmp, events, t, handleObjIn,
- special, eventHandle, handleObj,
- handlers, type, namespaces, origType,
- elemData = jQuery._data( elem );
-
- // Don't attach events to noData or text/comment nodes (but allow plain objects)
- if ( !elemData ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- selector = handleObjIn.selector;
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- if ( !( events = elemData.events ) ) {
- events = elemData.events = {};
- }
- if ( !( eventHandle = elemData.handle ) ) {
- eventHandle = elemData.handle = function( e ) {
-
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== "undefined" &&
- ( !e || jQuery.event.triggered !== e.type ) ?
- jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
- undefined;
- };
-
- // Add elem as a property of the handle fn to prevent a memory leak
- // with IE non-native events
- eventHandle.elem = elem;
- }
-
- // Handle multiple events separated by a space
- types = ( types || "" ).match( rnotwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[ t ] ) || [];
- type = origType = tmp[ 1 ];
- namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
-
- // There *must* be a type, no attaching namespace-only handlers
- if ( !type ) {
- continue;
- }
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend( {
- type: type,
- origType: origType,
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
- namespace: namespaces.join( "." )
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- if ( !( handlers = events[ type ] ) ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener/attachEvent if the special events handler returns false
- if ( !special.setup ||
- special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
-
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
- var j, handleObj, tmp,
- origCount, t, events,
- special, handlers, type,
- namespaces, origType,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem );
-
- if ( !elemData || !( events = elemData.events ) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).match( rnotwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[ t ] ) || [];
- type = origType = tmp[ 1 ];
- namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector ? special.delegateType : special.bindType ) || type;
- handlers = events[ type ] || [];
- tmp = tmp[ 2 ] &&
- new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
-
- // Remove matching events
- origCount = j = handlers.length;
- while ( j-- ) {
- handleObj = handlers[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !tmp || tmp.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector ||
- selector === "**" && handleObj.selector ) ) {
- handlers.splice( j, 1 );
-
- if ( handleObj.selector ) {
- handlers.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( origCount && !handlers.length ) {
- if ( !special.teardown ||
- special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
-
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- delete elemData.handle;
-
- // removeData also checks for emptiness and clears the expando if empty
- // so use it instead of delete
- jQuery._removeData( elem, "events" );
- }
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- var handle, ontype, cur,
- bubbleType, special, tmp, i,
- eventPath = [ elem || document ],
- type = hasOwn.call( event, "type" ) ? event.type : event,
- namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
-
- cur = tmp = elem = elem || document;
-
- // Don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf( "." ) > -1 ) {
-
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split( "." );
- type = namespaces.shift();
- namespaces.sort();
- }
- ontype = type.indexOf( ":" ) < 0 && "on" + type;
-
- // Caller can pass in a jQuery.Event object, Object, or just an event type string
- event = event[ jQuery.expando ] ?
- event :
- new jQuery.Event( type, typeof event === "object" && event );
-
- // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
- event.isTrigger = onlyHandlers ? 2 : 3;
- event.namespace = namespaces.join( "." );
- event.rnamespace = event.namespace ?
- new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
- null;
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data == null ?
- [ event ] :
- jQuery.makeArray( data, [ event ] );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- if ( !rfocusMorph.test( bubbleType + type ) ) {
- cur = cur.parentNode;
- }
- for ( ; cur; cur = cur.parentNode ) {
- eventPath.push( cur );
- tmp = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( tmp === ( elem.ownerDocument || document ) ) {
- eventPath.push( tmp.defaultView || tmp.parentWindow || window );
- }
- }
-
- // Fire handlers on the event path
- i = 0;
- while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
-
- event.type = i > 1 ?
- bubbleType :
- special.bindType || type;
-
- // jQuery handler
- handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
- jQuery._data( cur, "handle" );
-
- if ( handle ) {
- handle.apply( cur, data );
- }
-
- // Native handler
- handle = ontype && cur[ ontype ];
- if ( handle && handle.apply && acceptData( cur ) ) {
- event.result = handle.apply( cur, data );
- if ( event.result === false ) {
- event.preventDefault();
- }
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if (
- ( !special._default ||
- special._default.apply( eventPath.pop(), data ) === false
- ) && acceptData( elem )
- ) {
-
- // Call a native DOM method on the target with the same name name as the event.
- // Can't use an .isFunction() check here because IE6/7 fails that test.
- // Don't do default actions on window, that's where global variables be (#6170)
- if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
-
- // Don't re-trigger an onFOO event when we call its FOO() method
- tmp = elem[ ontype ];
-
- if ( tmp ) {
- elem[ ontype ] = null;
- }
-
- // Prevent re-triggering of the same event, since we already bubbled it above
- jQuery.event.triggered = type;
- try {
- elem[ type ]();
- } catch ( e ) {
-
- // IE<9 dies on focus/blur to hidden element (#1486,#12518)
- // only reproducible on winXP IE8 native, not IE9 in IE8 mode
- }
- jQuery.event.triggered = undefined;
-
- if ( tmp ) {
- elem[ ontype ] = tmp;
- }
- }
- }
- }
-
- return event.result;
- },
-
- dispatch: function( event ) {
-
- // Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( event );
-
- var i, j, ret, matched, handleObj,
- handlerQueue = [],
- args = slice.call( arguments ),
- handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
- special = jQuery.event.special[ event.type ] || {};
-
- // Use the fix-ed jQuery.Event rather than the (read-only) native event
- args[ 0 ] = event;
- event.delegateTarget = this;
-
- // Call the preDispatch hook for the mapped type, and let it bail if desired
- if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
- return;
- }
-
- // Determine handlers
- handlerQueue = jQuery.event.handlers.call( this, event, handlers );
-
- // Run delegates first; they may want to stop propagation beneath us
- i = 0;
- while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
- event.currentTarget = matched.elem;
-
- j = 0;
- while ( ( handleObj = matched.handlers[ j++ ] ) &&
- !event.isImmediatePropagationStopped() ) {
-
- // Triggered event must either 1) have no namespace, or 2) have namespace(s)
- // a subset or equal to those in the bound event (both can have no namespace).
- if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
-
- event.handleObj = handleObj;
- event.data = handleObj.data;
-
- ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
- handleObj.handler ).apply( matched.elem, args );
-
- if ( ret !== undefined ) {
- if ( ( event.result = ret ) === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- }
- }
- }
-
- // Call the postDispatch hook for the mapped type
- if ( special.postDispatch ) {
- special.postDispatch.call( this, event );
- }
-
- return event.result;
- },
-
- handlers: function( event, handlers ) {
- var i, matches, sel, handleObj,
- handlerQueue = [],
- delegateCount = handlers.delegateCount,
- cur = event.target;
-
- // Support (at least): Chrome, IE9
- // Find delegate handlers
- // Black-hole SVG <use> instance trees (#13180)
- //
- // Support: Firefox<=42+
- // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
- if ( delegateCount && cur.nodeType &&
- ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
-
- /* jshint eqeqeq: false */
- for ( ; cur != this; cur = cur.parentNode || this ) {
- /* jshint eqeqeq: true */
-
- // Don't check non-elements (#13208)
- // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
- if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
- matches = [];
- for ( i = 0; i < delegateCount; i++ ) {
- handleObj = handlers[ i ];
-
- // Don't conflict with Object.prototype properties (#13203)
- sel = handleObj.selector + " ";
-
- if ( matches[ sel ] === undefined ) {
- matches[ sel ] = handleObj.needsContext ?
- jQuery( sel, this ).index( cur ) > -1 :
- jQuery.find( sel, this, null, [ cur ] ).length;
- }
- if ( matches[ sel ] ) {
- matches.push( handleObj );
- }
- }
- if ( matches.length ) {
- handlerQueue.push( { elem: cur, handlers: matches } );
- }
- }
- }
- }
-
- // Add the remaining (directly-bound) handlers
- if ( delegateCount < handlers.length ) {
- handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
- }
-
- return handlerQueue;
- },
-
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
-
- // Create a writable copy of the event object and normalize some properties
- var i, prop, copy,
- type = event.type,
- originalEvent = event,
- fixHook = this.fixHooks[ type ];
-
- if ( !fixHook ) {
- this.fixHooks[ type ] = fixHook =
- rmouseEvent.test( type ) ? this.mouseHooks :
- rkeyEvent.test( type ) ? this.keyHooks :
- {};
- }
- copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
-
- event = new jQuery.Event( originalEvent );
-
- i = copy.length;
- while ( i-- ) {
- prop = copy[ i ];
- event[ prop ] = originalEvent[ prop ];
- }
-
- // Support: IE<9
- // Fix target property (#1925)
- if ( !event.target ) {
- event.target = originalEvent.srcElement || document;
- }
-
- // Support: Safari 6-8+
- // Target should not be a text node (#504, #13143)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
-
- // Support: IE<9
- // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
- event.metaKey = !!event.metaKey;
-
- return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
- },
-
- // Includes some event props shared by KeyEvent and MouseEvent
- props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
- "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
-
- fixHooks: {},
-
- keyHooks: {
- props: "char charCode key keyCode".split( " " ),
- filter: function( event, original ) {
-
- // Add which for key events
- if ( event.which == null ) {
- event.which = original.charCode != null ? original.charCode : original.keyCode;
- }
-
- return event;
- }
- },
-
- mouseHooks: {
- props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
- "pageX pageY screenX screenY toElement" ).split( " " ),
- filter: function( event, original ) {
- var body, eventDoc, doc,
- button = original.button,
- fromElement = original.fromElement;
-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && original.clientX != null ) {
- eventDoc = event.target.ownerDocument || document;
- doc = eventDoc.documentElement;
- body = eventDoc.body;
-
- event.pageX = original.clientX +
- ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
- ( doc && doc.clientLeft || body && body.clientLeft || 0 );
- event.pageY = original.clientY +
- ( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
- ( doc && doc.clientTop || body && body.clientTop || 0 );
- }
-
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && fromElement ) {
- event.relatedTarget = fromElement === event.target ?
- original.toElement :
- fromElement;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && button !== undefined ) {
- event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
- }
-
- return event;
- }
- },
-
- special: {
- load: {
-
- // Prevent triggered image.load events from bubbling to window.load
- noBubble: true
- },
- focus: {
-
- // Fire native event if possible so blur/focus sequence is correct
- trigger: function() {
- if ( this !== safeActiveElement() && this.focus ) {
- try {
- this.focus();
- return false;
- } catch ( e ) {
-
- // Support: IE<9
- // If we error on focus to hidden element (#1486, #12518),
- // let .trigger() run the handlers
- }
- }
- },
- delegateType: "focusin"
- },
- blur: {
- trigger: function() {
- if ( this === safeActiveElement() && this.blur ) {
- this.blur();
- return false;
- }
- },
- delegateType: "focusout"
- },
- click: {
-
- // For checkbox, fire native event so checked state will be right
- trigger: function() {
- if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
- this.click();
- return false;
- }
- },
-
- // For cross-browser consistency, don't fire native .click() on links
- _default: function( event ) {
- return jQuery.nodeName( event.target, "a" );
- }
- },
-
- beforeunload: {
- postDispatch: function( event ) {
-
- // Support: Firefox 20+
- // Firefox doesn't alert if the returnValue field is not set.
- if ( event.result !== undefined && event.originalEvent ) {
- event.originalEvent.returnValue = event.result;
- }
- }
- }
- },
-
- // Piggyback on a donor event to simulate a different one
- simulate: function( type, elem, event ) {
- var e = jQuery.extend(
- new jQuery.Event(),
- event,
- {
- type: type,
- isSimulated: true
-
- // Previously, `originalEvent: {}` was set here, so stopPropagation call
- // would not be triggered on donor event, since in our own
- // jQuery.event.stopPropagation function we had a check for existence of
- // originalEvent.stopPropagation method, so, consequently it would be a noop.
- //
- // Guard for simulated events was moved to jQuery.event.stopPropagation function
- // since `originalEvent` should point to the original event for the
- // constancy with other events and for more focused logic
- }
- );
-
- jQuery.event.trigger( e, null, elem );
-
- if ( e.isDefaultPrevented() ) {
- event.preventDefault();
- }
- }
-};
-
-jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
-
- // This "if" is needed for plain objects
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle );
- }
- } :
- function( elem, type, handle ) {
- var name = "on" + type;
-
- if ( elem.detachEvent ) {
-
- // #8545, #7054, preventing memory leaks for custom events in IE6-8
- // detachEvent needed property on element, by name of that event,
- // to properly expose it to GC
- if ( typeof elem[ name ] === "undefined" ) {
- elem[ name ] = null;
- }
-
- elem.detachEvent( name, handle );
- }
- };
-
-jQuery.Event = function( src, props ) {
-
- // Allow instantiation without the 'new' keyword
- if ( !( this instanceof jQuery.Event ) ) {
- return new jQuery.Event( src, props );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
-
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = src.defaultPrevented ||
- src.defaultPrevented === undefined &&
-
- // Support: IE < 9, Android < 4.0
- src.returnValue === false ?
- returnTrue :
- returnFalse;
-
- // Event type
- } else {
- this.type = src;
- }
-
- // Put explicitly provided properties onto the event object
- if ( props ) {
- jQuery.extend( this, props );
- }
-
- // Create a timestamp if incoming event doesn't have one
- this.timeStamp = src && src.timeStamp || jQuery.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
- constructor: jQuery.Event,
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse,
-
- preventDefault: function() {
- var e = this.originalEvent;
-
- this.isDefaultPrevented = returnTrue;
- if ( !e ) {
- return;
- }
-
- // If preventDefault exists, run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
-
- // Support: IE
- // Otherwise set the returnValue property of the original event to false
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- var e = this.originalEvent;
-
- this.isPropagationStopped = returnTrue;
-
- if ( !e || this.isSimulated ) {
- return;
- }
-
- // If stopPropagation exists, run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
-
- // Support: IE
- // Set the cancelBubble property of the original event to true
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- var e = this.originalEvent;
-
- this.isImmediatePropagationStopped = returnTrue;
-
- if ( e && e.stopImmediatePropagation ) {
- e.stopImmediatePropagation();
- }
-
- this.stopPropagation();
- }
-};
-
-// Create mouseenter/leave events using mouseover/out and event-time checks
-// so that event delegation works in jQuery.
-// Do the same for pointerenter/pointerleave and pointerover/pointerout
-//
-// Support: Safari 7 only
-// Safari sends mouseenter too often; see:
-// https://code.google.com/p/chromium/issues/detail?id=470258
-// for the description of the bug (it existed in older Chrome versions as well).
-jQuery.each( {
- mouseenter: "mouseover",
- mouseleave: "mouseout",
- pointerenter: "pointerover",
- pointerleave: "pointerout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- delegateType: fix,
- bindType: fix,
-
- handle: function( event ) {
- var ret,
- target = this,
- related = event.relatedTarget,
- handleObj = event.handleObj;
-
- // For mouseenter/leave call the handler if related is outside the target.
- // NB: No relatedTarget if the mouse left/entered the browser window
- if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
- event.type = handleObj.origType;
- ret = handleObj.handler.apply( this, arguments );
- event.type = fix;
- }
- return ret;
- }
- };
-} );
-
-// IE submit delegation
-if ( !support.submit ) {
-
- jQuery.event.special.submit = {
- setup: function() {
-
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Lazy-add a submit handler when a descendant form may potentially be submitted
- jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
-
- // Node name check avoids a VML-related crash in IE (#9807)
- var elem = e.target,
- form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
-
- // Support: IE <=8
- // We use jQuery.prop instead of elem.form
- // to allow fixing the IE8 delegated submit issue (gh-2332)
- // by 3rd party polyfills/workarounds.
- jQuery.prop( elem, "form" ) :
- undefined;
-
- if ( form && !jQuery._data( form, "submit" ) ) {
- jQuery.event.add( form, "submit._submit", function( event ) {
- event._submitBubble = true;
- } );
- jQuery._data( form, "submit", true );
- }
- } );
-
- // return undefined since we don't need an event listener
- },
-
- postDispatch: function( event ) {
-
- // If form was submitted by the user, bubble the event up the tree
- if ( event._submitBubble ) {
- delete event._submitBubble;
- if ( this.parentNode && !event.isTrigger ) {
- jQuery.event.simulate( "submit", this.parentNode, event );
- }
- }
- },
-
- teardown: function() {
-
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
- jQuery.event.remove( this, "._submit" );
- }
- };
-}
-
-// IE change delegation and checkbox/radio fix
-if ( !support.change ) {
-
- jQuery.event.special.change = {
-
- setup: function() {
-
- if ( rformElems.test( this.nodeName ) ) {
-
- // IE doesn't fire change on a check/radio until blur; trigger it on click
- // after a propertychange. Eat the blur-change in special.change.handle.
- // This still fires onchange a second time for check/radio after blur.
- if ( this.type === "checkbox" || this.type === "radio" ) {
- jQuery.event.add( this, "propertychange._change", function( event ) {
- if ( event.originalEvent.propertyName === "checked" ) {
- this._justChanged = true;
- }
- } );
- jQuery.event.add( this, "click._change", function( event ) {
- if ( this._justChanged && !event.isTrigger ) {
- this._justChanged = false;
- }
-
- // Allow triggered, simulated change events (#11500)
- jQuery.event.simulate( "change", this, event );
- } );
- }
- return false;
- }
-
- // Delegated event; lazy-add a change handler on descendant inputs
- jQuery.event.add( this, "beforeactivate._change", function( e ) {
- var elem = e.target;
-
- if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
- jQuery.event.add( elem, "change._change", function( event ) {
- if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
- jQuery.event.simulate( "change", this.parentNode, event );
- }
- } );
- jQuery._data( elem, "change", true );
- }
- } );
- },
-
- handle: function( event ) {
- var elem = event.target;
-
- // Swallow native change events from checkbox/radio, we already triggered them above
- if ( this !== elem || event.isSimulated || event.isTrigger ||
- ( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
-
- return event.handleObj.handler.apply( this, arguments );
- }
- },
-
- teardown: function() {
- jQuery.event.remove( this, "._change" );
-
- return !rformElems.test( this.nodeName );
- }
- };
-}
-
-// Support: Firefox
-// Firefox doesn't have focus(in | out) events
-// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
-//
-// Support: Chrome, Safari
-// focus(in | out) events fire after focus & blur events,
-// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
-// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
-if ( !support.focusin ) {
- jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
- // Attach a single capturing handler on the document while someone wants focusin/focusout
- var handler = function( event ) {
- jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
- };
-
- jQuery.event.special[ fix ] = {
- setup: function() {
- var doc = this.ownerDocument || this,
- attaches = jQuery._data( doc, fix );
-
- if ( !attaches ) {
- doc.addEventListener( orig, handler, true );
- }
- jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
- },
- teardown: function() {
- var doc = this.ownerDocument || this,
- attaches = jQuery._data( doc, fix ) - 1;
-
- if ( !attaches ) {
- doc.removeEventListener( orig, handler, true );
- jQuery._removeData( doc, fix );
- } else {
- jQuery._data( doc, fix, attaches );
- }
- }
- };
- } );
-}
-
-jQuery.fn.extend( {
-
- on: function( types, selector, data, fn ) {
- return on( this, types, selector, data, fn );
- },
- one: function( types, selector, data, fn ) {
- return on( this, types, selector, data, fn, 1 );
- },
- off: function( types, selector, fn ) {
- var handleObj, type;
- if ( types && types.preventDefault && types.handleObj ) {
-
- // ( event ) dispatched jQuery.Event
- handleObj = types.handleObj;
- jQuery( types.delegateTarget ).off(
- handleObj.namespace ?
- handleObj.origType + "." + handleObj.namespace :
- handleObj.origType,
- handleObj.selector,
- handleObj.handler
- );
- return this;
- }
- if ( typeof types === "object" ) {
-
- // ( types-object [, selector] )
- for ( type in types ) {
- this.off( type, selector, types[ type ] );
- }
- return this;
- }
- if ( selector === false || typeof selector === "function" ) {
-
- // ( types [, fn] )
- fn = selector;
- selector = undefined;
- }
- if ( fn === false ) {
- fn = returnFalse;
- }
- return this.each( function() {
- jQuery.event.remove( this, types, fn, selector );
- } );
- },
-
- trigger: function( type, data ) {
- return this.each( function() {
- jQuery.event.trigger( type, data, this );
- } );
- },
- triggerHandler: function( type, data ) {
- var elem = this[ 0 ];
- if ( elem ) {
- return jQuery.event.trigger( type, data, elem, true );
- }
- }
-} );
-
-
-var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
- rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
-
- // Support: IE 10-11, Edge 10240+
- // In IE/Edge using regex groups here causes severe slowdowns.
- // See https://connect.microsoft.com/IE/feedback/details/1736512/
- rnoInnerhtml = /<script|<style|<link/i,
-
- // checked="checked" or checked
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
- rscriptTypeMasked = /^true\/(.*)/,
- rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
- safeFragment = createSafeFragment( document ),
- fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
-
-// Support: IE<8
-// Manipulating tables requires a tbody
-function manipulationTarget( elem, content ) {
- return jQuery.nodeName( elem, "table" ) &&
- jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
-
- elem.getElementsByTagName( "tbody" )[ 0 ] ||
- elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
- elem;
-}
-
-// Replace/restore the type attribute of script elements for safe DOM manipulation
-function disableScript( elem ) {
- elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
- return elem;
-}
-function restoreScript( elem ) {
- var match = rscriptTypeMasked.exec( elem.type );
- if ( match ) {
- elem.type = match[ 1 ];
- } else {
- elem.removeAttribute( "type" );
- }
- return elem;
-}
-
-function cloneCopyEvent( src, dest ) {
- if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
- return;
- }
-
- var type, i, l,
- oldData = jQuery._data( src ),
- curData = jQuery._data( dest, oldData ),
- events = oldData.events;
-
- if ( events ) {
- delete curData.handle;
- curData.events = {};
-
- for ( type in events ) {
- for ( i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ] );
- }
- }
- }
-
- // make the cloned public data object a copy from the original
- if ( curData.data ) {
- curData.data = jQuery.extend( {}, curData.data );
- }
-}
-
-function fixCloneNodeIssues( src, dest ) {
- var nodeName, e, data;
-
- // We do not need to do anything for non-Elements
- if ( dest.nodeType !== 1 ) {
- return;
- }
-
- nodeName = dest.nodeName.toLowerCase();
-
- // IE6-8 copies events bound via attachEvent when using cloneNode.
- if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
- data = jQuery._data( dest );
-
- for ( e in data.events ) {
- jQuery.removeEvent( dest, e, data.handle );
- }
-
- // Event data gets referenced instead of copied if the expando gets copied too
- dest.removeAttribute( jQuery.expando );
- }
-
- // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
- if ( nodeName === "script" && dest.text !== src.text ) {
- disableScript( dest ).text = src.text;
- restoreScript( dest );
-
- // IE6-10 improperly clones children of object elements using classid.
- // IE10 throws NoModificationAllowedError if parent is null, #12132.
- } else if ( nodeName === "object" ) {
- if ( dest.parentNode ) {
- dest.outerHTML = src.outerHTML;
- }
-
- // This path appears unavoidable for IE9. When cloning an object
- // element in IE9, the outerHTML strategy above is not sufficient.
- // If the src has innerHTML and the destination does not,
- // copy the src.innerHTML into the dest.innerHTML. #10324
- if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
- dest.innerHTML = src.innerHTML;
- }
-
- } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
-
- // IE6-8 fails to persist the checked state of a cloned checkbox
- // or radio button. Worse, IE6-7 fail to give the cloned element
- // a checked appearance if the defaultChecked value isn't also set
-
- dest.defaultChecked = dest.checked = src.checked;
-
- // IE6-7 get confused and end up setting the value of a cloned
- // checkbox/radio button to an empty string instead of "on"
- if ( dest.value !== src.value ) {
- dest.value = src.value;
- }
-
- // IE6-8 fails to return the selected option to the default selected
- // state when cloning options
- } else if ( nodeName === "option" ) {
- dest.defaultSelected = dest.selected = src.defaultSelected;
-
- // IE6-8 fails to set the defaultValue to the correct value when
- // cloning other types of input fields
- } else if ( nodeName === "input" || nodeName === "textarea" ) {
- dest.defaultValue = src.defaultValue;
- }
-}
-
-function domManip( collection, args, callback, ignored ) {
-
- // Flatten any nested arrays
- args = concat.apply( [], args );
-
- var first, node, hasScripts,
- scripts, doc, fragment,
- i = 0,
- l = collection.length,
- iNoClone = l - 1,
- value = args[ 0 ],
- isFunction = jQuery.isFunction( value );
-
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( isFunction ||
- ( l > 1 && typeof value === "string" &&
- !support.checkClone && rchecked.test( value ) ) ) {
- return collection.each( function( index ) {
- var self = collection.eq( index );
- if ( isFunction ) {
- args[ 0 ] = value.call( this, index, self.html() );
- }
- domManip( self, args, callback, ignored );
- } );
- }
-
- if ( l ) {
- fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
- first = fragment.firstChild;
-
- if ( fragment.childNodes.length === 1 ) {
- fragment = first;
- }
-
- // Require either new content or an interest in ignored elements to invoke the callback
- if ( first || ignored ) {
- scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
- hasScripts = scripts.length;
-
- // Use the original fragment for the last item
- // instead of the first because it can end up
- // being emptied incorrectly in certain situations (#8070).
- for ( ; i < l; i++ ) {
- node = fragment;
-
- if ( i !== iNoClone ) {
- node = jQuery.clone( node, true, true );
-
- // Keep references to cloned scripts for later restoration
- if ( hasScripts ) {
-
- // Support: Android<4.1, PhantomJS<2
- // push.apply(_, arraylike) throws on ancient WebKit
- jQuery.merge( scripts, getAll( node, "script" ) );
- }
- }
-
- callback.call( collection[ i ], node, i );
- }
-
- if ( hasScripts ) {
- doc = scripts[ scripts.length - 1 ].ownerDocument;
-
- // Reenable scripts
- jQuery.map( scripts, restoreScript );
-
- // Evaluate executable scripts on first document insertion
- for ( i = 0; i < hasScripts; i++ ) {
- node = scripts[ i ];
- if ( rscriptType.test( node.type || "" ) &&
- !jQuery._data( node, "globalEval" ) &&
- jQuery.contains( doc, node ) ) {
-
- if ( node.src ) {
-
- // Optional AJAX dependency, but won't run scripts if not present
- if ( jQuery._evalUrl ) {
- jQuery._evalUrl( node.src );
- }
- } else {
- jQuery.globalEval(
- ( node.text || node.textContent || node.innerHTML || "" )
- .replace( rcleanScript, "" )
- );
- }
- }
- }
- }
-
- // Fix #11809: Avoid leaking memory
- fragment = first = null;
- }
- }
-
- return collection;
-}
-
-function remove( elem, selector, keepData ) {
- var node,
- elems = selector ? jQuery.filter( selector, elem ) : elem,
- i = 0;
-
- for ( ; ( node = elems[ i ] ) != null; i++ ) {
-
- if ( !keepData && node.nodeType === 1 ) {
- jQuery.cleanData( getAll( node ) );
- }
-
- if ( node.parentNode ) {
- if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
- setGlobalEval( getAll( node, "script" ) );
- }
- node.parentNode.removeChild( node );
- }
- }
-
- return elem;
-}
-
-jQuery.extend( {
- htmlPrefilter: function( html ) {
- return html.replace( rxhtmlTag, "<$1></$2>" );
- },
-
- clone: function( elem, dataAndEvents, deepDataAndEvents ) {
- var destElements, node, clone, i, srcElements,
- inPage = jQuery.contains( elem.ownerDocument, elem );
-
- if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
- !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
-
- clone = elem.cloneNode( true );
-
- // IE<=8 does not properly clone detached, unknown element nodes
- } else {
- fragmentDiv.innerHTML = elem.outerHTML;
- fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
- }
-
- if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
- ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
-
- // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
- destElements = getAll( clone );
- srcElements = getAll( elem );
-
- // Fix all IE cloning issues
- for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
-
- // Ensure that the destination node is not null; Fixes #9587
- if ( destElements[ i ] ) {
- fixCloneNodeIssues( node, destElements[ i ] );
- }
- }
- }
-
- // Copy the events from the original to the clone
- if ( dataAndEvents ) {
- if ( deepDataAndEvents ) {
- srcElements = srcElements || getAll( elem );
- destElements = destElements || getAll( clone );
-
- for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
- cloneCopyEvent( node, destElements[ i ] );
- }
- } else {
- cloneCopyEvent( elem, clone );
- }
- }
-
- // Preserve script evaluation history
- destElements = getAll( clone, "script" );
- if ( destElements.length > 0 ) {
- setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
- }
-
- destElements = srcElements = node = null;
-
- // Return the cloned set
- return clone;
- },
-
- cleanData: function( elems, /* internal */ forceAcceptData ) {
- var elem, type, id, data,
- i = 0,
- internalKey = jQuery.expando,
- cache = jQuery.cache,
- attributes = support.attributes,
- special = jQuery.event.special;
-
- for ( ; ( elem = elems[ i ] ) != null; i++ ) {
- if ( forceAcceptData || acceptData( elem ) ) {
-
- id = elem[ internalKey ];
- data = id && cache[ id ];
-
- if ( data ) {
- if ( data.events ) {
- for ( type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
-
- // This is a shortcut to avoid jQuery.event.remove's overhead
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- }
-
- // Remove cache only if it was not already removed by jQuery.event.remove
- if ( cache[ id ] ) {
-
- delete cache[ id ];
-
- // Support: IE<9
- // IE does not allow us to delete expando properties from nodes
- // IE creates expando attributes along with the property
- // IE does not have a removeAttribute function on Document nodes
- if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
- elem.removeAttribute( internalKey );
-
- // Webkit & Blink performance suffers when deleting properties
- // from DOM nodes, so set to undefined instead
- // https://code.google.com/p/chromium/issues/detail?id=378607
- } else {
- elem[ internalKey ] = undefined;
- }
-
- deletedIds.push( id );
- }
- }
- }
- }
- }
-} );
-
-jQuery.fn.extend( {
-
- // Keep domManip exposed until 3.0 (gh-2225)
- domManip: domManip,
-
- detach: function( selector ) {
- return remove( this, selector, true );
- },
-
- remove: function( selector ) {
- return remove( this, selector );
- },
-
- text: function( value ) {
- return access( this, function( value ) {
- return value === undefined ?
- jQuery.text( this ) :
- this.empty().append(
- ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
- );
- }, null, value, arguments.length );
- },
-
- append: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.appendChild( elem );
- }
- } );
- },
-
- prepend: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.insertBefore( elem, target.firstChild );
- }
- } );
- },
-
- before: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this );
- }
- } );
- },
-
- after: function() {
- return domManip( this, arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- }
- } );
- },
-
- empty: function() {
- var elem,
- i = 0;
-
- for ( ; ( elem = this[ i ] ) != null; i++ ) {
-
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem, false ) );
- }
-
- // Remove any remaining nodes
- while ( elem.firstChild ) {
- elem.removeChild( elem.firstChild );
- }
-
- // If this is a select, ensure that it displays empty (#12336)
- // Support: IE<9
- if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
- elem.options.length = 0;
- }
- }
-
- return this;
- },
-
- clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
-
- return this.map( function() {
- return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
- } );
- },
-
- html: function( value ) {
- return access( this, function( value ) {
- var elem = this[ 0 ] || {},
- i = 0,
- l = this.length;
-
- if ( value === undefined ) {
- return elem.nodeType === 1 ?
- elem.innerHTML.replace( rinlinejQuery, "" ) :
- undefined;
- }
-
- // See if we can take a shortcut and just use innerHTML
- if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
- ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
- ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
- !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
-
- value = jQuery.htmlPrefilter( value );
-
- try {
- for ( ; i < l; i++ ) {
-
- // Remove element nodes and prevent memory leaks
- elem = this[ i ] || {};
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem, false ) );
- elem.innerHTML = value;
- }
- }
-
- elem = 0;
-
- // If using innerHTML throws an exception, use the fallback method
- } catch ( e ) {}
- }
-
- if ( elem ) {
- this.empty().append( value );
- }
- }, null, value, arguments.length );
- },
-
- replaceWith: function() {
- var ignored = [];
-
- // Make the changes, replacing each non-ignored context element with the new content
- return domManip( this, arguments, function( elem ) {
- var parent = this.parentNode;
-
- if ( jQuery.inArray( this, ignored ) < 0 ) {
- jQuery.cleanData( getAll( this ) );
- if ( parent ) {
- parent.replaceChild( elem, this );
- }
- }
-
- // Force callback invocation
- }, ignored );
- }
-} );
-
-jQuery.each( {
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
-}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var elems,
- i = 0,
- ret = [],
- insert = jQuery( selector ),
- last = insert.length - 1;
-
- for ( ; i <= last; i++ ) {
- elems = i === last ? this : this.clone( true );
- jQuery( insert[ i ] )[ original ]( elems );
-
- // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
- push.apply( ret, elems.get() );
- }
-
- return this.pushStack( ret );
- };
-} );
-
-
-var iframe,
- elemdisplay = {
-
- // Support: Firefox
- // We have to pre-define these values for FF (#10227)
- HTML: "block",
- BODY: "block"
- };
-
-/**
- * Retrieve the actual display of a element
- * @param {String} name nodeName of the element
- * @param {Object} doc Document object
- */
-
-// Called only from within defaultDisplay
-function actualDisplay( name, doc ) {
- var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
-
- display = jQuery.css( elem[ 0 ], "display" );
-
- // We don't have any data stored on the element,
- // so use "detach" method as fast way to get rid of the element
- elem.detach();
-
- return display;
-}
-
-/**
- * Try to determine the default display value of an element
- * @param {String} nodeName
- */
-function defaultDisplay( nodeName ) {
- var doc = document,
- display = elemdisplay[ nodeName ];
-
- if ( !display ) {
- display = actualDisplay( nodeName, doc );
-
- // If the simple way fails, read from inside an iframe
- if ( display === "none" || !display ) {
-
- // Use the already-created iframe if possible
- iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
- .appendTo( doc.documentElement );
-
- // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
- doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
-
- // Support: IE
- doc.write();
- doc.close();
-
- display = actualDisplay( nodeName, doc );
- iframe.detach();
- }
-
- // Store the correct default display
- elemdisplay[ nodeName ] = display;
- }
-
- return display;
-}
-var rmargin = ( /^margin/ );
-
-var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
-
-var swap = function( elem, options, callback, args ) {
- var ret, name,
- old = {};
-
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- ret = callback.apply( elem, args || [] );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
-
- return ret;
-};
-
-
-var documentElement = document.documentElement;
-
-
-
-( function() {
- var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
- reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
- container = document.createElement( "div" ),
- div = document.createElement( "div" );
-
- // Finish early in limited (non-browser) environments
- if ( !div.style ) {
- return;
- }
-
- div.style.cssText = "float:left;opacity:.5";
-
- // Support: IE<9
- // Make sure that element opacity exists (as opposed to filter)
- support.opacity = div.style.opacity === "0.5";
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- support.cssFloat = !!div.style.cssFloat;
-
- div.style.backgroundClip = "content-box";
- div.cloneNode( true ).style.backgroundClip = "";
- support.clearCloneStyle = div.style.backgroundClip === "content-box";
-
- container = document.createElement( "div" );
- container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
- "padding:0;margin-top:1px;position:absolute";
- div.innerHTML = "";
- container.appendChild( div );
-
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
- div.style.WebkitBoxSizing === "";
-
- jQuery.extend( support, {
- reliableHiddenOffsets: function() {
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return reliableHiddenOffsetsVal;
- },
-
- boxSizingReliable: function() {
-
- // We're checking for pixelPositionVal here instead of boxSizingReliableVal
- // since that compresses better and they're computed together anyway.
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return boxSizingReliableVal;
- },
-
- pixelMarginRight: function() {
-
- // Support: Android 4.0-4.3
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return pixelMarginRightVal;
- },
-
- pixelPosition: function() {
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return pixelPositionVal;
- },
-
- reliableMarginRight: function() {
-
- // Support: Android 2.3
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return reliableMarginRightVal;
- },
-
- reliableMarginLeft: function() {
-
- // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return reliableMarginLeftVal;
- }
- } );
-
- function computeStyleTests() {
- var contents, divStyle,
- documentElement = document.documentElement;
-
- // Setup
- documentElement.appendChild( container );
-
- div.style.cssText =
-
- // Support: Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:border-box;box-sizing:border-box;" +
- "position:relative;display:block;" +
- "margin:auto;border:1px;padding:1px;" +
- "top:1%;width:50%";
-
- // Support: IE<9
- // Assume reasonable values in the absence of getComputedStyle
- pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
- pixelMarginRightVal = reliableMarginRightVal = true;
-
- // Check for getComputedStyle so that this code is not run in IE<9.
- if ( window.getComputedStyle ) {
- divStyle = window.getComputedStyle( div );
- pixelPositionVal = ( divStyle || {} ).top !== "1%";
- reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
- boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
-
- // Support: Android 4.0 - 4.3 only
- // Some styles come back with percentage values, even though they shouldn't
- div.style.marginRight = "50%";
- pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
-
- // Support: Android 2.3 only
- // Div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container (#3333)
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- contents = div.appendChild( document.createElement( "div" ) );
-
- // Reset CSS: box-sizing; display; margin; border; padding
- contents.style.cssText = div.style.cssText =
-
- // Support: Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
- "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
- contents.style.marginRight = contents.style.width = "0";
- div.style.width = "1px";
-
- reliableMarginRightVal =
- !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
-
- div.removeChild( contents );
- }
-
- // Support: IE6-8
- // First check that getClientRects works as expected
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- div.style.display = "none";
- reliableHiddenOffsetsVal = div.getClientRects().length === 0;
- if ( reliableHiddenOffsetsVal ) {
- div.style.display = "";
- div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
- div.childNodes[ 0 ].style.borderCollapse = "separate";
- contents = div.getElementsByTagName( "td" );
- contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
- reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
- if ( reliableHiddenOffsetsVal ) {
- contents[ 0 ].style.display = "";
- contents[ 1 ].style.display = "none";
- reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
- }
- }
-
- // Teardown
- documentElement.removeChild( container );
- }
-
-} )();
-
-
-var getStyles, curCSS,
- rposition = /^(top|right|bottom|left)$/;
-
-if ( window.getComputedStyle ) {
- getStyles = function( elem ) {
-
- // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
- // IE throws on elements created in popups
- // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
- var view = elem.ownerDocument.defaultView;
-
- if ( !view || !view.opener ) {
- view = window;
- }
-
- return view.getComputedStyle( elem );
- };
-
- curCSS = function( elem, name, computed ) {
- var width, minWidth, maxWidth, ret,
- style = elem.style;
-
- computed = computed || getStyles( elem );
-
- // getPropertyValue is only needed for .css('filter') in IE9, see #12537
- ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
-
- // Support: Opera 12.1x only
- // Fall back to style even without computed
- // computed is undefined for elems on document fragments
- if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
- ret = jQuery.style( elem, name );
- }
-
- if ( computed ) {
-
- // A tribute to the "awesome hack by Dean Edwards"
- // Chrome < 17 and Safari 5.0 uses "computed value"
- // instead of "used value" for margin-right
- // Safari 5.1.7 (at least) returns percentage for a larger set of values,
- // but width seems to be reliably pixels
- // this is against the CSSOM draft spec:
- // http://dev.w3.org/csswg/cssom/#resolved-values
- if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
-
- // Remember the original values
- width = style.width;
- minWidth = style.minWidth;
- maxWidth = style.maxWidth;
-
- // Put in the new values to get a computed value out
- style.minWidth = style.maxWidth = style.width = ret;
- ret = computed.width;
-
- // Revert the changed values
- style.width = width;
- style.minWidth = minWidth;
- style.maxWidth = maxWidth;
- }
- }
-
- // Support: IE
- // IE returns zIndex value as an integer.
- return ret === undefined ?
- ret :
- ret + "";
- };
-} else if ( documentElement.currentStyle ) {
- getStyles = function( elem ) {
- return elem.currentStyle;
- };
-
- curCSS = function( elem, name, computed ) {
- var left, rs, rsLeft, ret,
- style = elem.style;
-
- computed = computed || getStyles( elem );
- ret = computed ? computed[ name ] : undefined;
-
- // Avoid setting ret to empty string here
- // so we don't default to auto
- if ( ret == null && style && style[ name ] ) {
- ret = style[ name ];
- }
-
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- // but not position css attributes, as those are
- // proportional to the parent element instead
- // and we can't measure the parent instead because it
- // might trigger a "stacking dolls" problem
- if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
-
- // Remember the original values
- left = style.left;
- rs = elem.runtimeStyle;
- rsLeft = rs && rs.left;
-
- // Put in the new values to get a computed value out
- if ( rsLeft ) {
- rs.left = elem.currentStyle.left;
- }
- style.left = name === "fontSize" ? "1em" : ret;
- ret = style.pixelLeft + "px";
-
- // Revert the changed values
- style.left = left;
- if ( rsLeft ) {
- rs.left = rsLeft;
- }
- }
-
- // Support: IE
- // IE returns zIndex value as an integer.
- return ret === undefined ?
- ret :
- ret + "" || "auto";
- };
-}
-
-
-
-
-function addGetHookIf( conditionFn, hookFn ) {
-
- // Define the hook, we'll check on the first run if it's really needed.
- return {
- get: function() {
- if ( conditionFn() ) {
-
- // Hook not needed (or it's not possible to use it due
- // to missing dependency), remove it.
- delete this.get;
- return;
- }
-
- // Hook needed; redefine it so that the support test is not executed again.
- return ( this.get = hookFn ).apply( this, arguments );
- }
- };
-}
-
-
-var
-
- ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity\s*=\s*([^)]*)/i,
-
- // swappable if display is none or starts with table except
- // "table", "table-cell", or "table-caption"
- // see here for display values:
- // https://developer.mozilla.org/en-US/docs/CSS/display
- rdisplayswap = /^(none|table(?!-c[ea]).+)/,
- rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
-
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssNormalTransform = {
- letterSpacing: "0",
- fontWeight: "400"
- },
-
- cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
- emptyStyle = document.createElement( "div" ).style;
-
-
-// return a css property mapped to a potentially vendor prefixed property
-function vendorPropName( name ) {
-
- // shortcut for names that are not vendor prefixed
- if ( name in emptyStyle ) {
- return name;
- }
-
- // check for vendor prefixed names
- var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
- i = cssPrefixes.length;
-
- while ( i-- ) {
- name = cssPrefixes[ i ] + capName;
- if ( name in emptyStyle ) {
- return name;
- }
- }
-}
-
-function showHide( elements, show ) {
- var display, elem, hidden,
- values = [],
- index = 0,
- length = elements.length;
-
- for ( ; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
-
- values[ index ] = jQuery._data( elem, "olddisplay" );
- display = elem.style.display;
- if ( show ) {
-
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !values[ index ] && display === "none" ) {
- elem.style.display = "";
- }
-
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( elem.style.display === "" && isHidden( elem ) ) {
- values[ index ] =
- jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
- }
- } else {
- hidden = isHidden( elem );
-
- if ( display && display !== "none" || !hidden ) {
- jQuery._data(
- elem,
- "olddisplay",
- hidden ? display : jQuery.css( elem, "display" )
- );
- }
- }
- }
-
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( index = 0; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
- if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
- elem.style.display = show ? values[ index ] || "" : "none";
- }
- }
-
- return elements;
-}
-
-function setPositiveNumber( elem, value, subtract ) {
- var matches = rnumsplit.exec( value );
- return matches ?
-
- // Guard against undefined "subtract", e.g., when used as in cssHooks
- Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
- value;
-}
-
-function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
- var i = extra === ( isBorderBox ? "border" : "content" ) ?
-
- // If we already have the right measurement, avoid augmentation
- 4 :
-
- // Otherwise initialize for horizontal or vertical properties
- name === "width" ? 1 : 0,
-
- val = 0;
-
- for ( ; i < 4; i += 2 ) {
-
- // both box models exclude margin, so add it if we want it
- if ( extra === "margin" ) {
- val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
- }
-
- if ( isBorderBox ) {
-
- // border-box includes padding, so remove it if we want content
- if ( extra === "content" ) {
- val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
- }
-
- // at this point, extra isn't border nor margin, so remove border
- if ( extra !== "margin" ) {
- val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
- } else {
-
- // at this point, extra isn't content, so add padding
- val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
-
- // at this point, extra isn't content nor padding, so add border
- if ( extra !== "padding" ) {
- val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
- }
- }
-
- return val;
-}
-
-function getWidthOrHeight( elem, name, extra ) {
-
- // Start with offset property, which is equivalent to the border-box value
- var valueIsBorderBox = true,
- val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
- styles = getStyles( elem ),
- isBorderBox = support.boxSizing &&
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
-
- // some non-html elements return undefined for offsetWidth, so check for null/undefined
- // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
- // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
- if ( val <= 0 || val == null ) {
-
- // Fall back to computed then uncomputed css if necessary
- val = curCSS( elem, name, styles );
- if ( val < 0 || val == null ) {
- val = elem.style[ name ];
- }
-
- // Computed unit is not pixels. Stop here and return.
- if ( rnumnonpx.test( val ) ) {
- return val;
- }
-
- // we need the check for style in case a browser which returns unreliable values
- // for getComputedStyle silently falls back to the reliable elem.style
- valueIsBorderBox = isBorderBox &&
- ( support.boxSizingReliable() || val === elem.style[ name ] );
-
- // Normalize "", auto, and prepare for extra
- val = parseFloat( val ) || 0;
- }
-
- // use the active box-sizing model to add/subtract irrelevant styles
- return ( val +
- augmentWidthOrHeight(
- elem,
- name,
- extra || ( isBorderBox ? "border" : "content" ),
- valueIsBorderBox,
- styles
- )
- ) + "px";
-}
-
-jQuery.extend( {
-
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
-
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity" );
- return ret === "" ? "1" : ret;
- }
- }
- }
- },
-
- // Don't automatically add "px" to these possibly-unitless properties
- cssNumber: {
- "animationIterationCount": true,
- "columnCount": true,
- "fillOpacity": true,
- "flexGrow": true,
- "flexShrink": true,
- "fontWeight": true,
- "lineHeight": true,
- "opacity": true,
- "order": true,
- "orphans": true,
- "widows": true,
- "zIndex": true,
- "zoom": true
- },
-
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {
-
- // normalize float css property
- "float": support.cssFloat ? "cssFloat" : "styleFloat"
- },
-
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
-
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
-
- // Make sure that we're working with the right name
- var ret, type, hooks,
- origName = jQuery.camelCase( name ),
- style = elem.style;
-
- name = jQuery.cssProps[ origName ] ||
- ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // Check if we're setting a value
- if ( value !== undefined ) {
- type = typeof value;
-
- // Convert "+=" or "-=" to relative numbers (#7345)
- if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
- value = adjustCSS( elem, name, ret );
-
- // Fixes bug #9237
- type = "number";
- }
-
- // Make sure that null and NaN values aren't set. See: #7116
- if ( value == null || value !== value ) {
- return;
- }
-
- // If a number was passed in, add the unit (except for certain CSS properties)
- if ( type === "number" ) {
- value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
- }
-
- // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
- // but it would mean to define eight
- // (for every problematic property) identical functions
- if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
- style[ name ] = "inherit";
- }
-
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !( "set" in hooks ) ||
- ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
-
- // Support: IE
- // Swallow errors from 'invalid' CSS values (#5509)
- try {
- style[ name ] = value;
- } catch ( e ) {}
- }
-
- } else {
-
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks &&
- ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
-
- return ret;
- }
-
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
-
- css: function( elem, name, extra, styles ) {
- var num, val, hooks,
- origName = jQuery.camelCase( name );
-
- // Make sure that we're working with the right name
- name = jQuery.cssProps[ origName ] ||
- ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks ) {
- val = hooks.get( elem, true, extra );
- }
-
- // Otherwise, if a way to get the computed value exists, use that
- if ( val === undefined ) {
- val = curCSS( elem, name, styles );
- }
-
- //convert "normal" to computed value
- if ( val === "normal" && name in cssNormalTransform ) {
- val = cssNormalTransform[ name ];
- }
-
- // Return, converting to number if forced or a qualifier was provided and val looks numeric
- if ( extra === "" || extra ) {
- num = parseFloat( val );
- return extra === true || isFinite( num ) ? num || 0 : val;
- }
- return val;
- }
-} );
-
-jQuery.each( [ "height", "width" ], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- if ( computed ) {
-
- // certain elements can have dimension info if we invisibly show them
- // however, it must have a current display style that would benefit from this
- return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
- elem.offsetWidth === 0 ?
- swap( elem, cssShow, function() {
- return getWidthOrHeight( elem, name, extra );
- } ) :
- getWidthOrHeight( elem, name, extra );
- }
- },
-
- set: function( elem, value, extra ) {
- var styles = extra && getStyles( elem );
- return setPositiveNumber( elem, value, extra ?
- augmentWidthOrHeight(
- elem,
- name,
- extra,
- support.boxSizing &&
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
- styles
- ) : 0
- );
- }
- };
-} );
-
-if ( !support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
-
- // IE uses filters for opacity
- return ropacity.test( ( computed && elem.currentStyle ?
- elem.currentStyle.filter :
- elem.style.filter ) || "" ) ?
- ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
- computed ? "1" : "";
- },
-
- set: function( elem, value ) {
- var style = elem.style,
- currentStyle = elem.currentStyle,
- opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
- filter = currentStyle && currentStyle.filter || style.filter || "";
-
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
-
- // if setting opacity to 1, and no other filters exist -
- // attempt to remove filter attribute #6652
- // if value === "", then remove inline opacity #12685
- if ( ( value >= 1 || value === "" ) &&
- jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
- style.removeAttribute ) {
-
- // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
- // if "filter:" is present at all, clearType is disabled, we want to avoid this
- // style.removeAttribute is IE Only, but so apparently is this code path...
- style.removeAttribute( "filter" );
-
- // if there is no filter style applied in a css rule
- // or unset inline opacity, we are done
- if ( value === "" || currentStyle && !currentStyle.filter ) {
- return;
- }
- }
-
- // otherwise, set new filter values
- style.filter = ralpha.test( filter ) ?
- filter.replace( ralpha, opacity ) :
- filter + " " + opacity;
- }
- };
-}
-
-jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
- function( elem, computed ) {
- if ( computed ) {
- return swap( elem, { "display": "inline-block" },
- curCSS, [ elem, "marginRight" ] );
- }
- }
-);
-
-jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
- function( elem, computed ) {
- if ( computed ) {
- return (
- parseFloat( curCSS( elem, "marginLeft" ) ) ||
-
- // Support: IE<=11+
- // Running getBoundingClientRect on a disconnected node in IE throws an error
- // Support: IE8 only
- // getClientRects() errors on disconnected elems
- ( jQuery.contains( elem.ownerDocument, elem ) ?
- elem.getBoundingClientRect().left -
- swap( elem, { marginLeft: 0 }, function() {
- return elem.getBoundingClientRect().left;
- } ) :
- 0
- )
- ) + "px";
- }
- }
-);
-
-// These hooks are used by animate to expand properties
-jQuery.each( {
- margin: "",
- padding: "",
- border: "Width"
-}, function( prefix, suffix ) {
- jQuery.cssHooks[ prefix + suffix ] = {
- expand: function( value ) {
- var i = 0,
- expanded = {},
-
- // assumes a single number if not a string
- parts = typeof value === "string" ? value.split( " " ) : [ value ];
-
- for ( ; i < 4; i++ ) {
- expanded[ prefix + cssExpand[ i ] + suffix ] =
- parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
- }
-
- return expanded;
- }
- };
-
- if ( !rmargin.test( prefix ) ) {
- jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
- }
-} );
-
-jQuery.fn.extend( {
- css: function( name, value ) {
- return access( this, function( elem, name, value ) {
- var styles, len,
- map = {},
- i = 0;
-
- if ( jQuery.isArray( name ) ) {
- styles = getStyles( elem );
- len = name.length;
-
- for ( ; i < len; i++ ) {
- map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
- }
-
- return map;
- }
-
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- }, name, value, arguments.length > 1 );
- },
- show: function() {
- return showHide( this, true );
- },
- hide: function() {
- return showHide( this );
- },
- toggle: function( state ) {
- if ( typeof state === "boolean" ) {
- return state ? this.show() : this.hide();
- }
-
- return this.each( function() {
- if ( isHidden( this ) ) {
- jQuery( this ).show();
- } else {
- jQuery( this ).hide();
- }
- } );
- }
-} );
-
-
-function Tween( elem, options, prop, end, easing ) {
- return new Tween.prototype.init( elem, options, prop, end, easing );
-}
-jQuery.Tween = Tween;
-
-Tween.prototype = {
- constructor: Tween,
- init: function( elem, options, prop, end, easing, unit ) {
- this.elem = elem;
- this.prop = prop;
- this.easing = easing || jQuery.easing._default;
- this.options = options;
- this.start = this.now = this.cur();
- this.end = end;
- this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
- },
- cur: function() {
- var hooks = Tween.propHooks[ this.prop ];
-
- return hooks && hooks.get ?
- hooks.get( this ) :
- Tween.propHooks._default.get( this );
- },
- run: function( percent ) {
- var eased,
- hooks = Tween.propHooks[ this.prop ];
-
- if ( this.options.duration ) {
- this.pos = eased = jQuery.easing[ this.easing ](
- percent, this.options.duration * percent, 0, 1, this.options.duration
- );
- } else {
- this.pos = eased = percent;
- }
- this.now = ( this.end - this.start ) * eased + this.start;
-
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- if ( hooks && hooks.set ) {
- hooks.set( this );
- } else {
- Tween.propHooks._default.set( this );
- }
- return this;
- }
-};
-
-Tween.prototype.init.prototype = Tween.prototype;
-
-Tween.propHooks = {
- _default: {
- get: function( tween ) {
- var result;
-
- // Use a property on the element directly when it is not a DOM element,
- // or when there is no matching style property that exists.
- if ( tween.elem.nodeType !== 1 ||
- tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
- return tween.elem[ tween.prop ];
- }
-
- // passing an empty string as a 3rd parameter to .css will automatically
- // attempt a parseFloat and fallback to a string if the parse fails
- // so, simple values such as "10px" are parsed to Float.
- // complex values such as "rotate(1rad)" are returned as is.
- result = jQuery.css( tween.elem, tween.prop, "" );
-
- // Empty strings, null, undefined and "auto" are converted to 0.
- return !result || result === "auto" ? 0 : result;
- },
- set: function( tween ) {
-
- // use step hook for back compat - use cssHook if its there - use .style if its
- // available and use plain properties where available
- if ( jQuery.fx.step[ tween.prop ] ) {
- jQuery.fx.step[ tween.prop ]( tween );
- } else if ( tween.elem.nodeType === 1 &&
- ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
- jQuery.cssHooks[ tween.prop ] ) ) {
- jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
- } else {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- }
-};
-
-// Support: IE <=9
-// Panic based approach to setting things on disconnected nodes
-
-Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
- set: function( tween ) {
- if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
-};
-
-jQuery.easing = {
- linear: function( p ) {
- return p;
- },
- swing: function( p ) {
- return 0.5 - Math.cos( p * Math.PI ) / 2;
- },
- _default: "swing"
-};
-
-jQuery.fx = Tween.prototype.init;
-
-// Back Compat <1.8 extension point
-jQuery.fx.step = {};
-
-
-
-
-var
- fxNow, timerId,
- rfxtypes = /^(?:toggle|show|hide)$/,
- rrun = /queueHooks$/;
-
-// Animations created synchronously will run synchronously
-function createFxNow() {
- window.setTimeout( function() {
- fxNow = undefined;
- } );
- return ( fxNow = jQuery.now() );
-}
-
-// Generate parameters to create a standard animation
-function genFx( type, includeWidth ) {
- var which,
- attrs = { height: type },
- i = 0;
-
- // if we include width, step value is 1 to do all cssExpand values,
- // if we don't include width, step value is 2 to skip over Left and Right
- includeWidth = includeWidth ? 1 : 0;
- for ( ; i < 4 ; i += 2 - includeWidth ) {
- which = cssExpand[ i ];
- attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
- }
-
- if ( includeWidth ) {
- attrs.opacity = attrs.width = type;
- }
-
- return attrs;
-}
-
-function createTween( value, prop, animation ) {
- var tween,
- collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
- index = 0,
- length = collection.length;
- for ( ; index < length; index++ ) {
- if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
-
- // we're done with this property
- return tween;
- }
- }
-}
-
-function defaultPrefilter( elem, props, opts ) {
- /* jshint validthis: true */
- var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
- anim = this,
- orig = {},
- style = elem.style,
- hidden = elem.nodeType && isHidden( elem ),
- dataShow = jQuery._data( elem, "fxshow" );
-
- // handle queue: false promises
- if ( !opts.queue ) {
- hooks = jQuery._queueHooks( elem, "fx" );
- if ( hooks.unqueued == null ) {
- hooks.unqueued = 0;
- oldfire = hooks.empty.fire;
- hooks.empty.fire = function() {
- if ( !hooks.unqueued ) {
- oldfire();
- }
- };
- }
- hooks.unqueued++;
-
- anim.always( function() {
-
- // doing this makes sure that the complete handler will be called
- // before this completes
- anim.always( function() {
- hooks.unqueued--;
- if ( !jQuery.queue( elem, "fx" ).length ) {
- hooks.empty.fire();
- }
- } );
- } );
- }
-
- // height/width overflow pass
- if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
-
- // Make sure that nothing sneaks out
- // Record all 3 overflow attributes because IE does not
- // change the overflow attribute when overflowX and
- // overflowY are set to the same value
- opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
-
- // Set display property to inline-block for height/width
- // animations on inline elements that are having width/height animated
- display = jQuery.css( elem, "display" );
-
- // Test default display if display is currently "none"
- checkDisplay = display === "none" ?
- jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
-
- if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
-
- // inline-level elements accept inline-block;
- // block-level elements need to be inline with layout
- if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
- style.display = "inline-block";
- } else {
- style.zoom = 1;
- }
- }
- }
-
- if ( opts.overflow ) {
- style.overflow = "hidden";
- if ( !support.shrinkWrapBlocks() ) {
- anim.always( function() {
- style.overflow = opts.overflow[ 0 ];
- style.overflowX = opts.overflow[ 1 ];
- style.overflowY = opts.overflow[ 2 ];
- } );
- }
- }
-
- // show/hide pass
- for ( prop in props ) {
- value = props[ prop ];
- if ( rfxtypes.exec( value ) ) {
- delete props[ prop ];
- toggle = toggle || value === "toggle";
- if ( value === ( hidden ? "hide" : "show" ) ) {
-
- // If there is dataShow left over from a stopped hide or show
- // and we are going to proceed with show, we should pretend to be hidden
- if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
- hidden = true;
- } else {
- continue;
- }
- }
- orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
-
- // Any non-fx value stops us from restoring the original display value
- } else {
- display = undefined;
- }
- }
-
- if ( !jQuery.isEmptyObject( orig ) ) {
- if ( dataShow ) {
- if ( "hidden" in dataShow ) {
- hidden = dataShow.hidden;
- }
- } else {
- dataShow = jQuery._data( elem, "fxshow", {} );
- }
-
- // store state if its toggle - enables .stop().toggle() to "reverse"
- if ( toggle ) {
- dataShow.hidden = !hidden;
- }
- if ( hidden ) {
- jQuery( elem ).show();
- } else {
- anim.done( function() {
- jQuery( elem ).hide();
- } );
- }
- anim.done( function() {
- var prop;
- jQuery._removeData( elem, "fxshow" );
- for ( prop in orig ) {
- jQuery.style( elem, prop, orig[ prop ] );
- }
- } );
- for ( prop in orig ) {
- tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
-
- if ( !( prop in dataShow ) ) {
- dataShow[ prop ] = tween.start;
- if ( hidden ) {
- tween.end = tween.start;
- tween.start = prop === "width" || prop === "height" ? 1 : 0;
- }
- }
- }
-
- // If this is a noop like .hide().hide(), restore an overwritten display value
- } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
- style.display = display;
- }
-}
-
-function propFilter( props, specialEasing ) {
- var index, name, easing, value, hooks;
-
- // camelCase, specialEasing and expand cssHook pass
- for ( index in props ) {
- name = jQuery.camelCase( index );
- easing = specialEasing[ name ];
- value = props[ index ];
- if ( jQuery.isArray( value ) ) {
- easing = value[ 1 ];
- value = props[ index ] = value[ 0 ];
- }
-
- if ( index !== name ) {
- props[ name ] = value;
- delete props[ index ];
- }
-
- hooks = jQuery.cssHooks[ name ];
- if ( hooks && "expand" in hooks ) {
- value = hooks.expand( value );
- delete props[ name ];
-
- // not quite $.extend, this wont overwrite keys already present.
- // also - reusing 'index' from above because we have the correct "name"
- for ( index in value ) {
- if ( !( index in props ) ) {
- props[ index ] = value[ index ];
- specialEasing[ index ] = easing;
- }
- }
- } else {
- specialEasing[ name ] = easing;
- }
- }
-}
-
-function Animation( elem, properties, options ) {
- var result,
- stopped,
- index = 0,
- length = Animation.prefilters.length,
- deferred = jQuery.Deferred().always( function() {
-
- // don't match elem in the :animated selector
- delete tick.elem;
- } ),
- tick = function() {
- if ( stopped ) {
- return false;
- }
- var currentTime = fxNow || createFxNow(),
- remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
-
- // Support: Android 2.3
- // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
- temp = remaining / animation.duration || 0,
- percent = 1 - temp,
- index = 0,
- length = animation.tweens.length;
-
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( percent );
- }
-
- deferred.notifyWith( elem, [ animation, percent, remaining ] );
-
- if ( percent < 1 && length ) {
- return remaining;
- } else {
- deferred.resolveWith( elem, [ animation ] );
- return false;
- }
- },
- animation = deferred.promise( {
- elem: elem,
- props: jQuery.extend( {}, properties ),
- opts: jQuery.extend( true, {
- specialEasing: {},
- easing: jQuery.easing._default
- }, options ),
- originalProperties: properties,
- originalOptions: options,
- startTime: fxNow || createFxNow(),
- duration: options.duration,
- tweens: [],
- createTween: function( prop, end ) {
- var tween = jQuery.Tween( elem, animation.opts, prop, end,
- animation.opts.specialEasing[ prop ] || animation.opts.easing );
- animation.tweens.push( tween );
- return tween;
- },
- stop: function( gotoEnd ) {
- var index = 0,
-
- // if we are going to the end, we want to run all the tweens
- // otherwise we skip this part
- length = gotoEnd ? animation.tweens.length : 0;
- if ( stopped ) {
- return this;
- }
- stopped = true;
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( 1 );
- }
-
- // resolve when we played the last frame
- // otherwise, reject
- if ( gotoEnd ) {
- deferred.notifyWith( elem, [ animation, 1, 0 ] );
- deferred.resolveWith( elem, [ animation, gotoEnd ] );
- } else {
- deferred.rejectWith( elem, [ animation, gotoEnd ] );
- }
- return this;
- }
- } ),
- props = animation.props;
-
- propFilter( props, animation.opts.specialEasing );
-
- for ( ; index < length ; index++ ) {
- result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
- if ( result ) {
- if ( jQuery.isFunction( result.stop ) ) {
- jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
- jQuery.proxy( result.stop, result );
- }
- return result;
- }
- }
-
- jQuery.map( props, createTween, animation );
-
- if ( jQuery.isFunction( animation.opts.start ) ) {
- animation.opts.start.call( elem, animation );
- }
-
- jQuery.fx.timer(
- jQuery.extend( tick, {
- elem: elem,
- anim: animation,
- queue: animation.opts.queue
- } )
- );
-
- // attach callbacks from options
- return animation.progress( animation.opts.progress )
- .done( animation.opts.done, animation.opts.complete )
- .fail( animation.opts.fail )
- .always( animation.opts.always );
-}
-
-jQuery.Animation = jQuery.extend( Animation, {
-
- tweeners: {
- "*": [ function( prop, value ) {
- var tween = this.createTween( prop, value );
- adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
- return tween;
- } ]
- },
-
- tweener: function( props, callback ) {
- if ( jQuery.isFunction( props ) ) {
- callback = props;
- props = [ "*" ];
- } else {
- props = props.match( rnotwhite );
- }
-
- var prop,
- index = 0,
- length = props.length;
-
- for ( ; index < length ; index++ ) {
- prop = props[ index ];
- Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
- Animation.tweeners[ prop ].unshift( callback );
- }
- },
-
- prefilters: [ defaultPrefilter ],
-
- prefilter: function( callback, prepend ) {
- if ( prepend ) {
- Animation.prefilters.unshift( callback );
- } else {
- Animation.prefilters.push( callback );
- }
- }
-} );
-
-jQuery.speed = function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
- complete: fn || !fn && easing ||
- jQuery.isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
- };
-
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
- opt.duration in jQuery.fx.speeds ?
- jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
-
- // normalize opt.queue - true/undefined/null -> "fx"
- if ( opt.queue == null || opt.queue === true ) {
- opt.queue = "fx";
- }
-
- // Queueing
- opt.old = opt.complete;
-
- opt.complete = function() {
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
-
- if ( opt.queue ) {
- jQuery.dequeue( this, opt.queue );
- }
- };
-
- return opt;
-};
-
-jQuery.fn.extend( {
- fadeTo: function( speed, to, easing, callback ) {
-
- // show any hidden elements after setting opacity to 0
- return this.filter( isHidden ).css( "opacity", 0 ).show()
-
- // animate to the value specified
- .end().animate( { opacity: to }, speed, easing, callback );
- },
- animate: function( prop, speed, easing, callback ) {
- var empty = jQuery.isEmptyObject( prop ),
- optall = jQuery.speed( speed, easing, callback ),
- doAnimation = function() {
-
- // Operate on a copy of prop so per-property easing won't be lost
- var anim = Animation( this, jQuery.extend( {}, prop ), optall );
-
- // Empty animations, or finishing resolves immediately
- if ( empty || jQuery._data( this, "finish" ) ) {
- anim.stop( true );
- }
- };
- doAnimation.finish = doAnimation;
-
- return empty || optall.queue === false ?
- this.each( doAnimation ) :
- this.queue( optall.queue, doAnimation );
- },
- stop: function( type, clearQueue, gotoEnd ) {
- var stopQueue = function( hooks ) {
- var stop = hooks.stop;
- delete hooks.stop;
- stop( gotoEnd );
- };
-
- if ( typeof type !== "string" ) {
- gotoEnd = clearQueue;
- clearQueue = type;
- type = undefined;
- }
- if ( clearQueue && type !== false ) {
- this.queue( type || "fx", [] );
- }
-
- return this.each( function() {
- var dequeue = true,
- index = type != null && type + "queueHooks",
- timers = jQuery.timers,
- data = jQuery._data( this );
-
- if ( index ) {
- if ( data[ index ] && data[ index ].stop ) {
- stopQueue( data[ index ] );
- }
- } else {
- for ( index in data ) {
- if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
- stopQueue( data[ index ] );
- }
- }
- }
-
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this &&
- ( type == null || timers[ index ].queue === type ) ) {
-
- timers[ index ].anim.stop( gotoEnd );
- dequeue = false;
- timers.splice( index, 1 );
- }
- }
-
- // start the next in the queue if the last step wasn't forced
- // timers currently will call their complete callbacks, which will dequeue
- // but only if they were gotoEnd
- if ( dequeue || !gotoEnd ) {
- jQuery.dequeue( this, type );
- }
- } );
- },
- finish: function( type ) {
- if ( type !== false ) {
- type = type || "fx";
- }
- return this.each( function() {
- var index,
- data = jQuery._data( this ),
- queue = data[ type + "queue" ],
- hooks = data[ type + "queueHooks" ],
- timers = jQuery.timers,
- length = queue ? queue.length : 0;
-
- // enable finishing flag on private data
- data.finish = true;
-
- // empty the queue first
- jQuery.queue( this, type, [] );
-
- if ( hooks && hooks.stop ) {
- hooks.stop.call( this, true );
- }
-
- // look for any active animations, and finish them
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
- timers[ index ].anim.stop( true );
- timers.splice( index, 1 );
- }
- }
-
- // look for any animations in the old queue and finish them
- for ( index = 0; index < length; index++ ) {
- if ( queue[ index ] && queue[ index ].finish ) {
- queue[ index ].finish.call( this );
- }
- }
-
- // turn off finishing flag
- delete data.finish;
- } );
- }
-} );
-
-jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
- var cssFn = jQuery.fn[ name ];
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return speed == null || typeof speed === "boolean" ?
- cssFn.apply( this, arguments ) :
- this.animate( genFx( name, true ), speed, easing, callback );
- };
-} );
-
-// Generate shortcuts for custom animations
-jQuery.each( {
- slideDown: genFx( "show" ),
- slideUp: genFx( "hide" ),
- slideToggle: genFx( "toggle" ),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
-} );
-
-jQuery.timers = [];
-jQuery.fx.tick = function() {
- var timer,
- timers = jQuery.timers,
- i = 0;
-
- fxNow = jQuery.now();
-
- for ( ; i < timers.length; i++ ) {
- timer = timers[ i ];
-
- // Checks the timer has not already been removed
- if ( !timer() && timers[ i ] === timer ) {
- timers.splice( i--, 1 );
- }
- }
-
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
- fxNow = undefined;
-};
-
-jQuery.fx.timer = function( timer ) {
- jQuery.timers.push( timer );
- if ( timer() ) {
- jQuery.fx.start();
- } else {
- jQuery.timers.pop();
- }
-};
-
-jQuery.fx.interval = 13;
-
-jQuery.fx.start = function() {
- if ( !timerId ) {
- timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
- }
-};
-
-jQuery.fx.stop = function() {
- window.clearInterval( timerId );
- timerId = null;
-};
-
-jQuery.fx.speeds = {
- slow: 600,
- fast: 200,
-
- // Default speed
- _default: 400
-};
-
-
-// Based off of the plugin by Clint Helfers, with permission.
-// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
-jQuery.fn.delay = function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = window.setTimeout( next, time );
- hooks.stop = function() {
- window.clearTimeout( timeout );
- };
- } );
-};
-
-
-( function() {
- var a,
- input = document.createElement( "input" ),
- div = document.createElement( "div" ),
- select = document.createElement( "select" ),
- opt = select.appendChild( document.createElement( "option" ) );
-
- // Setup
- div = document.createElement( "div" );
- div.setAttribute( "className", "t" );
- div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
- a = div.getElementsByTagName( "a" )[ 0 ];
-
- // Support: Windows Web Apps (WWA)
- // `type` must use .setAttribute for WWA (#14901)
- input.setAttribute( "type", "checkbox" );
- div.appendChild( input );
-
- a = div.getElementsByTagName( "a" )[ 0 ];
-
- // First batch of tests.
- a.style.cssText = "top:1px";
-
- // Test setAttribute on camelCase class.
- // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- support.getSetAttribute = div.className !== "t";
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- support.style = /top/.test( a.getAttribute( "style" ) );
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- support.hrefNormalized = a.getAttribute( "href" ) === "/a";
-
- // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
- support.checkOn = !!input.value;
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- support.optSelected = opt.selected;
-
- // Tests for enctype support on a form (#6743)
- support.enctype = !!document.createElement( "form" ).enctype;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Support: IE8 only
- // Check if we can trust getAttribute("value")
- input = document.createElement( "input" );
- input.setAttribute( "value", "" );
- support.input = input.getAttribute( "value" ) === "";
-
- // Check if an input maintains its value after becoming a radio
- input.value = "t";
- input.setAttribute( "type", "radio" );
- support.radioValue = input.value === "t";
-} )();
-
-
-var rreturn = /\r/g,
- rspaces = /[\x20\t\r\n\f]+/g;
-
-jQuery.fn.extend( {
- val: function( value ) {
- var hooks, ret, isFunction,
- elem = this[ 0 ];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] ||
- jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if (
- hooks &&
- "get" in hooks &&
- ( ret = hooks.get( elem, "value" ) ) !== undefined
- ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
-
- // handle most common string cases
- ret.replace( rreturn, "" ) :
-
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each( function( i ) {
- var val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, jQuery( this ).val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map( val, function( value ) {
- return value == null ? "" : value + "";
- } );
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- } );
- }
-} );
-
-jQuery.extend( {
- valHooks: {
- option: {
- get: function( elem ) {
- var val = jQuery.find.attr( elem, "value" );
- return val != null ?
- val :
-
- // Support: IE10-11+
- // option.text throws exceptions (#14686, #14858)
- // Strip and collapse whitespace
- // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
- jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
- }
- },
- select: {
- get: function( elem ) {
- var value, option,
- options = elem.options,
- index = elem.selectedIndex,
- one = elem.type === "select-one" || index < 0,
- values = one ? null : [],
- max = one ? index + 1 : options.length,
- i = index < 0 ?
- max :
- one ? index : 0;
-
- // Loop through all the selected options
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // oldIE doesn't update selected after form reset (#2551)
- if ( ( option.selected || i === index ) &&
-
- // Don't return options that are disabled or in a disabled optgroup
- ( support.optDisabled ?
- !option.disabled :
- option.getAttribute( "disabled" ) === null ) &&
- ( !option.parentNode.disabled ||
- !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var optionSet, option,
- options = elem.options,
- values = jQuery.makeArray( value ),
- i = options.length;
-
- while ( i-- ) {
- option = options[ i ];
-
- if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {
-
- // Support: IE6
- // When new option element is added to select box we need to
- // force reflow of newly added node in order to workaround delay
- // of initialization properties
- try {
- option.selected = optionSet = true;
-
- } catch ( _ ) {
-
- // Will be executed only in IE6
- option.scrollHeight;
- }
-
- } else {
- option.selected = false;
- }
- }
-
- // Force browsers to behave consistently when non-matching value is set
- if ( !optionSet ) {
- elem.selectedIndex = -1;
- }
-
- return options;
- }
- }
- }
-} );
-
-// Radios and checkboxes getter/setter
-jQuery.each( [ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
- }
- }
- };
- if ( !support.checkOn ) {
- jQuery.valHooks[ this ].get = function( elem ) {
- return elem.getAttribute( "value" ) === null ? "on" : elem.value;
- };
- }
-} );
-
-
-
-
-var nodeHook, boolHook,
- attrHandle = jQuery.expr.attrHandle,
- ruseDefault = /^(?:checked|selected)$/i,
- getSetAttribute = support.getSetAttribute,
- getSetInput = support.input;
-
-jQuery.fn.extend( {
- attr: function( name, value ) {
- return access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each( function() {
- jQuery.removeAttr( this, name );
- } );
- }
-} );
-
-jQuery.extend( {
- attr: function( elem, name, value ) {
- var ret, hooks,
- nType = elem.nodeType;
-
- // Don't get/set attributes on text, comment and attribute nodes
- if ( nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === "undefined" ) {
- return jQuery.prop( elem, name, value );
- }
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] ||
- ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
- return;
- }
-
- if ( hooks && "set" in hooks &&
- ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
- return ret;
- }
-
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
- return ret;
- }
-
- ret = jQuery.find.attr( elem, name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ? undefined : ret;
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !support.radioValue && value === "radio" &&
- jQuery.nodeName( elem, "input" ) ) {
-
- // Setting the type on a radio button after the value resets the value in IE8-9
- // Reset value to default in case type is set after value during creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- },
-
- removeAttr: function( elem, value ) {
- var name, propName,
- i = 0,
- attrNames = value && value.match( rnotwhite );
-
- if ( attrNames && elem.nodeType === 1 ) {
- while ( ( name = attrNames[ i++ ] ) ) {
- propName = jQuery.propFix[ name ] || name;
-
- // Boolean attributes get special treatment (#10870)
- if ( jQuery.expr.match.bool.test( name ) ) {
-
- // Set corresponding property to false
- if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
- elem[ propName ] = false;
-
- // Support: IE<9
- // Also clear defaultChecked/defaultSelected (if appropriate)
- } else {
- elem[ jQuery.camelCase( "default-" + name ) ] =
- elem[ propName ] = false;
- }
-
- // See #9699 for explanation of this approach (setting first, then removal)
- } else {
- jQuery.attr( elem, name, "" );
- }
-
- elem.removeAttribute( getSetAttribute ? name : propName );
- }
- }
- }
-} );
-
-// Hooks for boolean attributes
-boolHook = {
- set: function( elem, value, name ) {
- if ( value === false ) {
-
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
-
- // IE<8 needs the *property* name
- elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
-
- } else {
-
- // Support: IE<9
- // Use defaultChecked and defaultSelected for oldIE
- elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
- }
- return name;
- }
-};
-
-jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
- var getter = attrHandle[ name ] || jQuery.find.attr;
-
- if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
- attrHandle[ name ] = function( elem, name, isXML ) {
- var ret, handle;
- if ( !isXML ) {
-
- // Avoid an infinite loop by temporarily removing this function from the getter
- handle = attrHandle[ name ];
- attrHandle[ name ] = ret;
- ret = getter( elem, name, isXML ) != null ?
- name.toLowerCase() :
- null;
- attrHandle[ name ] = handle;
- }
- return ret;
- };
- } else {
- attrHandle[ name ] = function( elem, name, isXML ) {
- if ( !isXML ) {
- return elem[ jQuery.camelCase( "default-" + name ) ] ?
- name.toLowerCase() :
- null;
- }
- };
- }
-} );
-
-// fix oldIE attroperties
-if ( !getSetInput || !getSetAttribute ) {
- jQuery.attrHooks.value = {
- set: function( elem, value, name ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
-
- // Does not return so that setAttribute is also used
- elem.defaultValue = value;
- } else {
-
- // Use nodeHook if defined (#1954); otherwise setAttribute is fine
- return nodeHook && nodeHook.set( elem, value, name );
- }
- }
- };
-}
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !getSetAttribute ) {
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = {
- set: function( elem, value, name ) {
-
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- elem.setAttributeNode(
- ( ret = elem.ownerDocument.createAttribute( name ) )
- );
- }
-
- ret.value = value += "";
-
- // Break association with cloned elements by also using setAttribute (#9646)
- if ( name === "value" || value === elem.getAttribute( name ) ) {
- return value;
- }
- }
- };
-
- // Some attributes are constructed with empty-string values when not defined
- attrHandle.id = attrHandle.name = attrHandle.coords =
- function( elem, name, isXML ) {
- var ret;
- if ( !isXML ) {
- return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
- ret.value :
- null;
- }
- };
-
- // Fixing value retrieval on a button requires this module
- jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret = elem.getAttributeNode( name );
- if ( ret && ret.specified ) {
- return ret.value;
- }
- },
- set: nodeHook.set
- };
-
- // Set contenteditable to false on removals(#10429)
- // Setting to empty string throws an error as an invalid value
- jQuery.attrHooks.contenteditable = {
- set: function( elem, value, name ) {
- nodeHook.set( elem, value === "" ? false : value, name );
- }
- };
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each( [ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- };
- } );
-}
-
-if ( !support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
-
- // Return undefined in the case of empty string
- // Note: IE uppercases css property names, but if we were to .toLowerCase()
- // .cssText, that would destroy case sensitivity in URL's, like in "background"
- return elem.style.cssText || undefined;
- },
- set: function( elem, value ) {
- return ( elem.style.cssText = value + "" );
- }
- };
-}
-
-
-
-
-var rfocusable = /^(?:input|select|textarea|button|object)$/i,
- rclickable = /^(?:a|area)$/i;
-
-jQuery.fn.extend( {
- prop: function( name, value ) {
- return access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each( function() {
-
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch ( e ) {}
- } );
- }
-} );
-
-jQuery.extend( {
- prop: function( elem, name, value ) {
- var ret, hooks,
- nType = elem.nodeType;
-
- // Don't get/set properties on text, comment and attribute nodes
- if ( nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
-
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks &&
- ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
- return ret;
- }
-
- return ( elem[ name ] = value );
- }
-
- if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
- return ret;
- }
-
- return elem[ name ];
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
-
- // elem.tabIndex doesn't always return the
- // correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- // Use proper attribute retrieval(#12072)
- var tabindex = jQuery.find.attr( elem, "tabindex" );
-
- return tabindex ?
- parseInt( tabindex, 10 ) :
- rfocusable.test( elem.nodeName ) ||
- rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- -1;
- }
- }
- },
-
- propFix: {
- "for": "htmlFor",
- "class": "className"
- }
-} );
-
-// Some attributes require a special call on IE
-// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !support.hrefNormalized ) {
-
- // href/src property should get the full normalized URL (#10299/#12915)
- jQuery.each( [ "href", "src" ], function( i, name ) {
- jQuery.propHooks[ name ] = {
- get: function( elem ) {
- return elem.getAttribute( name, 4 );
- }
- };
- } );
-}
-
-// Support: Safari, IE9+
-// Accessing the selectedIndex property
-// forces the browser to respect setting selected
-// on the option
-// The getter ensures a default option is selected
-// when in an optgroup
-if ( !support.optSelected ) {
- jQuery.propHooks.selected = {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- },
- set: function( elem ) {
- var parent = elem.parentNode;
- if ( parent ) {
- parent.selectedIndex;
-
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- }
- };
-}
-
-jQuery.each( [
- "tabIndex",
- "readOnly",
- "maxLength",
- "cellSpacing",
- "cellPadding",
- "rowSpan",
- "colSpan",
- "useMap",
- "frameBorder",
- "contentEditable"
-], function() {
- jQuery.propFix[ this.toLowerCase() ] = this;
-} );
-
-// IE6/7 call enctype encoding
-if ( !support.enctype ) {
- jQuery.propFix.enctype = "encoding";
-}
-
-
-
-
-var rclass = /[\t\r\n\f]/g;
-
-function getClass( elem ) {
- return jQuery.attr( elem, "class" ) || "";
-}
-
-jQuery.fn.extend( {
- addClass: function( value ) {
- var classes, elem, cur, curValue, clazz, j, finalValue,
- i = 0;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each( function( j ) {
- jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
- } );
- }
-
- if ( typeof value === "string" && value ) {
- classes = value.match( rnotwhite ) || [];
-
- while ( ( elem = this[ i++ ] ) ) {
- curValue = getClass( elem );
- cur = elem.nodeType === 1 &&
- ( " " + curValue + " " ).replace( rclass, " " );
-
- if ( cur ) {
- j = 0;
- while ( ( clazz = classes[ j++ ] ) ) {
- if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
- cur += clazz + " ";
- }
- }
-
- // only assign if different to avoid unneeded rendering.
- finalValue = jQuery.trim( cur );
- if ( curValue !== finalValue ) {
- jQuery.attr( elem, "class", finalValue );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classes, elem, cur, curValue, clazz, j, finalValue,
- i = 0;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each( function( j ) {
- jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
- } );
- }
-
- if ( !arguments.length ) {
- return this.attr( "class", "" );
- }
-
- if ( typeof value === "string" && value ) {
- classes = value.match( rnotwhite ) || [];
-
- while ( ( elem = this[ i++ ] ) ) {
- curValue = getClass( elem );
-
- // This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 &&
- ( " " + curValue + " " ).replace( rclass, " " );
-
- if ( cur ) {
- j = 0;
- while ( ( clazz = classes[ j++ ] ) ) {
-
- // Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
- cur = cur.replace( " " + clazz + " ", " " );
- }
- }
-
- // Only assign if different to avoid unneeded rendering.
- finalValue = jQuery.trim( cur );
- if ( curValue !== finalValue ) {
- jQuery.attr( elem, "class", finalValue );
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value;
-
- if ( typeof stateVal === "boolean" && type === "string" ) {
- return stateVal ? this.addClass( value ) : this.removeClass( value );
- }
-
- if ( jQuery.isFunction( value ) ) {
- return this.each( function( i ) {
- jQuery( this ).toggleClass(
- value.call( this, i, getClass( this ), stateVal ),
- stateVal
- );
- } );
- }
-
- return this.each( function() {
- var className, i, self, classNames;
-
- if ( type === "string" ) {
-
- // Toggle individual class names
- i = 0;
- self = jQuery( this );
- classNames = value.match( rnotwhite ) || [];
-
- while ( ( className = classNames[ i++ ] ) ) {
-
- // Check each className given, space separated list
- if ( self.hasClass( className ) ) {
- self.removeClass( className );
- } else {
- self.addClass( className );
- }
- }
-
- // Toggle whole class name
- } else if ( value === undefined || type === "boolean" ) {
- className = getClass( this );
- if ( className ) {
-
- // store className if set
- jQuery._data( this, "__className__", className );
- }
-
- // If the element has a class name or if we're passed "false",
- // then remove the whole classname (if there was one, the above saved it).
- // Otherwise bring back whatever was previously saved (if anything),
- // falling back to the empty string if nothing was stored.
- jQuery.attr( this, "class",
- className || value === false ?
- "" :
- jQuery._data( this, "__className__" ) || ""
- );
- }
- } );
- },
-
- hasClass: function( selector ) {
- var className, elem,
- i = 0;
-
- className = " " + selector + " ";
- while ( ( elem = this[ i++ ] ) ) {
- if ( elem.nodeType === 1 &&
- ( " " + getClass( elem ) + " " ).replace( rclass, " " )
- .indexOf( className ) > -1
- ) {
- return true;
- }
- }
-
- return false;
- }
-} );
-
-
-
-
-// Return jQuery for attributes-only inclusion
-
-
-jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
- function( i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- return arguments.length > 0 ?
- this.on( name, null, data, fn ) :
- this.trigger( name );
- };
-} );
-
-jQuery.fn.extend( {
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-} );
-
-
-var location = window.location;
-
-var nonce = jQuery.now();
-
-var rquery = ( /\?/ );
-
-
-
-var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
-
-jQuery.parseJSON = function( data ) {
-
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
-
- // Support: Android 2.3
- // Workaround failure to string-cast null input
- return window.JSON.parse( data + "" );
- }
-
- var requireNonComma,
- depth = null,
- str = jQuery.trim( data + "" );
-
- // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
- // after removing valid tokens
- return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
-
- // Force termination if we see a misplaced comma
- if ( requireNonComma && comma ) {
- depth = 0;
- }
-
- // Perform no more replacements after returning to outermost depth
- if ( depth === 0 ) {
- return token;
- }
-
- // Commas must not follow "[", "{", or ","
- requireNonComma = open || comma;
-
- // Determine new depth
- // array/object open ("[" or "{"): depth += true - false (increment)
- // array/object close ("]" or "}"): depth += false - true (decrement)
- // other cases ("," or primitive): depth += true - true (numeric cast)
- depth += !close - !open;
-
- // Remove this token
- return "";
- } ) ) ?
- ( Function( "return " + str ) )() :
- jQuery.error( "Invalid JSON: " + data );
-};
-
-
-// Cross-browser xml parsing
-jQuery.parseXML = function( data ) {
- var xml, tmp;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new window.DOMParser();
- xml = tmp.parseFromString( data, "text/xml" );
- } else { // IE
- xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch ( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
-};
-
-
-var
- rhash = /#.*$/,
- rts = /([?&])_=[^&]*/,
-
- // IE leaves an \r character at EOL
- rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
-
- // #7653, #8125, #8152: local protocol detection
- rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
- rnoContent = /^(?:GET|HEAD)$/,
- rprotocol = /^\/\//,
- rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
-
- /* Prefilters
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
- * 2) These are called:
- * - BEFORE asking for a transport
- * - AFTER param serialization (s.data is a string if s.processData is true)
- * 3) key is the dataType
- * 4) the catchall symbol "*" can be used
- * 5) execution will start with transport dataType and THEN continue down to "*" if needed
- */
- prefilters = {},
-
- /* Transports bindings
- * 1) key is the dataType
- * 2) the catchall symbol "*" can be used
- * 3) selection will start with transport dataType and THEN go to "*" if needed
- */
- transports = {},
-
- // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
- allTypes = "*/".concat( "*" ),
-
- // Document location
- ajaxLocation = location.href,
-
- // Segment location into parts
- ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
-
-// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
-function addToPrefiltersOrTransports( structure ) {
-
- // dataTypeExpression is optional and defaults to "*"
- return function( dataTypeExpression, func ) {
-
- if ( typeof dataTypeExpression !== "string" ) {
- func = dataTypeExpression;
- dataTypeExpression = "*";
- }
-
- var dataType,
- i = 0,
- dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
-
- if ( jQuery.isFunction( func ) ) {
-
- // For each dataType in the dataTypeExpression
- while ( ( dataType = dataTypes[ i++ ] ) ) {
-
- // Prepend if requested
- if ( dataType.charAt( 0 ) === "+" ) {
- dataType = dataType.slice( 1 ) || "*";
- ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
-
- // Otherwise append
- } else {
- ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
- }
- }
- }
- };
-}
-
-// Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
-
- var inspected = {},
- seekingTransport = ( structure === transports );
-
- function inspect( dataType ) {
- var selected;
- inspected[ dataType ] = true;
- jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
- var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
- if ( typeof dataTypeOrTransport === "string" &&
- !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
-
- options.dataTypes.unshift( dataTypeOrTransport );
- inspect( dataTypeOrTransport );
- return false;
- } else if ( seekingTransport ) {
- return !( selected = dataTypeOrTransport );
- }
- } );
- return selected;
- }
-
- return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
-}
-
-// A special extend for ajax options
-// that takes "flat" options (not to be deep extended)
-// Fixes #9887
-function ajaxExtend( target, src ) {
- var deep, key,
- flatOptions = jQuery.ajaxSettings.flatOptions || {};
-
- for ( key in src ) {
- if ( src[ key ] !== undefined ) {
- ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
- }
- }
- if ( deep ) {
- jQuery.extend( true, target, deep );
- }
-
- return target;
-}
-
-/* Handles responses to an ajax request:
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
-function ajaxHandleResponses( s, jqXHR, responses ) {
- var firstDataType, ct, finalDataType, type,
- contents = s.contents,
- dataTypes = s.dataTypes;
-
- // Remove auto dataType and get content-type in the process
- while ( dataTypes[ 0 ] === "*" ) {
- dataTypes.shift();
- if ( ct === undefined ) {
- ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
- }
- }
-
- // Check if we're dealing with a known content-type
- if ( ct ) {
- for ( type in contents ) {
- if ( contents[ type ] && contents[ type ].test( ct ) ) {
- dataTypes.unshift( type );
- break;
- }
- }
- }
-
- // Check to see if we have a response for the expected dataType
- if ( dataTypes[ 0 ] in responses ) {
- finalDataType = dataTypes[ 0 ];
- } else {
-
- // Try convertible dataTypes
- for ( type in responses ) {
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
- finalDataType = type;
- break;
- }
- if ( !firstDataType ) {
- firstDataType = type;
- }
- }
-
- // Or just use first one
- finalDataType = finalDataType || firstDataType;
- }
-
- // If we found a dataType
- // We add the dataType to the list if needed
- // and return the corresponding response
- if ( finalDataType ) {
- if ( finalDataType !== dataTypes[ 0 ] ) {
- dataTypes.unshift( finalDataType );
- }
- return responses[ finalDataType ];
- }
-}
-
-/* Chain conversions given the request and the original response
- * Also sets the responseXXX fields on the jqXHR instance
- */
-function ajaxConvert( s, response, jqXHR, isSuccess ) {
- var conv2, current, conv, tmp, prev,
- converters = {},
-
- // Work with a copy of dataTypes in case we need to modify it for conversion
- dataTypes = s.dataTypes.slice();
-
- // Create converters map with lowercased keys
- if ( dataTypes[ 1 ] ) {
- for ( conv in s.converters ) {
- converters[ conv.toLowerCase() ] = s.converters[ conv ];
- }
- }
-
- current = dataTypes.shift();
-
- // Convert to each sequential dataType
- while ( current ) {
-
- if ( s.responseFields[ current ] ) {
- jqXHR[ s.responseFields[ current ] ] = response;
- }
-
- // Apply the dataFilter if provided
- if ( !prev && isSuccess && s.dataFilter ) {
- response = s.dataFilter( response, s.dataType );
- }
-
- prev = current;
- current = dataTypes.shift();
-
- if ( current ) {
-
- // There's only work to do if current dataType is non-auto
- if ( current === "*" ) {
-
- current = prev;
-
- // Convert response if prev dataType is non-auto and differs from current
- } else if ( prev !== "*" && prev !== current ) {
-
- // Seek a direct converter
- conv = converters[ prev + " " + current ] || converters[ "* " + current ];
-
- // If none found, seek a pair
- if ( !conv ) {
- for ( conv2 in converters ) {
-
- // If conv2 outputs current
- tmp = conv2.split( " " );
- if ( tmp[ 1 ] === current ) {
-
- // If prev can be converted to accepted input
- conv = converters[ prev + " " + tmp[ 0 ] ] ||
- converters[ "* " + tmp[ 0 ] ];
- if ( conv ) {
-
- // Condense equivalence converters
- if ( conv === true ) {
- conv = converters[ conv2 ];
-
- // Otherwise, insert the intermediate dataType
- } else if ( converters[ conv2 ] !== true ) {
- current = tmp[ 0 ];
- dataTypes.unshift( tmp[ 1 ] );
- }
- break;
- }
- }
- }
- }
-
- // Apply converter (if not an equivalence)
- if ( conv !== true ) {
-
- // Unless errors are allowed to bubble, catch and return them
- if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
- response = conv( response );
- } else {
- try {
- response = conv( response );
- } catch ( e ) {
- return {
- state: "parsererror",
- error: conv ? e : "No conversion from " + prev + " to " + current
- };
- }
- }
- }
- }
- }
- }
-
- return { state: "success", data: response };
-}
-
-jQuery.extend( {
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {},
-
- ajaxSettings: {
- url: ajaxLocation,
- type: "GET",
- isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
- global: true,
- processData: true,
- async: true,
- contentType: "application/x-www-form-urlencoded; charset=UTF-8",
- /*
- timeout: 0,
- data: null,
- dataType: null,
- username: null,
- password: null,
- cache: null,
- throws: false,
- traditional: false,
- headers: {},
- */
-
- accepts: {
- "*": allTypes,
- text: "text/plain",
- html: "text/html",
- xml: "application/xml, text/xml",
- json: "application/json, text/javascript"
- },
-
- contents: {
- xml: /\bxml\b/,
- html: /\bhtml/,
- json: /\bjson\b/
- },
-
- responseFields: {
- xml: "responseXML",
- text: "responseText",
- json: "responseJSON"
- },
-
- // Data converters
- // Keys separate source (or catchall "*") and destination types with a single space
- converters: {
-
- // Convert anything to text
- "* text": String,
-
- // Text to html (true = no transformation)
- "text html": true,
-
- // Evaluate text as a json expression
- "text json": jQuery.parseJSON,
-
- // Parse text as xml
- "text xml": jQuery.parseXML
- },
-
- // For options that shouldn't be deep extended:
- // you can add your own custom options here if
- // and when you create one that shouldn't be
- // deep extended (see ajaxExtend)
- flatOptions: {
- url: true,
- context: true
- }
- },
-
- // Creates a full fledged settings object into target
- // with both ajaxSettings and settings fields.
- // If target is omitted, writes into ajaxSettings.
- ajaxSetup: function( target, settings ) {
- return settings ?
-
- // Building a settings object
- ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
-
- // Extending ajaxSettings
- ajaxExtend( jQuery.ajaxSettings, target );
- },
-
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
- ajaxTransport: addToPrefiltersOrTransports( transports ),
-
- // Main method
- ajax: function( url, options ) {
-
- // If url is an object, simulate pre-1.5 signature
- if ( typeof url === "object" ) {
- options = url;
- url = undefined;
- }
-
- // Force options to be an object
- options = options || {};
-
- var
-
- // Cross-domain detection vars
- parts,
-
- // Loop variable
- i,
-
- // URL without anti-cache param
- cacheURL,
-
- // Response headers as string
- responseHeadersString,
-
- // timeout handle
- timeoutTimer,
-
- // To know if global events are to be dispatched
- fireGlobals,
-
- transport,
-
- // Response headers
- responseHeaders,
-
- // Create the final options object
- s = jQuery.ajaxSetup( {}, options ),
-
- // Callbacks context
- callbackContext = s.context || s,
-
- // Context for global events is callbackContext if it is a DOM node or jQuery collection
- globalEventContext = s.context &&
- ( callbackContext.nodeType || callbackContext.jquery ) ?
- jQuery( callbackContext ) :
- jQuery.event,
-
- // Deferreds
- deferred = jQuery.Deferred(),
- completeDeferred = jQuery.Callbacks( "once memory" ),
-
- // Status-dependent callbacks
- statusCode = s.statusCode || {},
-
- // Headers (they are sent all at once)
- requestHeaders = {},
- requestHeadersNames = {},
-
- // The jqXHR state
- state = 0,
-
- // Default abort message
- strAbort = "canceled",
-
- // Fake xhr
- jqXHR = {
- readyState: 0,
-
- // Builds headers hashtable if needed
- getResponseHeader: function( key ) {
- var match;
- if ( state === 2 ) {
- if ( !responseHeaders ) {
- responseHeaders = {};
- while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
- responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
- }
- }
- match = responseHeaders[ key.toLowerCase() ];
- }
- return match == null ? null : match;
- },
-
- // Raw string
- getAllResponseHeaders: function() {
- return state === 2 ? responseHeadersString : null;
- },
-
- // Caches the header
- setRequestHeader: function( name, value ) {
- var lname = name.toLowerCase();
- if ( !state ) {
- name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
- requestHeaders[ name ] = value;
- }
- return this;
- },
-
- // Overrides response content-type header
- overrideMimeType: function( type ) {
- if ( !state ) {
- s.mimeType = type;
- }
- return this;
- },
-
- // Status-dependent callbacks
- statusCode: function( map ) {
- var code;
- if ( map ) {
- if ( state < 2 ) {
- for ( code in map ) {
-
- // Lazy-add the new callback in a way that preserves old ones
- statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
- }
- } else {
-
- // Execute the appropriate callbacks
- jqXHR.always( map[ jqXHR.status ] );
- }
- }
- return this;
- },
-
- // Cancel the request
- abort: function( statusText ) {
- var finalText = statusText || strAbort;
- if ( transport ) {
- transport.abort( finalText );
- }
- done( 0, finalText );
- return this;
- }
- };
-
- // Attach deferreds
- deferred.promise( jqXHR ).complete = completeDeferred.add;
- jqXHR.success = jqXHR.done;
- jqXHR.error = jqXHR.fail;
-
- // Remove hash character (#7531: and string promotion)
- // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
- // Handle falsy url in the settings object (#10093: consistency with old signature)
- // We also use the url parameter if available
- s.url = ( ( url || s.url || ajaxLocation ) + "" )
- .replace( rhash, "" )
- .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
-
- // Alias method option to type as per ticket #12004
- s.type = options.method || options.type || s.method || s.type;
-
- // Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
-
- // A cross-domain request is in order when we have a protocol:host:port mismatch
- if ( s.crossDomain == null ) {
- parts = rurl.exec( s.url.toLowerCase() );
- s.crossDomain = !!( parts &&
- ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
- ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
- ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
- );
- }
-
- // Convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
-
- // Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
-
- // If request was aborted inside a prefilter, stop there
- if ( state === 2 ) {
- return jqXHR;
- }
-
- // We can fire global events as of now if asked to
- // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
- fireGlobals = jQuery.event && s.global;
-
- // Watch for a new set of requests
- if ( fireGlobals && jQuery.active++ === 0 ) {
- jQuery.event.trigger( "ajaxStart" );
- }
-
- // Uppercase the type
- s.type = s.type.toUpperCase();
-
- // Determine if request has content
- s.hasContent = !rnoContent.test( s.type );
-
- // Save the URL in case we're toying with the If-Modified-Since
- // and/or If-None-Match header later on
- cacheURL = s.url;
-
- // More options handling for requests with no content
- if ( !s.hasContent ) {
-
- // If data is available, append data to url
- if ( s.data ) {
- cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
-
- // #9682: remove data so that it's not used in an eventual retry
- delete s.data;
- }
-
- // Add anti-cache in url if needed
- if ( s.cache === false ) {
- s.url = rts.test( cacheURL ) ?
-
- // If there is already a '_' parameter, set its value
- cacheURL.replace( rts, "$1_=" + nonce++ ) :
-
- // Otherwise add one to the end
- cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
- }
- }
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( jQuery.lastModified[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
- }
- if ( jQuery.etag[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
- }
- }
-
- // Set the correct header, if data is being sent
- if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- jqXHR.setRequestHeader( "Content-Type", s.contentType );
- }
-
- // Set the Accepts header for the server, depending on the dataType
- jqXHR.setRequestHeader(
- "Accept",
- s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
- s.accepts[ s.dataTypes[ 0 ] ] +
- ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
- s.accepts[ "*" ]
- );
-
- // Check for headers option
- for ( i in s.headers ) {
- jqXHR.setRequestHeader( i, s.headers[ i ] );
- }
-
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend &&
- ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
-
- // Abort if not done already and return
- return jqXHR.abort();
- }
-
- // aborting is no longer a cancellation
- strAbort = "abort";
-
- // Install callbacks on deferreds
- for ( i in { success: 1, error: 1, complete: 1 } ) {
- jqXHR[ i ]( s[ i ] );
- }
-
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
-
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- jqXHR.readyState = 1;
-
- // Send global event
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
- }
-
- // If request was aborted inside ajaxSend, stop there
- if ( state === 2 ) {
- return jqXHR;
- }
-
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = window.setTimeout( function() {
- jqXHR.abort( "timeout" );
- }, s.timeout );
- }
-
- try {
- state = 1;
- transport.send( requestHeaders, done );
- } catch ( e ) {
-
- // Propagate exception as error if not done
- if ( state < 2 ) {
- done( -1, e );
-
- // Simply rethrow otherwise
- } else {
- throw e;
- }
- }
- }
-
- // Callback for when everything is done
- function done( status, nativeStatusText, responses, headers ) {
- var isSuccess, success, error, response, modified,
- statusText = nativeStatusText;
-
- // Called once
- if ( state === 2 ) {
- return;
- }
-
- // State is "done" now
- state = 2;
-
- // Clear timeout if it exists
- if ( timeoutTimer ) {
- window.clearTimeout( timeoutTimer );
- }
-
- // Dereference transport for early garbage collection
- // (no matter how long the jqXHR object will be used)
- transport = undefined;
-
- // Cache response headers
- responseHeadersString = headers || "";
-
- // Set readyState
- jqXHR.readyState = status > 0 ? 4 : 0;
-
- // Determine if successful
- isSuccess = status >= 200 && status < 300 || status === 304;
-
- // Get response data
- if ( responses ) {
- response = ajaxHandleResponses( s, jqXHR, responses );
- }
-
- // Convert no matter what (that way responseXXX fields are always set)
- response = ajaxConvert( s, response, jqXHR, isSuccess );
-
- // If successful, handle type chaining
- if ( isSuccess ) {
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- modified = jqXHR.getResponseHeader( "Last-Modified" );
- if ( modified ) {
- jQuery.lastModified[ cacheURL ] = modified;
- }
- modified = jqXHR.getResponseHeader( "etag" );
- if ( modified ) {
- jQuery.etag[ cacheURL ] = modified;
- }
- }
-
- // if no content
- if ( status === 204 || s.type === "HEAD" ) {
- statusText = "nocontent";
-
- // if not modified
- } else if ( status === 304 ) {
- statusText = "notmodified";
-
- // If we have data, let's convert it
- } else {
- statusText = response.state;
- success = response.data;
- error = response.error;
- isSuccess = !error;
- }
- } else {
-
- // We extract error from statusText
- // then normalize statusText and status for non-aborts
- error = statusText;
- if ( status || !statusText ) {
- statusText = "error";
- if ( status < 0 ) {
- status = 0;
- }
- }
- }
-
- // Set data for the fake xhr object
- jqXHR.status = status;
- jqXHR.statusText = ( nativeStatusText || statusText ) + "";
-
- // Success/Error
- if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
- } else {
- deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
- }
-
- // Status-dependent callbacks
- jqXHR.statusCode( statusCode );
- statusCode = undefined;
-
- if ( fireGlobals ) {
- globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
- [ jqXHR, s, isSuccess ? success : error ] );
- }
-
- // Complete
- completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
-
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
-
- // Handle the global AJAX counter
- if ( !( --jQuery.active ) ) {
- jQuery.event.trigger( "ajaxStop" );
- }
- }
- }
-
- return jqXHR;
- },
-
- getJSON: function( url, data, callback ) {
- return jQuery.get( url, data, callback, "json" );
- },
-
- getScript: function( url, callback ) {
- return jQuery.get( url, undefined, callback, "script" );
- }
-} );
-
-jQuery.each( [ "get", "post" ], function( i, method ) {
- jQuery[ method ] = function( url, data, callback, type ) {
-
- // shift arguments if data argument was omitted
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = undefined;
- }
-
- // The url can be an options object (which then must have .url)
- return jQuery.ajax( jQuery.extend( {
- url: url,
- type: method,
- dataType: type,
- data: data,
- success: callback
- }, jQuery.isPlainObject( url ) && url ) );
- };
-} );
-
-
-jQuery._evalUrl = function( url ) {
- return jQuery.ajax( {
- url: url,
-
- // Make this explicit, since user can override this through ajaxSetup (#11264)
- type: "GET",
- dataType: "script",
- cache: true,
- async: false,
- global: false,
- "throws": true
- } );
-};
-
-
-jQuery.fn.extend( {
- wrapAll: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each( function( i ) {
- jQuery( this ).wrapAll( html.call( this, i ) );
- } );
- }
-
- if ( this[ 0 ] ) {
-
- // The elements to wrap the target around
- var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
-
- if ( this[ 0 ].parentNode ) {
- wrap.insertBefore( this[ 0 ] );
- }
-
- wrap.map( function() {
- var elem = this;
-
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
- }
-
- return elem;
- } ).append( this );
- }
-
- return this;
- },
-
- wrapInner: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each( function( i ) {
- jQuery( this ).wrapInner( html.call( this, i ) );
- } );
- }
-
- return this.each( function() {
- var self = jQuery( this ),
- contents = self.contents();
-
- if ( contents.length ) {
- contents.wrapAll( html );
-
- } else {
- self.append( html );
- }
- } );
- },
-
- wrap: function( html ) {
- var isFunction = jQuery.isFunction( html );
-
- return this.each( function( i ) {
- jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
- } );
- },
-
- unwrap: function() {
- return this.parent().each( function() {
- if ( !jQuery.nodeName( this, "body" ) ) {
- jQuery( this ).replaceWith( this.childNodes );
- }
- } ).end();
- }
-} );
-
-
-function getDisplay( elem ) {
- return elem.style && elem.style.display || jQuery.css( elem, "display" );
-}
-
-function filterHidden( elem ) {
-
- // Disconnected elements are considered hidden
- if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
- return true;
- }
- while ( elem && elem.nodeType === 1 ) {
- if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
- return true;
- }
- elem = elem.parentNode;
- }
- return false;
-}
-
-jQuery.expr.filters.hidden = function( elem ) {
-
- // Support: Opera <= 12.12
- // Opera reports offsetWidths and offsetHeights less than zero on some elements
- return support.reliableHiddenOffsets() ?
- ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
- !elem.getClientRects().length ) :
- filterHidden( elem );
-};
-
-jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
-};
-
-
-
-
-var r20 = /%20/g,
- rbracket = /\[\]$/,
- rCRLF = /\r?\n/g,
- rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
- rsubmittable = /^(?:input|select|textarea|keygen)/i;
-
-function buildParams( prefix, obj, traditional, add ) {
- var name;
-
- if ( jQuery.isArray( obj ) ) {
-
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
-
- // Treat each array item as a scalar.
- add( prefix, v );
-
- } else {
-
- // Item is non-scalar (array or object), encode its numeric index.
- buildParams(
- prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
- v,
- traditional,
- add
- );
- }
- } );
-
- } else if ( !traditional && jQuery.type( obj ) === "object" ) {
-
- // Serialize object item.
- for ( name in obj ) {
- buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
- }
-
- } else {
-
- // Serialize scalar item.
- add( prefix, obj );
- }
-}
-
-// Serialize an array of form elements or a set of
-// key/values into a query string
-jQuery.param = function( a, traditional ) {
- var prefix,
- s = [],
- add = function( key, value ) {
-
- // If value is a function, invoke it and return its value
- value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
- s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
- };
-
- // Set traditional to true for jQuery <= 1.3.2 behavior.
- if ( traditional === undefined ) {
- traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
- }
-
- // If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
-
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- } );
-
- } else {
-
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( prefix in a ) {
- buildParams( prefix, a[ prefix ], traditional, add );
- }
- }
-
- // Return the resulting serialization
- return s.join( "&" ).replace( r20, "+" );
-};
-
-jQuery.fn.extend( {
- serialize: function() {
- return jQuery.param( this.serializeArray() );
- },
- serializeArray: function() {
- return this.map( function() {
-
- // Can add propHook for "elements" to filter or add form elements
- var elements = jQuery.prop( this, "elements" );
- return elements ? jQuery.makeArray( elements ) : this;
- } )
- .filter( function() {
- var type = this.type;
-
- // Use .is(":disabled") so that fieldset[disabled] works
- return this.name && !jQuery( this ).is( ":disabled" ) &&
- rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
- ( this.checked || !rcheckableType.test( type ) );
- } )
- .map( function( i, elem ) {
- var val = jQuery( this ).val();
-
- return val == null ?
- null :
- jQuery.isArray( val ) ?
- jQuery.map( val, function( val ) {
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- } ) :
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- } ).get();
- }
-} );
-
-
-// Create the request object
-// (This is still attached to ajaxSettings for backward compatibility)
-jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
-
- // Support: IE6-IE8
- function() {
-
- // XHR cannot access local files, always use ActiveX for that case
- if ( this.isLocal ) {
- return createActiveXHR();
- }
-
- // Support: IE 9-11
- // IE seems to error on cross-domain PATCH requests when ActiveX XHR
- // is used. In IE 9+ always use the native XHR.
- // Note: this condition won't catch Edge as it doesn't define
- // document.documentMode but it also doesn't support ActiveX so it won't
- // reach this code.
- if ( document.documentMode > 8 ) {
- return createStandardXHR();
- }
-
- // Support: IE<9
- // oldIE XHR does not support non-RFC2616 methods (#13240)
- // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
- // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
- // Although this check for six methods instead of eight
- // since IE also does not support "trace" and "connect"
- return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
- createStandardXHR() || createActiveXHR();
- } :
-
- // For all other browsers, use the standard XMLHttpRequest object
- createStandardXHR;
-
-var xhrId = 0,
- xhrCallbacks = {},
- xhrSupported = jQuery.ajaxSettings.xhr();
-
-// Support: IE<10
-// Open requests must be manually aborted on unload (#5280)
-// See https://support.microsoft.com/kb/2856746 for more info
-if ( window.attachEvent ) {
- window.attachEvent( "onunload", function() {
- for ( var key in xhrCallbacks ) {
- xhrCallbacks[ key ]( undefined, true );
- }
- } );
-}
-
-// Determine support properties
-support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
-xhrSupported = support.ajax = !!xhrSupported;
-
-// Create transport if the browser can provide an xhr
-if ( xhrSupported ) {
-
- jQuery.ajaxTransport( function( options ) {
-
- // Cross domain only allowed if supported through XMLHttpRequest
- if ( !options.crossDomain || support.cors ) {
-
- var callback;
-
- return {
- send: function( headers, complete ) {
- var i,
- xhr = options.xhr(),
- id = ++xhrId;
-
- // Open the socket
- xhr.open(
- options.type,
- options.url,
- options.async,
- options.username,
- options.password
- );
-
- // Apply custom fields if provided
- if ( options.xhrFields ) {
- for ( i in options.xhrFields ) {
- xhr[ i ] = options.xhrFields[ i ];
- }
- }
-
- // Override mime type if needed
- if ( options.mimeType && xhr.overrideMimeType ) {
- xhr.overrideMimeType( options.mimeType );
- }
-
- // X-Requested-With header
- // For cross-domain requests, seeing as conditions for a preflight are
- // akin to a jigsaw puzzle, we simply never set it to be sure.
- // (it can always be set on a per-request basis or even using ajaxSetup)
- // For same-domain requests, won't change header if already provided.
- if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
- headers[ "X-Requested-With" ] = "XMLHttpRequest";
- }
-
- // Set headers
- for ( i in headers ) {
-
- // Support: IE<9
- // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
- // request header to a null-value.
- //
- // To keep consistent with other XHR implementations, cast the value
- // to string and ignore `undefined`.
- if ( headers[ i ] !== undefined ) {
- xhr.setRequestHeader( i, headers[ i ] + "" );
- }
- }
-
- // Do send the request
- // This may raise an exception which is actually
- // handled in jQuery.ajax (so no try/catch here)
- xhr.send( ( options.hasContent && options.data ) || null );
-
- // Listener
- callback = function( _, isAbort ) {
- var status, statusText, responses;
-
- // Was never called and is aborted or complete
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
-
- // Clean up
- delete xhrCallbacks[ id ];
- callback = undefined;
- xhr.onreadystatechange = jQuery.noop;
-
- // Abort manually if needed
- if ( isAbort ) {
- if ( xhr.readyState !== 4 ) {
- xhr.abort();
- }
- } else {
- responses = {};
- status = xhr.status;
-
- // Support: IE<10
- // Accessing binary-data responseText throws an exception
- // (#11426)
- if ( typeof xhr.responseText === "string" ) {
- responses.text = xhr.responseText;
- }
-
- // Firefox throws an exception when accessing
- // statusText for faulty cross-domain requests
- try {
- statusText = xhr.statusText;
- } catch ( e ) {
-
- // We normalize with Webkit giving an empty statusText
- statusText = "";
- }
-
- // Filter status for non standard behaviors
-
- // If the request is local and we have data: assume a success
- // (success with no data won't get notified, that's the best we
- // can do given current implementations)
- if ( !status && options.isLocal && !options.crossDomain ) {
- status = responses.text ? 200 : 404;
-
- // IE - #1450: sometimes returns 1223 when it should be 204
- } else if ( status === 1223 ) {
- status = 204;
- }
- }
- }
-
- // Call complete if needed
- if ( responses ) {
- complete( status, statusText, responses, xhr.getAllResponseHeaders() );
- }
- };
-
- // Do send the request
- // `xhr.send` may raise an exception, but it will be
- // handled in jQuery.ajax (so no try/catch here)
- if ( !options.async ) {
-
- // If we're in sync mode we fire the callback
- callback();
- } else if ( xhr.readyState === 4 ) {
-
- // (IE6 & IE7) if it's in cache and has been
- // retrieved directly we need to fire the callback
- window.setTimeout( callback );
- } else {
-
- // Register the callback, but delay it in case `xhr.send` throws
- // Add to the list of active xhr callbacks
- xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
- }
- },
-
- abort: function() {
- if ( callback ) {
- callback( undefined, true );
- }
- }
- };
- }
- } );
-}
-
-// Functions to create xhrs
-function createStandardXHR() {
- try {
- return new window.XMLHttpRequest();
- } catch ( e ) {}
-}
-
-function createActiveXHR() {
- try {
- return new window.ActiveXObject( "Microsoft.XMLHTTP" );
- } catch ( e ) {}
-}
-
-
-
-
-// Install script dataType
-jQuery.ajaxSetup( {
- accepts: {
- script: "text/javascript, application/javascript, " +
- "application/ecmascript, application/x-ecmascript"
- },
- contents: {
- script: /\b(?:java|ecma)script\b/
- },
- converters: {
- "text script": function( text ) {
- jQuery.globalEval( text );
- return text;
- }
- }
-} );
-
-// Handle cache's special case and global
-jQuery.ajaxPrefilter( "script", function( s ) {
- if ( s.cache === undefined ) {
- s.cache = false;
- }
- if ( s.crossDomain ) {
- s.type = "GET";
- s.global = false;
- }
-} );
-
-// Bind script tag hack transport
-jQuery.ajaxTransport( "script", function( s ) {
-
- // This transport only deals with cross domain requests
- if ( s.crossDomain ) {
-
- var script,
- head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
-
- return {
-
- send: function( _, callback ) {
-
- script = document.createElement( "script" );
-
- script.async = true;
-
- if ( s.scriptCharset ) {
- script.charset = s.scriptCharset;
- }
-
- script.src = s.url;
-
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function( _, isAbort ) {
-
- if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
-
- // Remove the script
- if ( script.parentNode ) {
- script.parentNode.removeChild( script );
- }
-
- // Dereference the script
- script = null;
-
- // Callback if not abort
- if ( !isAbort ) {
- callback( 200, "success" );
- }
- }
- };
-
- // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
- // Use native DOM manipulation to avoid our domManip AJAX trickery
- head.insertBefore( script, head.firstChild );
- },
-
- abort: function() {
- if ( script ) {
- script.onload( undefined, true );
- }
- }
- };
- }
-} );
-
-
-
-
-var oldCallbacks = [],
- rjsonp = /(=)\?(?=&|$)|\?\?/;
-
-// Default jsonp settings
-jQuery.ajaxSetup( {
- jsonp: "callback",
- jsonpCallback: function() {
- var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
- this[ callback ] = true;
- return callback;
- }
-} );
-
-// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
-
- var callbackName, overwritten, responseContainer,
- jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
- "url" :
- typeof s.data === "string" &&
- ( s.contentType || "" )
- .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
- rjsonp.test( s.data ) && "data"
- );
-
- // Handle iff the expected data type is "jsonp" or we have a parameter to set
- if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
-
- // Get callback name, remembering preexisting value associated with it
- callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
- s.jsonpCallback() :
- s.jsonpCallback;
-
- // Insert callback into url or form data
- if ( jsonProp ) {
- s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
- } else if ( s.jsonp !== false ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
- }
-
- // Use data converter to retrieve json after script execution
- s.converters[ "script json" ] = function() {
- if ( !responseContainer ) {
- jQuery.error( callbackName + " was not called" );
- }
- return responseContainer[ 0 ];
- };
-
- // force json dataType
- s.dataTypes[ 0 ] = "json";
-
- // Install callback
- overwritten = window[ callbackName ];
- window[ callbackName ] = function() {
- responseContainer = arguments;
- };
-
- // Clean-up function (fires after converters)
- jqXHR.always( function() {
-
- // If previous value didn't exist - remove it
- if ( overwritten === undefined ) {
- jQuery( window ).removeProp( callbackName );
-
- // Otherwise restore preexisting value
- } else {
- window[ callbackName ] = overwritten;
- }
-
- // Save back as free
- if ( s[ callbackName ] ) {
-
- // make sure that re-using the options doesn't screw things around
- s.jsonpCallback = originalSettings.jsonpCallback;
-
- // save the callback name for future use
- oldCallbacks.push( callbackName );
- }
-
- // Call if it was a function and we have a response
- if ( responseContainer && jQuery.isFunction( overwritten ) ) {
- overwritten( responseContainer[ 0 ] );
- }
-
- responseContainer = overwritten = undefined;
- } );
-
- // Delegate to script
- return "script";
- }
-} );
-
-
-
-
-// data: string of html
-// context (optional): If specified, the fragment will be created in this context,
-// defaults to document
-// keepScripts (optional): If true, will include scripts passed in the html string
-jQuery.parseHTML = function( data, context, keepScripts ) {
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- if ( typeof context === "boolean" ) {
- keepScripts = context;
- context = false;
- }
- context = context || document;
-
- var parsed = rsingleTag.exec( data ),
- scripts = !keepScripts && [];
-
- // Single tag
- if ( parsed ) {
- return [ context.createElement( parsed[ 1 ] ) ];
- }
-
- parsed = buildFragment( [ data ], context, scripts );
-
- if ( scripts && scripts.length ) {
- jQuery( scripts ).remove();
- }
-
- return jQuery.merge( [], parsed.childNodes );
-};
-
-
-// Keep a copy of the old load method
-var _load = jQuery.fn.load;
-
-/**
- * Load a url into a page
- */
-jQuery.fn.load = function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
- }
-
- var selector, type, response,
- self = this,
- off = url.indexOf( " " );
-
- if ( off > -1 ) {
- selector = jQuery.trim( url.slice( off, url.length ) );
- url = url.slice( 0, off );
- }
-
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
-
- // We assume that it's the callback
- callback = params;
- params = undefined;
-
- // Otherwise, build a param string
- } else if ( params && typeof params === "object" ) {
- type = "POST";
- }
-
- // If we have elements to modify, make the request
- if ( self.length > 0 ) {
- jQuery.ajax( {
- url: url,
-
- // If "type" variable is undefined, then "GET" method will be used.
- // Make value of this field explicit since
- // user can override it through ajaxSetup method
- type: type || "GET",
- dataType: "html",
- data: params
- } ).done( function( responseText ) {
-
- // Save response for use in complete callback
- response = arguments;
-
- self.html( selector ?
-
- // If a selector was specified, locate the right elements in a dummy div
- // Exclude scripts to avoid IE 'Permission Denied' errors
- jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
-
- // Otherwise use the full result
- responseText );
-
- // If the request succeeds, this function gets "data", "status", "jqXHR"
- // but they are ignored because response was set above.
- // If it fails, this function gets "jqXHR", "status", "error"
- } ).always( callback && function( jqXHR, status ) {
- self.each( function() {
- callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
- } );
- } );
- }
-
- return this;
-};
-
-
-
-
-// Attach a bunch of functions for handling common AJAX events
-jQuery.each( [
- "ajaxStart",
- "ajaxStop",
- "ajaxComplete",
- "ajaxError",
- "ajaxSuccess",
- "ajaxSend"
-], function( i, type ) {
- jQuery.fn[ type ] = function( fn ) {
- return this.on( type, fn );
- };
-} );
-
-
-
-
-jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep( jQuery.timers, function( fn ) {
- return elem === fn.elem;
- } ).length;
-};
-
-
-
-
-
-/**
- * Gets a window from an element
- */
-function getWindow( elem ) {
- return jQuery.isWindow( elem ) ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
-}
-
-jQuery.offset = {
- setOffset: function( elem, options, i ) {
- var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
- position = jQuery.css( elem, "position" ),
- curElem = jQuery( elem ),
- props = {};
-
- // set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
-
- curOffset = curElem.offset();
- curCSSTop = jQuery.css( elem, "top" );
- curCSSLeft = jQuery.css( elem, "left" );
- calculatePosition = ( position === "absolute" || position === "fixed" ) &&
- jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
-
- // need to be able to calculate position if either top or left
- // is auto and position is either absolute or fixed
- if ( calculatePosition ) {
- curPosition = curElem.position();
- curTop = curPosition.top;
- curLeft = curPosition.left;
- } else {
- curTop = parseFloat( curCSSTop ) || 0;
- curLeft = parseFloat( curCSSLeft ) || 0;
- }
-
- if ( jQuery.isFunction( options ) ) {
-
- // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
- options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
- }
-
- if ( options.top != null ) {
- props.top = ( options.top - curOffset.top ) + curTop;
- }
- if ( options.left != null ) {
- props.left = ( options.left - curOffset.left ) + curLeft;
- }
-
- if ( "using" in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- }
-};
-
-jQuery.fn.extend( {
- offset: function( options ) {
- if ( arguments.length ) {
- return options === undefined ?
- this :
- this.each( function( i ) {
- jQuery.offset.setOffset( this, options, i );
- } );
- }
-
- var docElem, win,
- box = { top: 0, left: 0 },
- elem = this[ 0 ],
- doc = elem && elem.ownerDocument;
-
- if ( !doc ) {
- return;
- }
-
- docElem = doc.documentElement;
-
- // Make sure it's not a disconnected DOM node
- if ( !jQuery.contains( docElem, elem ) ) {
- return box;
- }
-
- // If we don't have gBCR, just use 0,0 rather than error
- // BlackBerry 5, iOS 3 (original iPhone)
- if ( typeof elem.getBoundingClientRect !== "undefined" ) {
- box = elem.getBoundingClientRect();
- }
- win = getWindow( doc );
- return {
- top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
- left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
- };
- },
-
- position: function() {
- if ( !this[ 0 ] ) {
- return;
- }
-
- var offsetParent, offset,
- parentOffset = { top: 0, left: 0 },
- elem = this[ 0 ];
-
- // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
- // because it is its only offset parent
- if ( jQuery.css( elem, "position" ) === "fixed" ) {
-
- // we assume that getBoundingClientRect is available when computed position is fixed
- offset = elem.getBoundingClientRect();
- } else {
-
- // Get *real* offsetParent
- offsetParent = this.offsetParent();
-
- // Get correct offsets
- offset = this.offset();
- if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
- parentOffset = offsetParent.offset();
- }
-
- // Add offsetParent borders
- parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
- parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
- }
-
- // Subtract parent offsets and element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
- // are the same in Safari causing offset.left to incorrectly be 0
- return {
- top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
- left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
- };
- },
-
- offsetParent: function() {
- return this.map( function() {
- var offsetParent = this.offsetParent;
-
- while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
- jQuery.css( offsetParent, "position" ) === "static" ) ) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent || documentElement;
- } );
- }
-} );
-
-// Create scrollLeft and scrollTop methods
-jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
- var top = /Y/.test( prop );
-
- jQuery.fn[ method ] = function( val ) {
- return access( this, function( elem, method, val ) {
- var win = getWindow( elem );
-
- if ( val === undefined ) {
- return win ? ( prop in win ) ? win[ prop ] :
- win.document.documentElement[ method ] :
- elem[ method ];
- }
-
- if ( win ) {
- win.scrollTo(
- !top ? val : jQuery( win ).scrollLeft(),
- top ? val : jQuery( win ).scrollTop()
- );
-
- } else {
- elem[ method ] = val;
- }
- }, method, val, arguments.length, null );
- };
-} );
-
-// Support: Safari<7-8+, Chrome<37-44+
-// Add the top/left cssHooks using jQuery.fn.position
-// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
-// getComputedStyle returns percent when specified for top/left/bottom/right
-// rather than make the css module depend on the offset module, we just check for it here
-jQuery.each( [ "top", "left" ], function( i, prop ) {
- jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
- function( elem, computed ) {
- if ( computed ) {
- computed = curCSS( elem, prop );
-
- // if curCSS returns percentage, fallback to offset
- return rnumnonpx.test( computed ) ?
- jQuery( elem ).position()[ prop ] + "px" :
- computed;
- }
- }
- );
-} );
-
-
-// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
-jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
- jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
- function( defaultExtra, funcName ) {
-
- // margin is only for outerHeight, outerWidth
- jQuery.fn[ funcName ] = function( margin, value ) {
- var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
- extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
-
- return access( this, function( elem, type, value ) {
- var doc;
-
- if ( jQuery.isWindow( elem ) ) {
-
- // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
- // isn't a whole lot we can do. See pull request at this URL for discussion:
- // https://github.com/jquery/jquery/pull/764
- return elem.document.documentElement[ "client" + name ];
- }
-
- // Get document width or height
- if ( elem.nodeType === 9 ) {
- doc = elem.documentElement;
-
- // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
- // whichever is greatest
- // unfortunately, this causes bug #3838 in IE6/8 only,
- // but there is currently no good, small way to fix it.
- return Math.max(
- elem.body[ "scroll" + name ], doc[ "scroll" + name ],
- elem.body[ "offset" + name ], doc[ "offset" + name ],
- doc[ "client" + name ]
- );
- }
-
- return value === undefined ?
-
- // Get width or height on the element, requesting but not forcing parseFloat
- jQuery.css( elem, type, extra ) :
-
- // Set width or height on the element
- jQuery.style( elem, type, value, extra );
- }, type, chainable ? margin : undefined, chainable, null );
- };
- } );
-} );
-
-
-jQuery.fn.extend( {
-
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
-
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ?
- this.off( selector, "**" ) :
- this.off( types, selector || "**", fn );
- }
-} );
-
-// The number of elements contained in the matched element set
-jQuery.fn.size = function() {
- return this.length;
-};
-
-jQuery.fn.andSelf = jQuery.fn.addBack;
-
-
-
-
-// Register as a named AMD module, since jQuery can be concatenated with other
-// files that may use define, but not via a proper concatenation script that
-// understands anonymous AMD modules. A named AMD is safest and most robust
-// way to register. Lowercase jquery is used because AMD module names are
-// derived from file names, and jQuery is normally delivered in a lowercase
-// file name. Do this after creating the global so that if an AMD module wants
-// to call noConflict to hide this version of jQuery, it will work.
-
-// Note that for maximum portability, libraries that are not jQuery should
-// declare themselves as anonymous modules, and avoid setting a global if an
-// AMD loader is present. jQuery is a special case. For more information, see
-// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
-
-if ( typeof define === "function" && define.amd ) {
- define( "jquery", [], function() {
- return jQuery;
- } );
-}
-
-
-
-var
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$;
-
-jQuery.noConflict = function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
-};
-
-// Expose jQuery and $ identifiers, even in
-// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
-// and CommonJS for browser emulators (#13566)
-if ( !noGlobal ) {
- window.jQuery = window.$ = jQuery;
-}
-
-return jQuery;
-}));
--- a/domino/jqueryui/jquery-ui.js
+++ /dev/null
@@ -1,18706 +1,0 @@
-/*! jQuery UI - v1.12.1 - 2016-09-14
-* http://jqueryui.com
-* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
-* Copyright jQuery Foundation and other contributors; Licensed MIT */
-
-(function( factory ) {
- if ( typeof define === "function" && define.amd ) {
-
- // AMD. Register as an anonymous module.
- define([ "jquery" ], factory );
- } else {
-
- // Browser globals
- factory( jQuery );
- }
-}(function( $ ) {
-
-$.ui = $.ui || {};
-
-var version = $.ui.version = "1.12.1";
-
-
-/*!
- * jQuery UI Widget 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Widget
-//>>group: Core
-//>>description: Provides a factory for creating stateful widgets with a common API.
-//>>docs: http://api.jqueryui.com/jQuery.widget/
-//>>demos: http://jqueryui.com/widget/
-
-
-
-var widgetUuid = 0;
-var widgetSlice = Array.prototype.slice;
-
-$.cleanData = ( function( orig ) {
- return function( elems ) {
- var events, elem, i;
- for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
- try {
-
- // Only trigger remove when necessary to save time
- events = $._data( elem, "events" );
- if ( events && events.remove ) {
- $( elem ).triggerHandler( "remove" );
- }
-
- // Http://bugs.jquery.com/ticket/8235
- } catch ( e ) {}
- }
- orig( elems );
- };
-} )( $.cleanData );
-
-$.widget = function( name, base, prototype ) {
- var existingConstructor, constructor, basePrototype;
-
- // ProxiedPrototype allows the provided prototype to remain unmodified
- // so that it can be used as a mixin for multiple widgets (#8876)
- var proxiedPrototype = {};
-
- var namespace = name.split( "." )[ 0 ];
- name = name.split( "." )[ 1 ];
- var fullName = namespace + "-" + name;
-
- if ( !prototype ) {
- prototype = base;
- base = $.Widget;
- }
-
- if ( $.isArray( prototype ) ) {
- prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
- }
-
- // Create selector for plugin
- $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
- return !!$.data( elem, fullName );
- };
-
- $[ namespace ] = $[ namespace ] || {};
- existingConstructor = $[ namespace ][ name ];
- constructor = $[ namespace ][ name ] = function( options, element ) {
-
- // Allow instantiation without "new" keyword
- if ( !this._createWidget ) {
- return new constructor( options, element );
- }
-
- // Allow instantiation without initializing for simple inheritance
- // must use "new" keyword (the code above always passes args)
- if ( arguments.length ) {
- this._createWidget( options, element );
- }
- };
-
- // Extend with the existing constructor to carry over any static properties
- $.extend( constructor, existingConstructor, {
- version: prototype.version,
-
- // Copy the object used to create the prototype in case we need to
- // redefine the widget later
- _proto: $.extend( {}, prototype ),
-
- // Track widgets that inherit from this widget in case this widget is
- // redefined after a widget inherits from it
- _childConstructors: []
- } );
-
- basePrototype = new base();
-
- // We need to make the options hash a property directly on the new instance
- // otherwise we'll modify the options hash on the prototype that we're
- // inheriting from
- basePrototype.options = $.widget.extend( {}, basePrototype.options );
- $.each( prototype, function( prop, value ) {
- if ( !$.isFunction( value ) ) {
- proxiedPrototype[ prop ] = value;
- return;
- }
- proxiedPrototype[ prop ] = ( function() {
- function _super() {
- return base.prototype[ prop ].apply( this, arguments );
- }
-
- function _superApply( args ) {
- return base.prototype[ prop ].apply( this, args );
- }
-
- return function() {
- var __super = this._super;
- var __superApply = this._superApply;
- var returnValue;
-
- this._super = _super;
- this._superApply = _superApply;
-
- returnValue = value.apply( this, arguments );
-
- this._super = __super;
- this._superApply = __superApply;
-
- return returnValue;
- };
- } )();
- } );
- constructor.prototype = $.widget.extend( basePrototype, {
-
- // TODO: remove support for widgetEventPrefix
- // always use the name + a colon as the prefix, e.g., draggable:start
- // don't prefix for widgets that aren't DOM-based
- widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
- }, proxiedPrototype, {
- constructor: constructor,
- namespace: namespace,
- widgetName: name,
- widgetFullName: fullName
- } );
-
- // If this widget is being redefined then we need to find all widgets that
- // are inheriting from it and redefine all of them so that they inherit from
- // the new version of this widget. We're essentially trying to replace one
- // level in the prototype chain.
- if ( existingConstructor ) {
- $.each( existingConstructor._childConstructors, function( i, child ) {
- var childPrototype = child.prototype;
-
- // Redefine the child widget using the same prototype that was
- // originally used, but inherit from the new version of the base
- $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
- child._proto );
- } );
-
- // Remove the list of existing child constructors from the old constructor
- // so the old child constructors can be garbage collected
- delete existingConstructor._childConstructors;
- } else {
- base._childConstructors.push( constructor );
- }
-
- $.widget.bridge( name, constructor );
-
- return constructor;
-};
-
-$.widget.extend = function( target ) {
- var input = widgetSlice.call( arguments, 1 );
- var inputIndex = 0;
- var inputLength = input.length;
- var key;
- var value;
-
- for ( ; inputIndex < inputLength; inputIndex++ ) {
- for ( key in input[ inputIndex ] ) {
- value = input[ inputIndex ][ key ];
- if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
-
- // Clone objects
- if ( $.isPlainObject( value ) ) {
- target[ key ] = $.isPlainObject( target[ key ] ) ?
- $.widget.extend( {}, target[ key ], value ) :
-
- // Don't extend strings, arrays, etc. with objects
- $.widget.extend( {}, value );
-
- // Copy everything else by reference
- } else {
- target[ key ] = value;
- }
- }
- }
- }
- return target;
-};
-
-$.widget.bridge = function( name, object ) {
- var fullName = object.prototype.widgetFullName || name;
- $.fn[ name ] = function( options ) {
- var isMethodCall = typeof options === "string";
- var args = widgetSlice.call( arguments, 1 );
- var returnValue = this;
-
- if ( isMethodCall ) {
-
- // If this is an empty collection, we need to have the instance method
- // return undefined instead of the jQuery instance
- if ( !this.length && options === "instance" ) {
- returnValue = undefined;
- } else {
- this.each( function() {
- var methodValue;
- var instance = $.data( this, fullName );
-
- if ( options === "instance" ) {
- returnValue = instance;
- return false;
- }
-
- if ( !instance ) {
- return $.error( "cannot call methods on " + name +
- " prior to initialization; " +
- "attempted to call method '" + options + "'" );
- }
-
- if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
- return $.error( "no such method '" + options + "' for " + name +
- " widget instance" );
- }
-
- methodValue = instance[ options ].apply( instance, args );
-
- if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue && methodValue.jquery ?
- returnValue.pushStack( methodValue.get() ) :
- methodValue;
- return false;
- }
- } );
- }
- } else {
-
- // Allow multiple hashes to be passed on init
- if ( args.length ) {
- options = $.widget.extend.apply( null, [ options ].concat( args ) );
- }
-
- this.each( function() {
- var instance = $.data( this, fullName );
- if ( instance ) {
- instance.option( options || {} );
- if ( instance._init ) {
- instance._init();
- }
- } else {
- $.data( this, fullName, new object( options, this ) );
- }
- } );
- }
-
- return returnValue;
- };
-};
-
-$.Widget = function( /* options, element */ ) {};
-$.Widget._childConstructors = [];
-
-$.Widget.prototype = {
- widgetName: "widget",
- widgetEventPrefix: "",
- defaultElement: "<div>",
-
- options: {
- classes: {},
- disabled: false,
-
- // Callbacks
- create: null
- },
-
- _createWidget: function( options, element ) {
- element = $( element || this.defaultElement || this )[ 0 ];
- this.element = $( element );
- this.uuid = widgetUuid++;
- this.eventNamespace = "." + this.widgetName + this.uuid;
-
- this.bindings = $();
- this.hoverable = $();
- this.focusable = $();
- this.classesElementLookup = {};
-
- if ( element !== this ) {
- $.data( element, this.widgetFullName, this );
- this._on( true, this.element, {
- remove: function( event ) {
- if ( event.target === element ) {
- this.destroy();
- }
- }
- } );
- this.document = $( element.style ?
-
- // Element within the document
- element.ownerDocument :
-
- // Element is window or document
- element.document || element );
- this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
- }
-
- this.options = $.widget.extend( {},
- this.options,
- this._getCreateOptions(),
- options );
-
- this._create();
-
- if ( this.options.disabled ) {
- this._setOptionDisabled( this.options.disabled );
- }
-
- this._trigger( "create", null, this._getCreateEventData() );
- this._init();
- },
-
- _getCreateOptions: function() {
- return {};
- },
-
- _getCreateEventData: $.noop,
-
- _create: $.noop,
-
- _init: $.noop,
-
- destroy: function() {
- var that = this;
-
- this._destroy();
- $.each( this.classesElementLookup, function( key, value ) {
- that._removeClass( value, key );
- } );
-
- // We can probably remove the unbind calls in 2.0
- // all event bindings should go through this._on()
- this.element
- .off( this.eventNamespace )
- .removeData( this.widgetFullName );
- this.widget()
- .off( this.eventNamespace )
- .removeAttr( "aria-disabled" );
-
- // Clean up events and states
- this.bindings.off( this.eventNamespace );
- },
-
- _destroy: $.noop,
-
- widget: function() {
- return this.element;
- },
-
- option: function( key, value ) {
- var options = key;
- var parts;
- var curOption;
- var i;
-
- if ( arguments.length === 0 ) {
-
- // Don't return a reference to the internal hash
- return $.widget.extend( {}, this.options );
- }
-
- if ( typeof key === "string" ) {
-
- // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
- options = {};
- parts = key.split( "." );
- key = parts.shift();
- if ( parts.length ) {
- curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
- for ( i = 0; i < parts.length - 1; i++ ) {
- curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
- curOption = curOption[ parts[ i ] ];
- }
- key = parts.pop();
- if ( arguments.length === 1 ) {
- return curOption[ key ] === undefined ? null : curOption[ key ];
- }
- curOption[ key ] = value;
- } else {
- if ( arguments.length === 1 ) {
- return this.options[ key ] === undefined ? null : this.options[ key ];
- }
- options[ key ] = value;
- }
- }
-
- this._setOptions( options );
-
- return this;
- },
-
- _setOptions: function( options ) {
- var key;
-
- for ( key in options ) {
- this._setOption( key, options[ key ] );
- }
-
- return this;
- },
-
- _setOption: function( key, value ) {
- if ( key === "classes" ) {
- this._setOptionClasses( value );
- }
-
- this.options[ key ] = value;
-
- if ( key === "disabled" ) {
- this._setOptionDisabled( value );
- }
-
- return this;
- },
-
- _setOptionClasses: function( value ) {
- var classKey, elements, currentElements;
-
- for ( classKey in value ) {
- currentElements = this.classesElementLookup[ classKey ];
- if ( value[ classKey ] === this.options.classes[ classKey ] ||
- !currentElements ||
- !currentElements.length ) {
- continue;
- }
-
- // We are doing this to create a new jQuery object because the _removeClass() call
- // on the next line is going to destroy the reference to the current elements being
- // tracked. We need to save a copy of this collection so that we can add the new classes
- // below.
- elements = $( currentElements.get() );
- this._removeClass( currentElements, classKey );
-
- // We don't use _addClass() here, because that uses this.options.classes
- // for generating the string of classes. We want to use the value passed in from
- // _setOption(), this is the new value of the classes option which was passed to
- // _setOption(). We pass this value directly to _classes().
- elements.addClass( this._classes( {
- element: elements,
- keys: classKey,
- classes: value,
- add: true
- } ) );
- }
- },
-
- _setOptionDisabled: function( value ) {
- this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
-
- // If the widget is becoming disabled, then nothing is interactive
- if ( value ) {
- this._removeClass( this.hoverable, null, "ui-state-hover" );
- this._removeClass( this.focusable, null, "ui-state-focus" );
- }
- },
-
- enable: function() {
- return this._setOptions( { disabled: false } );
- },
-
- disable: function() {
- return this._setOptions( { disabled: true } );
- },
-
- _classes: function( options ) {
- var full = [];
- var that = this;
-
- options = $.extend( {
- element: this.element,
- classes: this.options.classes || {}
- }, options );
-
- function processClassString( classes, checkOption ) {
- var current, i;
- for ( i = 0; i < classes.length; i++ ) {
- current = that.classesElementLookup[ classes[ i ] ] || $();
- if ( options.add ) {
- current = $( $.unique( current.get().concat( options.element.get() ) ) );
- } else {
- current = $( current.not( options.element ).get() );
- }
- that.classesElementLookup[ classes[ i ] ] = current;
- full.push( classes[ i ] );
- if ( checkOption && options.classes[ classes[ i ] ] ) {
- full.push( options.classes[ classes[ i ] ] );
- }
- }
- }
-
- this._on( options.element, {
- "remove": "_untrackClassesElement"
- } );
-
- if ( options.keys ) {
- processClassString( options.keys.match( /\S+/g ) || [], true );
- }
- if ( options.extra ) {
- processClassString( options.extra.match( /\S+/g ) || [] );
- }
-
- return full.join( " " );
- },
-
- _untrackClassesElement: function( event ) {
- var that = this;
- $.each( that.classesElementLookup, function( key, value ) {
- if ( $.inArray( event.target, value ) !== -1 ) {
- that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
- }
- } );
- },
-
- _removeClass: function( element, keys, extra ) {
- return this._toggleClass( element, keys, extra, false );
- },
-
- _addClass: function( element, keys, extra ) {
- return this._toggleClass( element, keys, extra, true );
- },
-
- _toggleClass: function( element, keys, extra, add ) {
- add = ( typeof add === "boolean" ) ? add : extra;
- var shift = ( typeof element === "string" || element === null ),
- options = {
- extra: shift ? keys : extra,
- keys: shift ? element : keys,
- element: shift ? this.element : element,
- add: add
- };
- options.element.toggleClass( this._classes( options ), add );
- return this;
- },
-
- _on: function( suppressDisabledCheck, element, handlers ) {
- var delegateElement;
- var instance = this;
-
- // No suppressDisabledCheck flag, shuffle arguments
- if ( typeof suppressDisabledCheck !== "boolean" ) {
- handlers = element;
- element = suppressDisabledCheck;
- suppressDisabledCheck = false;
- }
-
- // No element argument, shuffle and use this.element
- if ( !handlers ) {
- handlers = element;
- element = this.element;
- delegateElement = this.widget();
- } else {
- element = delegateElement = $( element );
- this.bindings = this.bindings.add( element );
- }
-
- $.each( handlers, function( event, handler ) {
- function handlerProxy() {
-
- // Allow widgets to customize the disabled handling
- // - disabled as an array instead of boolean
- // - disabled class as method for disabling individual parts
- if ( !suppressDisabledCheck &&
- ( instance.options.disabled === true ||
- $( this ).hasClass( "ui-state-disabled" ) ) ) {
- return;
- }
- return ( typeof handler === "string" ? instance[ handler ] : handler )
- .apply( instance, arguments );
- }
-
- // Copy the guid so direct unbinding works
- if ( typeof handler !== "string" ) {
- handlerProxy.guid = handler.guid =
- handler.guid || handlerProxy.guid || $.guid++;
- }
-
- var match = event.match( /^([\w:-]*)\s*(.*)$/ );
- var eventName = match[ 1 ] + instance.eventNamespace;
- var selector = match[ 2 ];
-
- if ( selector ) {
- delegateElement.on( eventName, selector, handlerProxy );
- } else {
- element.on( eventName, handlerProxy );
- }
- } );
- },
-
- _off: function( element, eventName ) {
- eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
- this.eventNamespace;
- element.off( eventName ).off( eventName );
-
- // Clear the stack to avoid memory leaks (#10056)
- this.bindings = $( this.bindings.not( element ).get() );
- this.focusable = $( this.focusable.not( element ).get() );
- this.hoverable = $( this.hoverable.not( element ).get() );
- },
-
- _delay: function( handler, delay ) {
- function handlerProxy() {
- return ( typeof handler === "string" ? instance[ handler ] : handler )
- .apply( instance, arguments );
- }
- var instance = this;
- return setTimeout( handlerProxy, delay || 0 );
- },
-
- _hoverable: function( element ) {
- this.hoverable = this.hoverable.add( element );
- this._on( element, {
- mouseenter: function( event ) {
- this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
- },
- mouseleave: function( event ) {
- this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
- }
- } );
- },
-
- _focusable: function( element ) {
- this.focusable = this.focusable.add( element );
- this._on( element, {
- focusin: function( event ) {
- this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
- },
- focusout: function( event ) {
- this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
- }
- } );
- },
-
- _trigger: function( type, event, data ) {
- var prop, orig;
- var callback = this.options[ type ];
-
- data = data || {};
- event = $.Event( event );
- event.type = ( type === this.widgetEventPrefix ?
- type :
- this.widgetEventPrefix + type ).toLowerCase();
-
- // The original event may come from any element
- // so we need to reset the target on the new event
- event.target = this.element[ 0 ];
-
- // Copy original event properties over to the new event
- orig = event.originalEvent;
- if ( orig ) {
- for ( prop in orig ) {
- if ( !( prop in event ) ) {
- event[ prop ] = orig[ prop ];
- }
- }
- }
-
- this.element.trigger( event, data );
- return !( $.isFunction( callback ) &&
- callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
- event.isDefaultPrevented() );
- }
-};
-
-$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
- $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
- if ( typeof options === "string" ) {
- options = { effect: options };
- }
-
- var hasOptions;
- var effectName = !options ?
- method :
- options === true || typeof options === "number" ?
- defaultEffect :
- options.effect || defaultEffect;
-
- options = options || {};
- if ( typeof options === "number" ) {
- options = { duration: options };
- }
-
- hasOptions = !$.isEmptyObject( options );
- options.complete = callback;
-
- if ( options.delay ) {
- element.delay( options.delay );
- }
-
- if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
- element[ method ]( options );
- } else if ( effectName !== method && element[ effectName ] ) {
- element[ effectName ]( options.duration, options.easing, callback );
- } else {
- element.queue( function( next ) {
- $( this )[ method ]();
- if ( callback ) {
- callback.call( element[ 0 ] );
- }
- next();
- } );
- }
- };
-} );
-
-var widget = $.widget;
-
-
-/*!
- * jQuery UI Position 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- * http://api.jqueryui.com/position/
- */
-
-//>>label: Position
-//>>group: Core
-//>>description: Positions elements relative to other elements.
-//>>docs: http://api.jqueryui.com/position/
-//>>demos: http://jqueryui.com/position/
-
-
-( function() {
-var cachedScrollbarWidth,
- max = Math.max,
- abs = Math.abs,
- rhorizontal = /left|center|right/,
- rvertical = /top|center|bottom/,
- roffset = /[\+\-]\d+(\.[\d]+)?%?/,
- rposition = /^\w+/,
- rpercent = /%$/,
- _position = $.fn.position;
-
-function getOffsets( offsets, width, height ) {
- return [
- parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
- parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
- ];
-}
-
-function parseCss( element, property ) {
- return parseInt( $.css( element, property ), 10 ) || 0;
-}
-
-function getDimensions( elem ) {
- var raw = elem[ 0 ];
- if ( raw.nodeType === 9 ) {
- return {
- width: elem.width(),
- height: elem.height(),
- offset: { top: 0, left: 0 }
- };
- }
- if ( $.isWindow( raw ) ) {
- return {
- width: elem.width(),
- height: elem.height(),
- offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
- };
- }
- if ( raw.preventDefault ) {
- return {
- width: 0,
- height: 0,
- offset: { top: raw.pageY, left: raw.pageX }
- };
- }
- return {
- width: elem.outerWidth(),
- height: elem.outerHeight(),
- offset: elem.offset()
- };
-}
-
-$.position = {
- scrollbarWidth: function() {
- if ( cachedScrollbarWidth !== undefined ) {
- return cachedScrollbarWidth;
- }
- var w1, w2,
- div = $( "<div " +
- "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
- "<div style='height:100px;width:auto;'></div></div>" ),
- innerDiv = div.children()[ 0 ];
-
- $( "body" ).append( div );
- w1 = innerDiv.offsetWidth;
- div.css( "overflow", "scroll" );
-
- w2 = innerDiv.offsetWidth;
-
- if ( w1 === w2 ) {
- w2 = div[ 0 ].clientWidth;
- }
-
- div.remove();
-
- return ( cachedScrollbarWidth = w1 - w2 );
- },
- getScrollInfo: function( within ) {
- var overflowX = within.isWindow || within.isDocument ? "" :
- within.element.css( "overflow-x" ),
- overflowY = within.isWindow || within.isDocument ? "" :
- within.element.css( "overflow-y" ),
- hasOverflowX = overflowX === "scroll" ||
- ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
- hasOverflowY = overflowY === "scroll" ||
- ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
- return {
- width: hasOverflowY ? $.position.scrollbarWidth() : 0,
- height: hasOverflowX ? $.position.scrollbarWidth() : 0
- };
- },
- getWithinInfo: function( element ) {
- var withinElement = $( element || window ),
- isWindow = $.isWindow( withinElement[ 0 ] ),
- isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
- hasOffset = !isWindow && !isDocument;
- return {
- element: withinElement,
- isWindow: isWindow,
- isDocument: isDocument,
- offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
- scrollLeft: withinElement.scrollLeft(),
- scrollTop: withinElement.scrollTop(),
- width: withinElement.outerWidth(),
- height: withinElement.outerHeight()
- };
- }
-};
-
-$.fn.position = function( options ) {
- if ( !options || !options.of ) {
- return _position.apply( this, arguments );
- }
-
- // Make a copy, we don't want to modify arguments
- options = $.extend( {}, options );
-
- var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
- target = $( options.of ),
- within = $.position.getWithinInfo( options.within ),
- scrollInfo = $.position.getScrollInfo( within ),
- collision = ( options.collision || "flip" ).split( " " ),
- offsets = {};
-
- dimensions = getDimensions( target );
- if ( target[ 0 ].preventDefault ) {
-
- // Force left top to allow flipping
- options.at = "left top";
- }
- targetWidth = dimensions.width;
- targetHeight = dimensions.height;
- targetOffset = dimensions.offset;
-
- // Clone to reuse original targetOffset later
- basePosition = $.extend( {}, targetOffset );
-
- // Force my and at to have valid horizontal and vertical positions
- // if a value is missing or invalid, it will be converted to center
- $.each( [ "my", "at" ], function() {
- var pos = ( options[ this ] || "" ).split( " " ),
- horizontalOffset,
- verticalOffset;
-
- if ( pos.length === 1 ) {
- pos = rhorizontal.test( pos[ 0 ] ) ?
- pos.concat( [ "center" ] ) :
- rvertical.test( pos[ 0 ] ) ?
- [ "center" ].concat( pos ) :
- [ "center", "center" ];
- }
- pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
- pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
-
- // Calculate offsets
- horizontalOffset = roffset.exec( pos[ 0 ] );
- verticalOffset = roffset.exec( pos[ 1 ] );
- offsets[ this ] = [
- horizontalOffset ? horizontalOffset[ 0 ] : 0,
- verticalOffset ? verticalOffset[ 0 ] : 0
- ];
-
- // Reduce to just the positions without the offsets
- options[ this ] = [
- rposition.exec( pos[ 0 ] )[ 0 ],
- rposition.exec( pos[ 1 ] )[ 0 ]
- ];
- } );
-
- // Normalize collision option
- if ( collision.length === 1 ) {
- collision[ 1 ] = collision[ 0 ];
- }
-
- if ( options.at[ 0 ] === "right" ) {
- basePosition.left += targetWidth;
- } else if ( options.at[ 0 ] === "center" ) {
- basePosition.left += targetWidth / 2;
- }
-
- if ( options.at[ 1 ] === "bottom" ) {
- basePosition.top += targetHeight;
- } else if ( options.at[ 1 ] === "center" ) {
- basePosition.top += targetHeight / 2;
- }
-
- atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
- basePosition.left += atOffset[ 0 ];
- basePosition.top += atOffset[ 1 ];
-
- return this.each( function() {
- var collisionPosition, using,
- elem = $( this ),
- elemWidth = elem.outerWidth(),
- elemHeight = elem.outerHeight(),
- marginLeft = parseCss( this, "marginLeft" ),
- marginTop = parseCss( this, "marginTop" ),
- collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
- scrollInfo.width,
- collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
- scrollInfo.height,
- position = $.extend( {}, basePosition ),
- myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
-
- if ( options.my[ 0 ] === "right" ) {
- position.left -= elemWidth;
- } else if ( options.my[ 0 ] === "center" ) {
- position.left -= elemWidth / 2;
- }
-
- if ( options.my[ 1 ] === "bottom" ) {
- position.top -= elemHeight;
- } else if ( options.my[ 1 ] === "center" ) {
- position.top -= elemHeight / 2;
- }
-
- position.left += myOffset[ 0 ];
- position.top += myOffset[ 1 ];
-
- collisionPosition = {
- marginLeft: marginLeft,
- marginTop: marginTop
- };
-
- $.each( [ "left", "top" ], function( i, dir ) {
- if ( $.ui.position[ collision[ i ] ] ) {
- $.ui.position[ collision[ i ] ][ dir ]( position, {
- targetWidth: targetWidth,
- targetHeight: targetHeight,
- elemWidth: elemWidth,
- elemHeight: elemHeight,
- collisionPosition: collisionPosition,
- collisionWidth: collisionWidth,
- collisionHeight: collisionHeight,
- offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
- my: options.my,
- at: options.at,
- within: within,
- elem: elem
- } );
- }
- } );
-
- if ( options.using ) {
-
- // Adds feedback as second argument to using callback, if present
- using = function( props ) {
- var left = targetOffset.left - position.left,
- right = left + targetWidth - elemWidth,
- top = targetOffset.top - position.top,
- bottom = top + targetHeight - elemHeight,
- feedback = {
- target: {
- element: target,
- left: targetOffset.left,
- top: targetOffset.top,
- width: targetWidth,
- height: targetHeight
- },
- element: {
- element: elem,
- left: position.left,
- top: position.top,
- width: elemWidth,
- height: elemHeight
- },
- horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
- vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
- };
- if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
- feedback.horizontal = "center";
- }
- if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
- feedback.vertical = "middle";
- }
- if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
- feedback.important = "horizontal";
- } else {
- feedback.important = "vertical";
- }
- options.using.call( this, props, feedback );
- };
- }
-
- elem.offset( $.extend( position, { using: using } ) );
- } );
-};
-
-$.ui.position = {
- fit: {
- left: function( position, data ) {
- var within = data.within,
- withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
- outerWidth = within.width,
- collisionPosLeft = position.left - data.collisionPosition.marginLeft,
- overLeft = withinOffset - collisionPosLeft,
- overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
- newOverRight;
-
- // Element is wider than within
- if ( data.collisionWidth > outerWidth ) {
-
- // Element is initially over the left side of within
- if ( overLeft > 0 && overRight <= 0 ) {
- newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
- withinOffset;
- position.left += overLeft - newOverRight;
-
- // Element is initially over right side of within
- } else if ( overRight > 0 && overLeft <= 0 ) {
- position.left = withinOffset;
-
- // Element is initially over both left and right sides of within
- } else {
- if ( overLeft > overRight ) {
- position.left = withinOffset + outerWidth - data.collisionWidth;
- } else {
- position.left = withinOffset;
- }
- }
-
- // Too far left -> align with left edge
- } else if ( overLeft > 0 ) {
- position.left += overLeft;
-
- // Too far right -> align with right edge
- } else if ( overRight > 0 ) {
- position.left -= overRight;
-
- // Adjust based on position and margin
- } else {
- position.left = max( position.left - collisionPosLeft, position.left );
- }
- },
- top: function( position, data ) {
- var within = data.within,
- withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
- outerHeight = data.within.height,
- collisionPosTop = position.top - data.collisionPosition.marginTop,
- overTop = withinOffset - collisionPosTop,
- overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
- newOverBottom;
-
- // Element is taller than within
- if ( data.collisionHeight > outerHeight ) {
-
- // Element is initially over the top of within
- if ( overTop > 0 && overBottom <= 0 ) {
- newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
- withinOffset;
- position.top += overTop - newOverBottom;
-
- // Element is initially over bottom of within
- } else if ( overBottom > 0 && overTop <= 0 ) {
- position.top = withinOffset;
-
- // Element is initially over both top and bottom of within
- } else {
- if ( overTop > overBottom ) {
- position.top = withinOffset + outerHeight - data.collisionHeight;
- } else {
- position.top = withinOffset;
- }
- }
-
- // Too far up -> align with top
- } else if ( overTop > 0 ) {
- position.top += overTop;
-
- // Too far down -> align with bottom edge
- } else if ( overBottom > 0 ) {
- position.top -= overBottom;
-
- // Adjust based on position and margin
- } else {
- position.top = max( position.top - collisionPosTop, position.top );
- }
- }
- },
- flip: {
- left: function( position, data ) {
- var within = data.within,
- withinOffset = within.offset.left + within.scrollLeft,
- outerWidth = within.width,
- offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
- collisionPosLeft = position.left - data.collisionPosition.marginLeft,
- overLeft = collisionPosLeft - offsetLeft,
- overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
- myOffset = data.my[ 0 ] === "left" ?
- -data.elemWidth :
- data.my[ 0 ] === "right" ?
- data.elemWidth :
- 0,
- atOffset = data.at[ 0 ] === "left" ?
- data.targetWidth :
- data.at[ 0 ] === "right" ?
- -data.targetWidth :
- 0,
- offset = -2 * data.offset[ 0 ],
- newOverRight,
- newOverLeft;
-
- if ( overLeft < 0 ) {
- newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
- outerWidth - withinOffset;
- if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
- position.left += myOffset + atOffset + offset;
- }
- } else if ( overRight > 0 ) {
- newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
- atOffset + offset - offsetLeft;
- if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
- position.left += myOffset + atOffset + offset;
- }
- }
- },
- top: function( position, data ) {
- var within = data.within,
- withinOffset = within.offset.top + within.scrollTop,
- outerHeight = within.height,
- offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
- collisionPosTop = position.top - data.collisionPosition.marginTop,
- overTop = collisionPosTop - offsetTop,
- overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
- top = data.my[ 1 ] === "top",
- myOffset = top ?
- -data.elemHeight :
- data.my[ 1 ] === "bottom" ?
- data.elemHeight :
- 0,
- atOffset = data.at[ 1 ] === "top" ?
- data.targetHeight :
- data.at[ 1 ] === "bottom" ?
- -data.targetHeight :
- 0,
- offset = -2 * data.offset[ 1 ],
- newOverTop,
- newOverBottom;
- if ( overTop < 0 ) {
- newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
- outerHeight - withinOffset;
- if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
- position.top += myOffset + atOffset + offset;
- }
- } else if ( overBottom > 0 ) {
- newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
- offset - offsetTop;
- if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
- position.top += myOffset + atOffset + offset;
- }
- }
- }
- },
- flipfit: {
- left: function() {
- $.ui.position.flip.left.apply( this, arguments );
- $.ui.position.fit.left.apply( this, arguments );
- },
- top: function() {
- $.ui.position.flip.top.apply( this, arguments );
- $.ui.position.fit.top.apply( this, arguments );
- }
- }
-};
-
-} )();
-
-var position = $.ui.position;
-
-
-/*!
- * jQuery UI :data 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: :data Selector
-//>>group: Core
-//>>description: Selects elements which have data stored under the specified key.
-//>>docs: http://api.jqueryui.com/data-selector/
-
-
-var data = $.extend( $.expr[ ":" ], {
- data: $.expr.createPseudo ?
- $.expr.createPseudo( function( dataName ) {
- return function( elem ) {
- return !!$.data( elem, dataName );
- };
- } ) :
-
- // Support: jQuery <1.8
- function( elem, i, match ) {
- return !!$.data( elem, match[ 3 ] );
- }
-} );
-
-/*!
- * jQuery UI Disable Selection 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: disableSelection
-//>>group: Core
-//>>description: Disable selection of text content within the set of matched elements.
-//>>docs: http://api.jqueryui.com/disableSelection/
-
-// This file is deprecated
-
-
-var disableSelection = $.fn.extend( {
- disableSelection: ( function() {
- var eventType = "onselectstart" in document.createElement( "div" ) ?
- "selectstart" :
- "mousedown";
-
- return function() {
- return this.on( eventType + ".ui-disableSelection", function( event ) {
- event.preventDefault();
- } );
- };
- } )(),
-
- enableSelection: function() {
- return this.off( ".ui-disableSelection" );
- }
-} );
-
-
-/*!
- * jQuery UI Effects 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Effects Core
-//>>group: Effects
-// jscs:disable maximumLineLength
-//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
-// jscs:enable maximumLineLength
-//>>docs: http://api.jqueryui.com/category/effects-core/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var dataSpace = "ui-effects-",
- dataSpaceStyle = "ui-effects-style",
- dataSpaceAnimated = "ui-effects-animated",
-
- // Create a local jQuery because jQuery Color relies on it and the
- // global may not exist with AMD and a custom build (#10199)
- jQuery = $;
-
-$.effects = {
- effect: {}
-};
-
-/*!
- * jQuery Color Animations v2.1.2
- * https://github.com/jquery/jquery-color
- *
- * Copyright 2014 jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- * Date: Wed Jan 16 08:47:09 2013 -0600
- */
-( function( jQuery, undefined ) {
-
- var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
- "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
-
- // Plusequals test for += 100 -= 100
- rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
-
- // A set of RE's that can match strings and generate color tuples.
- stringParsers = [ {
- re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
- parse: function( execResult ) {
- return [
- execResult[ 1 ],
- execResult[ 2 ],
- execResult[ 3 ],
- execResult[ 4 ]
- ];
- }
- }, {
- re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
- parse: function( execResult ) {
- return [
- execResult[ 1 ] * 2.55,
- execResult[ 2 ] * 2.55,
- execResult[ 3 ] * 2.55,
- execResult[ 4 ]
- ];
- }
- }, {
-
- // This regex ignores A-F because it's compared against an already lowercased string
- re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
- parse: function( execResult ) {
- return [
- parseInt( execResult[ 1 ], 16 ),
- parseInt( execResult[ 2 ], 16 ),
- parseInt( execResult[ 3 ], 16 )
- ];
- }
- }, {
-
- // This regex ignores A-F because it's compared against an already lowercased string
- re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
- parse: function( execResult ) {
- return [
- parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
- parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
- parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
- ];
- }
- }, {
- re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
- space: "hsla",
- parse: function( execResult ) {
- return [
- execResult[ 1 ],
- execResult[ 2 ] / 100,
- execResult[ 3 ] / 100,
- execResult[ 4 ]
- ];
- }
- } ],
-
- // JQuery.Color( )
- color = jQuery.Color = function( color, green, blue, alpha ) {
- return new jQuery.Color.fn.parse( color, green, blue, alpha );
- },
- spaces = {
- rgba: {
- props: {
- red: {
- idx: 0,
- type: "byte"
- },
- green: {
- idx: 1,
- type: "byte"
- },
- blue: {
- idx: 2,
- type: "byte"
- }
- }
- },
-
- hsla: {
- props: {
- hue: {
- idx: 0,
- type: "degrees"
- },
- saturation: {
- idx: 1,
- type: "percent"
- },
- lightness: {
- idx: 2,
- type: "percent"
- }
- }
- }
- },
- propTypes = {
- "byte": {
- floor: true,
- max: 255
- },
- "percent": {
- max: 1
- },
- "degrees": {
- mod: 360,
- floor: true
- }
- },
- support = color.support = {},
-
- // Element for support tests
- supportElem = jQuery( "<p>" )[ 0 ],
-
- // Colors = jQuery.Color.names
- colors,
-
- // Local aliases of functions called often
- each = jQuery.each;
-
-// Determine rgba support immediately
-supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
-support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
-
-// Define cache name and alpha properties
-// for rgba and hsla spaces
-each( spaces, function( spaceName, space ) {
- space.cache = "_" + spaceName;
- space.props.alpha = {
- idx: 3,
- type: "percent",
- def: 1
- };
-} );
-
-function clamp( value, prop, allowEmpty ) {
- var type = propTypes[ prop.type ] || {};
-
- if ( value == null ) {
- return ( allowEmpty || !prop.def ) ? null : prop.def;
- }
-
- // ~~ is an short way of doing floor for positive numbers
- value = type.floor ? ~~value : parseFloat( value );
-
- // IE will pass in empty strings as value for alpha,
- // which will hit this case
- if ( isNaN( value ) ) {
- return prop.def;
- }
-
- if ( type.mod ) {
-
- // We add mod before modding to make sure that negatives values
- // get converted properly: -10 -> 350
- return ( value + type.mod ) % type.mod;
- }
-
- // For now all property types without mod have min and max
- return 0 > value ? 0 : type.max < value ? type.max : value;
-}
-
-function stringParse( string ) {
- var inst = color(),
- rgba = inst._rgba = [];
-
- string = string.toLowerCase();
-
- each( stringParsers, function( i, parser ) {
- var parsed,
- match = parser.re.exec( string ),
- values = match && parser.parse( match ),
- spaceName = parser.space || "rgba";
-
- if ( values ) {
- parsed = inst[ spaceName ]( values );
-
- // If this was an rgba parse the assignment might happen twice
- // oh well....
- inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
- rgba = inst._rgba = parsed._rgba;
-
- // Exit each( stringParsers ) here because we matched
- return false;
- }
- } );
-
- // Found a stringParser that handled it
- if ( rgba.length ) {
-
- // If this came from a parsed string, force "transparent" when alpha is 0
- // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
- if ( rgba.join() === "0,0,0,0" ) {
- jQuery.extend( rgba, colors.transparent );
- }
- return inst;
- }
-
- // Named colors
- return colors[ string ];
-}
-
-color.fn = jQuery.extend( color.prototype, {
- parse: function( red, green, blue, alpha ) {
- if ( red === undefined ) {
- this._rgba = [ null, null, null, null ];
- return this;
- }
- if ( red.jquery || red.nodeType ) {
- red = jQuery( red ).css( green );
- green = undefined;
- }
-
- var inst = this,
- type = jQuery.type( red ),
- rgba = this._rgba = [];
-
- // More than 1 argument specified - assume ( red, green, blue, alpha )
- if ( green !== undefined ) {
- red = [ red, green, blue, alpha ];
- type = "array";
- }
-
- if ( type === "string" ) {
- return this.parse( stringParse( red ) || colors._default );
- }
-
- if ( type === "array" ) {
- each( spaces.rgba.props, function( key, prop ) {
- rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
- } );
- return this;
- }
-
- if ( type === "object" ) {
- if ( red instanceof color ) {
- each( spaces, function( spaceName, space ) {
- if ( red[ space.cache ] ) {
- inst[ space.cache ] = red[ space.cache ].slice();
- }
- } );
- } else {
- each( spaces, function( spaceName, space ) {
- var cache = space.cache;
- each( space.props, function( key, prop ) {
-
- // If the cache doesn't exist, and we know how to convert
- if ( !inst[ cache ] && space.to ) {
-
- // If the value was null, we don't need to copy it
- // if the key was alpha, we don't need to copy it either
- if ( key === "alpha" || red[ key ] == null ) {
- return;
- }
- inst[ cache ] = space.to( inst._rgba );
- }
-
- // This is the only case where we allow nulls for ALL properties.
- // call clamp with alwaysAllowEmpty
- inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
- } );
-
- // Everything defined but alpha?
- if ( inst[ cache ] &&
- jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
-
- // Use the default of 1
- inst[ cache ][ 3 ] = 1;
- if ( space.from ) {
- inst._rgba = space.from( inst[ cache ] );
- }
- }
- } );
- }
- return this;
- }
- },
- is: function( compare ) {
- var is = color( compare ),
- same = true,
- inst = this;
-
- each( spaces, function( _, space ) {
- var localCache,
- isCache = is[ space.cache ];
- if ( isCache ) {
- localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
- each( space.props, function( _, prop ) {
- if ( isCache[ prop.idx ] != null ) {
- same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
- return same;
- }
- } );
- }
- return same;
- } );
- return same;
- },
- _space: function() {
- var used = [],
- inst = this;
- each( spaces, function( spaceName, space ) {
- if ( inst[ space.cache ] ) {
- used.push( spaceName );
- }
- } );
- return used.pop();
- },
- transition: function( other, distance ) {
- var end = color( other ),
- spaceName = end._space(),
- space = spaces[ spaceName ],
- startColor = this.alpha() === 0 ? color( "transparent" ) : this,
- start = startColor[ space.cache ] || space.to( startColor._rgba ),
- result = start.slice();
-
- end = end[ space.cache ];
- each( space.props, function( key, prop ) {
- var index = prop.idx,
- startValue = start[ index ],
- endValue = end[ index ],
- type = propTypes[ prop.type ] || {};
-
- // If null, don't override start value
- if ( endValue === null ) {
- return;
- }
-
- // If null - use end
- if ( startValue === null ) {
- result[ index ] = endValue;
- } else {
- if ( type.mod ) {
- if ( endValue - startValue > type.mod / 2 ) {
- startValue += type.mod;
- } else if ( startValue - endValue > type.mod / 2 ) {
- startValue -= type.mod;
- }
- }
- result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
- }
- } );
- return this[ spaceName ]( result );
- },
- blend: function( opaque ) {
-
- // If we are already opaque - return ourself
- if ( this._rgba[ 3 ] === 1 ) {
- return this;
- }
-
- var rgb = this._rgba.slice(),
- a = rgb.pop(),
- blend = color( opaque )._rgba;
-
- return color( jQuery.map( rgb, function( v, i ) {
- return ( 1 - a ) * blend[ i ] + a * v;
- } ) );
- },
- toRgbaString: function() {
- var prefix = "rgba(",
- rgba = jQuery.map( this._rgba, function( v, i ) {
- return v == null ? ( i > 2 ? 1 : 0 ) : v;
- } );
-
- if ( rgba[ 3 ] === 1 ) {
- rgba.pop();
- prefix = "rgb(";
- }
-
- return prefix + rgba.join() + ")";
- },
- toHslaString: function() {
- var prefix = "hsla(",
- hsla = jQuery.map( this.hsla(), function( v, i ) {
- if ( v == null ) {
- v = i > 2 ? 1 : 0;
- }
-
- // Catch 1 and 2
- if ( i && i < 3 ) {
- v = Math.round( v * 100 ) + "%";
- }
- return v;
- } );
-
- if ( hsla[ 3 ] === 1 ) {
- hsla.pop();
- prefix = "hsl(";
- }
- return prefix + hsla.join() + ")";
- },
- toHexString: function( includeAlpha ) {
- var rgba = this._rgba.slice(),
- alpha = rgba.pop();
-
- if ( includeAlpha ) {
- rgba.push( ~~( alpha * 255 ) );
- }
-
- return "#" + jQuery.map( rgba, function( v ) {
-
- // Default to 0 when nulls exist
- v = ( v || 0 ).toString( 16 );
- return v.length === 1 ? "0" + v : v;
- } ).join( "" );
- },
- toString: function() {
- return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
- }
-} );
-color.fn.parse.prototype = color.fn;
-
-// Hsla conversions adapted from:
-// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
-
-function hue2rgb( p, q, h ) {
- h = ( h + 1 ) % 1;
- if ( h * 6 < 1 ) {
- return p + ( q - p ) * h * 6;
- }
- if ( h * 2 < 1 ) {
- return q;
- }
- if ( h * 3 < 2 ) {
- return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
- }
- return p;
-}
-
-spaces.hsla.to = function( rgba ) {
- if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
- return [ null, null, null, rgba[ 3 ] ];
- }
- var r = rgba[ 0 ] / 255,
- g = rgba[ 1 ] / 255,
- b = rgba[ 2 ] / 255,
- a = rgba[ 3 ],
- max = Math.max( r, g, b ),
- min = Math.min( r, g, b ),
- diff = max - min,
- add = max + min,
- l = add * 0.5,
- h, s;
-
- if ( min === max ) {
- h = 0;
- } else if ( r === max ) {
- h = ( 60 * ( g - b ) / diff ) + 360;
- } else if ( g === max ) {
- h = ( 60 * ( b - r ) / diff ) + 120;
- } else {
- h = ( 60 * ( r - g ) / diff ) + 240;
- }
-
- // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
- // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
- if ( diff === 0 ) {
- s = 0;
- } else if ( l <= 0.5 ) {
- s = diff / add;
- } else {
- s = diff / ( 2 - add );
- }
- return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
-};
-
-spaces.hsla.from = function( hsla ) {
- if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
- return [ null, null, null, hsla[ 3 ] ];
- }
- var h = hsla[ 0 ] / 360,
- s = hsla[ 1 ],
- l = hsla[ 2 ],
- a = hsla[ 3 ],
- q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
- p = 2 * l - q;
-
- return [
- Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
- Math.round( hue2rgb( p, q, h ) * 255 ),
- Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
- a
- ];
-};
-
-each( spaces, function( spaceName, space ) {
- var props = space.props,
- cache = space.cache,
- to = space.to,
- from = space.from;
-
- // Makes rgba() and hsla()
- color.fn[ spaceName ] = function( value ) {
-
- // Generate a cache for this space if it doesn't exist
- if ( to && !this[ cache ] ) {
- this[ cache ] = to( this._rgba );
- }
- if ( value === undefined ) {
- return this[ cache ].slice();
- }
-
- var ret,
- type = jQuery.type( value ),
- arr = ( type === "array" || type === "object" ) ? value : arguments,
- local = this[ cache ].slice();
-
- each( props, function( key, prop ) {
- var val = arr[ type === "object" ? key : prop.idx ];
- if ( val == null ) {
- val = local[ prop.idx ];
- }
- local[ prop.idx ] = clamp( val, prop );
- } );
-
- if ( from ) {
- ret = color( from( local ) );
- ret[ cache ] = local;
- return ret;
- } else {
- return color( local );
- }
- };
-
- // Makes red() green() blue() alpha() hue() saturation() lightness()
- each( props, function( key, prop ) {
-
- // Alpha is included in more than one space
- if ( color.fn[ key ] ) {
- return;
- }
- color.fn[ key ] = function( value ) {
- var vtype = jQuery.type( value ),
- fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
- local = this[ fn ](),
- cur = local[ prop.idx ],
- match;
-
- if ( vtype === "undefined" ) {
- return cur;
- }
-
- if ( vtype === "function" ) {
- value = value.call( this, cur );
- vtype = jQuery.type( value );
- }
- if ( value == null && prop.empty ) {
- return this;
- }
- if ( vtype === "string" ) {
- match = rplusequals.exec( value );
- if ( match ) {
- value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
- }
- }
- local[ prop.idx ] = value;
- return this[ fn ]( local );
- };
- } );
-} );
-
-// Add cssHook and .fx.step function for each named hook.
-// accept a space separated string of properties
-color.hook = function( hook ) {
- var hooks = hook.split( " " );
- each( hooks, function( i, hook ) {
- jQuery.cssHooks[ hook ] = {
- set: function( elem, value ) {
- var parsed, curElem,
- backgroundColor = "";
-
- if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
- ( parsed = stringParse( value ) ) ) ) {
- value = color( parsed || value );
- if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
- curElem = hook === "backgroundColor" ? elem.parentNode : elem;
- while (
- ( backgroundColor === "" || backgroundColor === "transparent" ) &&
- curElem && curElem.style
- ) {
- try {
- backgroundColor = jQuery.css( curElem, "backgroundColor" );
- curElem = curElem.parentNode;
- } catch ( e ) {
- }
- }
-
- value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
- backgroundColor :
- "_default" );
- }
-
- value = value.toRgbaString();
- }
- try {
- elem.style[ hook ] = value;
- } catch ( e ) {
-
- // Wrapped to prevent IE from throwing errors on "invalid" values like
- // 'auto' or 'inherit'
- }
- }
- };
- jQuery.fx.step[ hook ] = function( fx ) {
- if ( !fx.colorInit ) {
- fx.start = color( fx.elem, hook );
- fx.end = color( fx.end );
- fx.colorInit = true;
- }
- jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
- };
- } );
-
-};
-
-color.hook( stepHooks );
-
-jQuery.cssHooks.borderColor = {
- expand: function( value ) {
- var expanded = {};
-
- each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
- expanded[ "border" + part + "Color" ] = value;
- } );
- return expanded;
- }
-};
-
-// Basic color names only.
-// Usage of any of the other color names requires adding yourself or including
-// jquery.color.svg-names.js.
-colors = jQuery.Color.names = {
-
- // 4.1. Basic color keywords
- aqua: "#00ffff",
- black: "#000000",
- blue: "#0000ff",
- fuchsia: "#ff00ff",
- gray: "#808080",
- green: "#008000",
- lime: "#00ff00",
- maroon: "#800000",
- navy: "#000080",
- olive: "#808000",
- purple: "#800080",
- red: "#ff0000",
- silver: "#c0c0c0",
- teal: "#008080",
- white: "#ffffff",
- yellow: "#ffff00",
-
- // 4.2.3. "transparent" color keyword
- transparent: [ null, null, null, 0 ],
-
- _default: "#ffffff"
-};
-
-} )( jQuery );
-
-/******************************************************************************/
-/****************************** CLASS ANIMATIONS ******************************/
-/******************************************************************************/
-( function() {
-
-var classAnimationActions = [ "add", "remove", "toggle" ],
- shorthandStyles = {
- border: 1,
- borderBottom: 1,
- borderColor: 1,
- borderLeft: 1,
- borderRight: 1,
- borderTop: 1,
- borderWidth: 1,
- margin: 1,
- padding: 1
- };
-
-$.each(
- [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
- function( _, prop ) {
- $.fx.step[ prop ] = function( fx ) {
- if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
- jQuery.style( fx.elem, prop, fx.end );
- fx.setAttr = true;
- }
- };
- }
-);
-
-function getElementStyles( elem ) {
- var key, len,
- style = elem.ownerDocument.defaultView ?
- elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
- elem.currentStyle,
- styles = {};
-
- if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
- len = style.length;
- while ( len-- ) {
- key = style[ len ];
- if ( typeof style[ key ] === "string" ) {
- styles[ $.camelCase( key ) ] = style[ key ];
- }
- }
-
- // Support: Opera, IE <9
- } else {
- for ( key in style ) {
- if ( typeof style[ key ] === "string" ) {
- styles[ key ] = style[ key ];
- }
- }
- }
-
- return styles;
-}
-
-function styleDifference( oldStyle, newStyle ) {
- var diff = {},
- name, value;
-
- for ( name in newStyle ) {
- value = newStyle[ name ];
- if ( oldStyle[ name ] !== value ) {
- if ( !shorthandStyles[ name ] ) {
- if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
- diff[ name ] = value;
- }
- }
- }
- }
-
- return diff;
-}
-
-// Support: jQuery <1.8
-if ( !$.fn.addBack ) {
- $.fn.addBack = function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter( selector )
- );
- };
-}
-
-$.effects.animateClass = function( value, duration, easing, callback ) {
- var o = $.speed( duration, easing, callback );
-
- return this.queue( function() {
- var animated = $( this ),
- baseClass = animated.attr( "class" ) || "",
- applyClassChange,
- allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
-
- // Map the animated objects to store the original styles.
- allAnimations = allAnimations.map( function() {
- var el = $( this );
- return {
- el: el,
- start: getElementStyles( this )
- };
- } );
-
- // Apply class change
- applyClassChange = function() {
- $.each( classAnimationActions, function( i, action ) {
- if ( value[ action ] ) {
- animated[ action + "Class" ]( value[ action ] );
- }
- } );
- };
- applyClassChange();
-
- // Map all animated objects again - calculate new styles and diff
- allAnimations = allAnimations.map( function() {
- this.end = getElementStyles( this.el[ 0 ] );
- this.diff = styleDifference( this.start, this.end );
- return this;
- } );
-
- // Apply original class
- animated.attr( "class", baseClass );
-
- // Map all animated objects again - this time collecting a promise
- allAnimations = allAnimations.map( function() {
- var styleInfo = this,
- dfd = $.Deferred(),
- opts = $.extend( {}, o, {
- queue: false,
- complete: function() {
- dfd.resolve( styleInfo );
- }
- } );
-
- this.el.animate( this.diff, opts );
- return dfd.promise();
- } );
-
- // Once all animations have completed:
- $.when.apply( $, allAnimations.get() ).done( function() {
-
- // Set the final class
- applyClassChange();
-
- // For each animated element,
- // clear all css properties that were animated
- $.each( arguments, function() {
- var el = this.el;
- $.each( this.diff, function( key ) {
- el.css( key, "" );
- } );
- } );
-
- // This is guarnteed to be there if you use jQuery.speed()
- // it also handles dequeuing the next anim...
- o.complete.call( animated[ 0 ] );
- } );
- } );
-};
-
-$.fn.extend( {
- addClass: ( function( orig ) {
- return function( classNames, speed, easing, callback ) {
- return speed ?
- $.effects.animateClass.call( this,
- { add: classNames }, speed, easing, callback ) :
- orig.apply( this, arguments );
- };
- } )( $.fn.addClass ),
-
- removeClass: ( function( orig ) {
- return function( classNames, speed, easing, callback ) {
- return arguments.length > 1 ?
- $.effects.animateClass.call( this,
- { remove: classNames }, speed, easing, callback ) :
- orig.apply( this, arguments );
- };
- } )( $.fn.removeClass ),
-
- toggleClass: ( function( orig ) {
- return function( classNames, force, speed, easing, callback ) {
- if ( typeof force === "boolean" || force === undefined ) {
- if ( !speed ) {
-
- // Without speed parameter
- return orig.apply( this, arguments );
- } else {
- return $.effects.animateClass.call( this,
- ( force ? { add: classNames } : { remove: classNames } ),
- speed, easing, callback );
- }
- } else {
-
- // Without force parameter
- return $.effects.animateClass.call( this,
- { toggle: classNames }, force, speed, easing );
- }
- };
- } )( $.fn.toggleClass ),
-
- switchClass: function( remove, add, speed, easing, callback ) {
- return $.effects.animateClass.call( this, {
- add: add,
- remove: remove
- }, speed, easing, callback );
- }
-} );
-
-} )();
-
-/******************************************************************************/
-/*********************************** EFFECTS **********************************/
-/******************************************************************************/
-
-( function() {
-
-if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
- $.expr.filters.animated = ( function( orig ) {
- return function( elem ) {
- return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
- };
- } )( $.expr.filters.animated );
-}
-
-if ( $.uiBackCompat !== false ) {
- $.extend( $.effects, {
-
- // Saves a set of properties in a data storage
- save: function( element, set ) {
- var i = 0, length = set.length;
- for ( ; i < length; i++ ) {
- if ( set[ i ] !== null ) {
- element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
- }
- }
- },
-
- // Restores a set of previously saved properties from a data storage
- restore: function( element, set ) {
- var val, i = 0, length = set.length;
- for ( ; i < length; i++ ) {
- if ( set[ i ] !== null ) {
- val = element.data( dataSpace + set[ i ] );
- element.css( set[ i ], val );
- }
- }
- },
-
- setMode: function( el, mode ) {
- if ( mode === "toggle" ) {
- mode = el.is( ":hidden" ) ? "show" : "hide";
- }
- return mode;
- },
-
- // Wraps the element around a wrapper that copies position properties
- createWrapper: function( element ) {
-
- // If the element is already wrapped, return it
- if ( element.parent().is( ".ui-effects-wrapper" ) ) {
- return element.parent();
- }
-
- // Wrap the element
- var props = {
- width: element.outerWidth( true ),
- height: element.outerHeight( true ),
- "float": element.css( "float" )
- },
- wrapper = $( "<div></div>" )
- .addClass( "ui-effects-wrapper" )
- .css( {
- fontSize: "100%",
- background: "transparent",
- border: "none",
- margin: 0,
- padding: 0
- } ),
-
- // Store the size in case width/height are defined in % - Fixes #5245
- size = {
- width: element.width(),
- height: element.height()
- },
- active = document.activeElement;
-
- // Support: Firefox
- // Firefox incorrectly exposes anonymous content
- // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
- try {
- active.id;
- } catch ( e ) {
- active = document.body;
- }
-
- element.wrap( wrapper );
-
- // Fixes #7595 - Elements lose focus when wrapped.
- if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
- $( active ).trigger( "focus" );
- }
-
- // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
- // lose the reference to the wrapped element
- wrapper = element.parent();
-
- // Transfer positioning properties to the wrapper
- if ( element.css( "position" ) === "static" ) {
- wrapper.css( { position: "relative" } );
- element.css( { position: "relative" } );
- } else {
- $.extend( props, {
- position: element.css( "position" ),
- zIndex: element.css( "z-index" )
- } );
- $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
- props[ pos ] = element.css( pos );
- if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
- props[ pos ] = "auto";
- }
- } );
- element.css( {
- position: "relative",
- top: 0,
- left: 0,
- right: "auto",
- bottom: "auto"
- } );
- }
- element.css( size );
-
- return wrapper.css( props ).show();
- },
-
- removeWrapper: function( element ) {
- var active = document.activeElement;
-
- if ( element.parent().is( ".ui-effects-wrapper" ) ) {
- element.parent().replaceWith( element );
-
- // Fixes #7595 - Elements lose focus when wrapped.
- if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
- $( active ).trigger( "focus" );
- }
- }
-
- return element;
- }
- } );
-}
-
-$.extend( $.effects, {
- version: "1.12.1",
-
- define: function( name, mode, effect ) {
- if ( !effect ) {
- effect = mode;
- mode = "effect";
- }
-
- $.effects.effect[ name ] = effect;
- $.effects.effect[ name ].mode = mode;
-
- return effect;
- },
-
- scaledDimensions: function( element, percent, direction ) {
- if ( percent === 0 ) {
- return {
- height: 0,
- width: 0,
- outerHeight: 0,
- outerWidth: 0
- };
- }
-
- var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
- y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
-
- return {
- height: element.height() * y,
- width: element.width() * x,
- outerHeight: element.outerHeight() * y,
- outerWidth: element.outerWidth() * x
- };
-
- },
-
- clipToBox: function( animation ) {
- return {
- width: animation.clip.right - animation.clip.left,
- height: animation.clip.bottom - animation.clip.top,
- left: animation.clip.left,
- top: animation.clip.top
- };
- },
-
- // Injects recently queued functions to be first in line (after "inprogress")
- unshift: function( element, queueLength, count ) {
- var queue = element.queue();
-
- if ( queueLength > 1 ) {
- queue.splice.apply( queue,
- [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
- }
- element.dequeue();
- },
-
- saveStyle: function( element ) {
- element.data( dataSpaceStyle, element[ 0 ].style.cssText );
- },
-
- restoreStyle: function( element ) {
- element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
- element.removeData( dataSpaceStyle );
- },
-
- mode: function( element, mode ) {
- var hidden = element.is( ":hidden" );
-
- if ( mode === "toggle" ) {
- mode = hidden ? "show" : "hide";
- }
- if ( hidden ? mode === "hide" : mode === "show" ) {
- mode = "none";
- }
- return mode;
- },
-
- // Translates a [top,left] array into a baseline value
- getBaseline: function( origin, original ) {
- var y, x;
-
- switch ( origin[ 0 ] ) {
- case "top":
- y = 0;
- break;
- case "middle":
- y = 0.5;
- break;
- case "bottom":
- y = 1;
- break;
- default:
- y = origin[ 0 ] / original.height;
- }
-
- switch ( origin[ 1 ] ) {
- case "left":
- x = 0;
- break;
- case "center":
- x = 0.5;
- break;
- case "right":
- x = 1;
- break;
- default:
- x = origin[ 1 ] / original.width;
- }
-
- return {
- x: x,
- y: y
- };
- },
-
- // Creates a placeholder element so that the original element can be made absolute
- createPlaceholder: function( element ) {
- var placeholder,
- cssPosition = element.css( "position" ),
- position = element.position();
-
- // Lock in margins first to account for form elements, which
- // will change margin if you explicitly set height
- // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
- // Support: Safari
- element.css( {
- marginTop: element.css( "marginTop" ),
- marginBottom: element.css( "marginBottom" ),
- marginLeft: element.css( "marginLeft" ),
- marginRight: element.css( "marginRight" )
- } )
- .outerWidth( element.outerWidth() )
- .outerHeight( element.outerHeight() );
-
- if ( /^(static|relative)/.test( cssPosition ) ) {
- cssPosition = "absolute";
-
- placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
-
- // Convert inline to inline block to account for inline elements
- // that turn to inline block based on content (like img)
- display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
- "inline-block" :
- "block",
- visibility: "hidden",
-
- // Margins need to be set to account for margin collapse
- marginTop: element.css( "marginTop" ),
- marginBottom: element.css( "marginBottom" ),
- marginLeft: element.css( "marginLeft" ),
- marginRight: element.css( "marginRight" ),
- "float": element.css( "float" )
- } )
- .outerWidth( element.outerWidth() )
- .outerHeight( element.outerHeight() )
- .addClass( "ui-effects-placeholder" );
-
- element.data( dataSpace + "placeholder", placeholder );
- }
-
- element.css( {
- position: cssPosition,
- left: position.left,
- top: position.top
- } );
-
- return placeholder;
- },
-
- removePlaceholder: function( element ) {
- var dataKey = dataSpace + "placeholder",
- placeholder = element.data( dataKey );
-
- if ( placeholder ) {
- placeholder.remove();
- element.removeData( dataKey );
- }
- },
-
- // Removes a placeholder if it exists and restores
- // properties that were modified during placeholder creation
- cleanUp: function( element ) {
- $.effects.restoreStyle( element );
- $.effects.removePlaceholder( element );
- },
-
- setTransition: function( element, list, factor, value ) {
- value = value || {};
- $.each( list, function( i, x ) {
- var unit = element.cssUnit( x );
- if ( unit[ 0 ] > 0 ) {
- value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
- }
- } );
- return value;
- }
-} );
-
-// Return an effect options object for the given parameters:
-function _normalizeArguments( effect, options, speed, callback ) {
-
- // Allow passing all options as the first parameter
- if ( $.isPlainObject( effect ) ) {
- options = effect;
- effect = effect.effect;
- }
-
- // Convert to an object
- effect = { effect: effect };
-
- // Catch (effect, null, ...)
- if ( options == null ) {
- options = {};
- }
-
- // Catch (effect, callback)
- if ( $.isFunction( options ) ) {
- callback = options;
- speed = null;
- options = {};
- }
-
- // Catch (effect, speed, ?)
- if ( typeof options === "number" || $.fx.speeds[ options ] ) {
- callback = speed;
- speed = options;
- options = {};
- }
-
- // Catch (effect, options, callback)
- if ( $.isFunction( speed ) ) {
- callback = speed;
- speed = null;
- }
-
- // Add options to effect
- if ( options ) {
- $.extend( effect, options );
- }
-
- speed = speed || options.duration;
- effect.duration = $.fx.off ? 0 :
- typeof speed === "number" ? speed :
- speed in $.fx.speeds ? $.fx.speeds[ speed ] :
- $.fx.speeds._default;
-
- effect.complete = callback || options.complete;
-
- return effect;
-}
-
-function standardAnimationOption( option ) {
-
- // Valid standard speeds (nothing, number, named speed)
- if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
- return true;
- }
-
- // Invalid strings - treat as "normal" speed
- if ( typeof option === "string" && !$.effects.effect[ option ] ) {
- return true;
- }
-
- // Complete callback
- if ( $.isFunction( option ) ) {
- return true;
- }
-
- // Options hash (but not naming an effect)
- if ( typeof option === "object" && !option.effect ) {
- return true;
- }
-
- // Didn't match any standard API
- return false;
-}
-
-$.fn.extend( {
- effect: function( /* effect, options, speed, callback */ ) {
- var args = _normalizeArguments.apply( this, arguments ),
- effectMethod = $.effects.effect[ args.effect ],
- defaultMode = effectMethod.mode,
- queue = args.queue,
- queueName = queue || "fx",
- complete = args.complete,
- mode = args.mode,
- modes = [],
- prefilter = function( next ) {
- var el = $( this ),
- normalizedMode = $.effects.mode( el, mode ) || defaultMode;
-
- // Sentinel for duck-punching the :animated psuedo-selector
- el.data( dataSpaceAnimated, true );
-
- // Save effect mode for later use,
- // we can't just call $.effects.mode again later,
- // as the .show() below destroys the initial state
- modes.push( normalizedMode );
-
- // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
- if ( defaultMode && ( normalizedMode === "show" ||
- ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
- el.show();
- }
-
- if ( !defaultMode || normalizedMode !== "none" ) {
- $.effects.saveStyle( el );
- }
-
- if ( $.isFunction( next ) ) {
- next();
- }
- };
-
- if ( $.fx.off || !effectMethod ) {
-
- // Delegate to the original method (e.g., .show()) if possible
- if ( mode ) {
- return this[ mode ]( args.duration, complete );
- } else {
- return this.each( function() {
- if ( complete ) {
- complete.call( this );
- }
- } );
- }
- }
-
- function run( next ) {
- var elem = $( this );
-
- function cleanup() {
- elem.removeData( dataSpaceAnimated );
-
- $.effects.cleanUp( elem );
-
- if ( args.mode === "hide" ) {
- elem.hide();
- }
-
- done();
- }
-
- function done() {
- if ( $.isFunction( complete ) ) {
- complete.call( elem[ 0 ] );
- }
-
- if ( $.isFunction( next ) ) {
- next();
- }
- }
-
- // Override mode option on a per element basis,
- // as toggle can be either show or hide depending on element state
- args.mode = modes.shift();
-
- if ( $.uiBackCompat !== false && !defaultMode ) {
- if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
-
- // Call the core method to track "olddisplay" properly
- elem[ mode ]();
- done();
- } else {
- effectMethod.call( elem[ 0 ], args, done );
- }
- } else {
- if ( args.mode === "none" ) {
-
- // Call the core method to track "olddisplay" properly
- elem[ mode ]();
- done();
- } else {
- effectMethod.call( elem[ 0 ], args, cleanup );
- }
- }
- }
-
- // Run prefilter on all elements first to ensure that
- // any showing or hiding happens before placeholder creation,
- // which ensures that any layout changes are correctly captured.
- return queue === false ?
- this.each( prefilter ).each( run ) :
- this.queue( queueName, prefilter ).queue( queueName, run );
- },
-
- show: ( function( orig ) {
- return function( option ) {
- if ( standardAnimationOption( option ) ) {
- return orig.apply( this, arguments );
- } else {
- var args = _normalizeArguments.apply( this, arguments );
- args.mode = "show";
- return this.effect.call( this, args );
- }
- };
- } )( $.fn.show ),
-
- hide: ( function( orig ) {
- return function( option ) {
- if ( standardAnimationOption( option ) ) {
- return orig.apply( this, arguments );
- } else {
- var args = _normalizeArguments.apply( this, arguments );
- args.mode = "hide";
- return this.effect.call( this, args );
- }
- };
- } )( $.fn.hide ),
-
- toggle: ( function( orig ) {
- return function( option ) {
- if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
- return orig.apply( this, arguments );
- } else {
- var args = _normalizeArguments.apply( this, arguments );
- args.mode = "toggle";
- return this.effect.call( this, args );
- }
- };
- } )( $.fn.toggle ),
-
- cssUnit: function( key ) {
- var style = this.css( key ),
- val = [];
-
- $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
- if ( style.indexOf( unit ) > 0 ) {
- val = [ parseFloat( style ), unit ];
- }
- } );
- return val;
- },
-
- cssClip: function( clipObj ) {
- if ( clipObj ) {
- return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
- clipObj.bottom + "px " + clipObj.left + "px)" );
- }
- return parseClip( this.css( "clip" ), this );
- },
-
- transfer: function( options, done ) {
- var element = $( this ),
- target = $( options.to ),
- targetFixed = target.css( "position" ) === "fixed",
- body = $( "body" ),
- fixTop = targetFixed ? body.scrollTop() : 0,
- fixLeft = targetFixed ? body.scrollLeft() : 0,
- endPosition = target.offset(),
- animation = {
- top: endPosition.top - fixTop,
- left: endPosition.left - fixLeft,
- height: target.innerHeight(),
- width: target.innerWidth()
- },
- startPosition = element.offset(),
- transfer = $( "<div class='ui-effects-transfer'></div>" )
- .appendTo( "body" )
- .addClass( options.className )
- .css( {
- top: startPosition.top - fixTop,
- left: startPosition.left - fixLeft,
- height: element.innerHeight(),
- width: element.innerWidth(),
- position: targetFixed ? "fixed" : "absolute"
- } )
- .animate( animation, options.duration, options.easing, function() {
- transfer.remove();
- if ( $.isFunction( done ) ) {
- done();
- }
- } );
- }
-} );
-
-function parseClip( str, element ) {
- var outerWidth = element.outerWidth(),
- outerHeight = element.outerHeight(),
- clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
- values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
-
- return {
- top: parseFloat( values[ 1 ] ) || 0,
- right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
- bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
- left: parseFloat( values[ 4 ] ) || 0
- };
-}
-
-$.fx.step.clip = function( fx ) {
- if ( !fx.clipInit ) {
- fx.start = $( fx.elem ).cssClip();
- if ( typeof fx.end === "string" ) {
- fx.end = parseClip( fx.end, fx.elem );
- }
- fx.clipInit = true;
- }
-
- $( fx.elem ).cssClip( {
- top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
- right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
- bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
- left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
- } );
-};
-
-} )();
-
-/******************************************************************************/
-/*********************************** EASING ***********************************/
-/******************************************************************************/
-
-( function() {
-
-// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
-
-var baseEasings = {};
-
-$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
- baseEasings[ name ] = function( p ) {
- return Math.pow( p, i + 2 );
- };
-} );
-
-$.extend( baseEasings, {
- Sine: function( p ) {
- return 1 - Math.cos( p * Math.PI / 2 );
- },
- Circ: function( p ) {
- return 1 - Math.sqrt( 1 - p * p );
- },
- Elastic: function( p ) {
- return p === 0 || p === 1 ? p :
- -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
- },
- Back: function( p ) {
- return p * p * ( 3 * p - 2 );
- },
- Bounce: function( p ) {
- var pow2,
- bounce = 4;
-
- while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
- return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
- }
-} );
-
-$.each( baseEasings, function( name, easeIn ) {
- $.easing[ "easeIn" + name ] = easeIn;
- $.easing[ "easeOut" + name ] = function( p ) {
- return 1 - easeIn( 1 - p );
- };
- $.easing[ "easeInOut" + name ] = function( p ) {
- return p < 0.5 ?
- easeIn( p * 2 ) / 2 :
- 1 - easeIn( p * -2 + 2 ) / 2;
- };
-} );
-
-} )();
-
-var effect = $.effects;
-
-
-/*!
- * jQuery UI Effects Blind 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Blind Effect
-//>>group: Effects
-//>>description: Blinds the element.
-//>>docs: http://api.jqueryui.com/blind-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
- var map = {
- up: [ "bottom", "top" ],
- vertical: [ "bottom", "top" ],
- down: [ "top", "bottom" ],
- left: [ "right", "left" ],
- horizontal: [ "right", "left" ],
- right: [ "left", "right" ]
- },
- element = $( this ),
- direction = options.direction || "up",
- start = element.cssClip(),
- animate = { clip: $.extend( {}, start ) },
- placeholder = $.effects.createPlaceholder( element );
-
- animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
-
- if ( options.mode === "show" ) {
- element.cssClip( animate.clip );
- if ( placeholder ) {
- placeholder.css( $.effects.clipToBox( animate ) );
- }
-
- animate.clip = start;
- }
-
- if ( placeholder ) {
- placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
- }
-
- element.animate( animate, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-} );
-
-
-/*!
- * jQuery UI Effects Bounce 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Bounce Effect
-//>>group: Effects
-//>>description: Bounces an element horizontally or vertically n times.
-//>>docs: http://api.jqueryui.com/bounce-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
- var upAnim, downAnim, refValue,
- element = $( this ),
-
- // Defaults:
- mode = options.mode,
- hide = mode === "hide",
- show = mode === "show",
- direction = options.direction || "up",
- distance = options.distance,
- times = options.times || 5,
-
- // Number of internal animations
- anims = times * 2 + ( show || hide ? 1 : 0 ),
- speed = options.duration / anims,
- easing = options.easing,
-
- // Utility:
- ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ),
- i = 0,
-
- queuelen = element.queue().length;
-
- $.effects.createPlaceholder( element );
-
- refValue = element.css( ref );
-
- // Default distance for the BIGGEST bounce is the outer Distance / 3
- if ( !distance ) {
- distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
- }
-
- if ( show ) {
- downAnim = { opacity: 1 };
- downAnim[ ref ] = refValue;
-
- // If we are showing, force opacity 0 and set the initial position
- // then do the "first" animation
- element
- .css( "opacity", 0 )
- .css( ref, motion ? -distance * 2 : distance * 2 )
- .animate( downAnim, speed, easing );
- }
-
- // Start at the smallest distance if we are hiding
- if ( hide ) {
- distance = distance / Math.pow( 2, times - 1 );
- }
-
- downAnim = {};
- downAnim[ ref ] = refValue;
-
- // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
- for ( ; i < times; i++ ) {
- upAnim = {};
- upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
-
- element
- .animate( upAnim, speed, easing )
- .animate( downAnim, speed, easing );
-
- distance = hide ? distance * 2 : distance / 2;
- }
-
- // Last Bounce when Hiding
- if ( hide ) {
- upAnim = { opacity: 0 };
- upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
-
- element.animate( upAnim, speed, easing );
- }
-
- element.queue( done );
-
- $.effects.unshift( element, queuelen, anims + 1 );
-} );
-
-
-/*!
- * jQuery UI Effects Clip 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Clip Effect
-//>>group: Effects
-//>>description: Clips the element on and off like an old TV.
-//>>docs: http://api.jqueryui.com/clip-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
- var start,
- animate = {},
- element = $( this ),
- direction = options.direction || "vertical",
- both = direction === "both",
- horizontal = both || direction === "horizontal",
- vertical = both || direction === "vertical";
-
- start = element.cssClip();
- animate.clip = {
- top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
- right: horizontal ? ( start.right - start.left ) / 2 : start.right,
- bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
- left: horizontal ? ( start.right - start.left ) / 2 : start.left
- };
-
- $.effects.createPlaceholder( element );
-
- if ( options.mode === "show" ) {
- element.cssClip( animate.clip );
- animate.clip = start;
- }
-
- element.animate( animate, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-
-} );
-
-
-/*!
- * jQuery UI Effects Drop 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Drop Effect
-//>>group: Effects
-//>>description: Moves an element in one direction and hides it at the same time.
-//>>docs: http://api.jqueryui.com/drop-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
-
- var distance,
- element = $( this ),
- mode = options.mode,
- show = mode === "show",
- direction = options.direction || "left",
- ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
- oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
- animation = {
- opacity: 0
- };
-
- $.effects.createPlaceholder( element );
-
- distance = options.distance ||
- element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
-
- animation[ ref ] = motion + distance;
-
- if ( show ) {
- element.css( animation );
-
- animation[ ref ] = oppositeMotion + distance;
- animation.opacity = 1;
- }
-
- // Animate
- element.animate( animation, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-} );
-
-
-/*!
- * jQuery UI Effects Explode 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Explode Effect
-//>>group: Effects
-// jscs:disable maximumLineLength
-//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
-// jscs:enable maximumLineLength
-//>>docs: http://api.jqueryui.com/explode-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
-
- var i, j, left, top, mx, my,
- rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
- cells = rows,
- element = $( this ),
- mode = options.mode,
- show = mode === "show",
-
- // Show and then visibility:hidden the element before calculating offset
- offset = element.show().css( "visibility", "hidden" ).offset(),
-
- // Width and height of a piece
- width = Math.ceil( element.outerWidth() / cells ),
- height = Math.ceil( element.outerHeight() / rows ),
- pieces = [];
-
- // Children animate complete:
- function childComplete() {
- pieces.push( this );
- if ( pieces.length === rows * cells ) {
- animComplete();
- }
- }
-
- // Clone the element for each row and cell.
- for ( i = 0; i < rows; i++ ) { // ===>
- top = offset.top + i * height;
- my = i - ( rows - 1 ) / 2;
-
- for ( j = 0; j < cells; j++ ) { // |||
- left = offset.left + j * width;
- mx = j - ( cells - 1 ) / 2;
-
- // Create a clone of the now hidden main element that will be absolute positioned
- // within a wrapper div off the -left and -top equal to size of our pieces
- element
- .clone()
- .appendTo( "body" )
- .wrap( "<div></div>" )
- .css( {
- position: "absolute",
- visibility: "visible",
- left: -j * width,
- top: -i * height
- } )
-
- // Select the wrapper - make it overflow: hidden and absolute positioned based on
- // where the original was located +left and +top equal to the size of pieces
- .parent()
- .addClass( "ui-effects-explode" )
- .css( {
- position: "absolute",
- overflow: "hidden",
- width: width,
- height: height,
- left: left + ( show ? mx * width : 0 ),
- top: top + ( show ? my * height : 0 ),
- opacity: show ? 0 : 1
- } )
- .animate( {
- left: left + ( show ? 0 : mx * width ),
- top: top + ( show ? 0 : my * height ),
- opacity: show ? 1 : 0
- }, options.duration || 500, options.easing, childComplete );
- }
- }
-
- function animComplete() {
- element.css( {
- visibility: "visible"
- } );
- $( pieces ).remove();
- done();
- }
-} );
-
-
-/*!
- * jQuery UI Effects Fade 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Fade Effect
-//>>group: Effects
-//>>description: Fades the element.
-//>>docs: http://api.jqueryui.com/fade-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
- var show = options.mode === "show";
-
- $( this )
- .css( "opacity", show ? 0 : 1 )
- .animate( {
- opacity: show ? 1 : 0
- }, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-} );
-
-
-/*!
- * jQuery UI Effects Fold 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Fold Effect
-//>>group: Effects
-//>>description: Folds an element first horizontally and then vertically.
-//>>docs: http://api.jqueryui.com/fold-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
-
- // Create element
- var element = $( this ),
- mode = options.mode,
- show = mode === "show",
- hide = mode === "hide",
- size = options.size || 15,
- percent = /([0-9]+)%/.exec( size ),
- horizFirst = !!options.horizFirst,
- ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
- duration = options.duration / 2,
-
- placeholder = $.effects.createPlaceholder( element ),
-
- start = element.cssClip(),
- animation1 = { clip: $.extend( {}, start ) },
- animation2 = { clip: $.extend( {}, start ) },
-
- distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
-
- queuelen = element.queue().length;
-
- if ( percent ) {
- size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
- }
- animation1.clip[ ref[ 0 ] ] = size;
- animation2.clip[ ref[ 0 ] ] = size;
- animation2.clip[ ref[ 1 ] ] = 0;
-
- if ( show ) {
- element.cssClip( animation2.clip );
- if ( placeholder ) {
- placeholder.css( $.effects.clipToBox( animation2 ) );
- }
-
- animation2.clip = start;
- }
-
- // Animate
- element
- .queue( function( next ) {
- if ( placeholder ) {
- placeholder
- .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
- .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
- }
-
- next();
- } )
- .animate( animation1, duration, options.easing )
- .animate( animation2, duration, options.easing )
- .queue( done );
-
- $.effects.unshift( element, queuelen, 4 );
-} );
-
-
-/*!
- * jQuery UI Effects Highlight 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Highlight Effect
-//>>group: Effects
-//>>description: Highlights the background of an element in a defined color for a custom duration.
-//>>docs: http://api.jqueryui.com/highlight-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
- var element = $( this ),
- animation = {
- backgroundColor: element.css( "backgroundColor" )
- };
-
- if ( options.mode === "hide" ) {
- animation.opacity = 0;
- }
-
- $.effects.saveStyle( element );
-
- element
- .css( {
- backgroundImage: "none",
- backgroundColor: options.color || "#ffff99"
- } )
- .animate( animation, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-} );
-
-
-/*!
- * jQuery UI Effects Size 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Size Effect
-//>>group: Effects
-//>>description: Resize an element to a specified width and height.
-//>>docs: http://api.jqueryui.com/size-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectSize = $.effects.define( "size", function( options, done ) {
-
- // Create element
- var baseline, factor, temp,
- element = $( this ),
-
- // Copy for children
- cProps = [ "fontSize" ],
- vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
- hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
-
- // Set options
- mode = options.mode,
- restore = mode !== "effect",
- scale = options.scale || "both",
- origin = options.origin || [ "middle", "center" ],
- position = element.css( "position" ),
- pos = element.position(),
- original = $.effects.scaledDimensions( element ),
- from = options.from || original,
- to = options.to || $.effects.scaledDimensions( element, 0 );
-
- $.effects.createPlaceholder( element );
-
- if ( mode === "show" ) {
- temp = from;
- from = to;
- to = temp;
- }
-
- // Set scaling factor
- factor = {
- from: {
- y: from.height / original.height,
- x: from.width / original.width
- },
- to: {
- y: to.height / original.height,
- x: to.width / original.width
- }
- };
-
- // Scale the css box
- if ( scale === "box" || scale === "both" ) {
-
- // Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
- from = $.effects.setTransition( element, vProps, factor.from.y, from );
- to = $.effects.setTransition( element, vProps, factor.to.y, to );
- }
-
- // Horizontal props scaling
- if ( factor.from.x !== factor.to.x ) {
- from = $.effects.setTransition( element, hProps, factor.from.x, from );
- to = $.effects.setTransition( element, hProps, factor.to.x, to );
- }
- }
-
- // Scale the content
- if ( scale === "content" || scale === "both" ) {
-
- // Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
- from = $.effects.setTransition( element, cProps, factor.from.y, from );
- to = $.effects.setTransition( element, cProps, factor.to.y, to );
- }
- }
-
- // Adjust the position properties based on the provided origin points
- if ( origin ) {
- baseline = $.effects.getBaseline( origin, original );
- from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
- from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
- to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
- to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
- }
- element.css( from );
-
- // Animate the children if desired
- if ( scale === "content" || scale === "both" ) {
-
- vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
- hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
-
- // Only animate children with width attributes specified
- // TODO: is this right? should we include anything with css width specified as well
- element.find( "*[width]" ).each( function() {
- var child = $( this ),
- childOriginal = $.effects.scaledDimensions( child ),
- childFrom = {
- height: childOriginal.height * factor.from.y,
- width: childOriginal.width * factor.from.x,
- outerHeight: childOriginal.outerHeight * factor.from.y,
- outerWidth: childOriginal.outerWidth * factor.from.x
- },
- childTo = {
- height: childOriginal.height * factor.to.y,
- width: childOriginal.width * factor.to.x,
- outerHeight: childOriginal.height * factor.to.y,
- outerWidth: childOriginal.width * factor.to.x
- };
-
- // Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
- childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
- childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
- }
-
- // Horizontal props scaling
- if ( factor.from.x !== factor.to.x ) {
- childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
- childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
- }
-
- if ( restore ) {
- $.effects.saveStyle( child );
- }
-
- // Animate children
- child.css( childFrom );
- child.animate( childTo, options.duration, options.easing, function() {
-
- // Restore children
- if ( restore ) {
- $.effects.restoreStyle( child );
- }
- } );
- } );
- }
-
- // Animate
- element.animate( to, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: function() {
-
- var offset = element.offset();
-
- if ( to.opacity === 0 ) {
- element.css( "opacity", from.opacity );
- }
-
- if ( !restore ) {
- element
- .css( "position", position === "static" ? "relative" : position )
- .offset( offset );
-
- // Need to save style here so that automatic style restoration
- // doesn't restore to the original styles from before the animation.
- $.effects.saveStyle( element );
- }
-
- done();
- }
- } );
-
-} );
-
-
-/*!
- * jQuery UI Effects Scale 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Scale Effect
-//>>group: Effects
-//>>description: Grows or shrinks an element and its content.
-//>>docs: http://api.jqueryui.com/scale-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
-
- // Create element
- var el = $( this ),
- mode = options.mode,
- percent = parseInt( options.percent, 10 ) ||
- ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
-
- newOptions = $.extend( true, {
- from: $.effects.scaledDimensions( el ),
- to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
- origin: options.origin || [ "middle", "center" ]
- }, options );
-
- // Fade option to support puff
- if ( options.fade ) {
- newOptions.from.opacity = 1;
- newOptions.to.opacity = 0;
- }
-
- $.effects.effect.size.call( this, newOptions, done );
-} );
-
-
-/*!
- * jQuery UI Effects Puff 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Puff Effect
-//>>group: Effects
-//>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
-//>>docs: http://api.jqueryui.com/puff-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
- var newOptions = $.extend( true, {}, options, {
- fade: true,
- percent: parseInt( options.percent, 10 ) || 150
- } );
-
- $.effects.effect.scale.call( this, newOptions, done );
-} );
-
-
-/*!
- * jQuery UI Effects Pulsate 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Pulsate Effect
-//>>group: Effects
-//>>description: Pulsates an element n times by changing the opacity to zero and back.
-//>>docs: http://api.jqueryui.com/pulsate-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
- var element = $( this ),
- mode = options.mode,
- show = mode === "show",
- hide = mode === "hide",
- showhide = show || hide,
-
- // Showing or hiding leaves off the "last" animation
- anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
- duration = options.duration / anims,
- animateTo = 0,
- i = 1,
- queuelen = element.queue().length;
-
- if ( show || !element.is( ":visible" ) ) {
- element.css( "opacity", 0 ).show();
- animateTo = 1;
- }
-
- // Anims - 1 opacity "toggles"
- for ( ; i < anims; i++ ) {
- element.animate( { opacity: animateTo }, duration, options.easing );
- animateTo = 1 - animateTo;
- }
-
- element.animate( { opacity: animateTo }, duration, options.easing );
-
- element.queue( done );
-
- $.effects.unshift( element, queuelen, anims + 1 );
-} );
-
-
-/*!
- * jQuery UI Effects Shake 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Shake Effect
-//>>group: Effects
-//>>description: Shakes an element horizontally or vertically n times.
-//>>docs: http://api.jqueryui.com/shake-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
-
- var i = 1,
- element = $( this ),
- direction = options.direction || "left",
- distance = options.distance || 20,
- times = options.times || 3,
- anims = times * 2 + 1,
- speed = Math.round( options.duration / anims ),
- ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- positiveMotion = ( direction === "up" || direction === "left" ),
- animation = {},
- animation1 = {},
- animation2 = {},
-
- queuelen = element.queue().length;
-
- $.effects.createPlaceholder( element );
-
- // Animation
- animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
- animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
- animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
-
- // Animate
- element.animate( animation, speed, options.easing );
-
- // Shakes
- for ( ; i < times; i++ ) {
- element
- .animate( animation1, speed, options.easing )
- .animate( animation2, speed, options.easing );
- }
-
- element
- .animate( animation1, speed, options.easing )
- .animate( animation, speed / 2, options.easing )
- .queue( done );
-
- $.effects.unshift( element, queuelen, anims + 1 );
-} );
-
-
-/*!
- * jQuery UI Effects Slide 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Slide Effect
-//>>group: Effects
-//>>description: Slides an element in and out of the viewport.
-//>>docs: http://api.jqueryui.com/slide-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
- var startClip, startRef,
- element = $( this ),
- map = {
- up: [ "bottom", "top" ],
- down: [ "top", "bottom" ],
- left: [ "right", "left" ],
- right: [ "left", "right" ]
- },
- mode = options.mode,
- direction = options.direction || "left",
- ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- positiveMotion = ( direction === "up" || direction === "left" ),
- distance = options.distance ||
- element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
- animation = {};
-
- $.effects.createPlaceholder( element );
-
- startClip = element.cssClip();
- startRef = element.position()[ ref ];
-
- // Define hide animation
- animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
- animation.clip = element.cssClip();
- animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
-
- // Reverse the animation if we're showing
- if ( mode === "show" ) {
- element.cssClip( animation.clip );
- element.css( ref, animation[ ref ] );
- animation.clip = startClip;
- animation[ ref ] = startRef;
- }
-
- // Actually animate
- element.animate( animation, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
-} );
-
-
-/*!
- * jQuery UI Effects Transfer 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Transfer Effect
-//>>group: Effects
-//>>description: Displays a transfer effect from one element to another.
-//>>docs: http://api.jqueryui.com/transfer-effect/
-//>>demos: http://jqueryui.com/effect/
-
-
-
-var effect;
-if ( $.uiBackCompat !== false ) {
- effect = $.effects.define( "transfer", function( options, done ) {
- $( this ).transfer( options, done );
- } );
-}
-var effectsEffectTransfer = effect;
-
-
-/*!
- * jQuery UI Focusable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: :focusable Selector
-//>>group: Core
-//>>description: Selects elements which can be focused.
-//>>docs: http://api.jqueryui.com/focusable-selector/
-
-
-
-// Selectors
-$.ui.focusable = function( element, hasTabindex ) {
- var map, mapName, img, focusableIfVisible, fieldset,
- nodeName = element.nodeName.toLowerCase();
-
- if ( "area" === nodeName ) {
- map = element.parentNode;
- mapName = map.name;
- if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
- return false;
- }
- img = $( "img[usemap='#" + mapName + "']" );
- return img.length > 0 && img.is( ":visible" );
- }
-
- if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
- focusableIfVisible = !element.disabled;
-
- if ( focusableIfVisible ) {
-
- // Form controls within a disabled fieldset are disabled.
- // However, controls within the fieldset's legend do not get disabled.
- // Since controls generally aren't placed inside legends, we skip
- // this portion of the check.
- fieldset = $( element ).closest( "fieldset" )[ 0 ];
- if ( fieldset ) {
- focusableIfVisible = !fieldset.disabled;
- }
- }
- } else if ( "a" === nodeName ) {
- focusableIfVisible = element.href || hasTabindex;
- } else {
- focusableIfVisible = hasTabindex;
- }
-
- return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
-};
-
-// Support: IE 8 only
-// IE 8 doesn't resolve inherit to visible/hidden for computed values
-function visible( element ) {
- var visibility = element.css( "visibility" );
- while ( visibility === "inherit" ) {
- element = element.parent();
- visibility = element.css( "visibility" );
- }
- return visibility !== "hidden";
-}
-
-$.extend( $.expr[ ":" ], {
- focusable: function( element ) {
- return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
- }
-} );
-
-var focusable = $.ui.focusable;
-
-
-
-
-// Support: IE8 Only
-// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
-// with a string, so we need to find the proper form.
-var form = $.fn.form = function() {
- return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
-};
-
-
-/*!
- * jQuery UI Form Reset Mixin 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Form Reset Mixin
-//>>group: Core
-//>>description: Refresh input widgets when their form is reset
-//>>docs: http://api.jqueryui.com/form-reset-mixin/
-
-
-
-var formResetMixin = $.ui.formResetMixin = {
- _formResetHandler: function() {
- var form = $( this );
-
- // Wait for the form reset to actually happen before refreshing
- setTimeout( function() {
- var instances = form.data( "ui-form-reset-instances" );
- $.each( instances, function() {
- this.refresh();
- } );
- } );
- },
-
- _bindFormResetHandler: function() {
- this.form = this.element.form();
- if ( !this.form.length ) {
- return;
- }
-
- var instances = this.form.data( "ui-form-reset-instances" ) || [];
- if ( !instances.length ) {
-
- // We don't use _on() here because we use a single event handler per form
- this.form.on( "reset.ui-form-reset", this._formResetHandler );
- }
- instances.push( this );
- this.form.data( "ui-form-reset-instances", instances );
- },
-
- _unbindFormResetHandler: function() {
- if ( !this.form.length ) {
- return;
- }
-
- var instances = this.form.data( "ui-form-reset-instances" );
- instances.splice( $.inArray( this, instances ), 1 );
- if ( instances.length ) {
- this.form.data( "ui-form-reset-instances", instances );
- } else {
- this.form
- .removeData( "ui-form-reset-instances" )
- .off( "reset.ui-form-reset" );
- }
- }
-};
-
-
-/*!
- * jQuery UI Support for jQuery core 1.7.x 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- */
-
-//>>label: jQuery 1.7 Support
-//>>group: Core
-//>>description: Support version 1.7.x of jQuery core
-
-
-
-// Support: jQuery 1.7 only
-// Not a great way to check versions, but since we only support 1.7+ and only
-// need to detect <1.8, this is a simple check that should suffice. Checking
-// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
-// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
-// 1.7 anymore). See #11197 for why we're not using feature detection.
-if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
-
- // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
- // Unlike jQuery Core 1.8+, these only support numeric values to set the
- // dimensions in pixels
- $.each( [ "Width", "Height" ], function( i, name ) {
- var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
- type = name.toLowerCase(),
- orig = {
- innerWidth: $.fn.innerWidth,
- innerHeight: $.fn.innerHeight,
- outerWidth: $.fn.outerWidth,
- outerHeight: $.fn.outerHeight
- };
-
- function reduce( elem, size, border, margin ) {
- $.each( side, function() {
- size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
- if ( border ) {
- size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
- }
- if ( margin ) {
- size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
- }
- } );
- return size;
- }
-
- $.fn[ "inner" + name ] = function( size ) {
- if ( size === undefined ) {
- return orig[ "inner" + name ].call( this );
- }
-
- return this.each( function() {
- $( this ).css( type, reduce( this, size ) + "px" );
- } );
- };
-
- $.fn[ "outer" + name ] = function( size, margin ) {
- if ( typeof size !== "number" ) {
- return orig[ "outer" + name ].call( this, size );
- }
-
- return this.each( function() {
- $( this ).css( type, reduce( this, size, true, margin ) + "px" );
- } );
- };
- } );
-
- $.fn.addBack = function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter( selector )
- );
- };
-}
-
-;
-/*!
- * jQuery UI Keycode 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Keycode
-//>>group: Core
-//>>description: Provide keycodes as keynames
-//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
-
-
-var keycode = $.ui.keyCode = {
- BACKSPACE: 8,
- COMMA: 188,
- DELETE: 46,
- DOWN: 40,
- END: 35,
- ENTER: 13,
- ESCAPE: 27,
- HOME: 36,
- LEFT: 37,
- PAGE_DOWN: 34,
- PAGE_UP: 33,
- PERIOD: 190,
- RIGHT: 39,
- SPACE: 32,
- TAB: 9,
- UP: 38
-};
-
-
-
-
-// Internal use only
-var escapeSelector = $.ui.escapeSelector = ( function() {
- var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
- return function( selector ) {
- return selector.replace( selectorEscape, "\\$1" );
- };
-} )();
-
-
-/*!
- * jQuery UI Labels 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: labels
-//>>group: Core
-//>>description: Find all the labels associated with a given input
-//>>docs: http://api.jqueryui.com/labels/
-
-
-
-var labels = $.fn.labels = function() {
- var ancestor, selector, id, labels, ancestors;
-
- // Check control.labels first
- if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
- return this.pushStack( this[ 0 ].labels );
- }
-
- // Support: IE <= 11, FF <= 37, Android <= 2.3 only
- // Above browsers do not support control.labels. Everything below is to support them
- // as well as document fragments. control.labels does not work on document fragments
- labels = this.eq( 0 ).parents( "label" );
-
- // Look for the label based on the id
- id = this.attr( "id" );
- if ( id ) {
-
- // We don't search against the document in case the element
- // is disconnected from the DOM
- ancestor = this.eq( 0 ).parents().last();
-
- // Get a full set of top level ancestors
- ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
-
- // Create a selector for the label based on the id
- selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
-
- labels = labels.add( ancestors.find( selector ).addBack( selector ) );
-
- }
-
- // Return whatever we have found for labels
- return this.pushStack( labels );
-};
-
-
-/*!
- * jQuery UI Scroll Parent 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: scrollParent
-//>>group: Core
-//>>description: Get the closest ancestor element that is scrollable.
-//>>docs: http://api.jqueryui.com/scrollParent/
-
-
-
-var scrollParent = $.fn.scrollParent = function( includeHidden ) {
- var position = this.css( "position" ),
- excludeStaticParent = position === "absolute",
- overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
- scrollParent = this.parents().filter( function() {
- var parent = $( this );
- if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
- return false;
- }
- return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
- parent.css( "overflow-x" ) );
- } ).eq( 0 );
-
- return position === "fixed" || !scrollParent.length ?
- $( this[ 0 ].ownerDocument || document ) :
- scrollParent;
-};
-
-
-/*!
- * jQuery UI Tabbable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: :tabbable Selector
-//>>group: Core
-//>>description: Selects elements which can be tabbed to.
-//>>docs: http://api.jqueryui.com/tabbable-selector/
-
-
-
-var tabbable = $.extend( $.expr[ ":" ], {
- tabbable: function( element ) {
- var tabIndex = $.attr( element, "tabindex" ),
- hasTabindex = tabIndex != null;
- return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
- }
-} );
-
-
-/*!
- * jQuery UI Unique ID 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: uniqueId
-//>>group: Core
-//>>description: Functions to generate and remove uniqueId's
-//>>docs: http://api.jqueryui.com/uniqueId/
-
-
-
-var uniqueId = $.fn.extend( {
- uniqueId: ( function() {
- var uuid = 0;
-
- return function() {
- return this.each( function() {
- if ( !this.id ) {
- this.id = "ui-id-" + ( ++uuid );
- }
- } );
- };
- } )(),
-
- removeUniqueId: function() {
- return this.each( function() {
- if ( /^ui-id-\d+$/.test( this.id ) ) {
- $( this ).removeAttr( "id" );
- }
- } );
- }
-} );
-
-
-/*!
- * jQuery UI Accordion 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Accordion
-//>>group: Widgets
-// jscs:disable maximumLineLength
-//>>description: Displays collapsible content panels for presenting information in a limited amount of space.
-// jscs:enable maximumLineLength
-//>>docs: http://api.jqueryui.com/accordion/
-//>>demos: http://jqueryui.com/accordion/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/accordion.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-var widgetsAccordion = $.widget( "ui.accordion", {
- version: "1.12.1",
- options: {
- active: 0,
- animate: {},
- classes: {
- "ui-accordion-header": "ui-corner-top",
- "ui-accordion-header-collapsed": "ui-corner-all",
- "ui-accordion-content": "ui-corner-bottom"
- },
- collapsible: false,
- event: "click",
- header: "> li > :first-child, > :not(li):even",
- heightStyle: "auto",
- icons: {
- activeHeader: "ui-icon-triangle-1-s",
- header: "ui-icon-triangle-1-e"
- },
-
- // Callbacks
- activate: null,
- beforeActivate: null
- },
-
- hideProps: {
- borderTopWidth: "hide",
- borderBottomWidth: "hide",
- paddingTop: "hide",
- paddingBottom: "hide",
- height: "hide"
- },
-
- showProps: {
- borderTopWidth: "show",
- borderBottomWidth: "show",
- paddingTop: "show",
- paddingBottom: "show",
- height: "show"
- },
-
- _create: function() {
- var options = this.options;
-
- this.prevShow = this.prevHide = $();
- this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
- this.element.attr( "role", "tablist" );
-
- // Don't allow collapsible: false and active: false / null
- if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
- options.active = 0;
- }
-
- this._processPanels();
-
- // handle negative values
- if ( options.active < 0 ) {
- options.active += this.headers.length;
- }
- this._refresh();
- },
-
- _getCreateEventData: function() {
- return {
- header: this.active,
- panel: !this.active.length ? $() : this.active.next()
- };
- },
-
- _createIcons: function() {
- var icon, children,
- icons = this.options.icons;
-
- if ( icons ) {
- icon = $( "<span>" );
- this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
- icon.prependTo( this.headers );
- children = this.active.children( ".ui-accordion-header-icon" );
- this._removeClass( children, icons.header )
- ._addClass( children, null, icons.activeHeader )
- ._addClass( this.headers, "ui-accordion-icons" );
- }
- },
-
- _destroyIcons: function() {
- this._removeClass( this.headers, "ui-accordion-icons" );
- this.headers.children( ".ui-accordion-header-icon" ).remove();
- },
-
- _destroy: function() {
- var contents;
-
- // Clean up main element
- this.element.removeAttr( "role" );
-
- // Clean up headers
- this.headers
- .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
- .removeUniqueId();
-
- this._destroyIcons();
-
- // Clean up content panels
- contents = this.headers.next()
- .css( "display", "" )
- .removeAttr( "role aria-hidden aria-labelledby" )
- .removeUniqueId();
-
- if ( this.options.heightStyle !== "content" ) {
- contents.css( "height", "" );
- }
- },
-
- _setOption: function( key, value ) {
- if ( key === "active" ) {
-
- // _activate() will handle invalid values and update this.options
- this._activate( value );
- return;
- }
-
- if ( key === "event" ) {
- if ( this.options.event ) {
- this._off( this.headers, this.options.event );
- }
- this._setupEvents( value );
- }
-
- this._super( key, value );
-
- // Setting collapsible: false while collapsed; open first panel
- if ( key === "collapsible" && !value && this.options.active === false ) {
- this._activate( 0 );
- }
-
- if ( key === "icons" ) {
- this._destroyIcons();
- if ( value ) {
- this._createIcons();
- }
- }
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this.element.attr( "aria-disabled", value );
-
- // Support: IE8 Only
- // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
- // so we need to add the disabled class to the headers and panels
- this._toggleClass( null, "ui-state-disabled", !!value );
- this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
- !!value );
- },
-
- _keydown: function( event ) {
- if ( event.altKey || event.ctrlKey ) {
- return;
- }
-
- var keyCode = $.ui.keyCode,
- length = this.headers.length,
- currentIndex = this.headers.index( event.target ),
- toFocus = false;
-
- switch ( event.keyCode ) {
- case keyCode.RIGHT:
- case keyCode.DOWN:
- toFocus = this.headers[ ( currentIndex + 1 ) % length ];
- break;
- case keyCode.LEFT:
- case keyCode.UP:
- toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
- break;
- case keyCode.SPACE:
- case keyCode.ENTER:
- this._eventHandler( event );
- break;
- case keyCode.HOME:
- toFocus = this.headers[ 0 ];
- break;
- case keyCode.END:
- toFocus = this.headers[ length - 1 ];
- break;
- }
-
- if ( toFocus ) {
- $( event.target ).attr( "tabIndex", -1 );
- $( toFocus ).attr( "tabIndex", 0 );
- $( toFocus ).trigger( "focus" );
- event.preventDefault();
- }
- },
-
- _panelKeyDown: function( event ) {
- if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
- $( event.currentTarget ).prev().trigger( "focus" );
- }
- },
-
- refresh: function() {
- var options = this.options;
- this._processPanels();
-
- // Was collapsed or no panel
- if ( ( options.active === false && options.collapsible === true ) ||
- !this.headers.length ) {
- options.active = false;
- this.active = $();
-
- // active false only when collapsible is true
- } else if ( options.active === false ) {
- this._activate( 0 );
-
- // was active, but active panel is gone
- } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
-
- // all remaining panel are disabled
- if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
- options.active = false;
- this.active = $();
-
- // activate previous panel
- } else {
- this._activate( Math.max( 0, options.active - 1 ) );
- }
-
- // was active, active panel still exists
- } else {
-
- // make sure active index is correct
- options.active = this.headers.index( this.active );
- }
-
- this._destroyIcons();
-
- this._refresh();
- },
-
- _processPanels: function() {
- var prevHeaders = this.headers,
- prevPanels = this.panels;
-
- this.headers = this.element.find( this.options.header );
- this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
- "ui-state-default" );
-
- this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
- this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
-
- // Avoid memory leaks (#10056)
- if ( prevPanels ) {
- this._off( prevHeaders.not( this.headers ) );
- this._off( prevPanels.not( this.panels ) );
- }
- },
-
- _refresh: function() {
- var maxHeight,
- options = this.options,
- heightStyle = options.heightStyle,
- parent = this.element.parent();
-
- this.active = this._findActive( options.active );
- this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
- ._removeClass( this.active, "ui-accordion-header-collapsed" );
- this._addClass( this.active.next(), "ui-accordion-content-active" );
- this.active.next().show();
-
- this.headers
- .attr( "role", "tab" )
- .each( function() {
- var header = $( this ),
- headerId = header.uniqueId().attr( "id" ),
- panel = header.next(),
- panelId = panel.uniqueId().attr( "id" );
- header.attr( "aria-controls", panelId );
- panel.attr( "aria-labelledby", headerId );
- } )
- .next()
- .attr( "role", "tabpanel" );
-
- this.headers
- .not( this.active )
- .attr( {
- "aria-selected": "false",
- "aria-expanded": "false",
- tabIndex: -1
- } )
- .next()
- .attr( {
- "aria-hidden": "true"
- } )
- .hide();
-
- // Make sure at least one header is in the tab order
- if ( !this.active.length ) {
- this.headers.eq( 0 ).attr( "tabIndex", 0 );
- } else {
- this.active.attr( {
- "aria-selected": "true",
- "aria-expanded": "true",
- tabIndex: 0
- } )
- .next()
- .attr( {
- "aria-hidden": "false"
- } );
- }
-
- this._createIcons();
-
- this._setupEvents( options.event );
-
- if ( heightStyle === "fill" ) {
- maxHeight = parent.height();
- this.element.siblings( ":visible" ).each( function() {
- var elem = $( this ),
- position = elem.css( "position" );
-
- if ( position === "absolute" || position === "fixed" ) {
- return;
- }
- maxHeight -= elem.outerHeight( true );
- } );
-
- this.headers.each( function() {
- maxHeight -= $( this ).outerHeight( true );
- } );
-
- this.headers.next()
- .each( function() {
- $( this ).height( Math.max( 0, maxHeight -
- $( this ).innerHeight() + $( this ).height() ) );
- } )
- .css( "overflow", "auto" );
- } else if ( heightStyle === "auto" ) {
- maxHeight = 0;
- this.headers.next()
- .each( function() {
- var isVisible = $( this ).is( ":visible" );
- if ( !isVisible ) {
- $( this ).show();
- }
- maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
- if ( !isVisible ) {
- $( this ).hide();
- }
- } )
- .height( maxHeight );
- }
- },
-
- _activate: function( index ) {
- var active = this._findActive( index )[ 0 ];
-
- // Trying to activate the already active panel
- if ( active === this.active[ 0 ] ) {
- return;
- }
-
- // Trying to collapse, simulate a click on the currently active header
- active = active || this.active[ 0 ];
-
- this._eventHandler( {
- target: active,
- currentTarget: active,
- preventDefault: $.noop
- } );
- },
-
- _findActive: function( selector ) {
- return typeof selector === "number" ? this.headers.eq( selector ) : $();
- },
-
- _setupEvents: function( event ) {
- var events = {
- keydown: "_keydown"
- };
- if ( event ) {
- $.each( event.split( " " ), function( index, eventName ) {
- events[ eventName ] = "_eventHandler";
- } );
- }
-
- this._off( this.headers.add( this.headers.next() ) );
- this._on( this.headers, events );
- this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
- this._hoverable( this.headers );
- this._focusable( this.headers );
- },
-
- _eventHandler: function( event ) {
- var activeChildren, clickedChildren,
- options = this.options,
- active = this.active,
- clicked = $( event.currentTarget ),
- clickedIsActive = clicked[ 0 ] === active[ 0 ],
- collapsing = clickedIsActive && options.collapsible,
- toShow = collapsing ? $() : clicked.next(),
- toHide = active.next(),
- eventData = {
- oldHeader: active,
- oldPanel: toHide,
- newHeader: collapsing ? $() : clicked,
- newPanel: toShow
- };
-
- event.preventDefault();
-
- if (
-
- // click on active header, but not collapsible
- ( clickedIsActive && !options.collapsible ) ||
-
- // allow canceling activation
- ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
- return;
- }
-
- options.active = collapsing ? false : this.headers.index( clicked );
-
- // When the call to ._toggle() comes after the class changes
- // it causes a very odd bug in IE 8 (see #6720)
- this.active = clickedIsActive ? $() : clicked;
- this._toggle( eventData );
-
- // Switch classes
- // corner classes on the previously active header stay after the animation
- this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
- if ( options.icons ) {
- activeChildren = active.children( ".ui-accordion-header-icon" );
- this._removeClass( activeChildren, null, options.icons.activeHeader )
- ._addClass( activeChildren, null, options.icons.header );
- }
-
- if ( !clickedIsActive ) {
- this._removeClass( clicked, "ui-accordion-header-collapsed" )
- ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
- if ( options.icons ) {
- clickedChildren = clicked.children( ".ui-accordion-header-icon" );
- this._removeClass( clickedChildren, null, options.icons.header )
- ._addClass( clickedChildren, null, options.icons.activeHeader );
- }
-
- this._addClass( clicked.next(), "ui-accordion-content-active" );
- }
- },
-
- _toggle: function( data ) {
- var toShow = data.newPanel,
- toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
-
- // Handle activating a panel during the animation for another activation
- this.prevShow.add( this.prevHide ).stop( true, true );
- this.prevShow = toShow;
- this.prevHide = toHide;
-
- if ( this.options.animate ) {
- this._animate( toShow, toHide, data );
- } else {
- toHide.hide();
- toShow.show();
- this._toggleComplete( data );
- }
-
- toHide.attr( {
- "aria-hidden": "true"
- } );
- toHide.prev().attr( {
- "aria-selected": "false",
- "aria-expanded": "false"
- } );
-
- // if we're switching panels, remove the old header from the tab order
- // if we're opening from collapsed state, remove the previous header from the tab order
- // if we're collapsing, then keep the collapsing header in the tab order
- if ( toShow.length && toHide.length ) {
- toHide.prev().attr( {
- "tabIndex": -1,
- "aria-expanded": "false"
- } );
- } else if ( toShow.length ) {
- this.headers.filter( function() {
- return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
- } )
- .attr( "tabIndex", -1 );
- }
-
- toShow
- .attr( "aria-hidden", "false" )
- .prev()
- .attr( {
- "aria-selected": "true",
- "aria-expanded": "true",
- tabIndex: 0
- } );
- },
-
- _animate: function( toShow, toHide, data ) {
- var total, easing, duration,
- that = this,
- adjust = 0,
- boxSizing = toShow.css( "box-sizing" ),
- down = toShow.length &&
- ( !toHide.length || ( toShow.index() < toHide.index() ) ),
- animate = this.options.animate || {},
- options = down && animate.down || animate,
- complete = function() {
- that._toggleComplete( data );
- };
-
- if ( typeof options === "number" ) {
- duration = options;
- }
- if ( typeof options === "string" ) {
- easing = options;
- }
-
- // fall back from options to animation in case of partial down settings
- easing = easing || options.easing || animate.easing;
- duration = duration || options.duration || animate.duration;
-
- if ( !toHide.length ) {
- return toShow.animate( this.showProps, duration, easing, complete );
- }
- if ( !toShow.length ) {
- return toHide.animate( this.hideProps, duration, easing, complete );
- }
-
- total = toShow.show().outerHeight();
- toHide.animate( this.hideProps, {
- duration: duration,
- easing: easing,
- step: function( now, fx ) {
- fx.now = Math.round( now );
- }
- } );
- toShow
- .hide()
- .animate( this.showProps, {
- duration: duration,
- easing: easing,
- complete: complete,
- step: function( now, fx ) {
- fx.now = Math.round( now );
- if ( fx.prop !== "height" ) {
- if ( boxSizing === "content-box" ) {
- adjust += fx.now;
- }
- } else if ( that.options.heightStyle !== "content" ) {
- fx.now = Math.round( total - toHide.outerHeight() - adjust );
- adjust = 0;
- }
- }
- } );
- },
-
- _toggleComplete: function( data ) {
- var toHide = data.oldPanel,
- prev = toHide.prev();
-
- this._removeClass( toHide, "ui-accordion-content-active" );
- this._removeClass( prev, "ui-accordion-header-active" )
- ._addClass( prev, "ui-accordion-header-collapsed" );
-
- // Work around for rendering bug in IE (#5421)
- if ( toHide.length ) {
- toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
- }
- this._trigger( "activate", null, data );
- }
-} );
-
-
-
-var safeActiveElement = $.ui.safeActiveElement = function( document ) {
- var activeElement;
-
- // Support: IE 9 only
- // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
- try {
- activeElement = document.activeElement;
- } catch ( error ) {
- activeElement = document.body;
- }
-
- // Support: IE 9 - 11 only
- // IE may return null instead of an element
- // Interestingly, this only seems to occur when NOT in an iframe
- if ( !activeElement ) {
- activeElement = document.body;
- }
-
- // Support: IE 11 only
- // IE11 returns a seemingly empty object in some cases when accessing
- // document.activeElement from an <iframe>
- if ( !activeElement.nodeName ) {
- activeElement = document.body;
- }
-
- return activeElement;
-};
-
-
-/*!
- * jQuery UI Menu 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Menu
-//>>group: Widgets
-//>>description: Creates nestable menus.
-//>>docs: http://api.jqueryui.com/menu/
-//>>demos: http://jqueryui.com/menu/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/menu.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-var widgetsMenu = $.widget( "ui.menu", {
- version: "1.12.1",
- defaultElement: "<ul>",
- delay: 300,
- options: {
- icons: {
- submenu: "ui-icon-caret-1-e"
- },
- items: "> *",
- menus: "ul",
- position: {
- my: "left top",
- at: "right top"
- },
- role: "menu",
-
- // Callbacks
- blur: null,
- focus: null,
- select: null
- },
-
- _create: function() {
- this.activeMenu = this.element;
-
- // Flag used to prevent firing of the click handler
- // as the event bubbles up through nested menus
- this.mouseHandled = false;
- this.element
- .uniqueId()
- .attr( {
- role: this.options.role,
- tabIndex: 0
- } );
-
- this._addClass( "ui-menu", "ui-widget ui-widget-content" );
- this._on( {
-
- // Prevent focus from sticking to links inside menu after clicking
- // them (focus should always stay on UL during navigation).
- "mousedown .ui-menu-item": function( event ) {
- event.preventDefault();
- },
- "click .ui-menu-item": function( event ) {
- var target = $( event.target );
- var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
- if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
- this.select( event );
-
- // Only set the mouseHandled flag if the event will bubble, see #9469.
- if ( !event.isPropagationStopped() ) {
- this.mouseHandled = true;
- }
-
- // Open submenu on click
- if ( target.has( ".ui-menu" ).length ) {
- this.expand( event );
- } else if ( !this.element.is( ":focus" ) &&
- active.closest( ".ui-menu" ).length ) {
-
- // Redirect focus to the menu
- this.element.trigger( "focus", [ true ] );
-
- // If the active item is on the top level, let it stay active.
- // Otherwise, blur the active item since it is no longer visible.
- if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
- clearTimeout( this.timer );
- }
- }
- }
- },
- "mouseenter .ui-menu-item": function( event ) {
-
- // Ignore mouse events while typeahead is active, see #10458.
- // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
- // is over an item in the menu
- if ( this.previousFilter ) {
- return;
- }
-
- var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
- target = $( event.currentTarget );
-
- // Ignore bubbled events on parent items, see #11641
- if ( actualTarget[ 0 ] !== target[ 0 ] ) {
- return;
- }
-
- // Remove ui-state-active class from siblings of the newly focused menu item
- // to avoid a jump caused by adjacent elements both having a class with a border
- this._removeClass( target.siblings().children( ".ui-state-active" ),
- null, "ui-state-active" );
- this.focus( event, target );
- },
- mouseleave: "collapseAll",
- "mouseleave .ui-menu": "collapseAll",
- focus: function( event, keepActiveItem ) {
-
- // If there's already an active item, keep it active
- // If not, activate the first item
- var item = this.active || this.element.find( this.options.items ).eq( 0 );
-
- if ( !keepActiveItem ) {
- this.focus( event, item );
- }
- },
- blur: function( event ) {
- this._delay( function() {
- var notContained = !$.contains(
- this.element[ 0 ],
- $.ui.safeActiveElement( this.document[ 0 ] )
- );
- if ( notContained ) {
- this.collapseAll( event );
- }
- } );
- },
- keydown: "_keydown"
- } );
-
- this.refresh();
-
- // Clicks outside of a menu collapse any open menus
- this._on( this.document, {
- click: function( event ) {
- if ( this._closeOnDocumentClick( event ) ) {
- this.collapseAll( event );
- }
-
- // Reset the mouseHandled flag
- this.mouseHandled = false;
- }
- } );
- },
-
- _destroy: function() {
- var items = this.element.find( ".ui-menu-item" )
- .removeAttr( "role aria-disabled" ),
- submenus = items.children( ".ui-menu-item-wrapper" )
- .removeUniqueId()
- .removeAttr( "tabIndex role aria-haspopup" );
-
- // Destroy (sub)menus
- this.element
- .removeAttr( "aria-activedescendant" )
- .find( ".ui-menu" ).addBack()
- .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
- "tabIndex" )
- .removeUniqueId()
- .show();
-
- submenus.children().each( function() {
- var elem = $( this );
- if ( elem.data( "ui-menu-submenu-caret" ) ) {
- elem.remove();
- }
- } );
- },
-
- _keydown: function( event ) {
- var match, prev, character, skip,
- preventDefault = true;
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.PAGE_UP:
- this.previousPage( event );
- break;
- case $.ui.keyCode.PAGE_DOWN:
- this.nextPage( event );
- break;
- case $.ui.keyCode.HOME:
- this._move( "first", "first", event );
- break;
- case $.ui.keyCode.END:
- this._move( "last", "last", event );
- break;
- case $.ui.keyCode.UP:
- this.previous( event );
- break;
- case $.ui.keyCode.DOWN:
- this.next( event );
- break;
- case $.ui.keyCode.LEFT:
- this.collapse( event );
- break;
- case $.ui.keyCode.RIGHT:
- if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
- this.expand( event );
- }
- break;
- case $.ui.keyCode.ENTER:
- case $.ui.keyCode.SPACE:
- this._activate( event );
- break;
- case $.ui.keyCode.ESCAPE:
- this.collapse( event );
- break;
- default:
- preventDefault = false;
- prev = this.previousFilter || "";
- skip = false;
-
- // Support number pad values
- character = event.keyCode >= 96 && event.keyCode <= 105 ?
- ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
-
- clearTimeout( this.filterTimer );
-
- if ( character === prev ) {
- skip = true;
- } else {
- character = prev + character;
- }
-
- match = this._filterMenuItems( character );
- match = skip && match.index( this.active.next() ) !== -1 ?
- this.active.nextAll( ".ui-menu-item" ) :
- match;
-
- // If no matches on the current filter, reset to the last character pressed
- // to move down the menu to the first item that starts with that character
- if ( !match.length ) {
- character = String.fromCharCode( event.keyCode );
- match = this._filterMenuItems( character );
- }
-
- if ( match.length ) {
- this.focus( event, match );
- this.previousFilter = character;
- this.filterTimer = this._delay( function() {
- delete this.previousFilter;
- }, 1000 );
- } else {
- delete this.previousFilter;
- }
- }
-
- if ( preventDefault ) {
- event.preventDefault();
- }
- },
-
- _activate: function( event ) {
- if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
- if ( this.active.children( "[aria-haspopup='true']" ).length ) {
- this.expand( event );
- } else {
- this.select( event );
- }
- }
- },
-
- refresh: function() {
- var menus, items, newSubmenus, newItems, newWrappers,
- that = this,
- icon = this.options.icons.submenu,
- submenus = this.element.find( this.options.menus );
-
- this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
-
- // Initialize nested menus
- newSubmenus = submenus.filter( ":not(.ui-menu)" )
- .hide()
- .attr( {
- role: this.options.role,
- "aria-hidden": "true",
- "aria-expanded": "false"
- } )
- .each( function() {
- var menu = $( this ),
- item = menu.prev(),
- submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
-
- that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
- item
- .attr( "aria-haspopup", "true" )
- .prepend( submenuCaret );
- menu.attr( "aria-labelledby", item.attr( "id" ) );
- } );
-
- this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
-
- menus = submenus.add( this.element );
- items = menus.find( this.options.items );
-
- // Initialize menu-items containing spaces and/or dashes only as dividers
- items.not( ".ui-menu-item" ).each( function() {
- var item = $( this );
- if ( that._isDivider( item ) ) {
- that._addClass( item, "ui-menu-divider", "ui-widget-content" );
- }
- } );
-
- // Don't refresh list items that are already adapted
- newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
- newWrappers = newItems.children()
- .not( ".ui-menu" )
- .uniqueId()
- .attr( {
- tabIndex: -1,
- role: this._itemRole()
- } );
- this._addClass( newItems, "ui-menu-item" )
- ._addClass( newWrappers, "ui-menu-item-wrapper" );
-
- // Add aria-disabled attribute to any disabled menu item
- items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
-
- // If the active item has been removed, blur the menu
- if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
- this.blur();
- }
- },
-
- _itemRole: function() {
- return {
- menu: "menuitem",
- listbox: "option"
- }[ this.options.role ];
- },
-
- _setOption: function( key, value ) {
- if ( key === "icons" ) {
- var icons = this.element.find( ".ui-menu-icon" );
- this._removeClass( icons, null, this.options.icons.submenu )
- ._addClass( icons, null, value.submenu );
- }
- this._super( key, value );
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this.element.attr( "aria-disabled", String( value ) );
- this._toggleClass( null, "ui-state-disabled", !!value );
- },
-
- focus: function( event, item ) {
- var nested, focused, activeParent;
- this.blur( event, event && event.type === "focus" );
-
- this._scrollIntoView( item );
-
- this.active = item.first();
-
- focused = this.active.children( ".ui-menu-item-wrapper" );
- this._addClass( focused, null, "ui-state-active" );
-
- // Only update aria-activedescendant if there's a role
- // otherwise we assume focus is managed elsewhere
- if ( this.options.role ) {
- this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
- }
-
- // Highlight active parent menu item, if any
- activeParent = this.active
- .parent()
- .closest( ".ui-menu-item" )
- .children( ".ui-menu-item-wrapper" );
- this._addClass( activeParent, null, "ui-state-active" );
-
- if ( event && event.type === "keydown" ) {
- this._close();
- } else {
- this.timer = this._delay( function() {
- this._close();
- }, this.delay );
- }
-
- nested = item.children( ".ui-menu" );
- if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
- this._startOpening( nested );
- }
- this.activeMenu = item.parent();
-
- this._trigger( "focus", event, { item: item } );
- },
-
- _scrollIntoView: function( item ) {
- var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
- if ( this._hasScroll() ) {
- borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
- paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
- offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
- scroll = this.activeMenu.scrollTop();
- elementHeight = this.activeMenu.height();
- itemHeight = item.outerHeight();
-
- if ( offset < 0 ) {
- this.activeMenu.scrollTop( scroll + offset );
- } else if ( offset + itemHeight > elementHeight ) {
- this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
- }
- }
- },
-
- blur: function( event, fromFocus ) {
- if ( !fromFocus ) {
- clearTimeout( this.timer );
- }
-
- if ( !this.active ) {
- return;
- }
-
- this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
- null, "ui-state-active" );
-
- this._trigger( "blur", event, { item: this.active } );
- this.active = null;
- },
-
- _startOpening: function( submenu ) {
- clearTimeout( this.timer );
-
- // Don't open if already open fixes a Firefox bug that caused a .5 pixel
- // shift in the submenu position when mousing over the caret icon
- if ( submenu.attr( "aria-hidden" ) !== "true" ) {
- return;
- }
-
- this.timer = this._delay( function() {
- this._close();
- this._open( submenu );
- }, this.delay );
- },
-
- _open: function( submenu ) {
- var position = $.extend( {
- of: this.active
- }, this.options.position );
-
- clearTimeout( this.timer );
- this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
- .hide()
- .attr( "aria-hidden", "true" );
-
- submenu
- .show()
- .removeAttr( "aria-hidden" )
- .attr( "aria-expanded", "true" )
- .position( position );
- },
-
- collapseAll: function( event, all ) {
- clearTimeout( this.timer );
- this.timer = this._delay( function() {
-
- // If we were passed an event, look for the submenu that contains the event
- var currentMenu = all ? this.element :
- $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
-
- // If we found no valid submenu ancestor, use the main menu to close all
- // sub menus anyway
- if ( !currentMenu.length ) {
- currentMenu = this.element;
- }
-
- this._close( currentMenu );
-
- this.blur( event );
-
- // Work around active item staying active after menu is blurred
- this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
-
- this.activeMenu = currentMenu;
- }, this.delay );
- },
-
- // With no arguments, closes the currently active menu - if nothing is active
- // it closes all menus. If passed an argument, it will search for menus BELOW
- _close: function( startMenu ) {
- if ( !startMenu ) {
- startMenu = this.active ? this.active.parent() : this.element;
- }
-
- startMenu.find( ".ui-menu" )
- .hide()
- .attr( "aria-hidden", "true" )
- .attr( "aria-expanded", "false" );
- },
-
- _closeOnDocumentClick: function( event ) {
- return !$( event.target ).closest( ".ui-menu" ).length;
- },
-
- _isDivider: function( item ) {
-
- // Match hyphen, em dash, en dash
- return !/[^\-\u2014\u2013\s]/.test( item.text() );
- },
-
- collapse: function( event ) {
- var newItem = this.active &&
- this.active.parent().closest( ".ui-menu-item", this.element );
- if ( newItem && newItem.length ) {
- this._close();
- this.focus( event, newItem );
- }
- },
-
- expand: function( event ) {
- var newItem = this.active &&
- this.active
- .children( ".ui-menu " )
- .find( this.options.items )
- .first();
-
- if ( newItem && newItem.length ) {
- this._open( newItem.parent() );
-
- // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
- this._delay( function() {
- this.focus( event, newItem );
- } );
- }
- },
-
- next: function( event ) {
- this._move( "next", "first", event );
- },
-
- previous: function( event ) {
- this._move( "prev", "last", event );
- },
-
- isFirstItem: function() {
- return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
- },
-
- isLastItem: function() {
- return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
- },
-
- _move: function( direction, filter, event ) {
- var next;
- if ( this.active ) {
- if ( direction === "first" || direction === "last" ) {
- next = this.active
- [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
- .eq( -1 );
- } else {
- next = this.active
- [ direction + "All" ]( ".ui-menu-item" )
- .eq( 0 );
- }
- }
- if ( !next || !next.length || !this.active ) {
- next = this.activeMenu.find( this.options.items )[ filter ]();
- }
-
- this.focus( event, next );
- },
-
- nextPage: function( event ) {
- var item, base, height;
-
- if ( !this.active ) {
- this.next( event );
- return;
- }
- if ( this.isLastItem() ) {
- return;
- }
- if ( this._hasScroll() ) {
- base = this.active.offset().top;
- height = this.element.height();
- this.active.nextAll( ".ui-menu-item" ).each( function() {
- item = $( this );
- return item.offset().top - base - height < 0;
- } );
-
- this.focus( event, item );
- } else {
- this.focus( event, this.activeMenu.find( this.options.items )
- [ !this.active ? "first" : "last" ]() );
- }
- },
-
- previousPage: function( event ) {
- var item, base, height;
- if ( !this.active ) {
- this.next( event );
- return;
- }
- if ( this.isFirstItem() ) {
- return;
- }
- if ( this._hasScroll() ) {
- base = this.active.offset().top;
- height = this.element.height();
- this.active.prevAll( ".ui-menu-item" ).each( function() {
- item = $( this );
- return item.offset().top - base + height > 0;
- } );
-
- this.focus( event, item );
- } else {
- this.focus( event, this.activeMenu.find( this.options.items ).first() );
- }
- },
-
- _hasScroll: function() {
- return this.element.outerHeight() < this.element.prop( "scrollHeight" );
- },
-
- select: function( event ) {
-
- // TODO: It should never be possible to not have an active item at this
- // point, but the tests don't trigger mouseenter before click.
- this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
- var ui = { item: this.active };
- if ( !this.active.has( ".ui-menu" ).length ) {
- this.collapseAll( event, true );
- }
- this._trigger( "select", event, ui );
- },
-
- _filterMenuItems: function( character ) {
- var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
- regex = new RegExp( "^" + escapedCharacter, "i" );
-
- return this.activeMenu
- .find( this.options.items )
-
- // Only match on items, not dividers or other content (#10571)
- .filter( ".ui-menu-item" )
- .filter( function() {
- return regex.test(
- $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
- } );
- }
-} );
-
-
-/*!
- * jQuery UI Autocomplete 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Autocomplete
-//>>group: Widgets
-//>>description: Lists suggested words as the user is typing.
-//>>docs: http://api.jqueryui.com/autocomplete/
-//>>demos: http://jqueryui.com/autocomplete/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/autocomplete.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.autocomplete", {
- version: "1.12.1",
- defaultElement: "<input>",
- options: {
- appendTo: null,
- autoFocus: false,
- delay: 300,
- minLength: 1,
- position: {
- my: "left top",
- at: "left bottom",
- collision: "none"
- },
- source: null,
-
- // Callbacks
- change: null,
- close: null,
- focus: null,
- open: null,
- response: null,
- search: null,
- select: null
- },
-
- requestIndex: 0,
- pending: 0,
-
- _create: function() {
-
- // Some browsers only repeat keydown events, not keypress events,
- // so we use the suppressKeyPress flag to determine if we've already
- // handled the keydown event. #7269
- // Unfortunately the code for & in keypress is the same as the up arrow,
- // so we use the suppressKeyPressRepeat flag to avoid handling keypress
- // events when we know the keydown event was used to modify the
- // search term. #7799
- var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
- nodeName = this.element[ 0 ].nodeName.toLowerCase(),
- isTextarea = nodeName === "textarea",
- isInput = nodeName === "input";
-
- // Textareas are always multi-line
- // Inputs are always single-line, even if inside a contentEditable element
- // IE also treats inputs as contentEditable
- // All other element types are determined by whether or not they're contentEditable
- this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
-
- this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
- this.isNewMenu = true;
-
- this._addClass( "ui-autocomplete-input" );
- this.element.attr( "autocomplete", "off" );
-
- this._on( this.element, {
- keydown: function( event ) {
- if ( this.element.prop( "readOnly" ) ) {
- suppressKeyPress = true;
- suppressInput = true;
- suppressKeyPressRepeat = true;
- return;
- }
-
- suppressKeyPress = false;
- suppressInput = false;
- suppressKeyPressRepeat = false;
- var keyCode = $.ui.keyCode;
- switch ( event.keyCode ) {
- case keyCode.PAGE_UP:
- suppressKeyPress = true;
- this._move( "previousPage", event );
- break;
- case keyCode.PAGE_DOWN:
- suppressKeyPress = true;
- this._move( "nextPage", event );
- break;
- case keyCode.UP:
- suppressKeyPress = true;
- this._keyEvent( "previous", event );
- break;
- case keyCode.DOWN:
- suppressKeyPress = true;
- this._keyEvent( "next", event );
- break;
- case keyCode.ENTER:
-
- // when menu is open and has focus
- if ( this.menu.active ) {
-
- // #6055 - Opera still allows the keypress to occur
- // which causes forms to submit
- suppressKeyPress = true;
- event.preventDefault();
- this.menu.select( event );
- }
- break;
- case keyCode.TAB:
- if ( this.menu.active ) {
- this.menu.select( event );
- }
- break;
- case keyCode.ESCAPE:
- if ( this.menu.element.is( ":visible" ) ) {
- if ( !this.isMultiLine ) {
- this._value( this.term );
- }
- this.close( event );
-
- // Different browsers have different default behavior for escape
- // Single press can mean undo or clear
- // Double press in IE means clear the whole form
- event.preventDefault();
- }
- break;
- default:
- suppressKeyPressRepeat = true;
-
- // search timeout should be triggered before the input value is changed
- this._searchTimeout( event );
- break;
- }
- },
- keypress: function( event ) {
- if ( suppressKeyPress ) {
- suppressKeyPress = false;
- if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
- event.preventDefault();
- }
- return;
- }
- if ( suppressKeyPressRepeat ) {
- return;
- }
-
- // Replicate some key handlers to allow them to repeat in Firefox and Opera
- var keyCode = $.ui.keyCode;
- switch ( event.keyCode ) {
- case keyCode.PAGE_UP:
- this._move( "previousPage", event );
- break;
- case keyCode.PAGE_DOWN:
- this._move( "nextPage", event );
- break;
- case keyCode.UP:
- this._keyEvent( "previous", event );
- break;
- case keyCode.DOWN:
- this._keyEvent( "next", event );
- break;
- }
- },
- input: function( event ) {
- if ( suppressInput ) {
- suppressInput = false;
- event.preventDefault();
- return;
- }
- this._searchTimeout( event );
- },
- focus: function() {
- this.selectedItem = null;
- this.previous = this._value();
- },
- blur: function( event ) {
- if ( this.cancelBlur ) {
- delete this.cancelBlur;
- return;
- }
-
- clearTimeout( this.searching );
- this.close( event );
- this._change( event );
- }
- } );
-
- this._initSource();
- this.menu = $( "<ul>" )
- .appendTo( this._appendTo() )
- .menu( {
-
- // disable ARIA support, the live region takes care of that
- role: null
- } )
- .hide()
- .menu( "instance" );
-
- this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
- this._on( this.menu.element, {
- mousedown: function( event ) {
-
- // prevent moving focus out of the text field
- event.preventDefault();
-
- // IE doesn't prevent moving focus even with event.preventDefault()
- // so we set a flag to know when we should ignore the blur event
- this.cancelBlur = true;
- this._delay( function() {
- delete this.cancelBlur;
-
- // Support: IE 8 only
- // Right clicking a menu item or selecting text from the menu items will
- // result in focus moving out of the input. However, we've already received
- // and ignored the blur event because of the cancelBlur flag set above. So
- // we restore focus to ensure that the menu closes properly based on the user's
- // next actions.
- if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
- this.element.trigger( "focus" );
- }
- } );
- },
- menufocus: function( event, ui ) {
- var label, item;
-
- // support: Firefox
- // Prevent accidental activation of menu items in Firefox (#7024 #9118)
- if ( this.isNewMenu ) {
- this.isNewMenu = false;
- if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
- this.menu.blur();
-
- this.document.one( "mousemove", function() {
- $( event.target ).trigger( event.originalEvent );
- } );
-
- return;
- }
- }
-
- item = ui.item.data( "ui-autocomplete-item" );
- if ( false !== this._trigger( "focus", event, { item: item } ) ) {
-
- // use value to match what will end up in the input, if it was a key event
- if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
- this._value( item.value );
- }
- }
-
- // Announce the value in the liveRegion
- label = ui.item.attr( "aria-label" ) || item.value;
- if ( label && $.trim( label ).length ) {
- this.liveRegion.children().hide();
- $( "<div>" ).text( label ).appendTo( this.liveRegion );
- }
- },
- menuselect: function( event, ui ) {
- var item = ui.item.data( "ui-autocomplete-item" ),
- previous = this.previous;
-
- // Only trigger when focus was lost (click on menu)
- if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
- this.element.trigger( "focus" );
- this.previous = previous;
-
- // #6109 - IE triggers two focus events and the second
- // is asynchronous, so we need to reset the previous
- // term synchronously and asynchronously :-(
- this._delay( function() {
- this.previous = previous;
- this.selectedItem = item;
- } );
- }
-
- if ( false !== this._trigger( "select", event, { item: item } ) ) {
- this._value( item.value );
- }
-
- // reset the term after the select event
- // this allows custom select handling to work properly
- this.term = this._value();
-
- this.close( event );
- this.selectedItem = item;
- }
- } );
-
- this.liveRegion = $( "<div>", {
- role: "status",
- "aria-live": "assertive",
- "aria-relevant": "additions"
- } )
- .appendTo( this.document[ 0 ].body );
-
- this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
-
- // Turning off autocomplete prevents the browser from remembering the
- // value when navigating through history, so we re-enable autocomplete
- // if the page is unloaded before the widget is destroyed. #7790
- this._on( this.window, {
- beforeunload: function() {
- this.element.removeAttr( "autocomplete" );
- }
- } );
- },
-
- _destroy: function() {
- clearTimeout( this.searching );
- this.element.removeAttr( "autocomplete" );
- this.menu.element.remove();
- this.liveRegion.remove();
- },
-
- _setOption: function( key, value ) {
- this._super( key, value );
- if ( key === "source" ) {
- this._initSource();
- }
- if ( key === "appendTo" ) {
- this.menu.element.appendTo( this._appendTo() );
- }
- if ( key === "disabled" && value && this.xhr ) {
- this.xhr.abort();
- }
- },
-
- _isEventTargetInWidget: function( event ) {
- var menuElement = this.menu.element[ 0 ];
-
- return event.target === this.element[ 0 ] ||
- event.target === menuElement ||
- $.contains( menuElement, event.target );
- },
-
- _closeOnClickOutside: function( event ) {
- if ( !this._isEventTargetInWidget( event ) ) {
- this.close();
- }
- },
-
- _appendTo: function() {
- var element = this.options.appendTo;
-
- if ( element ) {
- element = element.jquery || element.nodeType ?
- $( element ) :
- this.document.find( element ).eq( 0 );
- }
-
- if ( !element || !element[ 0 ] ) {
- element = this.element.closest( ".ui-front, dialog" );
- }
-
- if ( !element.length ) {
- element = this.document[ 0 ].body;
- }
-
- return element;
- },
-
- _initSource: function() {
- var array, url,
- that = this;
- if ( $.isArray( this.options.source ) ) {
- array = this.options.source;
- this.source = function( request, response ) {
- response( $.ui.autocomplete.filter( array, request.term ) );
- };
- } else if ( typeof this.options.source === "string" ) {
- url = this.options.source;
- this.source = function( request, response ) {
- if ( that.xhr ) {
- that.xhr.abort();
- }
- that.xhr = $.ajax( {
- url: url,
- data: request,
- dataType: "json",
- success: function( data ) {
- response( data );
- },
- error: function() {
- response( [] );
- }
- } );
- };
- } else {
- this.source = this.options.source;
- }
- },
-
- _searchTimeout: function( event ) {
- clearTimeout( this.searching );
- this.searching = this._delay( function() {
-
- // Search if the value has changed, or if the user retypes the same value (see #7434)
- var equalValues = this.term === this._value(),
- menuVisible = this.menu.element.is( ":visible" ),
- modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
-
- if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
- this.selectedItem = null;
- this.search( null, event );
- }
- }, this.options.delay );
- },
-
- search: function( value, event ) {
- value = value != null ? value : this._value();
-
- // Always save the actual value, not the one passed as an argument
- this.term = this._value();
-
- if ( value.length < this.options.minLength ) {
- return this.close( event );
- }
-
- if ( this._trigger( "search", event ) === false ) {
- return;
- }
-
- return this._search( value );
- },
-
- _search: function( value ) {
- this.pending++;
- this._addClass( "ui-autocomplete-loading" );
- this.cancelSearch = false;
-
- this.source( { term: value }, this._response() );
- },
-
- _response: function() {
- var index = ++this.requestIndex;
-
- return $.proxy( function( content ) {
- if ( index === this.requestIndex ) {
- this.__response( content );
- }
-
- this.pending--;
- if ( !this.pending ) {
- this._removeClass( "ui-autocomplete-loading" );
- }
- }, this );
- },
-
- __response: function( content ) {
- if ( content ) {
- content = this._normalize( content );
- }
- this._trigger( "response", null, { content: content } );
- if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
- this._suggest( content );
- this._trigger( "open" );
- } else {
-
- // use ._close() instead of .close() so we don't cancel future searches
- this._close();
- }
- },
-
- close: function( event ) {
- this.cancelSearch = true;
- this._close( event );
- },
-
- _close: function( event ) {
-
- // Remove the handler that closes the menu on outside clicks
- this._off( this.document, "mousedown" );
-
- if ( this.menu.element.is( ":visible" ) ) {
- this.menu.element.hide();
- this.menu.blur();
- this.isNewMenu = true;
- this._trigger( "close", event );
- }
- },
-
- _change: function( event ) {
- if ( this.previous !== this._value() ) {
- this._trigger( "change", event, { item: this.selectedItem } );
- }
- },
-
- _normalize: function( items ) {
-
- // assume all items have the right format when the first item is complete
- if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
- return items;
- }
- return $.map( items, function( item ) {
- if ( typeof item === "string" ) {
- return {
- label: item,
- value: item
- };
- }
- return $.extend( {}, item, {
- label: item.label || item.value,
- value: item.value || item.label
- } );
- } );
- },
-
- _suggest: function( items ) {
- var ul = this.menu.element.empty();
- this._renderMenu( ul, items );
- this.isNewMenu = true;
- this.menu.refresh();
-
- // Size and position menu
- ul.show();
- this._resizeMenu();
- ul.position( $.extend( {
- of: this.element
- }, this.options.position ) );
-
- if ( this.options.autoFocus ) {
- this.menu.next();
- }
-
- // Listen for interactions outside of the widget (#6642)
- this._on( this.document, {
- mousedown: "_closeOnClickOutside"
- } );
- },
-
- _resizeMenu: function() {
- var ul = this.menu.element;
- ul.outerWidth( Math.max(
-
- // Firefox wraps long text (possibly a rounding bug)
- // so we add 1px to avoid the wrapping (#7513)
- ul.width( "" ).outerWidth() + 1,
- this.element.outerWidth()
- ) );
- },
-
- _renderMenu: function( ul, items ) {
- var that = this;
- $.each( items, function( index, item ) {
- that._renderItemData( ul, item );
- } );
- },
-
- _renderItemData: function( ul, item ) {
- return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
- },
-
- _renderItem: function( ul, item ) {
- return $( "<li>" )
- .append( $( "<div>" ).text( item.label ) )
- .appendTo( ul );
- },
-
- _move: function( direction, event ) {
- if ( !this.menu.element.is( ":visible" ) ) {
- this.search( null, event );
- return;
- }
- if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
- this.menu.isLastItem() && /^next/.test( direction ) ) {
-
- if ( !this.isMultiLine ) {
- this._value( this.term );
- }
-
- this.menu.blur();
- return;
- }
- this.menu[ direction ]( event );
- },
-
- widget: function() {
- return this.menu.element;
- },
-
- _value: function() {
- return this.valueMethod.apply( this.element, arguments );
- },
-
- _keyEvent: function( keyEvent, event ) {
- if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
- this._move( keyEvent, event );
-
- // Prevents moving cursor to beginning/end of the text field in some browsers
- event.preventDefault();
- }
- },
-
- // Support: Chrome <=50
- // We should be able to just use this.element.prop( "isContentEditable" )
- // but hidden elements always report false in Chrome.
- // https://code.google.com/p/chromium/issues/detail?id=313082
- _isContentEditable: function( element ) {
- if ( !element.length ) {
- return false;
- }
-
- var editable = element.prop( "contentEditable" );
-
- if ( editable === "inherit" ) {
- return this._isContentEditable( element.parent() );
- }
-
- return editable === "true";
- }
-} );
-
-$.extend( $.ui.autocomplete, {
- escapeRegex: function( value ) {
- return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
- },
- filter: function( array, term ) {
- var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
- return $.grep( array, function( value ) {
- return matcher.test( value.label || value.value || value );
- } );
- }
-} );
-
-// Live region extension, adding a `messages` option
-// NOTE: This is an experimental API. We are still investigating
-// a full solution for string manipulation and internationalization.
-$.widget( "ui.autocomplete", $.ui.autocomplete, {
- options: {
- messages: {
- noResults: "No search results.",
- results: function( amount ) {
- return amount + ( amount > 1 ? " results are" : " result is" ) +
- " available, use up and down arrow keys to navigate.";
- }
- }
- },
-
- __response: function( content ) {
- var message;
- this._superApply( arguments );
- if ( this.options.disabled || this.cancelSearch ) {
- return;
- }
- if ( content && content.length ) {
- message = this.options.messages.results( content.length );
- } else {
- message = this.options.messages.noResults;
- }
- this.liveRegion.children().hide();
- $( "<div>" ).text( message ).appendTo( this.liveRegion );
- }
-} );
-
-var widgetsAutocomplete = $.ui.autocomplete;
-
-
-/*!
- * jQuery UI Controlgroup 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Controlgroup
-//>>group: Widgets
-//>>description: Visually groups form control widgets
-//>>docs: http://api.jqueryui.com/controlgroup/
-//>>demos: http://jqueryui.com/controlgroup/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/controlgroup.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
-
-var widgetsControlgroup = $.widget( "ui.controlgroup", {
- version: "1.12.1",
- defaultElement: "<div>",
- options: {
- direction: "horizontal",
- disabled: null,
- onlyVisible: true,
- items: {
- "button": "input[type=button], input[type=submit], input[type=reset], button, a",
- "controlgroupLabel": ".ui-controlgroup-label",
- "checkboxradio": "input[type='checkbox'], input[type='radio']",
- "selectmenu": "select",
- "spinner": ".ui-spinner-input"
- }
- },
-
- _create: function() {
- this._enhance();
- },
-
- // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
- _enhance: function() {
- this.element.attr( "role", "toolbar" );
- this.refresh();
- },
-
- _destroy: function() {
- this._callChildMethod( "destroy" );
- this.childWidgets.removeData( "ui-controlgroup-data" );
- this.element.removeAttr( "role" );
- if ( this.options.items.controlgroupLabel ) {
- this.element
- .find( this.options.items.controlgroupLabel )
- .find( ".ui-controlgroup-label-contents" )
- .contents().unwrap();
- }
- },
-
- _initWidgets: function() {
- var that = this,
- childWidgets = [];
-
- // First we iterate over each of the items options
- $.each( this.options.items, function( widget, selector ) {
- var labels;
- var options = {};
-
- // Make sure the widget has a selector set
- if ( !selector ) {
- return;
- }
-
- if ( widget === "controlgroupLabel" ) {
- labels = that.element.find( selector );
- labels.each( function() {
- var element = $( this );
-
- if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
- return;
- }
- element.contents()
- .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
- } );
- that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
- childWidgets = childWidgets.concat( labels.get() );
- return;
- }
-
- // Make sure the widget actually exists
- if ( !$.fn[ widget ] ) {
- return;
- }
-
- // We assume everything is in the middle to start because we can't determine
- // first / last elements until all enhancments are done.
- if ( that[ "_" + widget + "Options" ] ) {
- options = that[ "_" + widget + "Options" ]( "middle" );
- } else {
- options = { classes: {} };
- }
-
- // Find instances of this widget inside controlgroup and init them
- that.element
- .find( selector )
- .each( function() {
- var element = $( this );
- var instance = element[ widget ]( "instance" );
-
- // We need to clone the default options for this type of widget to avoid
- // polluting the variable options which has a wider scope than a single widget.
- var instanceOptions = $.widget.extend( {}, options );
-
- // If the button is the child of a spinner ignore it
- // TODO: Find a more generic solution
- if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
- return;
- }
-
- // Create the widget if it doesn't exist
- if ( !instance ) {
- instance = element[ widget ]()[ widget ]( "instance" );
- }
- if ( instance ) {
- instanceOptions.classes =
- that._resolveClassesValues( instanceOptions.classes, instance );
- }
- element[ widget ]( instanceOptions );
-
- // Store an instance of the controlgroup to be able to reference
- // from the outermost element for changing options and refresh
- var widgetElement = element[ widget ]( "widget" );
- $.data( widgetElement[ 0 ], "ui-controlgroup-data",
- instance ? instance : element[ widget ]( "instance" ) );
-
- childWidgets.push( widgetElement[ 0 ] );
- } );
- } );
-
- this.childWidgets = $( $.unique( childWidgets ) );
- this._addClass( this.childWidgets, "ui-controlgroup-item" );
- },
-
- _callChildMethod: function( method ) {
- this.childWidgets.each( function() {
- var element = $( this ),
- data = element.data( "ui-controlgroup-data" );
- if ( data && data[ method ] ) {
- data[ method ]();
- }
- } );
- },
-
- _updateCornerClass: function( element, position ) {
- var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
- var add = this._buildSimpleOptions( position, "label" ).classes.label;
-
- this._removeClass( element, null, remove );
- this._addClass( element, null, add );
- },
-
- _buildSimpleOptions: function( position, key ) {
- var direction = this.options.direction === "vertical";
- var result = {
- classes: {}
- };
- result.classes[ key ] = {
- "middle": "",
- "first": "ui-corner-" + ( direction ? "top" : "left" ),
- "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
- "only": "ui-corner-all"
- }[ position ];
-
- return result;
- },
-
- _spinnerOptions: function( position ) {
- var options = this._buildSimpleOptions( position, "ui-spinner" );
-
- options.classes[ "ui-spinner-up" ] = "";
- options.classes[ "ui-spinner-down" ] = "";
-
- return options;
- },
-
- _buttonOptions: function( position ) {
- return this._buildSimpleOptions( position, "ui-button" );
- },
-
- _checkboxradioOptions: function( position ) {
- return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
- },
-
- _selectmenuOptions: function( position ) {
- var direction = this.options.direction === "vertical";
- return {
- width: direction ? "auto" : false,
- classes: {
- middle: {
- "ui-selectmenu-button-open": "",
- "ui-selectmenu-button-closed": ""
- },
- first: {
- "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
- "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
- },
- last: {
- "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
- "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
- },
- only: {
- "ui-selectmenu-button-open": "ui-corner-top",
- "ui-selectmenu-button-closed": "ui-corner-all"
- }
-
- }[ position ]
- };
- },
-
- _resolveClassesValues: function( classes, instance ) {
- var result = {};
- $.each( classes, function( key ) {
- var current = instance.options.classes[ key ] || "";
- current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
- result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
- } );
- return result;
- },
-
- _setOption: function( key, value ) {
- if ( key === "direction" ) {
- this._removeClass( "ui-controlgroup-" + this.options.direction );
- }
-
- this._super( key, value );
- if ( key === "disabled" ) {
- this._callChildMethod( value ? "disable" : "enable" );
- return;
- }
-
- this.refresh();
- },
-
- refresh: function() {
- var children,
- that = this;
-
- this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
-
- if ( this.options.direction === "horizontal" ) {
- this._addClass( null, "ui-helper-clearfix" );
- }
- this._initWidgets();
-
- children = this.childWidgets;
-
- // We filter here because we need to track all childWidgets not just the visible ones
- if ( this.options.onlyVisible ) {
- children = children.filter( ":visible" );
- }
-
- if ( children.length ) {
-
- // We do this last because we need to make sure all enhancment is done
- // before determining first and last
- $.each( [ "first", "last" ], function( index, value ) {
- var instance = children[ value ]().data( "ui-controlgroup-data" );
-
- if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
- var options = that[ "_" + instance.widgetName + "Options" ](
- children.length === 1 ? "only" : value
- );
- options.classes = that._resolveClassesValues( options.classes, instance );
- instance.element[ instance.widgetName ]( options );
- } else {
- that._updateCornerClass( children[ value ](), value );
- }
- } );
-
- // Finally call the refresh method on each of the child widgets.
- this._callChildMethod( "refresh" );
- }
- }
-} );
-
-/*!
- * jQuery UI Checkboxradio 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Checkboxradio
-//>>group: Widgets
-//>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
-//>>docs: http://api.jqueryui.com/checkboxradio/
-//>>demos: http://jqueryui.com/checkboxradio/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/button.css
-//>>css.structure: ../../themes/base/checkboxradio.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
- version: "1.12.1",
- options: {
- disabled: null,
- label: null,
- icon: true,
- classes: {
- "ui-checkboxradio-label": "ui-corner-all",
- "ui-checkboxradio-icon": "ui-corner-all"
- }
- },
-
- _getCreateOptions: function() {
- var disabled, labels;
- var that = this;
- var options = this._super() || {};
-
- // We read the type here, because it makes more sense to throw a element type error first,
- // rather then the error for lack of a label. Often if its the wrong type, it
- // won't have a label (e.g. calling on a div, btn, etc)
- this._readType();
-
- labels = this.element.labels();
-
- // If there are multiple labels, use the last one
- this.label = $( labels[ labels.length - 1 ] );
- if ( !this.label.length ) {
- $.error( "No label found for checkboxradio widget" );
- }
-
- this.originalLabel = "";
-
- // We need to get the label text but this may also need to make sure it does not contain the
- // input itself.
- this.label.contents().not( this.element[ 0 ] ).each( function() {
-
- // The label contents could be text, html, or a mix. We concat each element to get a
- // string representation of the label, without the input as part of it.
- that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
- } );
-
- // Set the label option if we found label text
- if ( this.originalLabel ) {
- options.label = this.originalLabel;
- }
-
- disabled = this.element[ 0 ].disabled;
- if ( disabled != null ) {
- options.disabled = disabled;
- }
- return options;
- },
-
- _create: function() {
- var checked = this.element[ 0 ].checked;
-
- this._bindFormResetHandler();
-
- if ( this.options.disabled == null ) {
- this.options.disabled = this.element[ 0 ].disabled;
- }
-
- this._setOption( "disabled", this.options.disabled );
- this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
- this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
-
- if ( this.type === "radio" ) {
- this._addClass( this.label, "ui-checkboxradio-radio-label" );
- }
-
- if ( this.options.label && this.options.label !== this.originalLabel ) {
- this._updateLabel();
- } else if ( this.originalLabel ) {
- this.options.label = this.originalLabel;
- }
-
- this._enhance();
-
- if ( checked ) {
- this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
- if ( this.icon ) {
- this._addClass( this.icon, null, "ui-state-hover" );
- }
- }
-
- this._on( {
- change: "_toggleClasses",
- focus: function() {
- this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
- },
- blur: function() {
- this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
- }
- } );
- },
-
- _readType: function() {
- var nodeName = this.element[ 0 ].nodeName.toLowerCase();
- this.type = this.element[ 0 ].type;
- if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
- $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
- " and element.type=" + this.type );
- }
- },
-
- // Support jQuery Mobile enhanced option
- _enhance: function() {
- this._updateIcon( this.element[ 0 ].checked );
- },
-
- widget: function() {
- return this.label;
- },
-
- _getRadioGroup: function() {
- var group;
- var name = this.element[ 0 ].name;
- var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
-
- if ( !name ) {
- return $( [] );
- }
-
- if ( this.form.length ) {
- group = $( this.form[ 0 ].elements ).filter( nameSelector );
- } else {
-
- // Not inside a form, check all inputs that also are not inside a form
- group = $( nameSelector ).filter( function() {
- return $( this ).form().length === 0;
- } );
- }
-
- return group.not( this.element );
- },
-
- _toggleClasses: function() {
- var checked = this.element[ 0 ].checked;
- this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
-
- if ( this.options.icon && this.type === "checkbox" ) {
- this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
- ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
- }
-
- if ( this.type === "radio" ) {
- this._getRadioGroup()
- .each( function() {
- var instance = $( this ).checkboxradio( "instance" );
-
- if ( instance ) {
- instance._removeClass( instance.label,
- "ui-checkboxradio-checked", "ui-state-active" );
- }
- } );
- }
- },
-
- _destroy: function() {
- this._unbindFormResetHandler();
-
- if ( this.icon ) {
- this.icon.remove();
- this.iconSpace.remove();
- }
- },
-
- _setOption: function( key, value ) {
-
- // We don't allow the value to be set to nothing
- if ( key === "label" && !value ) {
- return;
- }
-
- this._super( key, value );
-
- if ( key === "disabled" ) {
- this._toggleClass( this.label, null, "ui-state-disabled", value );
- this.element[ 0 ].disabled = value;
-
- // Don't refresh when setting disabled
- return;
- }
- this.refresh();
- },
-
- _updateIcon: function( checked ) {
- var toAdd = "ui-icon ui-icon-background ";
-
- if ( this.options.icon ) {
- if ( !this.icon ) {
- this.icon = $( "<span>" );
- this.iconSpace = $( "<span> </span>" );
- this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
- }
-
- if ( this.type === "checkbox" ) {
- toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
- this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
- } else {
- toAdd += "ui-icon-blank";
- }
- this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
- if ( !checked ) {
- this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
- }
- this.icon.prependTo( this.label ).after( this.iconSpace );
- } else if ( this.icon !== undefined ) {
- this.icon.remove();
- this.iconSpace.remove();
- delete this.icon;
- }
- },
-
- _updateLabel: function() {
-
- // Remove the contents of the label ( minus the icon, icon space, and input )
- var contents = this.label.contents().not( this.element[ 0 ] );
- if ( this.icon ) {
- contents = contents.not( this.icon[ 0 ] );
- }
- if ( this.iconSpace ) {
- contents = contents.not( this.iconSpace[ 0 ] );
- }
- contents.remove();
-
- this.label.append( this.options.label );
- },
-
- refresh: function() {
- var checked = this.element[ 0 ].checked,
- isDisabled = this.element[ 0 ].disabled;
-
- this._updateIcon( checked );
- this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
- if ( this.options.label !== null ) {
- this._updateLabel();
- }
-
- if ( isDisabled !== this.options.disabled ) {
- this._setOptions( { "disabled": isDisabled } );
- }
- }
-
-} ] );
-
-var widgetsCheckboxradio = $.ui.checkboxradio;
-
-
-/*!
- * jQuery UI Button 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Button
-//>>group: Widgets
-//>>description: Enhances a form with themeable buttons.
-//>>docs: http://api.jqueryui.com/button/
-//>>demos: http://jqueryui.com/button/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/button.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.button", {
- version: "1.12.1",
- defaultElement: "<button>",
- options: {
- classes: {
- "ui-button": "ui-corner-all"
- },
- disabled: null,
- icon: null,
- iconPosition: "beginning",
- label: null,
- showLabel: true
- },
-
- _getCreateOptions: function() {
- var disabled,
-
- // This is to support cases like in jQuery Mobile where the base widget does have
- // an implementation of _getCreateOptions
- options = this._super() || {};
-
- this.isInput = this.element.is( "input" );
-
- disabled = this.element[ 0 ].disabled;
- if ( disabled != null ) {
- options.disabled = disabled;
- }
-
- this.originalLabel = this.isInput ? this.element.val() : this.element.html();
- if ( this.originalLabel ) {
- options.label = this.originalLabel;
- }
-
- return options;
- },
-
- _create: function() {
- if ( !this.option.showLabel & !this.options.icon ) {
- this.options.showLabel = true;
- }
-
- // We have to check the option again here even though we did in _getCreateOptions,
- // because null may have been passed on init which would override what was set in
- // _getCreateOptions
- if ( this.options.disabled == null ) {
- this.options.disabled = this.element[ 0 ].disabled || false;
- }
-
- this.hasTitle = !!this.element.attr( "title" );
-
- // Check to see if the label needs to be set or if its already correct
- if ( this.options.label && this.options.label !== this.originalLabel ) {
- if ( this.isInput ) {
- this.element.val( this.options.label );
- } else {
- this.element.html( this.options.label );
- }
- }
- this._addClass( "ui-button", "ui-widget" );
- this._setOption( "disabled", this.options.disabled );
- this._enhance();
-
- if ( this.element.is( "a" ) ) {
- this._on( {
- "keyup": function( event ) {
- if ( event.keyCode === $.ui.keyCode.SPACE ) {
- event.preventDefault();
-
- // Support: PhantomJS <= 1.9, IE 8 Only
- // If a native click is available use it so we actually cause navigation
- // otherwise just trigger a click event
- if ( this.element[ 0 ].click ) {
- this.element[ 0 ].click();
- } else {
- this.element.trigger( "click" );
- }
- }
- }
- } );
- }
- },
-
- _enhance: function() {
- if ( !this.element.is( "button" ) ) {
- this.element.attr( "role", "button" );
- }
-
- if ( this.options.icon ) {
- this._updateIcon( "icon", this.options.icon );
- this._updateTooltip();
- }
- },
-
- _updateTooltip: function() {
- this.title = this.element.attr( "title" );
-
- if ( !this.options.showLabel && !this.title ) {
- this.element.attr( "title", this.options.label );
- }
- },
-
- _updateIcon: function( option, value ) {
- var icon = option !== "iconPosition",
- position = icon ? this.options.iconPosition : value,
- displayBlock = position === "top" || position === "bottom";
-
- // Create icon
- if ( !this.icon ) {
- this.icon = $( "<span>" );
-
- this._addClass( this.icon, "ui-button-icon", "ui-icon" );
-
- if ( !this.options.showLabel ) {
- this._addClass( "ui-button-icon-only" );
- }
- } else if ( icon ) {
-
- // If we are updating the icon remove the old icon class
- this._removeClass( this.icon, null, this.options.icon );
- }
-
- // If we are updating the icon add the new icon class
- if ( icon ) {
- this._addClass( this.icon, null, value );
- }
-
- this._attachIcon( position );
-
- // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
- // the iconSpace if there is one.
- if ( displayBlock ) {
- this._addClass( this.icon, null, "ui-widget-icon-block" );
- if ( this.iconSpace ) {
- this.iconSpace.remove();
- }
- } else {
-
- // Position is beginning or end so remove the ui-widget-icon-block class and add the
- // space if it does not exist
- if ( !this.iconSpace ) {
- this.iconSpace = $( "<span> </span>" );
- this._addClass( this.iconSpace, "ui-button-icon-space" );
- }
- this._removeClass( this.icon, null, "ui-wiget-icon-block" );
- this._attachIconSpace( position );
- }
- },
-
- _destroy: function() {
- this.element.removeAttr( "role" );
-
- if ( this.icon ) {
- this.icon.remove();
- }
- if ( this.iconSpace ) {
- this.iconSpace.remove();
- }
- if ( !this.hasTitle ) {
- this.element.removeAttr( "title" );
- }
- },
-
- _attachIconSpace: function( iconPosition ) {
- this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
- },
-
- _attachIcon: function( iconPosition ) {
- this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
- },
-
- _setOptions: function( options ) {
- var newShowLabel = options.showLabel === undefined ?
- this.options.showLabel :
- options.showLabel,
- newIcon = options.icon === undefined ? this.options.icon : options.icon;
-
- if ( !newShowLabel && !newIcon ) {
- options.showLabel = true;
- }
- this._super( options );
- },
-
- _setOption: function( key, value ) {
- if ( key === "icon" ) {
- if ( value ) {
- this._updateIcon( key, value );
- } else if ( this.icon ) {
- this.icon.remove();
- if ( this.iconSpace ) {
- this.iconSpace.remove();
- }
- }
- }
-
- if ( key === "iconPosition" ) {
- this._updateIcon( key, value );
- }
-
- // Make sure we can't end up with a button that has neither text nor icon
- if ( key === "showLabel" ) {
- this._toggleClass( "ui-button-icon-only", null, !value );
- this._updateTooltip();
- }
-
- if ( key === "label" ) {
- if ( this.isInput ) {
- this.element.val( value );
- } else {
-
- // If there is an icon, append it, else nothing then append the value
- // this avoids removal of the icon when setting label text
- this.element.html( value );
- if ( this.icon ) {
- this._attachIcon( this.options.iconPosition );
- this._attachIconSpace( this.options.iconPosition );
- }
- }
- }
-
- this._super( key, value );
-
- if ( key === "disabled" ) {
- this._toggleClass( null, "ui-state-disabled", value );
- this.element[ 0 ].disabled = value;
- if ( value ) {
- this.element.blur();
- }
- }
- },
-
- refresh: function() {
-
- // Make sure to only check disabled if its an element that supports this otherwise
- // check for the disabled class to determine state
- var isDisabled = this.element.is( "input, button" ) ?
- this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
-
- if ( isDisabled !== this.options.disabled ) {
- this._setOptions( { disabled: isDisabled } );
- }
-
- this._updateTooltip();
- }
-} );
-
-// DEPRECATED
-if ( $.uiBackCompat !== false ) {
-
- // Text and Icons options
- $.widget( "ui.button", $.ui.button, {
- options: {
- text: true,
- icons: {
- primary: null,
- secondary: null
- }
- },
-
- _create: function() {
- if ( this.options.showLabel && !this.options.text ) {
- this.options.showLabel = this.options.text;
- }
- if ( !this.options.showLabel && this.options.text ) {
- this.options.text = this.options.showLabel;
- }
- if ( !this.options.icon && ( this.options.icons.primary ||
- this.options.icons.secondary ) ) {
- if ( this.options.icons.primary ) {
- this.options.icon = this.options.icons.primary;
- } else {
- this.options.icon = this.options.icons.secondary;
- this.options.iconPosition = "end";
- }
- } else if ( this.options.icon ) {
- this.options.icons.primary = this.options.icon;
- }
- this._super();
- },
-
- _setOption: function( key, value ) {
- if ( key === "text" ) {
- this._super( "showLabel", value );
- return;
- }
- if ( key === "showLabel" ) {
- this.options.text = value;
- }
- if ( key === "icon" ) {
- this.options.icons.primary = value;
- }
- if ( key === "icons" ) {
- if ( value.primary ) {
- this._super( "icon", value.primary );
- this._super( "iconPosition", "beginning" );
- } else if ( value.secondary ) {
- this._super( "icon", value.secondary );
- this._super( "iconPosition", "end" );
- }
- }
- this._superApply( arguments );
- }
- } );
-
- $.fn.button = ( function( orig ) {
- return function() {
- if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
- ( this.length && this[ 0 ].tagName === "INPUT" && (
- this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
- ) ) ) {
- return orig.apply( this, arguments );
- }
- if ( !$.ui.checkboxradio ) {
- $.error( "Checkboxradio widget missing" );
- }
- if ( arguments.length === 0 ) {
- return this.checkboxradio( {
- "icon": false
- } );
- }
- return this.checkboxradio.apply( this, arguments );
- };
- } )( $.fn.button );
-
- $.fn.buttonset = function() {
- if ( !$.ui.controlgroup ) {
- $.error( "Controlgroup widget missing" );
- }
- if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
- return this.controlgroup.apply( this,
- [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
- }
- if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
- return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
- }
- if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
- arguments[ 0 ].items = {
- button: arguments[ 0 ].items
- };
- }
- return this.controlgroup.apply( this, arguments );
- };
-}
-
-var widgetsButton = $.ui.button;
-
-
-// jscs:disable maximumLineLength
-/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
-/*!
- * jQuery UI Datepicker 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Datepicker
-//>>group: Widgets
-//>>description: Displays a calendar from an input or inline for selecting dates.
-//>>docs: http://api.jqueryui.com/datepicker/
-//>>demos: http://jqueryui.com/datepicker/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/datepicker.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.extend( $.ui, { datepicker: { version: "1.12.1" } } );
-
-var datepicker_instActive;
-
-function datepicker_getZindex( elem ) {
- var position, value;
- while ( elem.length && elem[ 0 ] !== document ) {
-
- // Ignore z-index if position is set to a value where z-index is ignored by the browser
- // This makes behavior of this function consistent across browsers
- // WebKit always returns auto if the element is positioned
- position = elem.css( "position" );
- if ( position === "absolute" || position === "relative" || position === "fixed" ) {
-
- // IE returns 0 when zIndex is not specified
- // other browsers return a string
- // we ignore the case of nested elements with an explicit value of 0
- // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
- value = parseInt( elem.css( "zIndex" ), 10 );
- if ( !isNaN( value ) && value !== 0 ) {
- return value;
- }
- }
- elem = elem.parent();
- }
-
- return 0;
-}
-/* Date picker manager.
- Use the singleton instance of this class, $.datepicker, to interact with the date picker.
- Settings for (groups of) date pickers are maintained in an instance object,
- allowing multiple different settings on the same page. */
-
-function Datepicker() {
- this._curInst = null; // The current instance in use
- this._keyEvent = false; // If the last event was a key event
- this._disabledInputs = []; // List of date picker inputs that have been disabled
- this._datepickerShowing = false; // True if the popup picker is showing , false if not
- this._inDialog = false; // True if showing within a "dialog", false if not
- this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
- this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
- this._appendClass = "ui-datepicker-append"; // The name of the append marker class
- this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
- this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
- this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
- this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
- this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
- this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
- this.regional = []; // Available regional settings, indexed by language code
- this.regional[ "" ] = { // Default regional settings
- closeText: "Done", // Display text for close link
- prevText: "Prev", // Display text for previous month link
- nextText: "Next", // Display text for next month link
- currentText: "Today", // Display text for current month link
- monthNames: [ "January","February","March","April","May","June",
- "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
- monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
- dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
- dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
- dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
- weekHeader: "Wk", // Column header for week of the year
- dateFormat: "mm/dd/yy", // See format options on parseDate
- firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
- isRTL: false, // True if right-to-left language, false if left-to-right
- showMonthAfterYear: false, // True if the year select precedes month, false for month then year
- yearSuffix: "" // Additional text to append to the year in the month headers
- };
- this._defaults = { // Global defaults for all the date picker instances
- showOn: "focus", // "focus" for popup on focus,
- // "button" for trigger button, or "both" for either
- showAnim: "fadeIn", // Name of jQuery animation for popup
- showOptions: {}, // Options for enhanced animations
- defaultDate: null, // Used when field is blank: actual date,
- // +/-number for offset from today, null for today
- appendText: "", // Display text following the input box, e.g. showing the format
- buttonText: "...", // Text for trigger button
- buttonImage: "", // URL for trigger button image
- buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
- hideIfNoPrevNext: false, // True to hide next/previous month links
- // if not applicable, false to just disable them
- navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
- gotoCurrent: false, // True if today link goes back to current selection instead
- changeMonth: false, // True if month can be selected directly, false if only prev/next
- changeYear: false, // True if year can be selected directly, false if only prev/next
- yearRange: "c-10:c+10", // Range of years to display in drop-down,
- // either relative to today's year (-nn:+nn), relative to currently displayed year
- // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
- showOtherMonths: false, // True to show dates in other months, false to leave blank
- selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
- showWeek: false, // True to show week of the year, false to not show it
- calculateWeek: this.iso8601Week, // How to calculate the week of the year,
- // takes a Date and returns the number of the week for it
- shortYearCutoff: "+10", // Short year values < this are in the current century,
- // > this are in the previous century,
- // string value starting with "+" for current year + value
- minDate: null, // The earliest selectable date, or null for no limit
- maxDate: null, // The latest selectable date, or null for no limit
- duration: "fast", // Duration of display/closure
- beforeShowDay: null, // Function that takes a date and returns an array with
- // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
- // [2] = cell title (optional), e.g. $.datepicker.noWeekends
- beforeShow: null, // Function that takes an input field and
- // returns a set of custom settings for the date picker
- onSelect: null, // Define a callback function when a date is selected
- onChangeMonthYear: null, // Define a callback function when the month or year is changed
- onClose: null, // Define a callback function when the datepicker is closed
- numberOfMonths: 1, // Number of months to show at a time
- showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
- stepMonths: 1, // Number of months to step back/forward
- stepBigMonths: 12, // Number of months to step back/forward for the big links
- altField: "", // Selector for an alternate field to store selected dates into
- altFormat: "", // The date format to use for the alternate field
- constrainInput: true, // The input is constrained by the current date format
- showButtonPanel: false, // True to show button panel, false to not show it
- autoSize: false, // True to size the input for the date format, false to leave as is
- disabled: false // The initial disabled state
- };
- $.extend( this._defaults, this.regional[ "" ] );
- this.regional.en = $.extend( true, {}, this.regional[ "" ] );
- this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
- this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
-}
-
-$.extend( Datepicker.prototype, {
- /* Class name added to elements to indicate already configured with a date picker. */
- markerClassName: "hasDatepicker",
-
- //Keep track of the maximum number of rows displayed (see #7043)
- maxRows: 4,
-
- // TODO rename to "widget" when switching to widget factory
- _widgetDatepicker: function() {
- return this.dpDiv;
- },
-
- /* Override the default settings for all instances of the date picker.
- * @param settings object - the new settings to use as defaults (anonymous object)
- * @return the manager object
- */
- setDefaults: function( settings ) {
- datepicker_extendRemove( this._defaults, settings || {} );
- return this;
- },
-
- /* Attach the date picker to a jQuery selection.
- * @param target element - the target input field or division or span
- * @param settings object - the new settings to use for this date picker instance (anonymous)
- */
- _attachDatepicker: function( target, settings ) {
- var nodeName, inline, inst;
- nodeName = target.nodeName.toLowerCase();
- inline = ( nodeName === "div" || nodeName === "span" );
- if ( !target.id ) {
- this.uuid += 1;
- target.id = "dp" + this.uuid;
- }
- inst = this._newInst( $( target ), inline );
- inst.settings = $.extend( {}, settings || {} );
- if ( nodeName === "input" ) {
- this._connectDatepicker( target, inst );
- } else if ( inline ) {
- this._inlineDatepicker( target, inst );
- }
- },
-
- /* Create a new instance object. */
- _newInst: function( target, inline ) {
- var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
- return { id: id, input: target, // associated target
- selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
- drawMonth: 0, drawYear: 0, // month being drawn
- inline: inline, // is datepicker inline or not
- dpDiv: ( !inline ? this.dpDiv : // presentation div
- datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
- },
-
- /* Attach the date picker to an input field. */
- _connectDatepicker: function( target, inst ) {
- var input = $( target );
- inst.append = $( [] );
- inst.trigger = $( [] );
- if ( input.hasClass( this.markerClassName ) ) {
- return;
- }
- this._attachments( input, inst );
- input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
- on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
- this._autoSize( inst );
- $.data( target, "datepicker", inst );
-
- //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
- if ( inst.settings.disabled ) {
- this._disableDatepicker( target );
- }
- },
-
- /* Make attachments based on settings. */
- _attachments: function( input, inst ) {
- var showOn, buttonText, buttonImage,
- appendText = this._get( inst, "appendText" ),
- isRTL = this._get( inst, "isRTL" );
-
- if ( inst.append ) {
- inst.append.remove();
- }
- if ( appendText ) {
- inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
- input[ isRTL ? "before" : "after" ]( inst.append );
- }
-
- input.off( "focus", this._showDatepicker );
-
- if ( inst.trigger ) {
- inst.trigger.remove();
- }
-
- showOn = this._get( inst, "showOn" );
- if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
- input.on( "focus", this._showDatepicker );
- }
- if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
- buttonText = this._get( inst, "buttonText" );
- buttonImage = this._get( inst, "buttonImage" );
- inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
- $( "<img/>" ).addClass( this._triggerClass ).
- attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
- $( "<button type='button'></button>" ).addClass( this._triggerClass ).
- html( !buttonImage ? buttonText : $( "<img/>" ).attr(
- { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
- input[ isRTL ? "before" : "after" ]( inst.trigger );
- inst.trigger.on( "click", function() {
- if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
- $.datepicker._hideDatepicker();
- } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
- $.datepicker._hideDatepicker();
- $.datepicker._showDatepicker( input[ 0 ] );
- } else {
- $.datepicker._showDatepicker( input[ 0 ] );
- }
- return false;
- } );
- }
- },
-
- /* Apply the maximum length for the date format. */
- _autoSize: function( inst ) {
- if ( this._get( inst, "autoSize" ) && !inst.inline ) {
- var findMax, max, maxI, i,
- date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
- dateFormat = this._get( inst, "dateFormat" );
-
- if ( dateFormat.match( /[DM]/ ) ) {
- findMax = function( names ) {
- max = 0;
- maxI = 0;
- for ( i = 0; i < names.length; i++ ) {
- if ( names[ i ].length > max ) {
- max = names[ i ].length;
- maxI = i;
- }
- }
- return maxI;
- };
- date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
- "monthNames" : "monthNamesShort" ) ) ) );
- date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
- "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
- }
- inst.input.attr( "size", this._formatDate( inst, date ).length );
- }
- },
-
- /* Attach an inline date picker to a div. */
- _inlineDatepicker: function( target, inst ) {
- var divSpan = $( target );
- if ( divSpan.hasClass( this.markerClassName ) ) {
- return;
- }
- divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
- $.data( target, "datepicker", inst );
- this._setDate( inst, this._getDefaultDate( inst ), true );
- this._updateDatepicker( inst );
- this._updateAlternate( inst );
-
- //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
- if ( inst.settings.disabled ) {
- this._disableDatepicker( target );
- }
-
- // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
- // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
- inst.dpDiv.css( "display", "block" );
- },
-
- /* Pop-up the date picker in a "dialog" box.
- * @param input element - ignored
- * @param date string or Date - the initial date to display
- * @param onSelect function - the function to call when a date is selected
- * @param settings object - update the dialog date picker instance's settings (anonymous object)
- * @param pos int[2] - coordinates for the dialog's position within the screen or
- * event - with x/y coordinates or
- * leave empty for default (screen centre)
- * @return the manager object
- */
- _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
- var id, browserWidth, browserHeight, scrollX, scrollY,
- inst = this._dialogInst; // internal instance
-
- if ( !inst ) {
- this.uuid += 1;
- id = "dp" + this.uuid;
- this._dialogInput = $( "<input type='text' id='" + id +
- "' style='position: absolute; top: -100px; width: 0px;'/>" );
- this._dialogInput.on( "keydown", this._doKeyDown );
- $( "body" ).append( this._dialogInput );
- inst = this._dialogInst = this._newInst( this._dialogInput, false );
- inst.settings = {};
- $.data( this._dialogInput[ 0 ], "datepicker", inst );
- }
- datepicker_extendRemove( inst.settings, settings || {} );
- date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
- this._dialogInput.val( date );
-
- this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
- if ( !this._pos ) {
- browserWidth = document.documentElement.clientWidth;
- browserHeight = document.documentElement.clientHeight;
- scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- scrollY = document.documentElement.scrollTop || document.body.scrollTop;
- this._pos = // should use actual width/height below
- [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
- }
-
- // Move input on screen for focus, but hidden behind dialog
- this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
- inst.settings.onSelect = onSelect;
- this._inDialog = true;
- this.dpDiv.addClass( this._dialogClass );
- this._showDatepicker( this._dialogInput[ 0 ] );
- if ( $.blockUI ) {
- $.blockUI( this.dpDiv );
- }
- $.data( this._dialogInput[ 0 ], "datepicker", inst );
- return this;
- },
-
- /* Detach a datepicker from its control.
- * @param target element - the target input field or division or span
- */
- _destroyDatepicker: function( target ) {
- var nodeName,
- $target = $( target ),
- inst = $.data( target, "datepicker" );
-
- if ( !$target.hasClass( this.markerClassName ) ) {
- return;
- }
-
- nodeName = target.nodeName.toLowerCase();
- $.removeData( target, "datepicker" );
- if ( nodeName === "input" ) {
- inst.append.remove();
- inst.trigger.remove();
- $target.removeClass( this.markerClassName ).
- off( "focus", this._showDatepicker ).
- off( "keydown", this._doKeyDown ).
- off( "keypress", this._doKeyPress ).
- off( "keyup", this._doKeyUp );
- } else if ( nodeName === "div" || nodeName === "span" ) {
- $target.removeClass( this.markerClassName ).empty();
- }
-
- if ( datepicker_instActive === inst ) {
- datepicker_instActive = null;
- }
- },
-
- /* Enable the date picker to a jQuery selection.
- * @param target element - the target input field or division or span
- */
- _enableDatepicker: function( target ) {
- var nodeName, inline,
- $target = $( target ),
- inst = $.data( target, "datepicker" );
-
- if ( !$target.hasClass( this.markerClassName ) ) {
- return;
- }
-
- nodeName = target.nodeName.toLowerCase();
- if ( nodeName === "input" ) {
- target.disabled = false;
- inst.trigger.filter( "button" ).
- each( function() { this.disabled = false; } ).end().
- filter( "img" ).css( { opacity: "1.0", cursor: "" } );
- } else if ( nodeName === "div" || nodeName === "span" ) {
- inline = $target.children( "." + this._inlineClass );
- inline.children().removeClass( "ui-state-disabled" );
- inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
- prop( "disabled", false );
- }
- this._disabledInputs = $.map( this._disabledInputs,
- function( value ) { return ( value === target ? null : value ); } ); // delete entry
- },
-
- /* Disable the date picker to a jQuery selection.
- * @param target element - the target input field or division or span
- */
- _disableDatepicker: function( target ) {
- var nodeName, inline,
- $target = $( target ),
- inst = $.data( target, "datepicker" );
-
- if ( !$target.hasClass( this.markerClassName ) ) {
- return;
- }
-
- nodeName = target.nodeName.toLowerCase();
- if ( nodeName === "input" ) {
- target.disabled = true;
- inst.trigger.filter( "button" ).
- each( function() { this.disabled = true; } ).end().
- filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
- } else if ( nodeName === "div" || nodeName === "span" ) {
- inline = $target.children( "." + this._inlineClass );
- inline.children().addClass( "ui-state-disabled" );
- inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
- prop( "disabled", true );
- }
- this._disabledInputs = $.map( this._disabledInputs,
- function( value ) { return ( value === target ? null : value ); } ); // delete entry
- this._disabledInputs[ this._disabledInputs.length ] = target;
- },
-
- /* Is the first field in a jQuery collection disabled as a datepicker?
- * @param target element - the target input field or division or span
- * @return boolean - true if disabled, false if enabled
- */
- _isDisabledDatepicker: function( target ) {
- if ( !target ) {
- return false;
- }
- for ( var i = 0; i < this._disabledInputs.length; i++ ) {
- if ( this._disabledInputs[ i ] === target ) {
- return true;
- }
- }
- return false;
- },
-
- /* Retrieve the instance data for the target control.
- * @param target element - the target input field or division or span
- * @return object - the associated instance data
- * @throws error if a jQuery problem getting data
- */
- _getInst: function( target ) {
- try {
- return $.data( target, "datepicker" );
- }
- catch ( err ) {
- throw "Missing instance data for this datepicker";
- }
- },
-
- /* Update or retrieve the settings for a date picker attached to an input field or division.
- * @param target element - the target input field or division or span
- * @param name object - the new settings to update or
- * string - the name of the setting to change or retrieve,
- * when retrieving also "all" for all instance settings or
- * "defaults" for all global defaults
- * @param value any - the new value for the setting
- * (omit if above is an object or to retrieve a value)
- */
- _optionDatepicker: function( target, name, value ) {
- var settings, date, minDate, maxDate,
- inst = this._getInst( target );
-
- if ( arguments.length === 2 && typeof name === "string" ) {
- return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
- ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
- this._get( inst, name ) ) : null ) );
- }
-
- settings = name || {};
- if ( typeof name === "string" ) {
- settings = {};
- settings[ name ] = value;
- }
-
- if ( inst ) {
- if ( this._curInst === inst ) {
- this._hideDatepicker();
- }
-
- date = this._getDateDatepicker( target, true );
- minDate = this._getMinMaxDate( inst, "min" );
- maxDate = this._getMinMaxDate( inst, "max" );
- datepicker_extendRemove( inst.settings, settings );
-
- // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
- if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
- inst.settings.minDate = this._formatDate( inst, minDate );
- }
- if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
- inst.settings.maxDate = this._formatDate( inst, maxDate );
- }
- if ( "disabled" in settings ) {
- if ( settings.disabled ) {
- this._disableDatepicker( target );
- } else {
- this._enableDatepicker( target );
- }
- }
- this._attachments( $( target ), inst );
- this._autoSize( inst );
- this._setDate( inst, date );
- this._updateAlternate( inst );
- this._updateDatepicker( inst );
- }
- },
-
- // Change method deprecated
- _changeDatepicker: function( target, name, value ) {
- this._optionDatepicker( target, name, value );
- },
-
- /* Redraw the date picker attached to an input field or division.
- * @param target element - the target input field or division or span
- */
- _refreshDatepicker: function( target ) {
- var inst = this._getInst( target );
- if ( inst ) {
- this._updateDatepicker( inst );
- }
- },
-
- /* Set the dates for a jQuery selection.
- * @param target element - the target input field or division or span
- * @param date Date - the new date
- */
- _setDateDatepicker: function( target, date ) {
- var inst = this._getInst( target );
- if ( inst ) {
- this._setDate( inst, date );
- this._updateDatepicker( inst );
- this._updateAlternate( inst );
- }
- },
-
- /* Get the date(s) for the first entry in a jQuery selection.
- * @param target element - the target input field or division or span
- * @param noDefault boolean - true if no default date is to be used
- * @return Date - the current date
- */
- _getDateDatepicker: function( target, noDefault ) {
- var inst = this._getInst( target );
- if ( inst && !inst.inline ) {
- this._setDateFromField( inst, noDefault );
- }
- return ( inst ? this._getDate( inst ) : null );
- },
-
- /* Handle keystrokes. */
- _doKeyDown: function( event ) {
- var onSelect, dateStr, sel,
- inst = $.datepicker._getInst( event.target ),
- handled = true,
- isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
-
- inst._keyEvent = true;
- if ( $.datepicker._datepickerShowing ) {
- switch ( event.keyCode ) {
- case 9: $.datepicker._hideDatepicker();
- handled = false;
- break; // hide on tab out
- case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
- $.datepicker._currentClass + ")", inst.dpDiv );
- if ( sel[ 0 ] ) {
- $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
- }
-
- onSelect = $.datepicker._get( inst, "onSelect" );
- if ( onSelect ) {
- dateStr = $.datepicker._formatDate( inst );
-
- // Trigger custom callback
- onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
- } else {
- $.datepicker._hideDatepicker();
- }
-
- return false; // don't submit the form
- case 27: $.datepicker._hideDatepicker();
- break; // hide on escape
- case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
- -$.datepicker._get( inst, "stepBigMonths" ) :
- -$.datepicker._get( inst, "stepMonths" ) ), "M" );
- break; // previous month/year on page up/+ ctrl
- case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
- +$.datepicker._get( inst, "stepBigMonths" ) :
- +$.datepicker._get( inst, "stepMonths" ) ), "M" );
- break; // next month/year on page down/+ ctrl
- case 35: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._clearDate( event.target );
- }
- handled = event.ctrlKey || event.metaKey;
- break; // clear on ctrl or command +end
- case 36: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._gotoToday( event.target );
- }
- handled = event.ctrlKey || event.metaKey;
- break; // current on ctrl or command +home
- case 37: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
- }
- handled = event.ctrlKey || event.metaKey;
-
- // -1 day on ctrl or command +left
- if ( event.originalEvent.altKey ) {
- $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
- -$.datepicker._get( inst, "stepBigMonths" ) :
- -$.datepicker._get( inst, "stepMonths" ) ), "M" );
- }
-
- // next month/year on alt +left on Mac
- break;
- case 38: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._adjustDate( event.target, -7, "D" );
- }
- handled = event.ctrlKey || event.metaKey;
- break; // -1 week on ctrl or command +up
- case 39: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
- }
- handled = event.ctrlKey || event.metaKey;
-
- // +1 day on ctrl or command +right
- if ( event.originalEvent.altKey ) {
- $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
- +$.datepicker._get( inst, "stepBigMonths" ) :
- +$.datepicker._get( inst, "stepMonths" ) ), "M" );
- }
-
- // next month/year on alt +right
- break;
- case 40: if ( event.ctrlKey || event.metaKey ) {
- $.datepicker._adjustDate( event.target, +7, "D" );
- }
- handled = event.ctrlKey || event.metaKey;
- break; // +1 week on ctrl or command +down
- default: handled = false;
- }
- } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
- $.datepicker._showDatepicker( this );
- } else {
- handled = false;
- }
-
- if ( handled ) {
- event.preventDefault();
- event.stopPropagation();
- }
- },
-
- /* Filter entered characters - based on date format. */
- _doKeyPress: function( event ) {
- var chars, chr,
- inst = $.datepicker._getInst( event.target );
-
- if ( $.datepicker._get( inst, "constrainInput" ) ) {
- chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
- chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
- return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
- }
- },
-
- /* Synchronise manual entry and field/alternate field. */
- _doKeyUp: function( event ) {
- var date,
- inst = $.datepicker._getInst( event.target );
-
- if ( inst.input.val() !== inst.lastVal ) {
- try {
- date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
- ( inst.input ? inst.input.val() : null ),
- $.datepicker._getFormatConfig( inst ) );
-
- if ( date ) { // only if valid
- $.datepicker._setDateFromField( inst );
- $.datepicker._updateAlternate( inst );
- $.datepicker._updateDatepicker( inst );
- }
- }
- catch ( err ) {
- }
- }
- return true;
- },
-
- /* Pop-up the date picker for a given input field.
- * If false returned from beforeShow event handler do not show.
- * @param input element - the input field attached to the date picker or
- * event - if triggered by focus
- */
- _showDatepicker: function( input ) {
- input = input.target || input;
- if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
- input = $( "input", input.parentNode )[ 0 ];
- }
-
- if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
- return;
- }
-
- var inst, beforeShow, beforeShowSettings, isFixed,
- offset, showAnim, duration;
-
- inst = $.datepicker._getInst( input );
- if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
- $.datepicker._curInst.dpDiv.stop( true, true );
- if ( inst && $.datepicker._datepickerShowing ) {
- $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
- }
- }
-
- beforeShow = $.datepicker._get( inst, "beforeShow" );
- beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
- if ( beforeShowSettings === false ) {
- return;
- }
- datepicker_extendRemove( inst.settings, beforeShowSettings );
-
- inst.lastVal = null;
- $.datepicker._lastInput = input;
- $.datepicker._setDateFromField( inst );
-
- if ( $.datepicker._inDialog ) { // hide cursor
- input.value = "";
- }
- if ( !$.datepicker._pos ) { // position below input
- $.datepicker._pos = $.datepicker._findPos( input );
- $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
- }
-
- isFixed = false;
- $( input ).parents().each( function() {
- isFixed |= $( this ).css( "position" ) === "fixed";
- return !isFixed;
- } );
-
- offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
- $.datepicker._pos = null;
-
- //to avoid flashes on Firefox
- inst.dpDiv.empty();
-
- // determine sizing offscreen
- inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
- $.datepicker._updateDatepicker( inst );
-
- // fix width for dynamic number of date pickers
- // and adjust position before showing
- offset = $.datepicker._checkOffset( inst, offset, isFixed );
- inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
- "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
- left: offset.left + "px", top: offset.top + "px" } );
-
- if ( !inst.inline ) {
- showAnim = $.datepicker._get( inst, "showAnim" );
- duration = $.datepicker._get( inst, "duration" );
- inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
- $.datepicker._datepickerShowing = true;
-
- if ( $.effects && $.effects.effect[ showAnim ] ) {
- inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
- } else {
- inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
- }
-
- if ( $.datepicker._shouldFocusInput( inst ) ) {
- inst.input.trigger( "focus" );
- }
-
- $.datepicker._curInst = inst;
- }
- },
-
- /* Generate the date picker content. */
- _updateDatepicker: function( inst ) {
- this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
- datepicker_instActive = inst; // for delegate hover events
- inst.dpDiv.empty().append( this._generateHTML( inst ) );
- this._attachHandlers( inst );
-
- var origyearshtml,
- numMonths = this._getNumberOfMonths( inst ),
- cols = numMonths[ 1 ],
- width = 17,
- activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
-
- if ( activeCell.length > 0 ) {
- datepicker_handleMouseover.apply( activeCell.get( 0 ) );
- }
-
- inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
- if ( cols > 1 ) {
- inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
- }
- inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
- "Class" ]( "ui-datepicker-multi" );
- inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
- "Class" ]( "ui-datepicker-rtl" );
-
- if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
- inst.input.trigger( "focus" );
- }
-
- // Deffered render of the years select (to avoid flashes on Firefox)
- if ( inst.yearshtml ) {
- origyearshtml = inst.yearshtml;
- setTimeout( function() {
-
- //assure that inst.yearshtml didn't change.
- if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
- inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
- }
- origyearshtml = inst.yearshtml = null;
- }, 0 );
- }
- },
-
- // #6694 - don't focus the input if it's already focused
- // this breaks the change event in IE
- // Support: IE and jQuery <1.9
- _shouldFocusInput: function( inst ) {
- return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
- },
-
- /* Check positioning to remain on screen. */
- _checkOffset: function( inst, offset, isFixed ) {
- var dpWidth = inst.dpDiv.outerWidth(),
- dpHeight = inst.dpDiv.outerHeight(),
- inputWidth = inst.input ? inst.input.outerWidth() : 0,
- inputHeight = inst.input ? inst.input.outerHeight() : 0,
- viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
- viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
-
- offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
- offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
- offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
-
- // Now check if datepicker is showing outside window viewport - move to a better place if so.
- offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
- Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
- offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
- Math.abs( dpHeight + inputHeight ) : 0 );
-
- return offset;
- },
-
- /* Find an object's position on the screen. */
- _findPos: function( obj ) {
- var position,
- inst = this._getInst( obj ),
- isRTL = this._get( inst, "isRTL" );
-
- while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
- obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
- }
-
- position = $( obj ).offset();
- return [ position.left, position.top ];
- },
-
- /* Hide the date picker from view.
- * @param input element - the input field attached to the date picker
- */
- _hideDatepicker: function( input ) {
- var showAnim, duration, postProcess, onClose,
- inst = this._curInst;
-
- if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
- return;
- }
-
- if ( this._datepickerShowing ) {
- showAnim = this._get( inst, "showAnim" );
- duration = this._get( inst, "duration" );
- postProcess = function() {
- $.datepicker._tidyDialog( inst );
- };
-
- // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
- if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
- inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
- } else {
- inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
- ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
- }
-
- if ( !showAnim ) {
- postProcess();
- }
- this._datepickerShowing = false;
-
- onClose = this._get( inst, "onClose" );
- if ( onClose ) {
- onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
- }
-
- this._lastInput = null;
- if ( this._inDialog ) {
- this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
- if ( $.blockUI ) {
- $.unblockUI();
- $( "body" ).append( this.dpDiv );
- }
- }
- this._inDialog = false;
- }
- },
-
- /* Tidy up after a dialog display. */
- _tidyDialog: function( inst ) {
- inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
- },
-
- /* Close date picker if clicked elsewhere. */
- _checkExternalClick: function( event ) {
- if ( !$.datepicker._curInst ) {
- return;
- }
-
- var $target = $( event.target ),
- inst = $.datepicker._getInst( $target[ 0 ] );
-
- if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
- $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
- !$target.hasClass( $.datepicker.markerClassName ) &&
- !$target.closest( "." + $.datepicker._triggerClass ).length &&
- $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
- ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
- $.datepicker._hideDatepicker();
- }
- },
-
- /* Adjust one of the date sub-fields. */
- _adjustDate: function( id, offset, period ) {
- var target = $( id ),
- inst = this._getInst( target[ 0 ] );
-
- if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
- return;
- }
- this._adjustInstDate( inst, offset +
- ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
- period );
- this._updateDatepicker( inst );
- },
-
- /* Action for current link. */
- _gotoToday: function( id ) {
- var date,
- target = $( id ),
- inst = this._getInst( target[ 0 ] );
-
- if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
- inst.selectedDay = inst.currentDay;
- inst.drawMonth = inst.selectedMonth = inst.currentMonth;
- inst.drawYear = inst.selectedYear = inst.currentYear;
- } else {
- date = new Date();
- inst.selectedDay = date.getDate();
- inst.drawMonth = inst.selectedMonth = date.getMonth();
- inst.drawYear = inst.selectedYear = date.getFullYear();
- }
- this._notifyChange( inst );
- this._adjustDate( target );
- },
-
- /* Action for selecting a new month/year. */
- _selectMonthYear: function( id, select, period ) {
- var target = $( id ),
- inst = this._getInst( target[ 0 ] );
-
- inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
- inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
- parseInt( select.options[ select.selectedIndex ].value, 10 );
-
- this._notifyChange( inst );
- this._adjustDate( target );
- },
-
- /* Action for selecting a day. */
- _selectDay: function( id, month, year, td ) {
- var inst,
- target = $( id );
-
- if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
- return;
- }
-
- inst = this._getInst( target[ 0 ] );
- inst.selectedDay = inst.currentDay = $( "a", td ).html();
- inst.selectedMonth = inst.currentMonth = month;
- inst.selectedYear = inst.currentYear = year;
- this._selectDate( id, this._formatDate( inst,
- inst.currentDay, inst.currentMonth, inst.currentYear ) );
- },
-
- /* Erase the input field and hide the date picker. */
- _clearDate: function( id ) {
- var target = $( id );
- this._selectDate( target, "" );
- },
-
- /* Update the input field with the selected date. */
- _selectDate: function( id, dateStr ) {
- var onSelect,
- target = $( id ),
- inst = this._getInst( target[ 0 ] );
-
- dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
- if ( inst.input ) {
- inst.input.val( dateStr );
- }
- this._updateAlternate( inst );
-
- onSelect = this._get( inst, "onSelect" );
- if ( onSelect ) {
- onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
- } else if ( inst.input ) {
- inst.input.trigger( "change" ); // fire the change event
- }
-
- if ( inst.inline ) {
- this._updateDatepicker( inst );
- } else {
- this._hideDatepicker();
- this._lastInput = inst.input[ 0 ];
- if ( typeof( inst.input[ 0 ] ) !== "object" ) {
- inst.input.trigger( "focus" ); // restore focus
- }
- this._lastInput = null;
- }
- },
-
- /* Update any alternate field to synchronise with the main field. */
- _updateAlternate: function( inst ) {
- var altFormat, date, dateStr,
- altField = this._get( inst, "altField" );
-
- if ( altField ) { // update alternate field too
- altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
- date = this._getDate( inst );
- dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
- $( altField ).val( dateStr );
- }
- },
-
- /* Set as beforeShowDay function to prevent selection of weekends.
- * @param date Date - the date to customise
- * @return [boolean, string] - is this date selectable?, what is its CSS class?
- */
- noWeekends: function( date ) {
- var day = date.getDay();
- return [ ( day > 0 && day < 6 ), "" ];
- },
-
- /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
- * @param date Date - the date to get the week for
- * @return number - the number of the week within the year that contains this date
- */
- iso8601Week: function( date ) {
- var time,
- checkDate = new Date( date.getTime() );
-
- // Find Thursday of this week starting on Monday
- checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
-
- time = checkDate.getTime();
- checkDate.setMonth( 0 ); // Compare with Jan 1
- checkDate.setDate( 1 );
- return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
- },
-
- /* Parse a string value into a date object.
- * See formatDate below for the possible formats.
- *
- * @param format string - the expected format of the date
- * @param value string - the date in the above format
- * @param settings Object - attributes include:
- * shortYearCutoff number - the cutoff year for determining the century (optional)
- * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
- * dayNames string[7] - names of the days from Sunday (optional)
- * monthNamesShort string[12] - abbreviated names of the months (optional)
- * monthNames string[12] - names of the months (optional)
- * @return Date - the extracted date value or null if value is blank
- */
- parseDate: function( format, value, settings ) {
- if ( format == null || value == null ) {
- throw "Invalid arguments";
- }
-
- value = ( typeof value === "object" ? value.toString() : value + "" );
- if ( value === "" ) {
- return null;
- }
-
- var iFormat, dim, extra,
- iValue = 0,
- shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
- shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
- new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
- dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
- dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
- monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
- monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
- year = -1,
- month = -1,
- day = -1,
- doy = -1,
- literal = false,
- date,
-
- // Check whether a format character is doubled
- lookAhead = function( match ) {
- var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
- if ( matches ) {
- iFormat++;
- }
- return matches;
- },
-
- // Extract a number from the string value
- getNumber = function( match ) {
- var isDoubled = lookAhead( match ),
- size = ( match === "@" ? 14 : ( match === "!" ? 20 :
- ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
- minSize = ( match === "y" ? size : 1 ),
- digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
- num = value.substring( iValue ).match( digits );
- if ( !num ) {
- throw "Missing number at position " + iValue;
- }
- iValue += num[ 0 ].length;
- return parseInt( num[ 0 ], 10 );
- },
-
- // Extract a name from the string value and convert to an index
- getName = function( match, shortNames, longNames ) {
- var index = -1,
- names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
- return [ [ k, v ] ];
- } ).sort( function( a, b ) {
- return -( a[ 1 ].length - b[ 1 ].length );
- } );
-
- $.each( names, function( i, pair ) {
- var name = pair[ 1 ];
- if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
- index = pair[ 0 ];
- iValue += name.length;
- return false;
- }
- } );
- if ( index !== -1 ) {
- return index + 1;
- } else {
- throw "Unknown name at position " + iValue;
- }
- },
-
- // Confirm that a literal character matches the string value
- checkLiteral = function() {
- if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
- throw "Unexpected literal at position " + iValue;
- }
- iValue++;
- };
-
- for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
- if ( literal ) {
- if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
- literal = false;
- } else {
- checkLiteral();
- }
- } else {
- switch ( format.charAt( iFormat ) ) {
- case "d":
- day = getNumber( "d" );
- break;
- case "D":
- getName( "D", dayNamesShort, dayNames );
- break;
- case "o":
- doy = getNumber( "o" );
- break;
- case "m":
- month = getNumber( "m" );
- break;
- case "M":
- month = getName( "M", monthNamesShort, monthNames );
- break;
- case "y":
- year = getNumber( "y" );
- break;
- case "@":
- date = new Date( getNumber( "@" ) );
- year = date.getFullYear();
- month = date.getMonth() + 1;
- day = date.getDate();
- break;
- case "!":
- date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
- year = date.getFullYear();
- month = date.getMonth() + 1;
- day = date.getDate();
- break;
- case "'":
- if ( lookAhead( "'" ) ) {
- checkLiteral();
- } else {
- literal = true;
- }
- break;
- default:
- checkLiteral();
- }
- }
- }
-
- if ( iValue < value.length ) {
- extra = value.substr( iValue );
- if ( !/^\s+/.test( extra ) ) {
- throw "Extra/unparsed characters found in date: " + extra;
- }
- }
-
- if ( year === -1 ) {
- year = new Date().getFullYear();
- } else if ( year < 100 ) {
- year += new Date().getFullYear() - new Date().getFullYear() % 100 +
- ( year <= shortYearCutoff ? 0 : -100 );
- }
-
- if ( doy > -1 ) {
- month = 1;
- day = doy;
- do {
- dim = this._getDaysInMonth( year, month - 1 );
- if ( day <= dim ) {
- break;
- }
- month++;
- day -= dim;
- } while ( true );
- }
-
- date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
- if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
- throw "Invalid date"; // E.g. 31/02/00
- }
- return date;
- },
-
- /* Standard date formats. */
- ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
- COOKIE: "D, dd M yy",
- ISO_8601: "yy-mm-dd",
- RFC_822: "D, d M y",
- RFC_850: "DD, dd-M-y",
- RFC_1036: "D, d M y",
- RFC_1123: "D, d M yy",
- RFC_2822: "D, d M yy",
- RSS: "D, d M y", // RFC 822
- TICKS: "!",
- TIMESTAMP: "@",
- W3C: "yy-mm-dd", // ISO 8601
-
- _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
- Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
-
- /* Format a date object into a string value.
- * The format can be combinations of the following:
- * d - day of month (no leading zero)
- * dd - day of month (two digit)
- * o - day of year (no leading zeros)
- * oo - day of year (three digit)
- * D - day name short
- * DD - day name long
- * m - month of year (no leading zero)
- * mm - month of year (two digit)
- * M - month name short
- * MM - month name long
- * y - year (two digit)
- * yy - year (four digit)
- * @ - Unix timestamp (ms since 01/01/1970)
- * ! - Windows ticks (100ns since 01/01/0001)
- * "..." - literal text
- * '' - single quote
- *
- * @param format string - the desired format of the date
- * @param date Date - the date value to format
- * @param settings Object - attributes include:
- * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
- * dayNames string[7] - names of the days from Sunday (optional)
- * monthNamesShort string[12] - abbreviated names of the months (optional)
- * monthNames string[12] - names of the months (optional)
- * @return string - the date in the above format
- */
- formatDate: function( format, date, settings ) {
- if ( !date ) {
- return "";
- }
-
- var iFormat,
- dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
- dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
- monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
- monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
-
- // Check whether a format character is doubled
- lookAhead = function( match ) {
- var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
- if ( matches ) {
- iFormat++;
- }
- return matches;
- },
-
- // Format a number, with leading zero if necessary
- formatNumber = function( match, value, len ) {
- var num = "" + value;
- if ( lookAhead( match ) ) {
- while ( num.length < len ) {
- num = "0" + num;
- }
- }
- return num;
- },
-
- // Format a name, short or long as requested
- formatName = function( match, value, shortNames, longNames ) {
- return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
- },
- output = "",
- literal = false;
-
- if ( date ) {
- for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
- if ( literal ) {
- if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
- literal = false;
- } else {
- output += format.charAt( iFormat );
- }
- } else {
- switch ( format.charAt( iFormat ) ) {
- case "d":
- output += formatNumber( "d", date.getDate(), 2 );
- break;
- case "D":
- output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
- break;
- case "o":
- output += formatNumber( "o",
- Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
- break;
- case "m":
- output += formatNumber( "m", date.getMonth() + 1, 2 );
- break;
- case "M":
- output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
- break;
- case "y":
- output += ( lookAhead( "y" ) ? date.getFullYear() :
- ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
- break;
- case "@":
- output += date.getTime();
- break;
- case "!":
- output += date.getTime() * 10000 + this._ticksTo1970;
- break;
- case "'":
- if ( lookAhead( "'" ) ) {
- output += "'";
- } else {
- literal = true;
- }
- break;
- default:
- output += format.charAt( iFormat );
- }
- }
- }
- }
- return output;
- },
-
- /* Extract all possible characters from the date format. */
- _possibleChars: function( format ) {
- var iFormat,
- chars = "",
- literal = false,
-
- // Check whether a format character is doubled
- lookAhead = function( match ) {
- var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
- if ( matches ) {
- iFormat++;
- }
- return matches;
- };
-
- for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
- if ( literal ) {
- if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
- literal = false;
- } else {
- chars += format.charAt( iFormat );
- }
- } else {
- switch ( format.charAt( iFormat ) ) {
- case "d": case "m": case "y": case "@":
- chars += "0123456789";
- break;
- case "D": case "M":
- return null; // Accept anything
- case "'":
- if ( lookAhead( "'" ) ) {
- chars += "'";
- } else {
- literal = true;
- }
- break;
- default:
- chars += format.charAt( iFormat );
- }
- }
- }
- return chars;
- },
-
- /* Get a setting value, defaulting if necessary. */
- _get: function( inst, name ) {
- return inst.settings[ name ] !== undefined ?
- inst.settings[ name ] : this._defaults[ name ];
- },
-
- /* Parse existing date and initialise date picker. */
- _setDateFromField: function( inst, noDefault ) {
- if ( inst.input.val() === inst.lastVal ) {
- return;
- }
-
- var dateFormat = this._get( inst, "dateFormat" ),
- dates = inst.lastVal = inst.input ? inst.input.val() : null,
- defaultDate = this._getDefaultDate( inst ),
- date = defaultDate,
- settings = this._getFormatConfig( inst );
-
- try {
- date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
- } catch ( event ) {
- dates = ( noDefault ? "" : dates );
- }
- inst.selectedDay = date.getDate();
- inst.drawMonth = inst.selectedMonth = date.getMonth();
- inst.drawYear = inst.selectedYear = date.getFullYear();
- inst.currentDay = ( dates ? date.getDate() : 0 );
- inst.currentMonth = ( dates ? date.getMonth() : 0 );
- inst.currentYear = ( dates ? date.getFullYear() : 0 );
- this._adjustInstDate( inst );
- },
-
- /* Retrieve the default date shown on opening. */
- _getDefaultDate: function( inst ) {
- return this._restrictMinMax( inst,
- this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
- },
-
- /* A date may be specified as an exact value or a relative one. */
- _determineDate: function( inst, date, defaultDate ) {
- var offsetNumeric = function( offset ) {
- var date = new Date();
- date.setDate( date.getDate() + offset );
- return date;
- },
- offsetString = function( offset ) {
- try {
- return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
- offset, $.datepicker._getFormatConfig( inst ) );
- }
- catch ( e ) {
-
- // Ignore
- }
-
- var date = ( offset.toLowerCase().match( /^c/ ) ?
- $.datepicker._getDate( inst ) : null ) || new Date(),
- year = date.getFullYear(),
- month = date.getMonth(),
- day = date.getDate(),
- pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
- matches = pattern.exec( offset );
-
- while ( matches ) {
- switch ( matches[ 2 ] || "d" ) {
- case "d" : case "D" :
- day += parseInt( matches[ 1 ], 10 ); break;
- case "w" : case "W" :
- day += parseInt( matches[ 1 ], 10 ) * 7; break;
- case "m" : case "M" :
- month += parseInt( matches[ 1 ], 10 );
- day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
- break;
- case "y": case "Y" :
- year += parseInt( matches[ 1 ], 10 );
- day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
- break;
- }
- matches = pattern.exec( offset );
- }
- return new Date( year, month, day );
- },
- newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
- ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
-
- newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
- if ( newDate ) {
- newDate.setHours( 0 );
- newDate.setMinutes( 0 );
- newDate.setSeconds( 0 );
- newDate.setMilliseconds( 0 );
- }
- return this._daylightSavingAdjust( newDate );
- },
-
- /* Handle switch to/from daylight saving.
- * Hours may be non-zero on daylight saving cut-over:
- * > 12 when midnight changeover, but then cannot generate
- * midnight datetime, so jump to 1AM, otherwise reset.
- * @param date (Date) the date to check
- * @return (Date) the corrected date
- */
- _daylightSavingAdjust: function( date ) {
- if ( !date ) {
- return null;
- }
- date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
- return date;
- },
-
- /* Set the date(s) directly. */
- _setDate: function( inst, date, noChange ) {
- var clear = !date,
- origMonth = inst.selectedMonth,
- origYear = inst.selectedYear,
- newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
-
- inst.selectedDay = inst.currentDay = newDate.getDate();
- inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
- inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
- if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
- this._notifyChange( inst );
- }
- this._adjustInstDate( inst );
- if ( inst.input ) {
- inst.input.val( clear ? "" : this._formatDate( inst ) );
- }
- },
-
- /* Retrieve the date(s) directly. */
- _getDate: function( inst ) {
- var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
- this._daylightSavingAdjust( new Date(
- inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
- return startDate;
- },
-
- /* Attach the onxxx handlers. These are declared statically so
- * they work with static code transformers like Caja.
- */
- _attachHandlers: function( inst ) {
- var stepMonths = this._get( inst, "stepMonths" ),
- id = "#" + inst.id.replace( /\\\\/g, "\\" );
- inst.dpDiv.find( "[data-handler]" ).map( function() {
- var handler = {
- prev: function() {
- $.datepicker._adjustDate( id, -stepMonths, "M" );
- },
- next: function() {
- $.datepicker._adjustDate( id, +stepMonths, "M" );
- },
- hide: function() {
- $.datepicker._hideDatepicker();
- },
- today: function() {
- $.datepicker._gotoToday( id );
- },
- selectDay: function() {
- $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
- return false;
- },
- selectMonth: function() {
- $.datepicker._selectMonthYear( id, this, "M" );
- return false;
- },
- selectYear: function() {
- $.datepicker._selectMonthYear( id, this, "Y" );
- return false;
- }
- };
- $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
- } );
- },
-
- /* Generate the HTML for the current state of the date picker. */
- _generateHTML: function( inst ) {
- var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
- controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
- monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
- selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
- cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
- printDate, dRow, tbody, daySettings, otherMonth, unselectable,
- tempDate = new Date(),
- today = this._daylightSavingAdjust(
- new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
- isRTL = this._get( inst, "isRTL" ),
- showButtonPanel = this._get( inst, "showButtonPanel" ),
- hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
- navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
- numMonths = this._getNumberOfMonths( inst ),
- showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
- stepMonths = this._get( inst, "stepMonths" ),
- isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
- currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
- new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
- minDate = this._getMinMaxDate( inst, "min" ),
- maxDate = this._getMinMaxDate( inst, "max" ),
- drawMonth = inst.drawMonth - showCurrentAtPos,
- drawYear = inst.drawYear;
-
- if ( drawMonth < 0 ) {
- drawMonth += 12;
- drawYear--;
- }
- if ( maxDate ) {
- maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
- maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
- maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
- while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
- drawMonth--;
- if ( drawMonth < 0 ) {
- drawMonth = 11;
- drawYear--;
- }
- }
- }
- inst.drawMonth = drawMonth;
- inst.drawYear = drawYear;
-
- prevText = this._get( inst, "prevText" );
- prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
- this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
- this._getFormatConfig( inst ) ) );
-
- prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
- "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
- " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
- ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) );
-
- nextText = this._get( inst, "nextText" );
- nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
- this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
- this._getFormatConfig( inst ) ) );
-
- next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
- "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
- " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
- ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) );
-
- currentText = this._get( inst, "currentText" );
- gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
- currentText = ( !navigationAsDateFormat ? currentText :
- this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
-
- controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
- this._get( inst, "closeText" ) + "</button>" : "" );
-
- buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
- ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
- ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
-
- firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
- firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
-
- showWeek = this._get( inst, "showWeek" );
- dayNames = this._get( inst, "dayNames" );
- dayNamesMin = this._get( inst, "dayNamesMin" );
- monthNames = this._get( inst, "monthNames" );
- monthNamesShort = this._get( inst, "monthNamesShort" );
- beforeShowDay = this._get( inst, "beforeShowDay" );
- showOtherMonths = this._get( inst, "showOtherMonths" );
- selectOtherMonths = this._get( inst, "selectOtherMonths" );
- defaultDate = this._getDefaultDate( inst );
- html = "";
-
- for ( row = 0; row < numMonths[ 0 ]; row++ ) {
- group = "";
- this.maxRows = 4;
- for ( col = 0; col < numMonths[ 1 ]; col++ ) {
- selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
- cornerClass = " ui-corner-all";
- calender = "";
- if ( isMultiMonth ) {
- calender += "<div class='ui-datepicker-group";
- if ( numMonths[ 1 ] > 1 ) {
- switch ( col ) {
- case 0: calender += " ui-datepicker-group-first";
- cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
- case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
- cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
- default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
- }
- }
- calender += "'>";
- }
- calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
- ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
- ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
- this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
- row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
- "</div><table class='ui-datepicker-calendar'><thead>" +
- "<tr>";
- thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
- for ( dow = 0; dow < 7; dow++ ) { // days of the week
- day = ( dow + firstDay ) % 7;
- thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
- "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
- }
- calender += thead + "</tr></thead><tbody>";
- daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
- if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
- inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
- }
- leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
- curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
- numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
- this.maxRows = numRows;
- printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
- for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
- calender += "<tr>";
- tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
- this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
- for ( dow = 0; dow < 7; dow++ ) { // create date picker days
- daySettings = ( beforeShowDay ?
- beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
- otherMonth = ( printDate.getMonth() !== drawMonth );
- unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
- ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
- tbody += "<td class='" +
- ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
- ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
- ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
- ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
-
- // or defaultDate is current printedDate and defaultDate is selectedDate
- " " + this._dayOverClass : "" ) + // highlight selected day
- ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
- ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
- ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
- ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
- ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title
- ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
- ( otherMonth && !showOtherMonths ? " " : // display for other months
- ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
- ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
- ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
- ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
- "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
- printDate.setDate( printDate.getDate() + 1 );
- printDate = this._daylightSavingAdjust( printDate );
- }
- calender += tbody + "</tr>";
- }
- drawMonth++;
- if ( drawMonth > 11 ) {
- drawMonth = 0;
- drawYear++;
- }
- calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
- ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
- group += calender;
- }
- html += group;
- }
- html += buttonPanel;
- inst._keyEvent = false;
- return html;
- },
-
- /* Generate the month and year header. */
- _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
- secondary, monthNames, monthNamesShort ) {
-
- var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
- changeMonth = this._get( inst, "changeMonth" ),
- changeYear = this._get( inst, "changeYear" ),
- showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
- html = "<div class='ui-datepicker-title'>",
- monthHtml = "";
-
- // Month selection
- if ( secondary || !changeMonth ) {
- monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
- } else {
- inMinYear = ( minDate && minDate.getFullYear() === drawYear );
- inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
- monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
- for ( month = 0; month < 12; month++ ) {
- if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
- monthHtml += "<option value='" + month + "'" +
- ( month === drawMonth ? " selected='selected'" : "" ) +
- ">" + monthNamesShort[ month ] + "</option>";
- }
- }
- monthHtml += "</select>";
- }
-
- if ( !showMonthAfterYear ) {
- html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? " " : "" );
- }
-
- // Year selection
- if ( !inst.yearshtml ) {
- inst.yearshtml = "";
- if ( secondary || !changeYear ) {
- html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
- } else {
-
- // determine range of years to display
- years = this._get( inst, "yearRange" ).split( ":" );
- thisYear = new Date().getFullYear();
- determineYear = function( value ) {
- var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
- ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
- parseInt( value, 10 ) ) );
- return ( isNaN( year ) ? thisYear : year );
- };
- year = determineYear( years[ 0 ] );
- endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
- year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
- endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
- inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
- for ( ; year <= endYear; year++ ) {
- inst.yearshtml += "<option value='" + year + "'" +
- ( year === drawYear ? " selected='selected'" : "" ) +
- ">" + year + "</option>";
- }
- inst.yearshtml += "</select>";
-
- html += inst.yearshtml;
- inst.yearshtml = null;
- }
- }
-
- html += this._get( inst, "yearSuffix" );
- if ( showMonthAfterYear ) {
- html += ( secondary || !( changeMonth && changeYear ) ? " " : "" ) + monthHtml;
- }
- html += "</div>"; // Close datepicker_header
- return html;
- },
-
- /* Adjust one of the date sub-fields. */
- _adjustInstDate: function( inst, offset, period ) {
- var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
- month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
- day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
- date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
-
- inst.selectedDay = date.getDate();
- inst.drawMonth = inst.selectedMonth = date.getMonth();
- inst.drawYear = inst.selectedYear = date.getFullYear();
- if ( period === "M" || period === "Y" ) {
- this._notifyChange( inst );
- }
- },
-
- /* Ensure a date is within any min/max bounds. */
- _restrictMinMax: function( inst, date ) {
- var minDate = this._getMinMaxDate( inst, "min" ),
- maxDate = this._getMinMaxDate( inst, "max" ),
- newDate = ( minDate && date < minDate ? minDate : date );
- return ( maxDate && newDate > maxDate ? maxDate : newDate );
- },
-
- /* Notify change of month/year. */
- _notifyChange: function( inst ) {
- var onChange = this._get( inst, "onChangeMonthYear" );
- if ( onChange ) {
- onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
- [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
- }
- },
-
- /* Determine the number of months to show. */
- _getNumberOfMonths: function( inst ) {
- var numMonths = this._get( inst, "numberOfMonths" );
- return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
- },
-
- /* Determine the current maximum date - ensure no time components are set. */
- _getMinMaxDate: function( inst, minMax ) {
- return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
- },
-
- /* Find the number of days in a given month. */
- _getDaysInMonth: function( year, month ) {
- return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
- },
-
- /* Find the day of the week of the first of a month. */
- _getFirstDayOfMonth: function( year, month ) {
- return new Date( year, month, 1 ).getDay();
- },
-
- /* Determines if we should allow a "next/prev" month display change. */
- _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
- var numMonths = this._getNumberOfMonths( inst ),
- date = this._daylightSavingAdjust( new Date( curYear,
- curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
-
- if ( offset < 0 ) {
- date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
- }
- return this._isInRange( inst, date );
- },
-
- /* Is the given date in the accepted range? */
- _isInRange: function( inst, date ) {
- var yearSplit, currentYear,
- minDate = this._getMinMaxDate( inst, "min" ),
- maxDate = this._getMinMaxDate( inst, "max" ),
- minYear = null,
- maxYear = null,
- years = this._get( inst, "yearRange" );
- if ( years ) {
- yearSplit = years.split( ":" );
- currentYear = new Date().getFullYear();
- minYear = parseInt( yearSplit[ 0 ], 10 );
- maxYear = parseInt( yearSplit[ 1 ], 10 );
- if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
- minYear += currentYear;
- }
- if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
- maxYear += currentYear;
- }
- }
-
- return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
- ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
- ( !minYear || date.getFullYear() >= minYear ) &&
- ( !maxYear || date.getFullYear() <= maxYear ) );
- },
-
- /* Provide the configuration settings for formatting/parsing. */
- _getFormatConfig: function( inst ) {
- var shortYearCutoff = this._get( inst, "shortYearCutoff" );
- shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
- new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
- return { shortYearCutoff: shortYearCutoff,
- dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
- monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
- },
-
- /* Format the given date for display. */
- _formatDate: function( inst, day, month, year ) {
- if ( !day ) {
- inst.currentDay = inst.selectedDay;
- inst.currentMonth = inst.selectedMonth;
- inst.currentYear = inst.selectedYear;
- }
- var date = ( day ? ( typeof day === "object" ? day :
- this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
- this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
- return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
- }
-} );
-
-/*
- * Bind hover events for datepicker elements.
- * Done via delegate so the binding only occurs once in the lifetime of the parent div.
- * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
- */
-function datepicker_bindHover( dpDiv ) {
- var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
- return dpDiv.on( "mouseout", selector, function() {
- $( this ).removeClass( "ui-state-hover" );
- if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
- $( this ).removeClass( "ui-datepicker-prev-hover" );
- }
- if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
- $( this ).removeClass( "ui-datepicker-next-hover" );
- }
- } )
- .on( "mouseover", selector, datepicker_handleMouseover );
-}
-
-function datepicker_handleMouseover() {
- if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
- $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
- $( this ).addClass( "ui-state-hover" );
- if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
- $( this ).addClass( "ui-datepicker-prev-hover" );
- }
- if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
- $( this ).addClass( "ui-datepicker-next-hover" );
- }
- }
-}
-
-/* jQuery extend now ignores nulls! */
-function datepicker_extendRemove( target, props ) {
- $.extend( target, props );
- for ( var name in props ) {
- if ( props[ name ] == null ) {
- target[ name ] = props[ name ];
- }
- }
- return target;
-}
-
-/* Invoke the datepicker functionality.
- @param options string - a command, optionally followed by additional parameters or
- Object - settings for attaching new datepicker functionality
- @return jQuery object */
-$.fn.datepicker = function( options ) {
-
- /* Verify an empty collection wasn't passed - Fixes #6976 */
- if ( !this.length ) {
- return this;
- }
-
- /* Initialise the date picker. */
- if ( !$.datepicker.initialized ) {
- $( document ).on( "mousedown", $.datepicker._checkExternalClick );
- $.datepicker.initialized = true;
- }
-
- /* Append datepicker main container to body if not exist. */
- if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
- $( "body" ).append( $.datepicker.dpDiv );
- }
-
- var otherArgs = Array.prototype.slice.call( arguments, 1 );
- if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
- return $.datepicker[ "_" + options + "Datepicker" ].
- apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
- }
- if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
- return $.datepicker[ "_" + options + "Datepicker" ].
- apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
- }
- return this.each( function() {
- typeof options === "string" ?
- $.datepicker[ "_" + options + "Datepicker" ].
- apply( $.datepicker, [ this ].concat( otherArgs ) ) :
- $.datepicker._attachDatepicker( this, options );
- } );
-};
-
-$.datepicker = new Datepicker(); // singleton instance
-$.datepicker.initialized = false;
-$.datepicker.uuid = new Date().getTime();
-$.datepicker.version = "1.12.1";
-
-var widgetsDatepicker = $.datepicker;
-
-
-
-
-// This file is deprecated
-var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
-
-/*!
- * jQuery UI Mouse 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Mouse
-//>>group: Widgets
-//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
-//>>docs: http://api.jqueryui.com/mouse/
-
-
-
-var mouseHandled = false;
-$( document ).on( "mouseup", function() {
- mouseHandled = false;
-} );
-
-var widgetsMouse = $.widget( "ui.mouse", {
- version: "1.12.1",
- options: {
- cancel: "input, textarea, button, select, option",
- distance: 1,
- delay: 0
- },
- _mouseInit: function() {
- var that = this;
-
- this.element
- .on( "mousedown." + this.widgetName, function( event ) {
- return that._mouseDown( event );
- } )
- .on( "click." + this.widgetName, function( event ) {
- if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
- $.removeData( event.target, that.widgetName + ".preventClickEvent" );
- event.stopImmediatePropagation();
- return false;
- }
- } );
-
- this.started = false;
- },
-
- // TODO: make sure destroying one instance of mouse doesn't mess with
- // other instances of mouse
- _mouseDestroy: function() {
- this.element.off( "." + this.widgetName );
- if ( this._mouseMoveDelegate ) {
- this.document
- .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
- .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
- }
- },
-
- _mouseDown: function( event ) {
-
- // don't let more than one widget handle mouseStart
- if ( mouseHandled ) {
- return;
- }
-
- this._mouseMoved = false;
-
- // We may have missed mouseup (out of window)
- ( this._mouseStarted && this._mouseUp( event ) );
-
- this._mouseDownEvent = event;
-
- var that = this,
- btnIsLeft = ( event.which === 1 ),
-
- // event.target.nodeName works around a bug in IE 8 with
- // disabled inputs (#7620)
- elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
- $( event.target ).closest( this.options.cancel ).length : false );
- if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
- return true;
- }
-
- this.mouseDelayMet = !this.options.delay;
- if ( !this.mouseDelayMet ) {
- this._mouseDelayTimer = setTimeout( function() {
- that.mouseDelayMet = true;
- }, this.options.delay );
- }
-
- if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
- this._mouseStarted = ( this._mouseStart( event ) !== false );
- if ( !this._mouseStarted ) {
- event.preventDefault();
- return true;
- }
- }
-
- // Click event may never have fired (Gecko & Opera)
- if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
- $.removeData( event.target, this.widgetName + ".preventClickEvent" );
- }
-
- // These delegates are required to keep context
- this._mouseMoveDelegate = function( event ) {
- return that._mouseMove( event );
- };
- this._mouseUpDelegate = function( event ) {
- return that._mouseUp( event );
- };
-
- this.document
- .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
- .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
-
- event.preventDefault();
-
- mouseHandled = true;
- return true;
- },
-
- _mouseMove: function( event ) {
-
- // Only check for mouseups outside the document if you've moved inside the document
- // at least once. This prevents the firing of mouseup in the case of IE<9, which will
- // fire a mousemove event if content is placed under the cursor. See #7778
- // Support: IE <9
- if ( this._mouseMoved ) {
-
- // IE mouseup check - mouseup happened when mouse was out of window
- if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
- !event.button ) {
- return this._mouseUp( event );
-
- // Iframe mouseup check - mouseup occurred in another document
- } else if ( !event.which ) {
-
- // Support: Safari <=8 - 9
- // Safari sets which to 0 if you press any of the following keys
- // during a drag (#14461)
- if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
- event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
- this.ignoreMissingWhich = true;
- } else if ( !this.ignoreMissingWhich ) {
- return this._mouseUp( event );
- }
- }
- }
-
- if ( event.which || event.button ) {
- this._mouseMoved = true;
- }
-
- if ( this._mouseStarted ) {
- this._mouseDrag( event );
- return event.preventDefault();
- }
-
- if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
- this._mouseStarted =
- ( this._mouseStart( this._mouseDownEvent, event ) !== false );
- ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
- }
-
- return !this._mouseStarted;
- },
-
- _mouseUp: function( event ) {
- this.document
- .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
- .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
-
- if ( this._mouseStarted ) {
- this._mouseStarted = false;
-
- if ( event.target === this._mouseDownEvent.target ) {
- $.data( event.target, this.widgetName + ".preventClickEvent", true );
- }
-
- this._mouseStop( event );
- }
-
- if ( this._mouseDelayTimer ) {
- clearTimeout( this._mouseDelayTimer );
- delete this._mouseDelayTimer;
- }
-
- this.ignoreMissingWhich = false;
- mouseHandled = false;
- event.preventDefault();
- },
-
- _mouseDistanceMet: function( event ) {
- return ( Math.max(
- Math.abs( this._mouseDownEvent.pageX - event.pageX ),
- Math.abs( this._mouseDownEvent.pageY - event.pageY )
- ) >= this.options.distance
- );
- },
-
- _mouseDelayMet: function( /* event */ ) {
- return this.mouseDelayMet;
- },
-
- // These are placeholder methods, to be overriden by extending plugin
- _mouseStart: function( /* event */ ) {},
- _mouseDrag: function( /* event */ ) {},
- _mouseStop: function( /* event */ ) {},
- _mouseCapture: function( /* event */ ) { return true; }
-} );
-
-
-
-
-// $.ui.plugin is deprecated. Use $.widget() extensions instead.
-var plugin = $.ui.plugin = {
- add: function( module, option, set ) {
- var i,
- proto = $.ui[ module ].prototype;
- for ( i in set ) {
- proto.plugins[ i ] = proto.plugins[ i ] || [];
- proto.plugins[ i ].push( [ option, set[ i ] ] );
- }
- },
- call: function( instance, name, args, allowDisconnected ) {
- var i,
- set = instance.plugins[ name ];
-
- if ( !set ) {
- return;
- }
-
- if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
- instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
- return;
- }
-
- for ( i = 0; i < set.length; i++ ) {
- if ( instance.options[ set[ i ][ 0 ] ] ) {
- set[ i ][ 1 ].apply( instance.element, args );
- }
- }
- }
-};
-
-
-
-var safeBlur = $.ui.safeBlur = function( element ) {
-
- // Support: IE9 - 10 only
- // If the <body> is blurred, IE will switch windows, see #9420
- if ( element && element.nodeName.toLowerCase() !== "body" ) {
- $( element ).trigger( "blur" );
- }
-};
-
-
-/*!
- * jQuery UI Draggable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Draggable
-//>>group: Interactions
-//>>description: Enables dragging functionality for any element.
-//>>docs: http://api.jqueryui.com/draggable/
-//>>demos: http://jqueryui.com/draggable/
-//>>css.structure: ../../themes/base/draggable.css
-
-
-
-$.widget( "ui.draggable", $.ui.mouse, {
- version: "1.12.1",
- widgetEventPrefix: "drag",
- options: {
- addClasses: true,
- appendTo: "parent",
- axis: false,
- connectToSortable: false,
- containment: false,
- cursor: "auto",
- cursorAt: false,
- grid: false,
- handle: false,
- helper: "original",
- iframeFix: false,
- opacity: false,
- refreshPositions: false,
- revert: false,
- revertDuration: 500,
- scope: "default",
- scroll: true,
- scrollSensitivity: 20,
- scrollSpeed: 20,
- snap: false,
- snapMode: "both",
- snapTolerance: 20,
- stack: false,
- zIndex: false,
-
- // Callbacks
- drag: null,
- start: null,
- stop: null
- },
- _create: function() {
-
- if ( this.options.helper === "original" ) {
- this._setPositionRelative();
- }
- if ( this.options.addClasses ) {
- this._addClass( "ui-draggable" );
- }
- this._setHandleClassName();
-
- this._mouseInit();
- },
-
- _setOption: function( key, value ) {
- this._super( key, value );
- if ( key === "handle" ) {
- this._removeHandleClassName();
- this._setHandleClassName();
- }
- },
-
- _destroy: function() {
- if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
- this.destroyOnClear = true;
- return;
- }
- this._removeHandleClassName();
- this._mouseDestroy();
- },
-
- _mouseCapture: function( event ) {
- var o = this.options;
-
- // Among others, prevent a drag on a resizable-handle
- if ( this.helper || o.disabled ||
- $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
- return false;
- }
-
- //Quit if we're not on a valid handle
- this.handle = this._getHandle( event );
- if ( !this.handle ) {
- return false;
- }
-
- this._blurActiveElement( event );
-
- this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
-
- return true;
-
- },
-
- _blockFrames: function( selector ) {
- this.iframeBlocks = this.document.find( selector ).map( function() {
- var iframe = $( this );
-
- return $( "<div>" )
- .css( "position", "absolute" )
- .appendTo( iframe.parent() )
- .outerWidth( iframe.outerWidth() )
- .outerHeight( iframe.outerHeight() )
- .offset( iframe.offset() )[ 0 ];
- } );
- },
-
- _unblockFrames: function() {
- if ( this.iframeBlocks ) {
- this.iframeBlocks.remove();
- delete this.iframeBlocks;
- }
- },
-
- _blurActiveElement: function( event ) {
- var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
- target = $( event.target );
-
- // Don't blur if the event occurred on an element that is within
- // the currently focused element
- // See #10527, #12472
- if ( target.closest( activeElement ).length ) {
- return;
- }
-
- // Blur any element that currently has focus, see #4261
- $.ui.safeBlur( activeElement );
- },
-
- _mouseStart: function( event ) {
-
- var o = this.options;
-
- //Create and append the visible helper
- this.helper = this._createHelper( event );
-
- this._addClass( this.helper, "ui-draggable-dragging" );
-
- //Cache the helper size
- this._cacheHelperProportions();
-
- //If ddmanager is used for droppables, set the global draggable
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.current = this;
- }
-
- /*
- * - Position generation -
- * This block generates everything position related - it's the core of draggables.
- */
-
- //Cache the margins of the original element
- this._cacheMargins();
-
- //Store the helper's css position
- this.cssPosition = this.helper.css( "position" );
- this.scrollParent = this.helper.scrollParent( true );
- this.offsetParent = this.helper.offsetParent();
- this.hasFixedAncestor = this.helper.parents().filter( function() {
- return $( this ).css( "position" ) === "fixed";
- } ).length > 0;
-
- //The element's absolute position on the page minus margins
- this.positionAbs = this.element.offset();
- this._refreshOffsets( event );
-
- //Generate the original position
- this.originalPosition = this.position = this._generatePosition( event, false );
- this.originalPageX = event.pageX;
- this.originalPageY = event.pageY;
-
- //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
- ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
-
- //Set a containment if given in the options
- this._setContainment();
-
- //Trigger event + callbacks
- if ( this._trigger( "start", event ) === false ) {
- this._clear();
- return false;
- }
-
- //Recache the helper size
- this._cacheHelperProportions();
-
- //Prepare the droppable offsets
- if ( $.ui.ddmanager && !o.dropBehaviour ) {
- $.ui.ddmanager.prepareOffsets( this, event );
- }
-
- // Execute the drag once - this causes the helper not to be visible before getting its
- // correct position
- this._mouseDrag( event, true );
-
- // If the ddmanager is used for droppables, inform the manager that dragging has started
- // (see #5003)
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStart( this, event );
- }
-
- return true;
- },
-
- _refreshOffsets: function( event ) {
- this.offset = {
- top: this.positionAbs.top - this.margins.top,
- left: this.positionAbs.left - this.margins.left,
- scroll: false,
- parent: this._getParentOffset(),
- relative: this._getRelativeOffset()
- };
-
- this.offset.click = {
- left: event.pageX - this.offset.left,
- top: event.pageY - this.offset.top
- };
- },
-
- _mouseDrag: function( event, noPropagation ) {
-
- // reset any necessary cached properties (see #5009)
- if ( this.hasFixedAncestor ) {
- this.offset.parent = this._getParentOffset();
- }
-
- //Compute the helpers position
- this.position = this._generatePosition( event, true );
- this.positionAbs = this._convertPositionTo( "absolute" );
-
- //Call plugins and callbacks and use the resulting position if something is returned
- if ( !noPropagation ) {
- var ui = this._uiHash();
- if ( this._trigger( "drag", event, ui ) === false ) {
- this._mouseUp( new $.Event( "mouseup", event ) );
- return false;
- }
- this.position = ui.position;
- }
-
- this.helper[ 0 ].style.left = this.position.left + "px";
- this.helper[ 0 ].style.top = this.position.top + "px";
-
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.drag( this, event );
- }
-
- return false;
- },
-
- _mouseStop: function( event ) {
-
- //If we are using droppables, inform the manager about the drop
- var that = this,
- dropped = false;
- if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
- dropped = $.ui.ddmanager.drop( this, event );
- }
-
- //if a drop comes from outside (a sortable)
- if ( this.dropped ) {
- dropped = this.dropped;
- this.dropped = false;
- }
-
- if ( ( this.options.revert === "invalid" && !dropped ) ||
- ( this.options.revert === "valid" && dropped ) ||
- this.options.revert === true || ( $.isFunction( this.options.revert ) &&
- this.options.revert.call( this.element, dropped ) )
- ) {
- $( this.helper ).animate(
- this.originalPosition,
- parseInt( this.options.revertDuration, 10 ),
- function() {
- if ( that._trigger( "stop", event ) !== false ) {
- that._clear();
- }
- }
- );
- } else {
- if ( this._trigger( "stop", event ) !== false ) {
- this._clear();
- }
- }
-
- return false;
- },
-
- _mouseUp: function( event ) {
- this._unblockFrames();
-
- // If the ddmanager is used for droppables, inform the manager that dragging has stopped
- // (see #5003)
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStop( this, event );
- }
-
- // Only need to focus if the event occurred on the draggable itself, see #10527
- if ( this.handleElement.is( event.target ) ) {
-
- // The interaction is over; whether or not the click resulted in a drag,
- // focus the element
- this.element.trigger( "focus" );
- }
-
- return $.ui.mouse.prototype._mouseUp.call( this, event );
- },
-
- cancel: function() {
-
- if ( this.helper.is( ".ui-draggable-dragging" ) ) {
- this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
- } else {
- this._clear();
- }
-
- return this;
-
- },
-
- _getHandle: function( event ) {
- return this.options.handle ?
- !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
- true;
- },
-
- _setHandleClassName: function() {
- this.handleElement = this.options.handle ?
- this.element.find( this.options.handle ) : this.element;
- this._addClass( this.handleElement, "ui-draggable-handle" );
- },
-
- _removeHandleClassName: function() {
- this._removeClass( this.handleElement, "ui-draggable-handle" );
- },
-
- _createHelper: function( event ) {
-
- var o = this.options,
- helperIsFunction = $.isFunction( o.helper ),
- helper = helperIsFunction ?
- $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
- ( o.helper === "clone" ?
- this.element.clone().removeAttr( "id" ) :
- this.element );
-
- if ( !helper.parents( "body" ).length ) {
- helper.appendTo( ( o.appendTo === "parent" ?
- this.element[ 0 ].parentNode :
- o.appendTo ) );
- }
-
- // Http://bugs.jqueryui.com/ticket/9446
- // a helper function can return the original element
- // which wouldn't have been set to relative in _create
- if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
- this._setPositionRelative();
- }
-
- if ( helper[ 0 ] !== this.element[ 0 ] &&
- !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
- helper.css( "position", "absolute" );
- }
-
- return helper;
-
- },
-
- _setPositionRelative: function() {
- if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
- this.element[ 0 ].style.position = "relative";
- }
- },
-
- _adjustOffsetFromHelper: function( obj ) {
- if ( typeof obj === "string" ) {
- obj = obj.split( " " );
- }
- if ( $.isArray( obj ) ) {
- obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
- }
- if ( "left" in obj ) {
- this.offset.click.left = obj.left + this.margins.left;
- }
- if ( "right" in obj ) {
- this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
- }
- if ( "top" in obj ) {
- this.offset.click.top = obj.top + this.margins.top;
- }
- if ( "bottom" in obj ) {
- this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
- }
- },
-
- _isRootNode: function( element ) {
- return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
- },
-
- _getParentOffset: function() {
-
- //Get the offsetParent and cache its position
- var po = this.offsetParent.offset(),
- document = this.document[ 0 ];
-
- // This is a special case where we need to modify a offset calculated on start, since the
- // following happened:
- // 1. The position of the helper is absolute, so it's position is calculated based on the
- // next positioned parent
- // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
- // the document, which means that the scroll is included in the initial calculation of the
- // offset of the parent, and never recalculated upon drag
- if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
- $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
- po.left += this.scrollParent.scrollLeft();
- po.top += this.scrollParent.scrollTop();
- }
-
- if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
- po = { top: 0, left: 0 };
- }
-
- return {
- top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
- left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
- };
-
- },
-
- _getRelativeOffset: function() {
- if ( this.cssPosition !== "relative" ) {
- return { top: 0, left: 0 };
- }
-
- var p = this.element.position(),
- scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
-
- return {
- top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
- ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
- left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
- ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
- };
-
- },
-
- _cacheMargins: function() {
- this.margins = {
- left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
- top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
- right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
- bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
- };
- },
-
- _cacheHelperProportions: function() {
- this.helperProportions = {
- width: this.helper.outerWidth(),
- height: this.helper.outerHeight()
- };
- },
-
- _setContainment: function() {
-
- var isUserScrollable, c, ce,
- o = this.options,
- document = this.document[ 0 ];
-
- this.relativeContainer = null;
-
- if ( !o.containment ) {
- this.containment = null;
- return;
- }
-
- if ( o.containment === "window" ) {
- this.containment = [
- $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
- $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
- $( window ).scrollLeft() + $( window ).width() -
- this.helperProportions.width - this.margins.left,
- $( window ).scrollTop() +
- ( $( window ).height() || document.body.parentNode.scrollHeight ) -
- this.helperProportions.height - this.margins.top
- ];
- return;
- }
-
- if ( o.containment === "document" ) {
- this.containment = [
- 0,
- 0,
- $( document ).width() - this.helperProportions.width - this.margins.left,
- ( $( document ).height() || document.body.parentNode.scrollHeight ) -
- this.helperProportions.height - this.margins.top
- ];
- return;
- }
-
- if ( o.containment.constructor === Array ) {
- this.containment = o.containment;
- return;
- }
-
- if ( o.containment === "parent" ) {
- o.containment = this.helper[ 0 ].parentNode;
- }
-
- c = $( o.containment );
- ce = c[ 0 ];
-
- if ( !ce ) {
- return;
- }
-
- isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
-
- this.containment = [
- ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
- ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
- ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
- ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
- ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
- ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
- ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
- this.helperProportions.width -
- this.margins.left -
- this.margins.right,
- ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
- ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
- ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
- this.helperProportions.height -
- this.margins.top -
- this.margins.bottom
- ];
- this.relativeContainer = c;
- },
-
- _convertPositionTo: function( d, pos ) {
-
- if ( !pos ) {
- pos = this.position;
- }
-
- var mod = d === "absolute" ? 1 : -1,
- scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
-
- return {
- top: (
-
- // The absolute mouse position
- pos.top +
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.top * mod +
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.top * mod -
- ( ( this.cssPosition === "fixed" ?
- -this.offset.scroll.top :
- ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
- ),
- left: (
-
- // The absolute mouse position
- pos.left +
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.left * mod +
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.left * mod -
- ( ( this.cssPosition === "fixed" ?
- -this.offset.scroll.left :
- ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
- )
- };
-
- },
-
- _generatePosition: function( event, constrainPosition ) {
-
- var containment, co, top, left,
- o = this.options,
- scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
- pageX = event.pageX,
- pageY = event.pageY;
-
- // Cache the scroll
- if ( !scrollIsRootNode || !this.offset.scroll ) {
- this.offset.scroll = {
- top: this.scrollParent.scrollTop(),
- left: this.scrollParent.scrollLeft()
- };
- }
-
- /*
- * - Position constraining -
- * Constrain the position to a mix of grid, containment.
- */
-
- // If we are not dragging yet, we won't check for options
- if ( constrainPosition ) {
- if ( this.containment ) {
- if ( this.relativeContainer ) {
- co = this.relativeContainer.offset();
- containment = [
- this.containment[ 0 ] + co.left,
- this.containment[ 1 ] + co.top,
- this.containment[ 2 ] + co.left,
- this.containment[ 3 ] + co.top
- ];
- } else {
- containment = this.containment;
- }
-
- if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
- pageX = containment[ 0 ] + this.offset.click.left;
- }
- if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
- pageY = containment[ 1 ] + this.offset.click.top;
- }
- if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
- pageX = containment[ 2 ] + this.offset.click.left;
- }
- if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
- pageY = containment[ 3 ] + this.offset.click.top;
- }
- }
-
- if ( o.grid ) {
-
- //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
- // argument errors in IE (see ticket #6950)
- top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
- this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
- pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
- top - this.offset.click.top > containment[ 3 ] ) ?
- top :
- ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
- top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
-
- left = o.grid[ 0 ] ? this.originalPageX +
- Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
- this.originalPageX;
- pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
- left - this.offset.click.left > containment[ 2 ] ) ?
- left :
- ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
- left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
- }
-
- if ( o.axis === "y" ) {
- pageX = this.originalPageX;
- }
-
- if ( o.axis === "x" ) {
- pageY = this.originalPageY;
- }
- }
-
- return {
- top: (
-
- // The absolute mouse position
- pageY -
-
- // Click offset (relative to the element)
- this.offset.click.top -
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.top -
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.top +
- ( this.cssPosition === "fixed" ?
- -this.offset.scroll.top :
- ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
- ),
- left: (
-
- // The absolute mouse position
- pageX -
-
- // Click offset (relative to the element)
- this.offset.click.left -
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.left -
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.left +
- ( this.cssPosition === "fixed" ?
- -this.offset.scroll.left :
- ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
- )
- };
-
- },
-
- _clear: function() {
- this._removeClass( this.helper, "ui-draggable-dragging" );
- if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
- this.helper.remove();
- }
- this.helper = null;
- this.cancelHelperRemoval = false;
- if ( this.destroyOnClear ) {
- this.destroy();
- }
- },
-
- // From now on bulk stuff - mainly helpers
-
- _trigger: function( type, event, ui ) {
- ui = ui || this._uiHash();
- $.ui.plugin.call( this, type, [ event, ui, this ], true );
-
- // Absolute position and offset (see #6884 ) have to be recalculated after plugins
- if ( /^(drag|start|stop)/.test( type ) ) {
- this.positionAbs = this._convertPositionTo( "absolute" );
- ui.offset = this.positionAbs;
- }
- return $.Widget.prototype._trigger.call( this, type, event, ui );
- },
-
- plugins: {},
-
- _uiHash: function() {
- return {
- helper: this.helper,
- position: this.position,
- originalPosition: this.originalPosition,
- offset: this.positionAbs
- };
- }
-
-} );
-
-$.ui.plugin.add( "draggable", "connectToSortable", {
- start: function( event, ui, draggable ) {
- var uiSortable = $.extend( {}, ui, {
- item: draggable.element
- } );
-
- draggable.sortables = [];
- $( draggable.options.connectToSortable ).each( function() {
- var sortable = $( this ).sortable( "instance" );
-
- if ( sortable && !sortable.options.disabled ) {
- draggable.sortables.push( sortable );
-
- // RefreshPositions is called at drag start to refresh the containerCache
- // which is used in drag. This ensures it's initialized and synchronized
- // with any changes that might have happened on the page since initialization.
- sortable.refreshPositions();
- sortable._trigger( "activate", event, uiSortable );
- }
- } );
- },
- stop: function( event, ui, draggable ) {
- var uiSortable = $.extend( {}, ui, {
- item: draggable.element
- } );
-
- draggable.cancelHelperRemoval = false;
-
- $.each( draggable.sortables, function() {
- var sortable = this;
-
- if ( sortable.isOver ) {
- sortable.isOver = 0;
-
- // Allow this sortable to handle removing the helper
- draggable.cancelHelperRemoval = true;
- sortable.cancelHelperRemoval = false;
-
- // Use _storedCSS To restore properties in the sortable,
- // as this also handles revert (#9675) since the draggable
- // may have modified them in unexpected ways (#8809)
- sortable._storedCSS = {
- position: sortable.placeholder.css( "position" ),
- top: sortable.placeholder.css( "top" ),
- left: sortable.placeholder.css( "left" )
- };
-
- sortable._mouseStop( event );
-
- // Once drag has ended, the sortable should return to using
- // its original helper, not the shared helper from draggable
- sortable.options.helper = sortable.options._helper;
- } else {
-
- // Prevent this Sortable from removing the helper.
- // However, don't set the draggable to remove the helper
- // either as another connected Sortable may yet handle the removal.
- sortable.cancelHelperRemoval = true;
-
- sortable._trigger( "deactivate", event, uiSortable );
- }
- } );
- },
- drag: function( event, ui, draggable ) {
- $.each( draggable.sortables, function() {
- var innermostIntersecting = false,
- sortable = this;
-
- // Copy over variables that sortable's _intersectsWith uses
- sortable.positionAbs = draggable.positionAbs;
- sortable.helperProportions = draggable.helperProportions;
- sortable.offset.click = draggable.offset.click;
-
- if ( sortable._intersectsWith( sortable.containerCache ) ) {
- innermostIntersecting = true;
-
- $.each( draggable.sortables, function() {
-
- // Copy over variables that sortable's _intersectsWith uses
- this.positionAbs = draggable.positionAbs;
- this.helperProportions = draggable.helperProportions;
- this.offset.click = draggable.offset.click;
-
- if ( this !== sortable &&
- this._intersectsWith( this.containerCache ) &&
- $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
- innermostIntersecting = false;
- }
-
- return innermostIntersecting;
- } );
- }
-
- if ( innermostIntersecting ) {
-
- // If it intersects, we use a little isOver variable and set it once,
- // so that the move-in stuff gets fired only once.
- if ( !sortable.isOver ) {
- sortable.isOver = 1;
-
- // Store draggable's parent in case we need to reappend to it later.
- draggable._parent = ui.helper.parent();
-
- sortable.currentItem = ui.helper
- .appendTo( sortable.element )
- .data( "ui-sortable-item", true );
-
- // Store helper option to later restore it
- sortable.options._helper = sortable.options.helper;
-
- sortable.options.helper = function() {
- return ui.helper[ 0 ];
- };
-
- // Fire the start events of the sortable with our passed browser event,
- // and our own helper (so it doesn't create a new one)
- event.target = sortable.currentItem[ 0 ];
- sortable._mouseCapture( event, true );
- sortable._mouseStart( event, true, true );
-
- // Because the browser event is way off the new appended portlet,
- // modify necessary variables to reflect the changes
- sortable.offset.click.top = draggable.offset.click.top;
- sortable.offset.click.left = draggable.offset.click.left;
- sortable.offset.parent.left -= draggable.offset.parent.left -
- sortable.offset.parent.left;
- sortable.offset.parent.top -= draggable.offset.parent.top -
- sortable.offset.parent.top;
-
- draggable._trigger( "toSortable", event );
-
- // Inform draggable that the helper is in a valid drop zone,
- // used solely in the revert option to handle "valid/invalid".
- draggable.dropped = sortable.element;
-
- // Need to refreshPositions of all sortables in the case that
- // adding to one sortable changes the location of the other sortables (#9675)
- $.each( draggable.sortables, function() {
- this.refreshPositions();
- } );
-
- // Hack so receive/update callbacks work (mostly)
- draggable.currentItem = draggable.element;
- sortable.fromOutside = draggable;
- }
-
- if ( sortable.currentItem ) {
- sortable._mouseDrag( event );
-
- // Copy the sortable's position because the draggable's can potentially reflect
- // a relative position, while sortable is always absolute, which the dragged
- // element has now become. (#8809)
- ui.position = sortable.position;
- }
- } else {
-
- // If it doesn't intersect with the sortable, and it intersected before,
- // we fake the drag stop of the sortable, but make sure it doesn't remove
- // the helper by using cancelHelperRemoval.
- if ( sortable.isOver ) {
-
- sortable.isOver = 0;
- sortable.cancelHelperRemoval = true;
-
- // Calling sortable's mouseStop would trigger a revert,
- // so revert must be temporarily false until after mouseStop is called.
- sortable.options._revert = sortable.options.revert;
- sortable.options.revert = false;
-
- sortable._trigger( "out", event, sortable._uiHash( sortable ) );
- sortable._mouseStop( event, true );
-
- // Restore sortable behaviors that were modfied
- // when the draggable entered the sortable area (#9481)
- sortable.options.revert = sortable.options._revert;
- sortable.options.helper = sortable.options._helper;
-
- if ( sortable.placeholder ) {
- sortable.placeholder.remove();
- }
-
- // Restore and recalculate the draggable's offset considering the sortable
- // may have modified them in unexpected ways. (#8809, #10669)
- ui.helper.appendTo( draggable._parent );
- draggable._refreshOffsets( event );
- ui.position = draggable._generatePosition( event, true );
-
- draggable._trigger( "fromSortable", event );
-
- // Inform draggable that the helper is no longer in a valid drop zone
- draggable.dropped = false;
-
- // Need to refreshPositions of all sortables just in case removing
- // from one sortable changes the location of other sortables (#9675)
- $.each( draggable.sortables, function() {
- this.refreshPositions();
- } );
- }
- }
- } );
- }
-} );
-
-$.ui.plugin.add( "draggable", "cursor", {
- start: function( event, ui, instance ) {
- var t = $( "body" ),
- o = instance.options;
-
- if ( t.css( "cursor" ) ) {
- o._cursor = t.css( "cursor" );
- }
- t.css( "cursor", o.cursor );
- },
- stop: function( event, ui, instance ) {
- var o = instance.options;
- if ( o._cursor ) {
- $( "body" ).css( "cursor", o._cursor );
- }
- }
-} );
-
-$.ui.plugin.add( "draggable", "opacity", {
- start: function( event, ui, instance ) {
- var t = $( ui.helper ),
- o = instance.options;
- if ( t.css( "opacity" ) ) {
- o._opacity = t.css( "opacity" );
- }
- t.css( "opacity", o.opacity );
- },
- stop: function( event, ui, instance ) {
- var o = instance.options;
- if ( o._opacity ) {
- $( ui.helper ).css( "opacity", o._opacity );
- }
- }
-} );
-
-$.ui.plugin.add( "draggable", "scroll", {
- start: function( event, ui, i ) {
- if ( !i.scrollParentNotHidden ) {
- i.scrollParentNotHidden = i.helper.scrollParent( false );
- }
-
- if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
- i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
- i.overflowOffset = i.scrollParentNotHidden.offset();
- }
- },
- drag: function( event, ui, i ) {
-
- var o = i.options,
- scrolled = false,
- scrollParent = i.scrollParentNotHidden[ 0 ],
- document = i.document[ 0 ];
-
- if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
- if ( !o.axis || o.axis !== "x" ) {
- if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
- o.scrollSensitivity ) {
- scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
- } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
- scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
- }
- }
-
- if ( !o.axis || o.axis !== "y" ) {
- if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
- o.scrollSensitivity ) {
- scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
- } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
- scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
- }
- }
-
- } else {
-
- if ( !o.axis || o.axis !== "x" ) {
- if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
- scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
- } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
- o.scrollSensitivity ) {
- scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
- }
- }
-
- if ( !o.axis || o.axis !== "y" ) {
- if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
- scrolled = $( document ).scrollLeft(
- $( document ).scrollLeft() - o.scrollSpeed
- );
- } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
- o.scrollSensitivity ) {
- scrolled = $( document ).scrollLeft(
- $( document ).scrollLeft() + o.scrollSpeed
- );
- }
- }
-
- }
-
- if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
- $.ui.ddmanager.prepareOffsets( i, event );
- }
-
- }
-} );
-
-$.ui.plugin.add( "draggable", "snap", {
- start: function( event, ui, i ) {
-
- var o = i.options;
-
- i.snapElements = [];
-
- $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
- .each( function() {
- var $t = $( this ),
- $o = $t.offset();
- if ( this !== i.element[ 0 ] ) {
- i.snapElements.push( {
- item: this,
- width: $t.outerWidth(), height: $t.outerHeight(),
- top: $o.top, left: $o.left
- } );
- }
- } );
-
- },
- drag: function( event, ui, inst ) {
-
- var ts, bs, ls, rs, l, r, t, b, i, first,
- o = inst.options,
- d = o.snapTolerance,
- x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
- y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
-
- for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
-
- l = inst.snapElements[ i ].left - inst.margins.left;
- r = l + inst.snapElements[ i ].width;
- t = inst.snapElements[ i ].top - inst.margins.top;
- b = t + inst.snapElements[ i ].height;
-
- if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
- !$.contains( inst.snapElements[ i ].item.ownerDocument,
- inst.snapElements[ i ].item ) ) {
- if ( inst.snapElements[ i ].snapping ) {
- ( inst.options.snap.release &&
- inst.options.snap.release.call(
- inst.element,
- event,
- $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
- ) );
- }
- inst.snapElements[ i ].snapping = false;
- continue;
- }
-
- if ( o.snapMode !== "inner" ) {
- ts = Math.abs( t - y2 ) <= d;
- bs = Math.abs( b - y1 ) <= d;
- ls = Math.abs( l - x2 ) <= d;
- rs = Math.abs( r - x1 ) <= d;
- if ( ts ) {
- ui.position.top = inst._convertPositionTo( "relative", {
- top: t - inst.helperProportions.height,
- left: 0
- } ).top;
- }
- if ( bs ) {
- ui.position.top = inst._convertPositionTo( "relative", {
- top: b,
- left: 0
- } ).top;
- }
- if ( ls ) {
- ui.position.left = inst._convertPositionTo( "relative", {
- top: 0,
- left: l - inst.helperProportions.width
- } ).left;
- }
- if ( rs ) {
- ui.position.left = inst._convertPositionTo( "relative", {
- top: 0,
- left: r
- } ).left;
- }
- }
-
- first = ( ts || bs || ls || rs );
-
- if ( o.snapMode !== "outer" ) {
- ts = Math.abs( t - y1 ) <= d;
- bs = Math.abs( b - y2 ) <= d;
- ls = Math.abs( l - x1 ) <= d;
- rs = Math.abs( r - x2 ) <= d;
- if ( ts ) {
- ui.position.top = inst._convertPositionTo( "relative", {
- top: t,
- left: 0
- } ).top;
- }
- if ( bs ) {
- ui.position.top = inst._convertPositionTo( "relative", {
- top: b - inst.helperProportions.height,
- left: 0
- } ).top;
- }
- if ( ls ) {
- ui.position.left = inst._convertPositionTo( "relative", {
- top: 0,
- left: l
- } ).left;
- }
- if ( rs ) {
- ui.position.left = inst._convertPositionTo( "relative", {
- top: 0,
- left: r - inst.helperProportions.width
- } ).left;
- }
- }
-
- if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
- ( inst.options.snap.snap &&
- inst.options.snap.snap.call(
- inst.element,
- event,
- $.extend( inst._uiHash(), {
- snapItem: inst.snapElements[ i ].item
- } ) ) );
- }
- inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
-
- }
-
- }
-} );
-
-$.ui.plugin.add( "draggable", "stack", {
- start: function( event, ui, instance ) {
- var min,
- o = instance.options,
- group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
- return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
- ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
- } );
-
- if ( !group.length ) { return; }
-
- min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
- $( group ).each( function( i ) {
- $( this ).css( "zIndex", min + i );
- } );
- this.css( "zIndex", ( min + group.length ) );
- }
-} );
-
-$.ui.plugin.add( "draggable", "zIndex", {
- start: function( event, ui, instance ) {
- var t = $( ui.helper ),
- o = instance.options;
-
- if ( t.css( "zIndex" ) ) {
- o._zIndex = t.css( "zIndex" );
- }
- t.css( "zIndex", o.zIndex );
- },
- stop: function( event, ui, instance ) {
- var o = instance.options;
-
- if ( o._zIndex ) {
- $( ui.helper ).css( "zIndex", o._zIndex );
- }
- }
-} );
-
-var widgetsDraggable = $.ui.draggable;
-
-
-/*!
- * jQuery UI Resizable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Resizable
-//>>group: Interactions
-//>>description: Enables resize functionality for any element.
-//>>docs: http://api.jqueryui.com/resizable/
-//>>demos: http://jqueryui.com/resizable/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/resizable.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.resizable", $.ui.mouse, {
- version: "1.12.1",
- widgetEventPrefix: "resize",
- options: {
- alsoResize: false,
- animate: false,
- animateDuration: "slow",
- animateEasing: "swing",
- aspectRatio: false,
- autoHide: false,
- classes: {
- "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
- },
- containment: false,
- ghost: false,
- grid: false,
- handles: "e,s,se",
- helper: false,
- maxHeight: null,
- maxWidth: null,
- minHeight: 10,
- minWidth: 10,
-
- // See #7960
- zIndex: 90,
-
- // Callbacks
- resize: null,
- start: null,
- stop: null
- },
-
- _num: function( value ) {
- return parseFloat( value ) || 0;
- },
-
- _isNumber: function( value ) {
- return !isNaN( parseFloat( value ) );
- },
-
- _hasScroll: function( el, a ) {
-
- if ( $( el ).css( "overflow" ) === "hidden" ) {
- return false;
- }
-
- var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
- has = false;
-
- if ( el[ scroll ] > 0 ) {
- return true;
- }
-
- // TODO: determine which cases actually cause this to happen
- // if the element doesn't have the scroll set, see if it's possible to
- // set the scroll
- el[ scroll ] = 1;
- has = ( el[ scroll ] > 0 );
- el[ scroll ] = 0;
- return has;
- },
-
- _create: function() {
-
- var margins,
- o = this.options,
- that = this;
- this._addClass( "ui-resizable" );
-
- $.extend( this, {
- _aspectRatio: !!( o.aspectRatio ),
- aspectRatio: o.aspectRatio,
- originalElement: this.element,
- _proportionallyResizeElements: [],
- _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
- } );
-
- // Wrap the element if it cannot hold child nodes
- if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
-
- this.element.wrap(
- $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
- position: this.element.css( "position" ),
- width: this.element.outerWidth(),
- height: this.element.outerHeight(),
- top: this.element.css( "top" ),
- left: this.element.css( "left" )
- } )
- );
-
- this.element = this.element.parent().data(
- "ui-resizable", this.element.resizable( "instance" )
- );
-
- this.elementIsWrapper = true;
-
- margins = {
- marginTop: this.originalElement.css( "marginTop" ),
- marginRight: this.originalElement.css( "marginRight" ),
- marginBottom: this.originalElement.css( "marginBottom" ),
- marginLeft: this.originalElement.css( "marginLeft" )
- };
-
- this.element.css( margins );
- this.originalElement.css( "margin", 0 );
-
- // support: Safari
- // Prevent Safari textarea resize
- this.originalResizeStyle = this.originalElement.css( "resize" );
- this.originalElement.css( "resize", "none" );
-
- this._proportionallyResizeElements.push( this.originalElement.css( {
- position: "static",
- zoom: 1,
- display: "block"
- } ) );
-
- // Support: IE9
- // avoid IE jump (hard set the margin)
- this.originalElement.css( margins );
-
- this._proportionallyResize();
- }
-
- this._setupHandles();
-
- if ( o.autoHide ) {
- $( this.element )
- .on( "mouseenter", function() {
- if ( o.disabled ) {
- return;
- }
- that._removeClass( "ui-resizable-autohide" );
- that._handles.show();
- } )
- .on( "mouseleave", function() {
- if ( o.disabled ) {
- return;
- }
- if ( !that.resizing ) {
- that._addClass( "ui-resizable-autohide" );
- that._handles.hide();
- }
- } );
- }
-
- this._mouseInit();
- },
-
- _destroy: function() {
-
- this._mouseDestroy();
-
- var wrapper,
- _destroy = function( exp ) {
- $( exp )
- .removeData( "resizable" )
- .removeData( "ui-resizable" )
- .off( ".resizable" )
- .find( ".ui-resizable-handle" )
- .remove();
- };
-
- // TODO: Unwrap at same DOM position
- if ( this.elementIsWrapper ) {
- _destroy( this.element );
- wrapper = this.element;
- this.originalElement.css( {
- position: wrapper.css( "position" ),
- width: wrapper.outerWidth(),
- height: wrapper.outerHeight(),
- top: wrapper.css( "top" ),
- left: wrapper.css( "left" )
- } ).insertAfter( wrapper );
- wrapper.remove();
- }
-
- this.originalElement.css( "resize", this.originalResizeStyle );
- _destroy( this.originalElement );
-
- return this;
- },
-
- _setOption: function( key, value ) {
- this._super( key, value );
-
- switch ( key ) {
- case "handles":
- this._removeHandles();
- this._setupHandles();
- break;
- default:
- break;
- }
- },
-
- _setupHandles: function() {
- var o = this.options, handle, i, n, hname, axis, that = this;
- this.handles = o.handles ||
- ( !$( ".ui-resizable-handle", this.element ).length ?
- "e,s,se" : {
- n: ".ui-resizable-n",
- e: ".ui-resizable-e",
- s: ".ui-resizable-s",
- w: ".ui-resizable-w",
- se: ".ui-resizable-se",
- sw: ".ui-resizable-sw",
- ne: ".ui-resizable-ne",
- nw: ".ui-resizable-nw"
- } );
-
- this._handles = $();
- if ( this.handles.constructor === String ) {
-
- if ( this.handles === "all" ) {
- this.handles = "n,e,s,w,se,sw,ne,nw";
- }
-
- n = this.handles.split( "," );
- this.handles = {};
-
- for ( i = 0; i < n.length; i++ ) {
-
- handle = $.trim( n[ i ] );
- hname = "ui-resizable-" + handle;
- axis = $( "<div>" );
- this._addClass( axis, "ui-resizable-handle " + hname );
-
- axis.css( { zIndex: o.zIndex } );
-
- this.handles[ handle ] = ".ui-resizable-" + handle;
- this.element.append( axis );
- }
-
- }
-
- this._renderAxis = function( target ) {
-
- var i, axis, padPos, padWrapper;
-
- target = target || this.element;
-
- for ( i in this.handles ) {
-
- if ( this.handles[ i ].constructor === String ) {
- this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
- } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
- this.handles[ i ] = $( this.handles[ i ] );
- this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
- }
-
- if ( this.elementIsWrapper &&
- this.originalElement[ 0 ]
- .nodeName
- .match( /^(textarea|input|select|button)$/i ) ) {
- axis = $( this.handles[ i ], this.element );
-
- padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
- axis.outerHeight() :
- axis.outerWidth();
-
- padPos = [ "padding",
- /ne|nw|n/.test( i ) ? "Top" :
- /se|sw|s/.test( i ) ? "Bottom" :
- /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
-
- target.css( padPos, padWrapper );
-
- this._proportionallyResize();
- }
-
- this._handles = this._handles.add( this.handles[ i ] );
- }
- };
-
- // TODO: make renderAxis a prototype function
- this._renderAxis( this.element );
-
- this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
- this._handles.disableSelection();
-
- this._handles.on( "mouseover", function() {
- if ( !that.resizing ) {
- if ( this.className ) {
- axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
- }
- that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
- }
- } );
-
- if ( o.autoHide ) {
- this._handles.hide();
- this._addClass( "ui-resizable-autohide" );
- }
- },
-
- _removeHandles: function() {
- this._handles.remove();
- },
-
- _mouseCapture: function( event ) {
- var i, handle,
- capture = false;
-
- for ( i in this.handles ) {
- handle = $( this.handles[ i ] )[ 0 ];
- if ( handle === event.target || $.contains( handle, event.target ) ) {
- capture = true;
- }
- }
-
- return !this.options.disabled && capture;
- },
-
- _mouseStart: function( event ) {
-
- var curleft, curtop, cursor,
- o = this.options,
- el = this.element;
-
- this.resizing = true;
-
- this._renderProxy();
-
- curleft = this._num( this.helper.css( "left" ) );
- curtop = this._num( this.helper.css( "top" ) );
-
- if ( o.containment ) {
- curleft += $( o.containment ).scrollLeft() || 0;
- curtop += $( o.containment ).scrollTop() || 0;
- }
-
- this.offset = this.helper.offset();
- this.position = { left: curleft, top: curtop };
-
- this.size = this._helper ? {
- width: this.helper.width(),
- height: this.helper.height()
- } : {
- width: el.width(),
- height: el.height()
- };
-
- this.originalSize = this._helper ? {
- width: el.outerWidth(),
- height: el.outerHeight()
- } : {
- width: el.width(),
- height: el.height()
- };
-
- this.sizeDiff = {
- width: el.outerWidth() - el.width(),
- height: el.outerHeight() - el.height()
- };
-
- this.originalPosition = { left: curleft, top: curtop };
- this.originalMousePosition = { left: event.pageX, top: event.pageY };
-
- this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
- o.aspectRatio :
- ( ( this.originalSize.width / this.originalSize.height ) || 1 );
-
- cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
- $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
-
- this._addClass( "ui-resizable-resizing" );
- this._propagate( "start", event );
- return true;
- },
-
- _mouseDrag: function( event ) {
-
- var data, props,
- smp = this.originalMousePosition,
- a = this.axis,
- dx = ( event.pageX - smp.left ) || 0,
- dy = ( event.pageY - smp.top ) || 0,
- trigger = this._change[ a ];
-
- this._updatePrevProperties();
-
- if ( !trigger ) {
- return false;
- }
-
- data = trigger.apply( this, [ event, dx, dy ] );
-
- this._updateVirtualBoundaries( event.shiftKey );
- if ( this._aspectRatio || event.shiftKey ) {
- data = this._updateRatio( data, event );
- }
-
- data = this._respectSize( data, event );
-
- this._updateCache( data );
-
- this._propagate( "resize", event );
-
- props = this._applyChanges();
-
- if ( !this._helper && this._proportionallyResizeElements.length ) {
- this._proportionallyResize();
- }
-
- if ( !$.isEmptyObject( props ) ) {
- this._updatePrevProperties();
- this._trigger( "resize", event, this.ui() );
- this._applyChanges();
- }
-
- return false;
- },
-
- _mouseStop: function( event ) {
-
- this.resizing = false;
- var pr, ista, soffseth, soffsetw, s, left, top,
- o = this.options, that = this;
-
- if ( this._helper ) {
-
- pr = this._proportionallyResizeElements;
- ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
- soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
- soffsetw = ista ? 0 : that.sizeDiff.width;
-
- s = {
- width: ( that.helper.width() - soffsetw ),
- height: ( that.helper.height() - soffseth )
- };
- left = ( parseFloat( that.element.css( "left" ) ) +
- ( that.position.left - that.originalPosition.left ) ) || null;
- top = ( parseFloat( that.element.css( "top" ) ) +
- ( that.position.top - that.originalPosition.top ) ) || null;
-
- if ( !o.animate ) {
- this.element.css( $.extend( s, { top: top, left: left } ) );
- }
-
- that.helper.height( that.size.height );
- that.helper.width( that.size.width );
-
- if ( this._helper && !o.animate ) {
- this._proportionallyResize();
- }
- }
-
- $( "body" ).css( "cursor", "auto" );
-
- this._removeClass( "ui-resizable-resizing" );
-
- this._propagate( "stop", event );
-
- if ( this._helper ) {
- this.helper.remove();
- }
-
- return false;
-
- },
-
- _updatePrevProperties: function() {
- this.prevPosition = {
- top: this.position.top,
- left: this.position.left
- };
- this.prevSize = {
- width: this.size.width,
- height: this.size.height
- };
- },
-
- _applyChanges: function() {
- var props = {};
-
- if ( this.position.top !== this.prevPosition.top ) {
- props.top = this.position.top + "px";
- }
- if ( this.position.left !== this.prevPosition.left ) {
- props.left = this.position.left + "px";
- }
- if ( this.size.width !== this.prevSize.width ) {
- props.width = this.size.width + "px";
- }
- if ( this.size.height !== this.prevSize.height ) {
- props.height = this.size.height + "px";
- }
-
- this.helper.css( props );
-
- return props;
- },
-
- _updateVirtualBoundaries: function( forceAspectRatio ) {
- var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
- o = this.options;
-
- b = {
- minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
- maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
- minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
- maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
- };
-
- if ( this._aspectRatio || forceAspectRatio ) {
- pMinWidth = b.minHeight * this.aspectRatio;
- pMinHeight = b.minWidth / this.aspectRatio;
- pMaxWidth = b.maxHeight * this.aspectRatio;
- pMaxHeight = b.maxWidth / this.aspectRatio;
-
- if ( pMinWidth > b.minWidth ) {
- b.minWidth = pMinWidth;
- }
- if ( pMinHeight > b.minHeight ) {
- b.minHeight = pMinHeight;
- }
- if ( pMaxWidth < b.maxWidth ) {
- b.maxWidth = pMaxWidth;
- }
- if ( pMaxHeight < b.maxHeight ) {
- b.maxHeight = pMaxHeight;
- }
- }
- this._vBoundaries = b;
- },
-
- _updateCache: function( data ) {
- this.offset = this.helper.offset();
- if ( this._isNumber( data.left ) ) {
- this.position.left = data.left;
- }
- if ( this._isNumber( data.top ) ) {
- this.position.top = data.top;
- }
- if ( this._isNumber( data.height ) ) {
- this.size.height = data.height;
- }
- if ( this._isNumber( data.width ) ) {
- this.size.width = data.width;
- }
- },
-
- _updateRatio: function( data ) {
-
- var cpos = this.position,
- csize = this.size,
- a = this.axis;
-
- if ( this._isNumber( data.height ) ) {
- data.width = ( data.height * this.aspectRatio );
- } else if ( this._isNumber( data.width ) ) {
- data.height = ( data.width / this.aspectRatio );
- }
-
- if ( a === "sw" ) {
- data.left = cpos.left + ( csize.width - data.width );
- data.top = null;
- }
- if ( a === "nw" ) {
- data.top = cpos.top + ( csize.height - data.height );
- data.left = cpos.left + ( csize.width - data.width );
- }
-
- return data;
- },
-
- _respectSize: function( data ) {
-
- var o = this._vBoundaries,
- a = this.axis,
- ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
- ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
- isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
- isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
- dw = this.originalPosition.left + this.originalSize.width,
- dh = this.originalPosition.top + this.originalSize.height,
- cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
- if ( isminw ) {
- data.width = o.minWidth;
- }
- if ( isminh ) {
- data.height = o.minHeight;
- }
- if ( ismaxw ) {
- data.width = o.maxWidth;
- }
- if ( ismaxh ) {
- data.height = o.maxHeight;
- }
-
- if ( isminw && cw ) {
- data.left = dw - o.minWidth;
- }
- if ( ismaxw && cw ) {
- data.left = dw - o.maxWidth;
- }
- if ( isminh && ch ) {
- data.top = dh - o.minHeight;
- }
- if ( ismaxh && ch ) {
- data.top = dh - o.maxHeight;
- }
-
- // Fixing jump error on top/left - bug #2330
- if ( !data.width && !data.height && !data.left && data.top ) {
- data.top = null;
- } else if ( !data.width && !data.height && !data.top && data.left ) {
- data.left = null;
- }
-
- return data;
- },
-
- _getPaddingPlusBorderDimensions: function( element ) {
- var i = 0,
- widths = [],
- borders = [
- element.css( "borderTopWidth" ),
- element.css( "borderRightWidth" ),
- element.css( "borderBottomWidth" ),
- element.css( "borderLeftWidth" )
- ],
- paddings = [
- element.css( "paddingTop" ),
- element.css( "paddingRight" ),
- element.css( "paddingBottom" ),
- element.css( "paddingLeft" )
- ];
-
- for ( ; i < 4; i++ ) {
- widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
- widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
- }
-
- return {
- height: widths[ 0 ] + widths[ 2 ],
- width: widths[ 1 ] + widths[ 3 ]
- };
- },
-
- _proportionallyResize: function() {
-
- if ( !this._proportionallyResizeElements.length ) {
- return;
- }
-
- var prel,
- i = 0,
- element = this.helper || this.element;
-
- for ( ; i < this._proportionallyResizeElements.length; i++ ) {
-
- prel = this._proportionallyResizeElements[ i ];
-
- // TODO: Seems like a bug to cache this.outerDimensions
- // considering that we are in a loop.
- if ( !this.outerDimensions ) {
- this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
- }
-
- prel.css( {
- height: ( element.height() - this.outerDimensions.height ) || 0,
- width: ( element.width() - this.outerDimensions.width ) || 0
- } );
-
- }
-
- },
-
- _renderProxy: function() {
-
- var el = this.element, o = this.options;
- this.elementOffset = el.offset();
-
- if ( this._helper ) {
-
- this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
-
- this._addClass( this.helper, this._helper );
- this.helper.css( {
- width: this.element.outerWidth(),
- height: this.element.outerHeight(),
- position: "absolute",
- left: this.elementOffset.left + "px",
- top: this.elementOffset.top + "px",
- zIndex: ++o.zIndex //TODO: Don't modify option
- } );
-
- this.helper
- .appendTo( "body" )
- .disableSelection();
-
- } else {
- this.helper = this.element;
- }
-
- },
-
- _change: {
- e: function( event, dx ) {
- return { width: this.originalSize.width + dx };
- },
- w: function( event, dx ) {
- var cs = this.originalSize, sp = this.originalPosition;
- return { left: sp.left + dx, width: cs.width - dx };
- },
- n: function( event, dx, dy ) {
- var cs = this.originalSize, sp = this.originalPosition;
- return { top: sp.top + dy, height: cs.height - dy };
- },
- s: function( event, dx, dy ) {
- return { height: this.originalSize.height + dy };
- },
- se: function( event, dx, dy ) {
- return $.extend( this._change.s.apply( this, arguments ),
- this._change.e.apply( this, [ event, dx, dy ] ) );
- },
- sw: function( event, dx, dy ) {
- return $.extend( this._change.s.apply( this, arguments ),
- this._change.w.apply( this, [ event, dx, dy ] ) );
- },
- ne: function( event, dx, dy ) {
- return $.extend( this._change.n.apply( this, arguments ),
- this._change.e.apply( this, [ event, dx, dy ] ) );
- },
- nw: function( event, dx, dy ) {
- return $.extend( this._change.n.apply( this, arguments ),
- this._change.w.apply( this, [ event, dx, dy ] ) );
- }
- },
-
- _propagate: function( n, event ) {
- $.ui.plugin.call( this, n, [ event, this.ui() ] );
- ( n !== "resize" && this._trigger( n, event, this.ui() ) );
- },
-
- plugins: {},
-
- ui: function() {
- return {
- originalElement: this.originalElement,
- element: this.element,
- helper: this.helper,
- position: this.position,
- size: this.size,
- originalSize: this.originalSize,
- originalPosition: this.originalPosition
- };
- }
-
-} );
-
-/*
- * Resizable Extensions
- */
-
-$.ui.plugin.add( "resizable", "animate", {
-
- stop: function( event ) {
- var that = $( this ).resizable( "instance" ),
- o = that.options,
- pr = that._proportionallyResizeElements,
- ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
- soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
- soffsetw = ista ? 0 : that.sizeDiff.width,
- style = {
- width: ( that.size.width - soffsetw ),
- height: ( that.size.height - soffseth )
- },
- left = ( parseFloat( that.element.css( "left" ) ) +
- ( that.position.left - that.originalPosition.left ) ) || null,
- top = ( parseFloat( that.element.css( "top" ) ) +
- ( that.position.top - that.originalPosition.top ) ) || null;
-
- that.element.animate(
- $.extend( style, top && left ? { top: top, left: left } : {} ), {
- duration: o.animateDuration,
- easing: o.animateEasing,
- step: function() {
-
- var data = {
- width: parseFloat( that.element.css( "width" ) ),
- height: parseFloat( that.element.css( "height" ) ),
- top: parseFloat( that.element.css( "top" ) ),
- left: parseFloat( that.element.css( "left" ) )
- };
-
- if ( pr && pr.length ) {
- $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
- }
-
- // Propagating resize, and updating values for each animation step
- that._updateCache( data );
- that._propagate( "resize", event );
-
- }
- }
- );
- }
-
-} );
-
-$.ui.plugin.add( "resizable", "containment", {
-
- start: function() {
- var element, p, co, ch, cw, width, height,
- that = $( this ).resizable( "instance" ),
- o = that.options,
- el = that.element,
- oc = o.containment,
- ce = ( oc instanceof $ ) ?
- oc.get( 0 ) :
- ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
-
- if ( !ce ) {
- return;
- }
-
- that.containerElement = $( ce );
-
- if ( /document/.test( oc ) || oc === document ) {
- that.containerOffset = {
- left: 0,
- top: 0
- };
- that.containerPosition = {
- left: 0,
- top: 0
- };
-
- that.parentData = {
- element: $( document ),
- left: 0,
- top: 0,
- width: $( document ).width(),
- height: $( document ).height() || document.body.parentNode.scrollHeight
- };
- } else {
- element = $( ce );
- p = [];
- $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
- p[ i ] = that._num( element.css( "padding" + name ) );
- } );
-
- that.containerOffset = element.offset();
- that.containerPosition = element.position();
- that.containerSize = {
- height: ( element.innerHeight() - p[ 3 ] ),
- width: ( element.innerWidth() - p[ 1 ] )
- };
-
- co = that.containerOffset;
- ch = that.containerSize.height;
- cw = that.containerSize.width;
- width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
- height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
-
- that.parentData = {
- element: ce,
- left: co.left,
- top: co.top,
- width: width,
- height: height
- };
- }
- },
-
- resize: function( event ) {
- var woset, hoset, isParent, isOffsetRelative,
- that = $( this ).resizable( "instance" ),
- o = that.options,
- co = that.containerOffset,
- cp = that.position,
- pRatio = that._aspectRatio || event.shiftKey,
- cop = {
- top: 0,
- left: 0
- },
- ce = that.containerElement,
- continueResize = true;
-
- if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
- cop = co;
- }
-
- if ( cp.left < ( that._helper ? co.left : 0 ) ) {
- that.size.width = that.size.width +
- ( that._helper ?
- ( that.position.left - co.left ) :
- ( that.position.left - cop.left ) );
-
- if ( pRatio ) {
- that.size.height = that.size.width / that.aspectRatio;
- continueResize = false;
- }
- that.position.left = o.helper ? co.left : 0;
- }
-
- if ( cp.top < ( that._helper ? co.top : 0 ) ) {
- that.size.height = that.size.height +
- ( that._helper ?
- ( that.position.top - co.top ) :
- that.position.top );
-
- if ( pRatio ) {
- that.size.width = that.size.height * that.aspectRatio;
- continueResize = false;
- }
- that.position.top = that._helper ? co.top : 0;
- }
-
- isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
- isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
-
- if ( isParent && isOffsetRelative ) {
- that.offset.left = that.parentData.left + that.position.left;
- that.offset.top = that.parentData.top + that.position.top;
- } else {
- that.offset.left = that.element.offset().left;
- that.offset.top = that.element.offset().top;
- }
-
- woset = Math.abs( that.sizeDiff.width +
- ( that._helper ?
- that.offset.left - cop.left :
- ( that.offset.left - co.left ) ) );
-
- hoset = Math.abs( that.sizeDiff.height +
- ( that._helper ?
- that.offset.top - cop.top :
- ( that.offset.top - co.top ) ) );
-
- if ( woset + that.size.width >= that.parentData.width ) {
- that.size.width = that.parentData.width - woset;
- if ( pRatio ) {
- that.size.height = that.size.width / that.aspectRatio;
- continueResize = false;
- }
- }
-
- if ( hoset + that.size.height >= that.parentData.height ) {
- that.size.height = that.parentData.height - hoset;
- if ( pRatio ) {
- that.size.width = that.size.height * that.aspectRatio;
- continueResize = false;
- }
- }
-
- if ( !continueResize ) {
- that.position.left = that.prevPosition.left;
- that.position.top = that.prevPosition.top;
- that.size.width = that.prevSize.width;
- that.size.height = that.prevSize.height;
- }
- },
-
- stop: function() {
- var that = $( this ).resizable( "instance" ),
- o = that.options,
- co = that.containerOffset,
- cop = that.containerPosition,
- ce = that.containerElement,
- helper = $( that.helper ),
- ho = helper.offset(),
- w = helper.outerWidth() - that.sizeDiff.width,
- h = helper.outerHeight() - that.sizeDiff.height;
-
- if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
- $( this ).css( {
- left: ho.left - cop.left - co.left,
- width: w,
- height: h
- } );
- }
-
- if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
- $( this ).css( {
- left: ho.left - cop.left - co.left,
- width: w,
- height: h
- } );
- }
- }
-} );
-
-$.ui.plugin.add( "resizable", "alsoResize", {
-
- start: function() {
- var that = $( this ).resizable( "instance" ),
- o = that.options;
-
- $( o.alsoResize ).each( function() {
- var el = $( this );
- el.data( "ui-resizable-alsoresize", {
- width: parseFloat( el.width() ), height: parseFloat( el.height() ),
- left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
- } );
- } );
- },
-
- resize: function( event, ui ) {
- var that = $( this ).resizable( "instance" ),
- o = that.options,
- os = that.originalSize,
- op = that.originalPosition,
- delta = {
- height: ( that.size.height - os.height ) || 0,
- width: ( that.size.width - os.width ) || 0,
- top: ( that.position.top - op.top ) || 0,
- left: ( that.position.left - op.left ) || 0
- };
-
- $( o.alsoResize ).each( function() {
- var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
- css = el.parents( ui.originalElement[ 0 ] ).length ?
- [ "width", "height" ] :
- [ "width", "height", "top", "left" ];
-
- $.each( css, function( i, prop ) {
- var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
- if ( sum && sum >= 0 ) {
- style[ prop ] = sum || null;
- }
- } );
-
- el.css( style );
- } );
- },
-
- stop: function() {
- $( this ).removeData( "ui-resizable-alsoresize" );
- }
-} );
-
-$.ui.plugin.add( "resizable", "ghost", {
-
- start: function() {
-
- var that = $( this ).resizable( "instance" ), cs = that.size;
-
- that.ghost = that.originalElement.clone();
- that.ghost.css( {
- opacity: 0.25,
- display: "block",
- position: "relative",
- height: cs.height,
- width: cs.width,
- margin: 0,
- left: 0,
- top: 0
- } );
-
- that._addClass( that.ghost, "ui-resizable-ghost" );
-
- // DEPRECATED
- // TODO: remove after 1.12
- if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
-
- // Ghost option
- that.ghost.addClass( this.options.ghost );
- }
-
- that.ghost.appendTo( that.helper );
-
- },
-
- resize: function() {
- var that = $( this ).resizable( "instance" );
- if ( that.ghost ) {
- that.ghost.css( {
- position: "relative",
- height: that.size.height,
- width: that.size.width
- } );
- }
- },
-
- stop: function() {
- var that = $( this ).resizable( "instance" );
- if ( that.ghost && that.helper ) {
- that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
- }
- }
-
-} );
-
-$.ui.plugin.add( "resizable", "grid", {
-
- resize: function() {
- var outerDimensions,
- that = $( this ).resizable( "instance" ),
- o = that.options,
- cs = that.size,
- os = that.originalSize,
- op = that.originalPosition,
- a = that.axis,
- grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
- gridX = ( grid[ 0 ] || 1 ),
- gridY = ( grid[ 1 ] || 1 ),
- ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
- oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
- newWidth = os.width + ox,
- newHeight = os.height + oy,
- isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
- isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
- isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
- isMinHeight = o.minHeight && ( o.minHeight > newHeight );
-
- o.grid = grid;
-
- if ( isMinWidth ) {
- newWidth += gridX;
- }
- if ( isMinHeight ) {
- newHeight += gridY;
- }
- if ( isMaxWidth ) {
- newWidth -= gridX;
- }
- if ( isMaxHeight ) {
- newHeight -= gridY;
- }
-
- if ( /^(se|s|e)$/.test( a ) ) {
- that.size.width = newWidth;
- that.size.height = newHeight;
- } else if ( /^(ne)$/.test( a ) ) {
- that.size.width = newWidth;
- that.size.height = newHeight;
- that.position.top = op.top - oy;
- } else if ( /^(sw)$/.test( a ) ) {
- that.size.width = newWidth;
- that.size.height = newHeight;
- that.position.left = op.left - ox;
- } else {
- if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
- outerDimensions = that._getPaddingPlusBorderDimensions( this );
- }
-
- if ( newHeight - gridY > 0 ) {
- that.size.height = newHeight;
- that.position.top = op.top - oy;
- } else {
- newHeight = gridY - outerDimensions.height;
- that.size.height = newHeight;
- that.position.top = op.top + os.height - newHeight;
- }
- if ( newWidth - gridX > 0 ) {
- that.size.width = newWidth;
- that.position.left = op.left - ox;
- } else {
- newWidth = gridX - outerDimensions.width;
- that.size.width = newWidth;
- that.position.left = op.left + os.width - newWidth;
- }
- }
- }
-
-} );
-
-var widgetsResizable = $.ui.resizable;
-
-
-/*!
- * jQuery UI Dialog 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Dialog
-//>>group: Widgets
-//>>description: Displays customizable dialog windows.
-//>>docs: http://api.jqueryui.com/dialog/
-//>>demos: http://jqueryui.com/dialog/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/dialog.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.dialog", {
- version: "1.12.1",
- options: {
- appendTo: "body",
- autoOpen: true,
- buttons: [],
- classes: {
- "ui-dialog": "ui-corner-all",
- "ui-dialog-titlebar": "ui-corner-all"
- },
- closeOnEscape: true,
- closeText: "Close",
- draggable: true,
- hide: null,
- height: "auto",
- maxHeight: null,
- maxWidth: null,
- minHeight: 150,
- minWidth: 150,
- modal: false,
- position: {
- my: "center",
- at: "center",
- of: window,
- collision: "fit",
-
- // Ensure the titlebar is always visible
- using: function( pos ) {
- var topOffset = $( this ).css( pos ).offset().top;
- if ( topOffset < 0 ) {
- $( this ).css( "top", pos.top - topOffset );
- }
- }
- },
- resizable: true,
- show: null,
- title: null,
- width: 300,
-
- // Callbacks
- beforeClose: null,
- close: null,
- drag: null,
- dragStart: null,
- dragStop: null,
- focus: null,
- open: null,
- resize: null,
- resizeStart: null,
- resizeStop: null
- },
-
- sizeRelatedOptions: {
- buttons: true,
- height: true,
- maxHeight: true,
- maxWidth: true,
- minHeight: true,
- minWidth: true,
- width: true
- },
-
- resizableRelatedOptions: {
- maxHeight: true,
- maxWidth: true,
- minHeight: true,
- minWidth: true
- },
-
- _create: function() {
- this.originalCss = {
- display: this.element[ 0 ].style.display,
- width: this.element[ 0 ].style.width,
- minHeight: this.element[ 0 ].style.minHeight,
- maxHeight: this.element[ 0 ].style.maxHeight,
- height: this.element[ 0 ].style.height
- };
- this.originalPosition = {
- parent: this.element.parent(),
- index: this.element.parent().children().index( this.element )
- };
- this.originalTitle = this.element.attr( "title" );
- if ( this.options.title == null && this.originalTitle != null ) {
- this.options.title = this.originalTitle;
- }
-
- // Dialogs can't be disabled
- if ( this.options.disabled ) {
- this.options.disabled = false;
- }
-
- this._createWrapper();
-
- this.element
- .show()
- .removeAttr( "title" )
- .appendTo( this.uiDialog );
-
- this._addClass( "ui-dialog-content", "ui-widget-content" );
-
- this._createTitlebar();
- this._createButtonPane();
-
- if ( this.options.draggable && $.fn.draggable ) {
- this._makeDraggable();
- }
- if ( this.options.resizable && $.fn.resizable ) {
- this._makeResizable();
- }
-
- this._isOpen = false;
-
- this._trackFocus();
- },
-
- _init: function() {
- if ( this.options.autoOpen ) {
- this.open();
- }
- },
-
- _appendTo: function() {
- var element = this.options.appendTo;
- if ( element && ( element.jquery || element.nodeType ) ) {
- return $( element );
- }
- return this.document.find( element || "body" ).eq( 0 );
- },
-
- _destroy: function() {
- var next,
- originalPosition = this.originalPosition;
-
- this._untrackInstance();
- this._destroyOverlay();
-
- this.element
- .removeUniqueId()
- .css( this.originalCss )
-
- // Without detaching first, the following becomes really slow
- .detach();
-
- this.uiDialog.remove();
-
- if ( this.originalTitle ) {
- this.element.attr( "title", this.originalTitle );
- }
-
- next = originalPosition.parent.children().eq( originalPosition.index );
-
- // Don't try to place the dialog next to itself (#8613)
- if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
- next.before( this.element );
- } else {
- originalPosition.parent.append( this.element );
- }
- },
-
- widget: function() {
- return this.uiDialog;
- },
-
- disable: $.noop,
- enable: $.noop,
-
- close: function( event ) {
- var that = this;
-
- if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
- return;
- }
-
- this._isOpen = false;
- this._focusedElement = null;
- this._destroyOverlay();
- this._untrackInstance();
-
- if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
-
- // Hiding a focused element doesn't trigger blur in WebKit
- // so in case we have nothing to focus on, explicitly blur the active element
- // https://bugs.webkit.org/show_bug.cgi?id=47182
- $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
- }
-
- this._hide( this.uiDialog, this.options.hide, function() {
- that._trigger( "close", event );
- } );
- },
-
- isOpen: function() {
- return this._isOpen;
- },
-
- moveToTop: function() {
- this._moveToTop();
- },
-
- _moveToTop: function( event, silent ) {
- var moved = false,
- zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
- return +$( this ).css( "z-index" );
- } ).get(),
- zIndexMax = Math.max.apply( null, zIndices );
-
- if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
- this.uiDialog.css( "z-index", zIndexMax + 1 );
- moved = true;
- }
-
- if ( moved && !silent ) {
- this._trigger( "focus", event );
- }
- return moved;
- },
-
- open: function() {
- var that = this;
- if ( this._isOpen ) {
- if ( this._moveToTop() ) {
- this._focusTabbable();
- }
- return;
- }
-
- this._isOpen = true;
- this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
-
- this._size();
- this._position();
- this._createOverlay();
- this._moveToTop( null, true );
-
- // Ensure the overlay is moved to the top with the dialog, but only when
- // opening. The overlay shouldn't move after the dialog is open so that
- // modeless dialogs opened after the modal dialog stack properly.
- if ( this.overlay ) {
- this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
- }
-
- this._show( this.uiDialog, this.options.show, function() {
- that._focusTabbable();
- that._trigger( "focus" );
- } );
-
- // Track the dialog immediately upon openening in case a focus event
- // somehow occurs outside of the dialog before an element inside the
- // dialog is focused (#10152)
- this._makeFocusTarget();
-
- this._trigger( "open" );
- },
-
- _focusTabbable: function() {
-
- // Set focus to the first match:
- // 1. An element that was focused previously
- // 2. First element inside the dialog matching [autofocus]
- // 3. Tabbable element inside the content element
- // 4. Tabbable element inside the buttonpane
- // 5. The close button
- // 6. The dialog itself
- var hasFocus = this._focusedElement;
- if ( !hasFocus ) {
- hasFocus = this.element.find( "[autofocus]" );
- }
- if ( !hasFocus.length ) {
- hasFocus = this.element.find( ":tabbable" );
- }
- if ( !hasFocus.length ) {
- hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
- }
- if ( !hasFocus.length ) {
- hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
- }
- if ( !hasFocus.length ) {
- hasFocus = this.uiDialog;
- }
- hasFocus.eq( 0 ).trigger( "focus" );
- },
-
- _keepFocus: function( event ) {
- function checkFocus() {
- var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
- isActive = this.uiDialog[ 0 ] === activeElement ||
- $.contains( this.uiDialog[ 0 ], activeElement );
- if ( !isActive ) {
- this._focusTabbable();
- }
- }
- event.preventDefault();
- checkFocus.call( this );
-
- // support: IE
- // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
- // so we check again later
- this._delay( checkFocus );
- },
-
- _createWrapper: function() {
- this.uiDialog = $( "<div>" )
- .hide()
- .attr( {
-
- // Setting tabIndex makes the div focusable
- tabIndex: -1,
- role: "dialog"
- } )
- .appendTo( this._appendTo() );
-
- this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
- this._on( this.uiDialog, {
- keydown: function( event ) {
- if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE ) {
- event.preventDefault();
- this.close( event );
- return;
- }
-
- // Prevent tabbing out of dialogs
- if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
- return;
- }
- var tabbables = this.uiDialog.find( ":tabbable" ),
- first = tabbables.filter( ":first" ),
- last = tabbables.filter( ":last" );
-
- if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
- !event.shiftKey ) {
- this._delay( function() {
- first.trigger( "focus" );
- } );
- event.preventDefault();
- } else if ( ( event.target === first[ 0 ] ||
- event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
- this._delay( function() {
- last.trigger( "focus" );
- } );
- event.preventDefault();
- }
- },
- mousedown: function( event ) {
- if ( this._moveToTop( event ) ) {
- this._focusTabbable();
- }
- }
- } );
-
- // We assume that any existing aria-describedby attribute means
- // that the dialog content is marked up properly
- // otherwise we brute force the content as the description
- if ( !this.element.find( "[aria-describedby]" ).length ) {
- this.uiDialog.attr( {
- "aria-describedby": this.element.uniqueId().attr( "id" )
- } );
- }
- },
-
- _createTitlebar: function() {
- var uiDialogTitle;
-
- this.uiDialogTitlebar = $( "<div>" );
- this._addClass( this.uiDialogTitlebar,
- "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
- this._on( this.uiDialogTitlebar, {
- mousedown: function( event ) {
-
- // Don't prevent click on close button (#8838)
- // Focusing a dialog that is partially scrolled out of view
- // causes the browser to scroll it into view, preventing the click event
- if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
-
- // Dialog isn't getting focus when dragging (#8063)
- this.uiDialog.trigger( "focus" );
- }
- }
- } );
-
- // Support: IE
- // Use type="button" to prevent enter keypresses in textboxes from closing the
- // dialog in IE (#9312)
- this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
- .button( {
- label: $( "<a>" ).text( this.options.closeText ).html(),
- icon: "ui-icon-closethick",
- showLabel: false
- } )
- .appendTo( this.uiDialogTitlebar );
-
- this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
- this._on( this.uiDialogTitlebarClose, {
- click: function( event ) {
- event.preventDefault();
- this.close( event );
- }
- } );
-
- uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
- this._addClass( uiDialogTitle, "ui-dialog-title" );
- this._title( uiDialogTitle );
-
- this.uiDialogTitlebar.prependTo( this.uiDialog );
-
- this.uiDialog.attr( {
- "aria-labelledby": uiDialogTitle.attr( "id" )
- } );
- },
-
- _title: function( title ) {
- if ( this.options.title ) {
- title.text( this.options.title );
- } else {
- title.html( " " );
- }
- },
-
- _createButtonPane: function() {
- this.uiDialogButtonPane = $( "<div>" );
- this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
- "ui-widget-content ui-helper-clearfix" );
-
- this.uiButtonSet = $( "<div>" )
- .appendTo( this.uiDialogButtonPane );
- this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
-
- this._createButtons();
- },
-
- _createButtons: function() {
- var that = this,
- buttons = this.options.buttons;
-
- // If we already have a button pane, remove it
- this.uiDialogButtonPane.remove();
- this.uiButtonSet.empty();
-
- if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
- this._removeClass( this.uiDialog, "ui-dialog-buttons" );
- return;
- }
-
- $.each( buttons, function( name, props ) {
- var click, buttonOptions;
- props = $.isFunction( props ) ?
- { click: props, text: name } :
- props;
-
- // Default to a non-submitting button
- props = $.extend( { type: "button" }, props );
-
- // Change the context for the click callback to be the main element
- click = props.click;
- buttonOptions = {
- icon: props.icon,
- iconPosition: props.iconPosition,
- showLabel: props.showLabel,
-
- // Deprecated options
- icons: props.icons,
- text: props.text
- };
-
- delete props.click;
- delete props.icon;
- delete props.iconPosition;
- delete props.showLabel;
-
- // Deprecated options
- delete props.icons;
- if ( typeof props.text === "boolean" ) {
- delete props.text;
- }
-
- $( "<button></button>", props )
- .button( buttonOptions )
- .appendTo( that.uiButtonSet )
- .on( "click", function() {
- click.apply( that.element[ 0 ], arguments );
- } );
- } );
- this._addClass( this.uiDialog, "ui-dialog-buttons" );
- this.uiDialogButtonPane.appendTo( this.uiDialog );
- },
-
- _makeDraggable: function() {
- var that = this,
- options = this.options;
-
- function filteredUi( ui ) {
- return {
- position: ui.position,
- offset: ui.offset
- };
- }
-
- this.uiDialog.draggable( {
- cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
- handle: ".ui-dialog-titlebar",
- containment: "document",
- start: function( event, ui ) {
- that._addClass( $( this ), "ui-dialog-dragging" );
- that._blockFrames();
- that._trigger( "dragStart", event, filteredUi( ui ) );
- },
- drag: function( event, ui ) {
- that._trigger( "drag", event, filteredUi( ui ) );
- },
- stop: function( event, ui ) {
- var left = ui.offset.left - that.document.scrollLeft(),
- top = ui.offset.top - that.document.scrollTop();
-
- options.position = {
- my: "left top",
- at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
- "top" + ( top >= 0 ? "+" : "" ) + top,
- of: that.window
- };
- that._removeClass( $( this ), "ui-dialog-dragging" );
- that._unblockFrames();
- that._trigger( "dragStop", event, filteredUi( ui ) );
- }
- } );
- },
-
- _makeResizable: function() {
- var that = this,
- options = this.options,
- handles = options.resizable,
-
- // .ui-resizable has position: relative defined in the stylesheet
- // but dialogs have to use absolute or fixed positioning
- position = this.uiDialog.css( "position" ),
- resizeHandles = typeof handles === "string" ?
- handles :
- "n,e,s,w,se,sw,ne,nw";
-
- function filteredUi( ui ) {
- return {
- originalPosition: ui.originalPosition,
- originalSize: ui.originalSize,
- position: ui.position,
- size: ui.size
- };
- }
-
- this.uiDialog.resizable( {
- cancel: ".ui-dialog-content",
- containment: "document",
- alsoResize: this.element,
- maxWidth: options.maxWidth,
- maxHeight: options.maxHeight,
- minWidth: options.minWidth,
- minHeight: this._minHeight(),
- handles: resizeHandles,
- start: function( event, ui ) {
- that._addClass( $( this ), "ui-dialog-resizing" );
- that._blockFrames();
- that._trigger( "resizeStart", event, filteredUi( ui ) );
- },
- resize: function( event, ui ) {
- that._trigger( "resize", event, filteredUi( ui ) );
- },
- stop: function( event, ui ) {
- var offset = that.uiDialog.offset(),
- left = offset.left - that.document.scrollLeft(),
- top = offset.top - that.document.scrollTop();
-
- options.height = that.uiDialog.height();
- options.width = that.uiDialog.width();
- options.position = {
- my: "left top",
- at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
- "top" + ( top >= 0 ? "+" : "" ) + top,
- of: that.window
- };
- that._removeClass( $( this ), "ui-dialog-resizing" );
- that._unblockFrames();
- that._trigger( "resizeStop", event, filteredUi( ui ) );
- }
- } )
- .css( "position", position );
- },
-
- _trackFocus: function() {
- this._on( this.widget(), {
- focusin: function( event ) {
- this._makeFocusTarget();
- this._focusedElement = $( event.target );
- }
- } );
- },
-
- _makeFocusTarget: function() {
- this._untrackInstance();
- this._trackingInstances().unshift( this );
- },
-
- _untrackInstance: function() {
- var instances = this._trackingInstances(),
- exists = $.inArray( this, instances );
- if ( exists !== -1 ) {
- instances.splice( exists, 1 );
- }
- },
-
- _trackingInstances: function() {
- var instances = this.document.data( "ui-dialog-instances" );
- if ( !instances ) {
- instances = [];
- this.document.data( "ui-dialog-instances", instances );
- }
- return instances;
- },
-
- _minHeight: function() {
- var options = this.options;
-
- return options.height === "auto" ?
- options.minHeight :
- Math.min( options.minHeight, options.height );
- },
-
- _position: function() {
-
- // Need to show the dialog to get the actual offset in the position plugin
- var isVisible = this.uiDialog.is( ":visible" );
- if ( !isVisible ) {
- this.uiDialog.show();
- }
- this.uiDialog.position( this.options.position );
- if ( !isVisible ) {
- this.uiDialog.hide();
- }
- },
-
- _setOptions: function( options ) {
- var that = this,
- resize = false,
- resizableOptions = {};
-
- $.each( options, function( key, value ) {
- that._setOption( key, value );
-
- if ( key in that.sizeRelatedOptions ) {
- resize = true;
- }
- if ( key in that.resizableRelatedOptions ) {
- resizableOptions[ key ] = value;
- }
- } );
-
- if ( resize ) {
- this._size();
- this._position();
- }
- if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
- this.uiDialog.resizable( "option", resizableOptions );
- }
- },
-
- _setOption: function( key, value ) {
- var isDraggable, isResizable,
- uiDialog = this.uiDialog;
-
- if ( key === "disabled" ) {
- return;
- }
-
- this._super( key, value );
-
- if ( key === "appendTo" ) {
- this.uiDialog.appendTo( this._appendTo() );
- }
-
- if ( key === "buttons" ) {
- this._createButtons();
- }
-
- if ( key === "closeText" ) {
- this.uiDialogTitlebarClose.button( {
-
- // Ensure that we always pass a string
- label: $( "<a>" ).text( "" + this.options.closeText ).html()
- } );
- }
-
- if ( key === "draggable" ) {
- isDraggable = uiDialog.is( ":data(ui-draggable)" );
- if ( isDraggable && !value ) {
- uiDialog.draggable( "destroy" );
- }
-
- if ( !isDraggable && value ) {
- this._makeDraggable();
- }
- }
-
- if ( key === "position" ) {
- this._position();
- }
-
- if ( key === "resizable" ) {
-
- // currently resizable, becoming non-resizable
- isResizable = uiDialog.is( ":data(ui-resizable)" );
- if ( isResizable && !value ) {
- uiDialog.resizable( "destroy" );
- }
-
- // Currently resizable, changing handles
- if ( isResizable && typeof value === "string" ) {
- uiDialog.resizable( "option", "handles", value );
- }
-
- // Currently non-resizable, becoming resizable
- if ( !isResizable && value !== false ) {
- this._makeResizable();
- }
- }
-
- if ( key === "title" ) {
- this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
- }
- },
-
- _size: function() {
-
- // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
- // divs will both have width and height set, so we need to reset them
- var nonContentHeight, minContentHeight, maxContentHeight,
- options = this.options;
-
- // Reset content sizing
- this.element.show().css( {
- width: "auto",
- minHeight: 0,
- maxHeight: "none",
- height: 0
- } );
-
- if ( options.minWidth > options.width ) {
- options.width = options.minWidth;
- }
-
- // Reset wrapper sizing
- // determine the height of all the non-content elements
- nonContentHeight = this.uiDialog.css( {
- height: "auto",
- width: options.width
- } )
- .outerHeight();
- minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
- maxContentHeight = typeof options.maxHeight === "number" ?
- Math.max( 0, options.maxHeight - nonContentHeight ) :
- "none";
-
- if ( options.height === "auto" ) {
- this.element.css( {
- minHeight: minContentHeight,
- maxHeight: maxContentHeight,
- height: "auto"
- } );
- } else {
- this.element.height( Math.max( 0, options.height - nonContentHeight ) );
- }
-
- if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
- this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
- }
- },
-
- _blockFrames: function() {
- this.iframeBlocks = this.document.find( "iframe" ).map( function() {
- var iframe = $( this );
-
- return $( "<div>" )
- .css( {
- position: "absolute",
- width: iframe.outerWidth(),
- height: iframe.outerHeight()
- } )
- .appendTo( iframe.parent() )
- .offset( iframe.offset() )[ 0 ];
- } );
- },
-
- _unblockFrames: function() {
- if ( this.iframeBlocks ) {
- this.iframeBlocks.remove();
- delete this.iframeBlocks;
- }
- },
-
- _allowInteraction: function( event ) {
- if ( $( event.target ).closest( ".ui-dialog" ).length ) {
- return true;
- }
-
- // TODO: Remove hack when datepicker implements
- // the .ui-front logic (#8989)
- return !!$( event.target ).closest( ".ui-datepicker" ).length;
- },
-
- _createOverlay: function() {
- if ( !this.options.modal ) {
- return;
- }
-
- // We use a delay in case the overlay is created from an
- // event that we're going to be cancelling (#2804)
- var isOpening = true;
- this._delay( function() {
- isOpening = false;
- } );
-
- if ( !this.document.data( "ui-dialog-overlays" ) ) {
-
- // Prevent use of anchors and inputs
- // Using _on() for an event handler shared across many instances is
- // safe because the dialogs stack and must be closed in reverse order
- this._on( this.document, {
- focusin: function( event ) {
- if ( isOpening ) {
- return;
- }
-
- if ( !this._allowInteraction( event ) ) {
- event.preventDefault();
- this._trackingInstances()[ 0 ]._focusTabbable();
- }
- }
- } );
- }
-
- this.overlay = $( "<div>" )
- .appendTo( this._appendTo() );
-
- this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
- this._on( this.overlay, {
- mousedown: "_keepFocus"
- } );
- this.document.data( "ui-dialog-overlays",
- ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
- },
-
- _destroyOverlay: function() {
- if ( !this.options.modal ) {
- return;
- }
-
- if ( this.overlay ) {
- var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
-
- if ( !overlays ) {
- this._off( this.document, "focusin" );
- this.document.removeData( "ui-dialog-overlays" );
- } else {
- this.document.data( "ui-dialog-overlays", overlays );
- }
-
- this.overlay.remove();
- this.overlay = null;
- }
- }
-} );
-
-// DEPRECATED
-// TODO: switch return back to widget declaration at top of file when this is removed
-if ( $.uiBackCompat !== false ) {
-
- // Backcompat for dialogClass option
- $.widget( "ui.dialog", $.ui.dialog, {
- options: {
- dialogClass: ""
- },
- _createWrapper: function() {
- this._super();
- this.uiDialog.addClass( this.options.dialogClass );
- },
- _setOption: function( key, value ) {
- if ( key === "dialogClass" ) {
- this.uiDialog
- .removeClass( this.options.dialogClass )
- .addClass( value );
- }
- this._superApply( arguments );
- }
- } );
-}
-
-var widgetsDialog = $.ui.dialog;
-
-
-/*!
- * jQuery UI Droppable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Droppable
-//>>group: Interactions
-//>>description: Enables drop targets for draggable elements.
-//>>docs: http://api.jqueryui.com/droppable/
-//>>demos: http://jqueryui.com/droppable/
-
-
-
-$.widget( "ui.droppable", {
- version: "1.12.1",
- widgetEventPrefix: "drop",
- options: {
- accept: "*",
- addClasses: true,
- greedy: false,
- scope: "default",
- tolerance: "intersect",
-
- // Callbacks
- activate: null,
- deactivate: null,
- drop: null,
- out: null,
- over: null
- },
- _create: function() {
-
- var proportions,
- o = this.options,
- accept = o.accept;
-
- this.isover = false;
- this.isout = true;
-
- this.accept = $.isFunction( accept ) ? accept : function( d ) {
- return d.is( accept );
- };
-
- this.proportions = function( /* valueToWrite */ ) {
- if ( arguments.length ) {
-
- // Store the droppable's proportions
- proportions = arguments[ 0 ];
- } else {
-
- // Retrieve or derive the droppable's proportions
- return proportions ?
- proportions :
- proportions = {
- width: this.element[ 0 ].offsetWidth,
- height: this.element[ 0 ].offsetHeight
- };
- }
- };
-
- this._addToManager( o.scope );
-
- o.addClasses && this._addClass( "ui-droppable" );
-
- },
-
- _addToManager: function( scope ) {
-
- // Add the reference and positions to the manager
- $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
- $.ui.ddmanager.droppables[ scope ].push( this );
- },
-
- _splice: function( drop ) {
- var i = 0;
- for ( ; i < drop.length; i++ ) {
- if ( drop[ i ] === this ) {
- drop.splice( i, 1 );
- }
- }
- },
-
- _destroy: function() {
- var drop = $.ui.ddmanager.droppables[ this.options.scope ];
-
- this._splice( drop );
- },
-
- _setOption: function( key, value ) {
-
- if ( key === "accept" ) {
- this.accept = $.isFunction( value ) ? value : function( d ) {
- return d.is( value );
- };
- } else if ( key === "scope" ) {
- var drop = $.ui.ddmanager.droppables[ this.options.scope ];
-
- this._splice( drop );
- this._addToManager( value );
- }
-
- this._super( key, value );
- },
-
- _activate: function( event ) {
- var draggable = $.ui.ddmanager.current;
-
- this._addActiveClass();
- if ( draggable ) {
- this._trigger( "activate", event, this.ui( draggable ) );
- }
- },
-
- _deactivate: function( event ) {
- var draggable = $.ui.ddmanager.current;
-
- this._removeActiveClass();
- if ( draggable ) {
- this._trigger( "deactivate", event, this.ui( draggable ) );
- }
- },
-
- _over: function( event ) {
-
- var draggable = $.ui.ddmanager.current;
-
- // Bail if draggable and droppable are same element
- if ( !draggable || ( draggable.currentItem ||
- draggable.element )[ 0 ] === this.element[ 0 ] ) {
- return;
- }
-
- if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
- draggable.element ) ) ) {
- this._addHoverClass();
- this._trigger( "over", event, this.ui( draggable ) );
- }
-
- },
-
- _out: function( event ) {
-
- var draggable = $.ui.ddmanager.current;
-
- // Bail if draggable and droppable are same element
- if ( !draggable || ( draggable.currentItem ||
- draggable.element )[ 0 ] === this.element[ 0 ] ) {
- return;
- }
-
- if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
- draggable.element ) ) ) {
- this._removeHoverClass();
- this._trigger( "out", event, this.ui( draggable ) );
- }
-
- },
-
- _drop: function( event, custom ) {
-
- var draggable = custom || $.ui.ddmanager.current,
- childrenIntersection = false;
-
- // Bail if draggable and droppable are same element
- if ( !draggable || ( draggable.currentItem ||
- draggable.element )[ 0 ] === this.element[ 0 ] ) {
- return false;
- }
-
- this.element
- .find( ":data(ui-droppable)" )
- .not( ".ui-draggable-dragging" )
- .each( function() {
- var inst = $( this ).droppable( "instance" );
- if (
- inst.options.greedy &&
- !inst.options.disabled &&
- inst.options.scope === draggable.options.scope &&
- inst.accept.call(
- inst.element[ 0 ], ( draggable.currentItem || draggable.element )
- ) &&
- intersect(
- draggable,
- $.extend( inst, { offset: inst.element.offset() } ),
- inst.options.tolerance, event
- )
- ) {
- childrenIntersection = true;
- return false; }
- } );
- if ( childrenIntersection ) {
- return false;
- }
-
- if ( this.accept.call( this.element[ 0 ],
- ( draggable.currentItem || draggable.element ) ) ) {
- this._removeActiveClass();
- this._removeHoverClass();
-
- this._trigger( "drop", event, this.ui( draggable ) );
- return this.element;
- }
-
- return false;
-
- },
-
- ui: function( c ) {
- return {
- draggable: ( c.currentItem || c.element ),
- helper: c.helper,
- position: c.position,
- offset: c.positionAbs
- };
- },
-
- // Extension points just to make backcompat sane and avoid duplicating logic
- // TODO: Remove in 1.13 along with call to it below
- _addHoverClass: function() {
- this._addClass( "ui-droppable-hover" );
- },
-
- _removeHoverClass: function() {
- this._removeClass( "ui-droppable-hover" );
- },
-
- _addActiveClass: function() {
- this._addClass( "ui-droppable-active" );
- },
-
- _removeActiveClass: function() {
- this._removeClass( "ui-droppable-active" );
- }
-} );
-
-var intersect = $.ui.intersect = ( function() {
- function isOverAxis( x, reference, size ) {
- return ( x >= reference ) && ( x < ( reference + size ) );
- }
-
- return function( draggable, droppable, toleranceMode, event ) {
-
- if ( !droppable.offset ) {
- return false;
- }
-
- var x1 = ( draggable.positionAbs ||
- draggable.position.absolute ).left + draggable.margins.left,
- y1 = ( draggable.positionAbs ||
- draggable.position.absolute ).top + draggable.margins.top,
- x2 = x1 + draggable.helperProportions.width,
- y2 = y1 + draggable.helperProportions.height,
- l = droppable.offset.left,
- t = droppable.offset.top,
- r = l + droppable.proportions().width,
- b = t + droppable.proportions().height;
-
- switch ( toleranceMode ) {
- case "fit":
- return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
- case "intersect":
- return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
- x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
- t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
- y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
- case "pointer":
- return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
- isOverAxis( event.pageX, l, droppable.proportions().width );
- case "touch":
- return (
- ( y1 >= t && y1 <= b ) || // Top edge touching
- ( y2 >= t && y2 <= b ) || // Bottom edge touching
- ( y1 < t && y2 > b ) // Surrounded vertically
- ) && (
- ( x1 >= l && x1 <= r ) || // Left edge touching
- ( x2 >= l && x2 <= r ) || // Right edge touching
- ( x1 < l && x2 > r ) // Surrounded horizontally
- );
- default:
- return false;
- }
- };
-} )();
-
-/*
- This manager tracks offsets of draggables and droppables
-*/
-$.ui.ddmanager = {
- current: null,
- droppables: { "default": [] },
- prepareOffsets: function( t, event ) {
-
- var i, j,
- m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
- type = event ? event.type : null, // workaround for #2317
- list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
-
- droppablesLoop: for ( i = 0; i < m.length; i++ ) {
-
- // No disabled and non-accepted
- if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
- ( t.currentItem || t.element ) ) ) ) {
- continue;
- }
-
- // Filter out elements in the current dragged item
- for ( j = 0; j < list.length; j++ ) {
- if ( list[ j ] === m[ i ].element[ 0 ] ) {
- m[ i ].proportions().height = 0;
- continue droppablesLoop;
- }
- }
-
- m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
- if ( !m[ i ].visible ) {
- continue;
- }
-
- // Activate the droppable if used directly from draggables
- if ( type === "mousedown" ) {
- m[ i ]._activate.call( m[ i ], event );
- }
-
- m[ i ].offset = m[ i ].element.offset();
- m[ i ].proportions( {
- width: m[ i ].element[ 0 ].offsetWidth,
- height: m[ i ].element[ 0 ].offsetHeight
- } );
-
- }
-
- },
- drop: function( draggable, event ) {
-
- var dropped = false;
-
- // Create a copy of the droppables in case the list changes during the drop (#9116)
- $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
-
- if ( !this.options ) {
- return;
- }
- if ( !this.options.disabled && this.visible &&
- intersect( draggable, this, this.options.tolerance, event ) ) {
- dropped = this._drop.call( this, event ) || dropped;
- }
-
- if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
- ( draggable.currentItem || draggable.element ) ) ) {
- this.isout = true;
- this.isover = false;
- this._deactivate.call( this, event );
- }
-
- } );
- return dropped;
-
- },
- dragStart: function( draggable, event ) {
-
- // Listen for scrolling so that if the dragging causes scrolling the position of the
- // droppables can be recalculated (see #5003)
- draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
- if ( !draggable.options.refreshPositions ) {
- $.ui.ddmanager.prepareOffsets( draggable, event );
- }
- } );
- },
- drag: function( draggable, event ) {
-
- // If you have a highly dynamic page, you might try this option. It renders positions
- // every time you move the mouse.
- if ( draggable.options.refreshPositions ) {
- $.ui.ddmanager.prepareOffsets( draggable, event );
- }
-
- // Run through all droppables and check their positions based on specific tolerance options
- $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
-
- if ( this.options.disabled || this.greedyChild || !this.visible ) {
- return;
- }
-
- var parentInstance, scope, parent,
- intersects = intersect( draggable, this, this.options.tolerance, event ),
- c = !intersects && this.isover ?
- "isout" :
- ( intersects && !this.isover ? "isover" : null );
- if ( !c ) {
- return;
- }
-
- if ( this.options.greedy ) {
-
- // find droppable parents with same scope
- scope = this.options.scope;
- parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
- return $( this ).droppable( "instance" ).options.scope === scope;
- } );
-
- if ( parent.length ) {
- parentInstance = $( parent[ 0 ] ).droppable( "instance" );
- parentInstance.greedyChild = ( c === "isover" );
- }
- }
-
- // We just moved into a greedy child
- if ( parentInstance && c === "isover" ) {
- parentInstance.isover = false;
- parentInstance.isout = true;
- parentInstance._out.call( parentInstance, event );
- }
-
- this[ c ] = true;
- this[ c === "isout" ? "isover" : "isout" ] = false;
- this[ c === "isover" ? "_over" : "_out" ].call( this, event );
-
- // We just moved out of a greedy child
- if ( parentInstance && c === "isout" ) {
- parentInstance.isout = false;
- parentInstance.isover = true;
- parentInstance._over.call( parentInstance, event );
- }
- } );
-
- },
- dragStop: function( draggable, event ) {
- draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
-
- // Call prepareOffsets one final time since IE does not fire return scroll events when
- // overflow was caused by drag (see #5003)
- if ( !draggable.options.refreshPositions ) {
- $.ui.ddmanager.prepareOffsets( draggable, event );
- }
- }
-};
-
-// DEPRECATED
-// TODO: switch return back to widget declaration at top of file when this is removed
-if ( $.uiBackCompat !== false ) {
-
- // Backcompat for activeClass and hoverClass options
- $.widget( "ui.droppable", $.ui.droppable, {
- options: {
- hoverClass: false,
- activeClass: false
- },
- _addActiveClass: function() {
- this._super();
- if ( this.options.activeClass ) {
- this.element.addClass( this.options.activeClass );
- }
- },
- _removeActiveClass: function() {
- this._super();
- if ( this.options.activeClass ) {
- this.element.removeClass( this.options.activeClass );
- }
- },
- _addHoverClass: function() {
- this._super();
- if ( this.options.hoverClass ) {
- this.element.addClass( this.options.hoverClass );
- }
- },
- _removeHoverClass: function() {
- this._super();
- if ( this.options.hoverClass ) {
- this.element.removeClass( this.options.hoverClass );
- }
- }
- } );
-}
-
-var widgetsDroppable = $.ui.droppable;
-
-
-/*!
- * jQuery UI Progressbar 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Progressbar
-//>>group: Widgets
-// jscs:disable maximumLineLength
-//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
-// jscs:enable maximumLineLength
-//>>docs: http://api.jqueryui.com/progressbar/
-//>>demos: http://jqueryui.com/progressbar/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/progressbar.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-var widgetsProgressbar = $.widget( "ui.progressbar", {
- version: "1.12.1",
- options: {
- classes: {
- "ui-progressbar": "ui-corner-all",
- "ui-progressbar-value": "ui-corner-left",
- "ui-progressbar-complete": "ui-corner-right"
- },
- max: 100,
- value: 0,
-
- change: null,
- complete: null
- },
-
- min: 0,
-
- _create: function() {
-
- // Constrain initial value
- this.oldValue = this.options.value = this._constrainedValue();
-
- this.element.attr( {
-
- // Only set static values; aria-valuenow and aria-valuemax are
- // set inside _refreshValue()
- role: "progressbar",
- "aria-valuemin": this.min
- } );
- this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
-
- this.valueDiv = $( "<div>" ).appendTo( this.element );
- this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
- this._refreshValue();
- },
-
- _destroy: function() {
- this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
-
- this.valueDiv.remove();
- },
-
- value: function( newValue ) {
- if ( newValue === undefined ) {
- return this.options.value;
- }
-
- this.options.value = this._constrainedValue( newValue );
- this._refreshValue();
- },
-
- _constrainedValue: function( newValue ) {
- if ( newValue === undefined ) {
- newValue = this.options.value;
- }
-
- this.indeterminate = newValue === false;
-
- // Sanitize value
- if ( typeof newValue !== "number" ) {
- newValue = 0;
- }
-
- return this.indeterminate ? false :
- Math.min( this.options.max, Math.max( this.min, newValue ) );
- },
-
- _setOptions: function( options ) {
-
- // Ensure "value" option is set after other values (like max)
- var value = options.value;
- delete options.value;
-
- this._super( options );
-
- this.options.value = this._constrainedValue( value );
- this._refreshValue();
- },
-
- _setOption: function( key, value ) {
- if ( key === "max" ) {
-
- // Don't allow a max less than min
- value = Math.max( this.min, value );
- }
- this._super( key, value );
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this.element.attr( "aria-disabled", value );
- this._toggleClass( null, "ui-state-disabled", !!value );
- },
-
- _percentage: function() {
- return this.indeterminate ?
- 100 :
- 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
- },
-
- _refreshValue: function() {
- var value = this.options.value,
- percentage = this._percentage();
-
- this.valueDiv
- .toggle( this.indeterminate || value > this.min )
- .width( percentage.toFixed( 0 ) + "%" );
-
- this
- ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
- value === this.options.max )
- ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
-
- if ( this.indeterminate ) {
- this.element.removeAttr( "aria-valuenow" );
- if ( !this.overlayDiv ) {
- this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
- this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
- }
- } else {
- this.element.attr( {
- "aria-valuemax": this.options.max,
- "aria-valuenow": value
- } );
- if ( this.overlayDiv ) {
- this.overlayDiv.remove();
- this.overlayDiv = null;
- }
- }
-
- if ( this.oldValue !== value ) {
- this.oldValue = value;
- this._trigger( "change" );
- }
- if ( value === this.options.max ) {
- this._trigger( "complete" );
- }
- }
-} );
-
-
-/*!
- * jQuery UI Selectable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Selectable
-//>>group: Interactions
-//>>description: Allows groups of elements to be selected with the mouse.
-//>>docs: http://api.jqueryui.com/selectable/
-//>>demos: http://jqueryui.com/selectable/
-//>>css.structure: ../../themes/base/selectable.css
-
-
-
-var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
- version: "1.12.1",
- options: {
- appendTo: "body",
- autoRefresh: true,
- distance: 0,
- filter: "*",
- tolerance: "touch",
-
- // Callbacks
- selected: null,
- selecting: null,
- start: null,
- stop: null,
- unselected: null,
- unselecting: null
- },
- _create: function() {
- var that = this;
-
- this._addClass( "ui-selectable" );
-
- this.dragged = false;
-
- // Cache selectee children based on filter
- this.refresh = function() {
- that.elementPos = $( that.element[ 0 ] ).offset();
- that.selectees = $( that.options.filter, that.element[ 0 ] );
- that._addClass( that.selectees, "ui-selectee" );
- that.selectees.each( function() {
- var $this = $( this ),
- selecteeOffset = $this.offset(),
- pos = {
- left: selecteeOffset.left - that.elementPos.left,
- top: selecteeOffset.top - that.elementPos.top
- };
- $.data( this, "selectable-item", {
- element: this,
- $element: $this,
- left: pos.left,
- top: pos.top,
- right: pos.left + $this.outerWidth(),
- bottom: pos.top + $this.outerHeight(),
- startselected: false,
- selected: $this.hasClass( "ui-selected" ),
- selecting: $this.hasClass( "ui-selecting" ),
- unselecting: $this.hasClass( "ui-unselecting" )
- } );
- } );
- };
- this.refresh();
-
- this._mouseInit();
-
- this.helper = $( "<div>" );
- this._addClass( this.helper, "ui-selectable-helper" );
- },
-
- _destroy: function() {
- this.selectees.removeData( "selectable-item" );
- this._mouseDestroy();
- },
-
- _mouseStart: function( event ) {
- var that = this,
- options = this.options;
-
- this.opos = [ event.pageX, event.pageY ];
- this.elementPos = $( this.element[ 0 ] ).offset();
-
- if ( this.options.disabled ) {
- return;
- }
-
- this.selectees = $( options.filter, this.element[ 0 ] );
-
- this._trigger( "start", event );
-
- $( options.appendTo ).append( this.helper );
-
- // position helper (lasso)
- this.helper.css( {
- "left": event.pageX,
- "top": event.pageY,
- "width": 0,
- "height": 0
- } );
-
- if ( options.autoRefresh ) {
- this.refresh();
- }
-
- this.selectees.filter( ".ui-selected" ).each( function() {
- var selectee = $.data( this, "selectable-item" );
- selectee.startselected = true;
- if ( !event.metaKey && !event.ctrlKey ) {
- that._removeClass( selectee.$element, "ui-selected" );
- selectee.selected = false;
- that._addClass( selectee.$element, "ui-unselecting" );
- selectee.unselecting = true;
-
- // selectable UNSELECTING callback
- that._trigger( "unselecting", event, {
- unselecting: selectee.element
- } );
- }
- } );
-
- $( event.target ).parents().addBack().each( function() {
- var doSelect,
- selectee = $.data( this, "selectable-item" );
- if ( selectee ) {
- doSelect = ( !event.metaKey && !event.ctrlKey ) ||
- !selectee.$element.hasClass( "ui-selected" );
- that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
- ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
- selectee.unselecting = !doSelect;
- selectee.selecting = doSelect;
- selectee.selected = doSelect;
-
- // selectable (UN)SELECTING callback
- if ( doSelect ) {
- that._trigger( "selecting", event, {
- selecting: selectee.element
- } );
- } else {
- that._trigger( "unselecting", event, {
- unselecting: selectee.element
- } );
- }
- return false;
- }
- } );
-
- },
-
- _mouseDrag: function( event ) {
-
- this.dragged = true;
-
- if ( this.options.disabled ) {
- return;
- }
-
- var tmp,
- that = this,
- options = this.options,
- x1 = this.opos[ 0 ],
- y1 = this.opos[ 1 ],
- x2 = event.pageX,
- y2 = event.pageY;
-
- if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
- if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
- this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
-
- this.selectees.each( function() {
- var selectee = $.data( this, "selectable-item" ),
- hit = false,
- offset = {};
-
- //prevent helper from being selected if appendTo: selectable
- if ( !selectee || selectee.element === that.element[ 0 ] ) {
- return;
- }
-
- offset.left = selectee.left + that.elementPos.left;
- offset.right = selectee.right + that.elementPos.left;
- offset.top = selectee.top + that.elementPos.top;
- offset.bottom = selectee.bottom + that.elementPos.top;
-
- if ( options.tolerance === "touch" ) {
- hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
- offset.bottom < y1 ) );
- } else if ( options.tolerance === "fit" ) {
- hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
- offset.bottom < y2 );
- }
-
- if ( hit ) {
-
- // SELECT
- if ( selectee.selected ) {
- that._removeClass( selectee.$element, "ui-selected" );
- selectee.selected = false;
- }
- if ( selectee.unselecting ) {
- that._removeClass( selectee.$element, "ui-unselecting" );
- selectee.unselecting = false;
- }
- if ( !selectee.selecting ) {
- that._addClass( selectee.$element, "ui-selecting" );
- selectee.selecting = true;
-
- // selectable SELECTING callback
- that._trigger( "selecting", event, {
- selecting: selectee.element
- } );
- }
- } else {
-
- // UNSELECT
- if ( selectee.selecting ) {
- if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
- that._removeClass( selectee.$element, "ui-selecting" );
- selectee.selecting = false;
- that._addClass( selectee.$element, "ui-selected" );
- selectee.selected = true;
- } else {
- that._removeClass( selectee.$element, "ui-selecting" );
- selectee.selecting = false;
- if ( selectee.startselected ) {
- that._addClass( selectee.$element, "ui-unselecting" );
- selectee.unselecting = true;
- }
-
- // selectable UNSELECTING callback
- that._trigger( "unselecting", event, {
- unselecting: selectee.element
- } );
- }
- }
- if ( selectee.selected ) {
- if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
- that._removeClass( selectee.$element, "ui-selected" );
- selectee.selected = false;
-
- that._addClass( selectee.$element, "ui-unselecting" );
- selectee.unselecting = true;
-
- // selectable UNSELECTING callback
- that._trigger( "unselecting", event, {
- unselecting: selectee.element
- } );
- }
- }
- }
- } );
-
- return false;
- },
-
- _mouseStop: function( event ) {
- var that = this;
-
- this.dragged = false;
-
- $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
- var selectee = $.data( this, "selectable-item" );
- that._removeClass( selectee.$element, "ui-unselecting" );
- selectee.unselecting = false;
- selectee.startselected = false;
- that._trigger( "unselected", event, {
- unselected: selectee.element
- } );
- } );
- $( ".ui-selecting", this.element[ 0 ] ).each( function() {
- var selectee = $.data( this, "selectable-item" );
- that._removeClass( selectee.$element, "ui-selecting" )
- ._addClass( selectee.$element, "ui-selected" );
- selectee.selecting = false;
- selectee.selected = true;
- selectee.startselected = true;
- that._trigger( "selected", event, {
- selected: selectee.element
- } );
- } );
- this._trigger( "stop", event );
-
- this.helper.remove();
-
- return false;
- }
-
-} );
-
-
-/*!
- * jQuery UI Selectmenu 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Selectmenu
-//>>group: Widgets
-// jscs:disable maximumLineLength
-//>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
-// jscs:enable maximumLineLength
-//>>docs: http://api.jqueryui.com/selectmenu/
-//>>demos: http://jqueryui.com/selectmenu/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
- version: "1.12.1",
- defaultElement: "<select>",
- options: {
- appendTo: null,
- classes: {
- "ui-selectmenu-button-open": "ui-corner-top",
- "ui-selectmenu-button-closed": "ui-corner-all"
- },
- disabled: null,
- icons: {
- button: "ui-icon-triangle-1-s"
- },
- position: {
- my: "left top",
- at: "left bottom",
- collision: "none"
- },
- width: false,
-
- // Callbacks
- change: null,
- close: null,
- focus: null,
- open: null,
- select: null
- },
-
- _create: function() {
- var selectmenuId = this.element.uniqueId().attr( "id" );
- this.ids = {
- element: selectmenuId,
- button: selectmenuId + "-button",
- menu: selectmenuId + "-menu"
- };
-
- this._drawButton();
- this._drawMenu();
- this._bindFormResetHandler();
-
- this._rendered = false;
- this.menuItems = $();
- },
-
- _drawButton: function() {
- var icon,
- that = this,
- item = this._parseOption(
- this.element.find( "option:selected" ),
- this.element[ 0 ].selectedIndex
- );
-
- // Associate existing label with the new button
- this.labels = this.element.labels().attr( "for", this.ids.button );
- this._on( this.labels, {
- click: function( event ) {
- this.button.focus();
- event.preventDefault();
- }
- } );
-
- // Hide original select element
- this.element.hide();
-
- // Create button
- this.button = $( "<span>", {
- tabindex: this.options.disabled ? -1 : 0,
- id: this.ids.button,
- role: "combobox",
- "aria-expanded": "false",
- "aria-autocomplete": "list",
- "aria-owns": this.ids.menu,
- "aria-haspopup": "true",
- title: this.element.attr( "title" )
- } )
- .insertAfter( this.element );
-
- this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
- "ui-button ui-widget" );
-
- icon = $( "<span>" ).appendTo( this.button );
- this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
- this.buttonItem = this._renderButtonItem( item )
- .appendTo( this.button );
-
- if ( this.options.width !== false ) {
- this._resizeButton();
- }
-
- this._on( this.button, this._buttonEvents );
- this.button.one( "focusin", function() {
-
- // Delay rendering the menu items until the button receives focus.
- // The menu may have already been rendered via a programmatic open.
- if ( !that._rendered ) {
- that._refreshMenu();
- }
- } );
- },
-
- _drawMenu: function() {
- var that = this;
-
- // Create menu
- this.menu = $( "<ul>", {
- "aria-hidden": "true",
- "aria-labelledby": this.ids.button,
- id: this.ids.menu
- } );
-
- // Wrap menu
- this.menuWrap = $( "<div>" ).append( this.menu );
- this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
- this.menuWrap.appendTo( this._appendTo() );
-
- // Initialize menu widget
- this.menuInstance = this.menu
- .menu( {
- classes: {
- "ui-menu": "ui-corner-bottom"
- },
- role: "listbox",
- select: function( event, ui ) {
- event.preventDefault();
-
- // Support: IE8
- // If the item was selected via a click, the text selection
- // will be destroyed in IE
- that._setSelection();
-
- that._select( ui.item.data( "ui-selectmenu-item" ), event );
- },
- focus: function( event, ui ) {
- var item = ui.item.data( "ui-selectmenu-item" );
-
- // Prevent inital focus from firing and check if its a newly focused item
- if ( that.focusIndex != null && item.index !== that.focusIndex ) {
- that._trigger( "focus", event, { item: item } );
- if ( !that.isOpen ) {
- that._select( item, event );
- }
- }
- that.focusIndex = item.index;
-
- that.button.attr( "aria-activedescendant",
- that.menuItems.eq( item.index ).attr( "id" ) );
- }
- } )
- .menu( "instance" );
-
- // Don't close the menu on mouseleave
- this.menuInstance._off( this.menu, "mouseleave" );
-
- // Cancel the menu's collapseAll on document click
- this.menuInstance._closeOnDocumentClick = function() {
- return false;
- };
-
- // Selects often contain empty items, but never contain dividers
- this.menuInstance._isDivider = function() {
- return false;
- };
- },
-
- refresh: function() {
- this._refreshMenu();
- this.buttonItem.replaceWith(
- this.buttonItem = this._renderButtonItem(
-
- // Fall back to an empty object in case there are no options
- this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
- )
- );
- if ( this.options.width === null ) {
- this._resizeButton();
- }
- },
-
- _refreshMenu: function() {
- var item,
- options = this.element.find( "option" );
-
- this.menu.empty();
-
- this._parseOptions( options );
- this._renderMenu( this.menu, this.items );
-
- this.menuInstance.refresh();
- this.menuItems = this.menu.find( "li" )
- .not( ".ui-selectmenu-optgroup" )
- .find( ".ui-menu-item-wrapper" );
-
- this._rendered = true;
-
- if ( !options.length ) {
- return;
- }
-
- item = this._getSelectedItem();
-
- // Update the menu to have the correct item focused
- this.menuInstance.focus( null, item );
- this._setAria( item.data( "ui-selectmenu-item" ) );
-
- // Set disabled state
- this._setOption( "disabled", this.element.prop( "disabled" ) );
- },
-
- open: function( event ) {
- if ( this.options.disabled ) {
- return;
- }
-
- // If this is the first time the menu is being opened, render the items
- if ( !this._rendered ) {
- this._refreshMenu();
- } else {
-
- // Menu clears focus on close, reset focus to selected item
- this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
- this.menuInstance.focus( null, this._getSelectedItem() );
- }
-
- // If there are no options, don't open the menu
- if ( !this.menuItems.length ) {
- return;
- }
-
- this.isOpen = true;
- this._toggleAttr();
- this._resizeMenu();
- this._position();
-
- this._on( this.document, this._documentClick );
-
- this._trigger( "open", event );
- },
-
- _position: function() {
- this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
- },
-
- close: function( event ) {
- if ( !this.isOpen ) {
- return;
- }
-
- this.isOpen = false;
- this._toggleAttr();
-
- this.range = null;
- this._off( this.document );
-
- this._trigger( "close", event );
- },
-
- widget: function() {
- return this.button;
- },
-
- menuWidget: function() {
- return this.menu;
- },
-
- _renderButtonItem: function( item ) {
- var buttonItem = $( "<span>" );
-
- this._setText( buttonItem, item.label );
- this._addClass( buttonItem, "ui-selectmenu-text" );
-
- return buttonItem;
- },
-
- _renderMenu: function( ul, items ) {
- var that = this,
- currentOptgroup = "";
-
- $.each( items, function( index, item ) {
- var li;
-
- if ( item.optgroup !== currentOptgroup ) {
- li = $( "<li>", {
- text: item.optgroup
- } );
- that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
- ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
- " ui-state-disabled" :
- "" ) );
-
- li.appendTo( ul );
-
- currentOptgroup = item.optgroup;
- }
-
- that._renderItemData( ul, item );
- } );
- },
-
- _renderItemData: function( ul, item ) {
- return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
- },
-
- _renderItem: function( ul, item ) {
- var li = $( "<li>" ),
- wrapper = $( "<div>", {
- title: item.element.attr( "title" )
- } );
-
- if ( item.disabled ) {
- this._addClass( li, null, "ui-state-disabled" );
- }
- this._setText( wrapper, item.label );
-
- return li.append( wrapper ).appendTo( ul );
- },
-
- _setText: function( element, value ) {
- if ( value ) {
- element.text( value );
- } else {
- element.html( " " );
- }
- },
-
- _move: function( direction, event ) {
- var item, next,
- filter = ".ui-menu-item";
-
- if ( this.isOpen ) {
- item = this.menuItems.eq( this.focusIndex ).parent( "li" );
- } else {
- item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
- filter += ":not(.ui-state-disabled)";
- }
-
- if ( direction === "first" || direction === "last" ) {
- next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
- } else {
- next = item[ direction + "All" ]( filter ).eq( 0 );
- }
-
- if ( next.length ) {
- this.menuInstance.focus( event, next );
- }
- },
-
- _getSelectedItem: function() {
- return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
- },
-
- _toggle: function( event ) {
- this[ this.isOpen ? "close" : "open" ]( event );
- },
-
- _setSelection: function() {
- var selection;
-
- if ( !this.range ) {
- return;
- }
-
- if ( window.getSelection ) {
- selection = window.getSelection();
- selection.removeAllRanges();
- selection.addRange( this.range );
-
- // Support: IE8
- } else {
- this.range.select();
- }
-
- // Support: IE
- // Setting the text selection kills the button focus in IE, but
- // restoring the focus doesn't kill the selection.
- this.button.focus();
- },
-
- _documentClick: {
- mousedown: function( event ) {
- if ( !this.isOpen ) {
- return;
- }
-
- if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
- $.ui.escapeSelector( this.ids.button ) ).length ) {
- this.close( event );
- }
- }
- },
-
- _buttonEvents: {
-
- // Prevent text selection from being reset when interacting with the selectmenu (#10144)
- mousedown: function() {
- var selection;
-
- if ( window.getSelection ) {
- selection = window.getSelection();
- if ( selection.rangeCount ) {
- this.range = selection.getRangeAt( 0 );
- }
-
- // Support: IE8
- } else {
- this.range = document.selection.createRange();
- }
- },
-
- click: function( event ) {
- this._setSelection();
- this._toggle( event );
- },
-
- keydown: function( event ) {
- var preventDefault = true;
- switch ( event.keyCode ) {
- case $.ui.keyCode.TAB:
- case $.ui.keyCode.ESCAPE:
- this.close( event );
- preventDefault = false;
- break;
- case $.ui.keyCode.ENTER:
- if ( this.isOpen ) {
- this._selectFocusedItem( event );
- }
- break;
- case $.ui.keyCode.UP:
- if ( event.altKey ) {
- this._toggle( event );
- } else {
- this._move( "prev", event );
- }
- break;
- case $.ui.keyCode.DOWN:
- if ( event.altKey ) {
- this._toggle( event );
- } else {
- this._move( "next", event );
- }
- break;
- case $.ui.keyCode.SPACE:
- if ( this.isOpen ) {
- this._selectFocusedItem( event );
- } else {
- this._toggle( event );
- }
- break;
- case $.ui.keyCode.LEFT:
- this._move( "prev", event );
- break;
- case $.ui.keyCode.RIGHT:
- this._move( "next", event );
- break;
- case $.ui.keyCode.HOME:
- case $.ui.keyCode.PAGE_UP:
- this._move( "first", event );
- break;
- case $.ui.keyCode.END:
- case $.ui.keyCode.PAGE_DOWN:
- this._move( "last", event );
- break;
- default:
- this.menu.trigger( event );
- preventDefault = false;
- }
-
- if ( preventDefault ) {
- event.preventDefault();
- }
- }
- },
-
- _selectFocusedItem: function( event ) {
- var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
- if ( !item.hasClass( "ui-state-disabled" ) ) {
- this._select( item.data( "ui-selectmenu-item" ), event );
- }
- },
-
- _select: function( item, event ) {
- var oldIndex = this.element[ 0 ].selectedIndex;
-
- // Change native select element
- this.element[ 0 ].selectedIndex = item.index;
- this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
- this._setAria( item );
- this._trigger( "select", event, { item: item } );
-
- if ( item.index !== oldIndex ) {
- this._trigger( "change", event, { item: item } );
- }
-
- this.close( event );
- },
-
- _setAria: function( item ) {
- var id = this.menuItems.eq( item.index ).attr( "id" );
-
- this.button.attr( {
- "aria-labelledby": id,
- "aria-activedescendant": id
- } );
- this.menu.attr( "aria-activedescendant", id );
- },
-
- _setOption: function( key, value ) {
- if ( key === "icons" ) {
- var icon = this.button.find( "span.ui-icon" );
- this._removeClass( icon, null, this.options.icons.button )
- ._addClass( icon, null, value.button );
- }
-
- this._super( key, value );
-
- if ( key === "appendTo" ) {
- this.menuWrap.appendTo( this._appendTo() );
- }
-
- if ( key === "width" ) {
- this._resizeButton();
- }
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this.menuInstance.option( "disabled", value );
- this.button.attr( "aria-disabled", value );
- this._toggleClass( this.button, null, "ui-state-disabled", value );
-
- this.element.prop( "disabled", value );
- if ( value ) {
- this.button.attr( "tabindex", -1 );
- this.close();
- } else {
- this.button.attr( "tabindex", 0 );
- }
- },
-
- _appendTo: function() {
- var element = this.options.appendTo;
-
- if ( element ) {
- element = element.jquery || element.nodeType ?
- $( element ) :
- this.document.find( element ).eq( 0 );
- }
-
- if ( !element || !element[ 0 ] ) {
- element = this.element.closest( ".ui-front, dialog" );
- }
-
- if ( !element.length ) {
- element = this.document[ 0 ].body;
- }
-
- return element;
- },
-
- _toggleAttr: function() {
- this.button.attr( "aria-expanded", this.isOpen );
-
- // We can't use two _toggleClass() calls here, because we need to make sure
- // we always remove classes first and add them second, otherwise if both classes have the
- // same theme class, it will be removed after we add it.
- this._removeClass( this.button, "ui-selectmenu-button-" +
- ( this.isOpen ? "closed" : "open" ) )
- ._addClass( this.button, "ui-selectmenu-button-" +
- ( this.isOpen ? "open" : "closed" ) )
- ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
-
- this.menu.attr( "aria-hidden", !this.isOpen );
- },
-
- _resizeButton: function() {
- var width = this.options.width;
-
- // For `width: false`, just remove inline style and stop
- if ( width === false ) {
- this.button.css( "width", "" );
- return;
- }
-
- // For `width: null`, match the width of the original element
- if ( width === null ) {
- width = this.element.show().outerWidth();
- this.element.hide();
- }
-
- this.button.outerWidth( width );
- },
-
- _resizeMenu: function() {
- this.menu.outerWidth( Math.max(
- this.button.outerWidth(),
-
- // Support: IE10
- // IE10 wraps long text (possibly a rounding bug)
- // so we add 1px to avoid the wrapping
- this.menu.width( "" ).outerWidth() + 1
- ) );
- },
-
- _getCreateOptions: function() {
- var options = this._super();
-
- options.disabled = this.element.prop( "disabled" );
-
- return options;
- },
-
- _parseOptions: function( options ) {
- var that = this,
- data = [];
- options.each( function( index, item ) {
- data.push( that._parseOption( $( item ), index ) );
- } );
- this.items = data;
- },
-
- _parseOption: function( option, index ) {
- var optgroup = option.parent( "optgroup" );
-
- return {
- element: option,
- index: index,
- value: option.val(),
- label: option.text(),
- optgroup: optgroup.attr( "label" ) || "",
- disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
- };
- },
-
- _destroy: function() {
- this._unbindFormResetHandler();
- this.menuWrap.remove();
- this.button.remove();
- this.element.show();
- this.element.removeUniqueId();
- this.labels.attr( "for", this.ids.element );
- }
-} ] );
-
-
-/*!
- * jQuery UI Slider 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Slider
-//>>group: Widgets
-//>>description: Displays a flexible slider with ranges and accessibility via keyboard.
-//>>docs: http://api.jqueryui.com/slider/
-//>>demos: http://jqueryui.com/slider/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/slider.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
- version: "1.12.1",
- widgetEventPrefix: "slide",
-
- options: {
- animate: false,
- classes: {
- "ui-slider": "ui-corner-all",
- "ui-slider-handle": "ui-corner-all",
-
- // Note: ui-widget-header isn't the most fittingly semantic framework class for this
- // element, but worked best visually with a variety of themes
- "ui-slider-range": "ui-corner-all ui-widget-header"
- },
- distance: 0,
- max: 100,
- min: 0,
- orientation: "horizontal",
- range: false,
- step: 1,
- value: 0,
- values: null,
-
- // Callbacks
- change: null,
- slide: null,
- start: null,
- stop: null
- },
-
- // Number of pages in a slider
- // (how many times can you page up/down to go through the whole range)
- numPages: 5,
-
- _create: function() {
- this._keySliding = false;
- this._mouseSliding = false;
- this._animateOff = true;
- this._handleIndex = null;
- this._detectOrientation();
- this._mouseInit();
- this._calculateNewMax();
-
- this._addClass( "ui-slider ui-slider-" + this.orientation,
- "ui-widget ui-widget-content" );
-
- this._refresh();
-
- this._animateOff = false;
- },
-
- _refresh: function() {
- this._createRange();
- this._createHandles();
- this._setupEvents();
- this._refreshValue();
- },
-
- _createHandles: function() {
- var i, handleCount,
- options = this.options,
- existingHandles = this.element.find( ".ui-slider-handle" ),
- handle = "<span tabindex='0'></span>",
- handles = [];
-
- handleCount = ( options.values && options.values.length ) || 1;
-
- if ( existingHandles.length > handleCount ) {
- existingHandles.slice( handleCount ).remove();
- existingHandles = existingHandles.slice( 0, handleCount );
- }
-
- for ( i = existingHandles.length; i < handleCount; i++ ) {
- handles.push( handle );
- }
-
- this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
-
- this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
-
- this.handle = this.handles.eq( 0 );
-
- this.handles.each( function( i ) {
- $( this )
- .data( "ui-slider-handle-index", i )
- .attr( "tabIndex", 0 );
- } );
- },
-
- _createRange: function() {
- var options = this.options;
-
- if ( options.range ) {
- if ( options.range === true ) {
- if ( !options.values ) {
- options.values = [ this._valueMin(), this._valueMin() ];
- } else if ( options.values.length && options.values.length !== 2 ) {
- options.values = [ options.values[ 0 ], options.values[ 0 ] ];
- } else if ( $.isArray( options.values ) ) {
- options.values = options.values.slice( 0 );
- }
- }
-
- if ( !this.range || !this.range.length ) {
- this.range = $( "<div>" )
- .appendTo( this.element );
-
- this._addClass( this.range, "ui-slider-range" );
- } else {
- this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
-
- // Handle range switching from true to min/max
- this.range.css( {
- "left": "",
- "bottom": ""
- } );
- }
- if ( options.range === "min" || options.range === "max" ) {
- this._addClass( this.range, "ui-slider-range-" + options.range );
- }
- } else {
- if ( this.range ) {
- this.range.remove();
- }
- this.range = null;
- }
- },
-
- _setupEvents: function() {
- this._off( this.handles );
- this._on( this.handles, this._handleEvents );
- this._hoverable( this.handles );
- this._focusable( this.handles );
- },
-
- _destroy: function() {
- this.handles.remove();
- if ( this.range ) {
- this.range.remove();
- }
-
- this._mouseDestroy();
- },
-
- _mouseCapture: function( event ) {
- var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
- that = this,
- o = this.options;
-
- if ( o.disabled ) {
- return false;
- }
-
- this.elementSize = {
- width: this.element.outerWidth(),
- height: this.element.outerHeight()
- };
- this.elementOffset = this.element.offset();
-
- position = { x: event.pageX, y: event.pageY };
- normValue = this._normValueFromMouse( position );
- distance = this._valueMax() - this._valueMin() + 1;
- this.handles.each( function( i ) {
- var thisDistance = Math.abs( normValue - that.values( i ) );
- if ( ( distance > thisDistance ) ||
- ( distance === thisDistance &&
- ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
- distance = thisDistance;
- closestHandle = $( this );
- index = i;
- }
- } );
-
- allowed = this._start( event, index );
- if ( allowed === false ) {
- return false;
- }
- this._mouseSliding = true;
-
- this._handleIndex = index;
-
- this._addClass( closestHandle, null, "ui-state-active" );
- closestHandle.trigger( "focus" );
-
- offset = closestHandle.offset();
- mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
- this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
- left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
- top: event.pageY - offset.top -
- ( closestHandle.height() / 2 ) -
- ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
- ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
- ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
- };
-
- if ( !this.handles.hasClass( "ui-state-hover" ) ) {
- this._slide( event, index, normValue );
- }
- this._animateOff = true;
- return true;
- },
-
- _mouseStart: function() {
- return true;
- },
-
- _mouseDrag: function( event ) {
- var position = { x: event.pageX, y: event.pageY },
- normValue = this._normValueFromMouse( position );
-
- this._slide( event, this._handleIndex, normValue );
-
- return false;
- },
-
- _mouseStop: function( event ) {
- this._removeClass( this.handles, null, "ui-state-active" );
- this._mouseSliding = false;
-
- this._stop( event, this._handleIndex );
- this._change( event, this._handleIndex );
-
- this._handleIndex = null;
- this._clickOffset = null;
- this._animateOff = false;
-
- return false;
- },
-
- _detectOrientation: function() {
- this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
- },
-
- _normValueFromMouse: function( position ) {
- var pixelTotal,
- pixelMouse,
- percentMouse,
- valueTotal,
- valueMouse;
-
- if ( this.orientation === "horizontal" ) {
- pixelTotal = this.elementSize.width;
- pixelMouse = position.x - this.elementOffset.left -
- ( this._clickOffset ? this._clickOffset.left : 0 );
- } else {
- pixelTotal = this.elementSize.height;
- pixelMouse = position.y - this.elementOffset.top -
- ( this._clickOffset ? this._clickOffset.top : 0 );
- }
-
- percentMouse = ( pixelMouse / pixelTotal );
- if ( percentMouse > 1 ) {
- percentMouse = 1;
- }
- if ( percentMouse < 0 ) {
- percentMouse = 0;
- }
- if ( this.orientation === "vertical" ) {
- percentMouse = 1 - percentMouse;
- }
-
- valueTotal = this._valueMax() - this._valueMin();
- valueMouse = this._valueMin() + percentMouse * valueTotal;
-
- return this._trimAlignValue( valueMouse );
- },
-
- _uiHash: function( index, value, values ) {
- var uiHash = {
- handle: this.handles[ index ],
- handleIndex: index,
- value: value !== undefined ? value : this.value()
- };
-
- if ( this._hasMultipleValues() ) {
- uiHash.value = value !== undefined ? value : this.values( index );
- uiHash.values = values || this.values();
- }
-
- return uiHash;
- },
-
- _hasMultipleValues: function() {
- return this.options.values && this.options.values.length;
- },
-
- _start: function( event, index ) {
- return this._trigger( "start", event, this._uiHash( index ) );
- },
-
- _slide: function( event, index, newVal ) {
- var allowed, otherVal,
- currentValue = this.value(),
- newValues = this.values();
-
- if ( this._hasMultipleValues() ) {
- otherVal = this.values( index ? 0 : 1 );
- currentValue = this.values( index );
-
- if ( this.options.values.length === 2 && this.options.range === true ) {
- newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
- }
-
- newValues[ index ] = newVal;
- }
-
- if ( newVal === currentValue ) {
- return;
- }
-
- allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
-
- // A slide can be canceled by returning false from the slide callback
- if ( allowed === false ) {
- return;
- }
-
- if ( this._hasMultipleValues() ) {
- this.values( index, newVal );
- } else {
- this.value( newVal );
- }
- },
-
- _stop: function( event, index ) {
- this._trigger( "stop", event, this._uiHash( index ) );
- },
-
- _change: function( event, index ) {
- if ( !this._keySliding && !this._mouseSliding ) {
-
- //store the last changed value index for reference when handles overlap
- this._lastChangedValue = index;
- this._trigger( "change", event, this._uiHash( index ) );
- }
- },
-
- value: function( newValue ) {
- if ( arguments.length ) {
- this.options.value = this._trimAlignValue( newValue );
- this._refreshValue();
- this._change( null, 0 );
- return;
- }
-
- return this._value();
- },
-
- values: function( index, newValue ) {
- var vals,
- newValues,
- i;
-
- if ( arguments.length > 1 ) {
- this.options.values[ index ] = this._trimAlignValue( newValue );
- this._refreshValue();
- this._change( null, index );
- return;
- }
-
- if ( arguments.length ) {
- if ( $.isArray( arguments[ 0 ] ) ) {
- vals = this.options.values;
- newValues = arguments[ 0 ];
- for ( i = 0; i < vals.length; i += 1 ) {
- vals[ i ] = this._trimAlignValue( newValues[ i ] );
- this._change( null, i );
- }
- this._refreshValue();
- } else {
- if ( this._hasMultipleValues() ) {
- return this._values( index );
- } else {
- return this.value();
- }
- }
- } else {
- return this._values();
- }
- },
-
- _setOption: function( key, value ) {
- var i,
- valsLength = 0;
-
- if ( key === "range" && this.options.range === true ) {
- if ( value === "min" ) {
- this.options.value = this._values( 0 );
- this.options.values = null;
- } else if ( value === "max" ) {
- this.options.value = this._values( this.options.values.length - 1 );
- this.options.values = null;
- }
- }
-
- if ( $.isArray( this.options.values ) ) {
- valsLength = this.options.values.length;
- }
-
- this._super( key, value );
-
- switch ( key ) {
- case "orientation":
- this._detectOrientation();
- this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
- ._addClass( "ui-slider-" + this.orientation );
- this._refreshValue();
- if ( this.options.range ) {
- this._refreshRange( value );
- }
-
- // Reset positioning from previous orientation
- this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
- break;
- case "value":
- this._animateOff = true;
- this._refreshValue();
- this._change( null, 0 );
- this._animateOff = false;
- break;
- case "values":
- this._animateOff = true;
- this._refreshValue();
-
- // Start from the last handle to prevent unreachable handles (#9046)
- for ( i = valsLength - 1; i >= 0; i-- ) {
- this._change( null, i );
- }
- this._animateOff = false;
- break;
- case "step":
- case "min":
- case "max":
- this._animateOff = true;
- this._calculateNewMax();
- this._refreshValue();
- this._animateOff = false;
- break;
- case "range":
- this._animateOff = true;
- this._refresh();
- this._animateOff = false;
- break;
- }
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this._toggleClass( null, "ui-state-disabled", !!value );
- },
-
- //internal value getter
- // _value() returns value trimmed by min and max, aligned by step
- _value: function() {
- var val = this.options.value;
- val = this._trimAlignValue( val );
-
- return val;
- },
-
- //internal values getter
- // _values() returns array of values trimmed by min and max, aligned by step
- // _values( index ) returns single value trimmed by min and max, aligned by step
- _values: function( index ) {
- var val,
- vals,
- i;
-
- if ( arguments.length ) {
- val = this.options.values[ index ];
- val = this._trimAlignValue( val );
-
- return val;
- } else if ( this._hasMultipleValues() ) {
-
- // .slice() creates a copy of the array
- // this copy gets trimmed by min and max and then returned
- vals = this.options.values.slice();
- for ( i = 0; i < vals.length; i += 1 ) {
- vals[ i ] = this._trimAlignValue( vals[ i ] );
- }
-
- return vals;
- } else {
- return [];
- }
- },
-
- // Returns the step-aligned value that val is closest to, between (inclusive) min and max
- _trimAlignValue: function( val ) {
- if ( val <= this._valueMin() ) {
- return this._valueMin();
- }
- if ( val >= this._valueMax() ) {
- return this._valueMax();
- }
- var step = ( this.options.step > 0 ) ? this.options.step : 1,
- valModStep = ( val - this._valueMin() ) % step,
- alignValue = val - valModStep;
-
- if ( Math.abs( valModStep ) * 2 >= step ) {
- alignValue += ( valModStep > 0 ) ? step : ( -step );
- }
-
- // Since JavaScript has problems with large floats, round
- // the final value to 5 digits after the decimal point (see #4124)
- return parseFloat( alignValue.toFixed( 5 ) );
- },
-
- _calculateNewMax: function() {
- var max = this.options.max,
- min = this._valueMin(),
- step = this.options.step,
- aboveMin = Math.round( ( max - min ) / step ) * step;
- max = aboveMin + min;
- if ( max > this.options.max ) {
-
- //If max is not divisible by step, rounding off may increase its value
- max -= step;
- }
- this.max = parseFloat( max.toFixed( this._precision() ) );
- },
-
- _precision: function() {
- var precision = this._precisionOf( this.options.step );
- if ( this.options.min !== null ) {
- precision = Math.max( precision, this._precisionOf( this.options.min ) );
- }
- return precision;
- },
-
- _precisionOf: function( num ) {
- var str = num.toString(),
- decimal = str.indexOf( "." );
- return decimal === -1 ? 0 : str.length - decimal - 1;
- },
-
- _valueMin: function() {
- return this.options.min;
- },
-
- _valueMax: function() {
- return this.max;
- },
-
- _refreshRange: function( orientation ) {
- if ( orientation === "vertical" ) {
- this.range.css( { "width": "", "left": "" } );
- }
- if ( orientation === "horizontal" ) {
- this.range.css( { "height": "", "bottom": "" } );
- }
- },
-
- _refreshValue: function() {
- var lastValPercent, valPercent, value, valueMin, valueMax,
- oRange = this.options.range,
- o = this.options,
- that = this,
- animate = ( !this._animateOff ) ? o.animate : false,
- _set = {};
-
- if ( this._hasMultipleValues() ) {
- this.handles.each( function( i ) {
- valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
- that._valueMin() ) * 100;
- _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
- $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
- if ( that.options.range === true ) {
- if ( that.orientation === "horizontal" ) {
- if ( i === 0 ) {
- that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- left: valPercent + "%"
- }, o.animate );
- }
- if ( i === 1 ) {
- that.range[ animate ? "animate" : "css" ]( {
- width: ( valPercent - lastValPercent ) + "%"
- }, {
- queue: false,
- duration: o.animate
- } );
- }
- } else {
- if ( i === 0 ) {
- that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- bottom: ( valPercent ) + "%"
- }, o.animate );
- }
- if ( i === 1 ) {
- that.range[ animate ? "animate" : "css" ]( {
- height: ( valPercent - lastValPercent ) + "%"
- }, {
- queue: false,
- duration: o.animate
- } );
- }
- }
- }
- lastValPercent = valPercent;
- } );
- } else {
- value = this.value();
- valueMin = this._valueMin();
- valueMax = this._valueMax();
- valPercent = ( valueMax !== valueMin ) ?
- ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
- 0;
- _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
- this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
-
- if ( oRange === "min" && this.orientation === "horizontal" ) {
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- width: valPercent + "%"
- }, o.animate );
- }
- if ( oRange === "max" && this.orientation === "horizontal" ) {
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- width: ( 100 - valPercent ) + "%"
- }, o.animate );
- }
- if ( oRange === "min" && this.orientation === "vertical" ) {
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- height: valPercent + "%"
- }, o.animate );
- }
- if ( oRange === "max" && this.orientation === "vertical" ) {
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
- height: ( 100 - valPercent ) + "%"
- }, o.animate );
- }
- }
- },
-
- _handleEvents: {
- keydown: function( event ) {
- var allowed, curVal, newVal, step,
- index = $( event.target ).data( "ui-slider-handle-index" );
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.HOME:
- case $.ui.keyCode.END:
- case $.ui.keyCode.PAGE_UP:
- case $.ui.keyCode.PAGE_DOWN:
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- event.preventDefault();
- if ( !this._keySliding ) {
- this._keySliding = true;
- this._addClass( $( event.target ), null, "ui-state-active" );
- allowed = this._start( event, index );
- if ( allowed === false ) {
- return;
- }
- }
- break;
- }
-
- step = this.options.step;
- if ( this._hasMultipleValues() ) {
- curVal = newVal = this.values( index );
- } else {
- curVal = newVal = this.value();
- }
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.HOME:
- newVal = this._valueMin();
- break;
- case $.ui.keyCode.END:
- newVal = this._valueMax();
- break;
- case $.ui.keyCode.PAGE_UP:
- newVal = this._trimAlignValue(
- curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
- );
- break;
- case $.ui.keyCode.PAGE_DOWN:
- newVal = this._trimAlignValue(
- curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
- break;
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- if ( curVal === this._valueMax() ) {
- return;
- }
- newVal = this._trimAlignValue( curVal + step );
- break;
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- if ( curVal === this._valueMin() ) {
- return;
- }
- newVal = this._trimAlignValue( curVal - step );
- break;
- }
-
- this._slide( event, index, newVal );
- },
- keyup: function( event ) {
- var index = $( event.target ).data( "ui-slider-handle-index" );
-
- if ( this._keySliding ) {
- this._keySliding = false;
- this._stop( event, index );
- this._change( event, index );
- this._removeClass( $( event.target ), null, "ui-state-active" );
- }
- }
- }
-} );
-
-
-/*!
- * jQuery UI Sortable 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Sortable
-//>>group: Interactions
-//>>description: Enables items in a list to be sorted using the mouse.
-//>>docs: http://api.jqueryui.com/sortable/
-//>>demos: http://jqueryui.com/sortable/
-//>>css.structure: ../../themes/base/sortable.css
-
-
-
-var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
- version: "1.12.1",
- widgetEventPrefix: "sort",
- ready: false,
- options: {
- appendTo: "parent",
- axis: false,
- connectWith: false,
- containment: false,
- cursor: "auto",
- cursorAt: false,
- dropOnEmpty: true,
- forcePlaceholderSize: false,
- forceHelperSize: false,
- grid: false,
- handle: false,
- helper: "original",
- items: "> *",
- opacity: false,
- placeholder: false,
- revert: false,
- scroll: true,
- scrollSensitivity: 20,
- scrollSpeed: 20,
- scope: "default",
- tolerance: "intersect",
- zIndex: 1000,
-
- // Callbacks
- activate: null,
- beforeStop: null,
- change: null,
- deactivate: null,
- out: null,
- over: null,
- receive: null,
- remove: null,
- sort: null,
- start: null,
- stop: null,
- update: null
- },
-
- _isOverAxis: function( x, reference, size ) {
- return ( x >= reference ) && ( x < ( reference + size ) );
- },
-
- _isFloating: function( item ) {
- return ( /left|right/ ).test( item.css( "float" ) ) ||
- ( /inline|table-cell/ ).test( item.css( "display" ) );
- },
-
- _create: function() {
- this.containerCache = {};
- this._addClass( "ui-sortable" );
-
- //Get the items
- this.refresh();
-
- //Let's determine the parent's offset
- this.offset = this.element.offset();
-
- //Initialize mouse events for interaction
- this._mouseInit();
-
- this._setHandleClassName();
-
- //We're ready to go
- this.ready = true;
-
- },
-
- _setOption: function( key, value ) {
- this._super( key, value );
-
- if ( key === "handle" ) {
- this._setHandleClassName();
- }
- },
-
- _setHandleClassName: function() {
- var that = this;
- this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
- $.each( this.items, function() {
- that._addClass(
- this.instance.options.handle ?
- this.item.find( this.instance.options.handle ) :
- this.item,
- "ui-sortable-handle"
- );
- } );
- },
-
- _destroy: function() {
- this._mouseDestroy();
-
- for ( var i = this.items.length - 1; i >= 0; i-- ) {
- this.items[ i ].item.removeData( this.widgetName + "-item" );
- }
-
- return this;
- },
-
- _mouseCapture: function( event, overrideHandle ) {
- var currentItem = null,
- validHandle = false,
- that = this;
-
- if ( this.reverting ) {
- return false;
- }
-
- if ( this.options.disabled || this.options.type === "static" ) {
- return false;
- }
-
- //We have to refresh the items data once first
- this._refreshItems( event );
-
- //Find out if the clicked node (or one of its parents) is a actual item in this.items
- $( event.target ).parents().each( function() {
- if ( $.data( this, that.widgetName + "-item" ) === that ) {
- currentItem = $( this );
- return false;
- }
- } );
- if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
- currentItem = $( event.target );
- }
-
- if ( !currentItem ) {
- return false;
- }
- if ( this.options.handle && !overrideHandle ) {
- $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
- if ( this === event.target ) {
- validHandle = true;
- }
- } );
- if ( !validHandle ) {
- return false;
- }
- }
-
- this.currentItem = currentItem;
- this._removeCurrentsFromItems();
- return true;
-
- },
-
- _mouseStart: function( event, overrideHandle, noActivation ) {
-
- var i, body,
- o = this.options;
-
- this.currentContainer = this;
-
- //We only need to call refreshPositions, because the refreshItems call has been moved to
- // mouseCapture
- this.refreshPositions();
-
- //Create and append the visible helper
- this.helper = this._createHelper( event );
-
- //Cache the helper size
- this._cacheHelperProportions();
-
- /*
- * - Position generation -
- * This block generates everything position related - it's the core of draggables.
- */
-
- //Cache the margins of the original element
- this._cacheMargins();
-
- //Get the next scrolling parent
- this.scrollParent = this.helper.scrollParent();
-
- //The element's absolute position on the page minus margins
- this.offset = this.currentItem.offset();
- this.offset = {
- top: this.offset.top - this.margins.top,
- left: this.offset.left - this.margins.left
- };
-
- $.extend( this.offset, {
- click: { //Where the click happened, relative to the element
- left: event.pageX - this.offset.left,
- top: event.pageY - this.offset.top
- },
- parent: this._getParentOffset(),
-
- // This is a relative to absolute position minus the actual position calculation -
- // only used for relative positioned helper
- relative: this._getRelativeOffset()
- } );
-
- // Only after we got the offset, we can change the helper's position to absolute
- // TODO: Still need to figure out a way to make relative sorting possible
- this.helper.css( "position", "absolute" );
- this.cssPosition = this.helper.css( "position" );
-
- //Generate the original position
- this.originalPosition = this._generatePosition( event );
- this.originalPageX = event.pageX;
- this.originalPageY = event.pageY;
-
- //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
- ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
-
- //Cache the former DOM position
- this.domPosition = {
- prev: this.currentItem.prev()[ 0 ],
- parent: this.currentItem.parent()[ 0 ]
- };
-
- // If the helper is not the original, hide the original so it's not playing any role during
- // the drag, won't cause anything bad this way
- if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
- this.currentItem.hide();
- }
-
- //Create the placeholder
- this._createPlaceholder();
-
- //Set a containment if given in the options
- if ( o.containment ) {
- this._setContainment();
- }
-
- if ( o.cursor && o.cursor !== "auto" ) { // cursor option
- body = this.document.find( "body" );
-
- // Support: IE
- this.storedCursor = body.css( "cursor" );
- body.css( "cursor", o.cursor );
-
- this.storedStylesheet =
- $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
- }
-
- if ( o.opacity ) { // opacity option
- if ( this.helper.css( "opacity" ) ) {
- this._storedOpacity = this.helper.css( "opacity" );
- }
- this.helper.css( "opacity", o.opacity );
- }
-
- if ( o.zIndex ) { // zIndex option
- if ( this.helper.css( "zIndex" ) ) {
- this._storedZIndex = this.helper.css( "zIndex" );
- }
- this.helper.css( "zIndex", o.zIndex );
- }
-
- //Prepare scrolling
- if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- this.scrollParent[ 0 ].tagName !== "HTML" ) {
- this.overflowOffset = this.scrollParent.offset();
- }
-
- //Call callbacks
- this._trigger( "start", event, this._uiHash() );
-
- //Recache the helper size
- if ( !this._preserveHelperProportions ) {
- this._cacheHelperProportions();
- }
-
- //Post "activate" events to possible containers
- if ( !noActivation ) {
- for ( i = this.containers.length - 1; i >= 0; i-- ) {
- this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
- }
- }
-
- //Prepare possible droppables
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.current = this;
- }
-
- if ( $.ui.ddmanager && !o.dropBehaviour ) {
- $.ui.ddmanager.prepareOffsets( this, event );
- }
-
- this.dragging = true;
-
- this._addClass( this.helper, "ui-sortable-helper" );
-
- // Execute the drag once - this causes the helper not to be visiblebefore getting its
- // correct position
- this._mouseDrag( event );
- return true;
-
- },
-
- _mouseDrag: function( event ) {
- var i, item, itemElement, intersection,
- o = this.options,
- scrolled = false;
-
- //Compute the helpers position
- this.position = this._generatePosition( event );
- this.positionAbs = this._convertPositionTo( "absolute" );
-
- if ( !this.lastPositionAbs ) {
- this.lastPositionAbs = this.positionAbs;
- }
-
- //Do scrolling
- if ( this.options.scroll ) {
- if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- this.scrollParent[ 0 ].tagName !== "HTML" ) {
-
- if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
- event.pageY < o.scrollSensitivity ) {
- this.scrollParent[ 0 ].scrollTop =
- scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
- } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
- this.scrollParent[ 0 ].scrollTop =
- scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
- }
-
- if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
- event.pageX < o.scrollSensitivity ) {
- this.scrollParent[ 0 ].scrollLeft = scrolled =
- this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
- } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
- this.scrollParent[ 0 ].scrollLeft = scrolled =
- this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
- }
-
- } else {
-
- if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
- scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
- } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
- o.scrollSensitivity ) {
- scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
- }
-
- if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
- scrolled = this.document.scrollLeft(
- this.document.scrollLeft() - o.scrollSpeed
- );
- } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
- o.scrollSensitivity ) {
- scrolled = this.document.scrollLeft(
- this.document.scrollLeft() + o.scrollSpeed
- );
- }
-
- }
-
- if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
- $.ui.ddmanager.prepareOffsets( this, event );
- }
- }
-
- //Regenerate the absolute position used for position checks
- this.positionAbs = this._convertPositionTo( "absolute" );
-
- //Set the helper position
- if ( !this.options.axis || this.options.axis !== "y" ) {
- this.helper[ 0 ].style.left = this.position.left + "px";
- }
- if ( !this.options.axis || this.options.axis !== "x" ) {
- this.helper[ 0 ].style.top = this.position.top + "px";
- }
-
- //Rearrange
- for ( i = this.items.length - 1; i >= 0; i-- ) {
-
- //Cache variables and intersection, continue if no intersection
- item = this.items[ i ];
- itemElement = item.item[ 0 ];
- intersection = this._intersectsWithPointer( item );
- if ( !intersection ) {
- continue;
- }
-
- // Only put the placeholder inside the current Container, skip all
- // items from other containers. This works because when moving
- // an item from one container to another the
- // currentContainer is switched before the placeholder is moved.
- //
- // Without this, moving items in "sub-sortables" can cause
- // the placeholder to jitter between the outer and inner container.
- if ( item.instance !== this.currentContainer ) {
- continue;
- }
-
- // Cannot intersect with itself
- // no useless actions that have been done before
- // no action if the item moved is the parent of the item checked
- if ( itemElement !== this.currentItem[ 0 ] &&
- this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
- !$.contains( this.placeholder[ 0 ], itemElement ) &&
- ( this.options.type === "semi-dynamic" ?
- !$.contains( this.element[ 0 ], itemElement ) :
- true
- )
- ) {
-
- this.direction = intersection === 1 ? "down" : "up";
-
- if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
- this._rearrange( event, item );
- } else {
- break;
- }
-
- this._trigger( "change", event, this._uiHash() );
- break;
- }
- }
-
- //Post events to containers
- this._contactContainers( event );
-
- //Interconnect with droppables
- if ( $.ui.ddmanager ) {
- $.ui.ddmanager.drag( this, event );
- }
-
- //Call callbacks
- this._trigger( "sort", event, this._uiHash() );
-
- this.lastPositionAbs = this.positionAbs;
- return false;
-
- },
-
- _mouseStop: function( event, noPropagation ) {
-
- if ( !event ) {
- return;
- }
-
- //If we are using droppables, inform the manager about the drop
- if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
- $.ui.ddmanager.drop( this, event );
- }
-
- if ( this.options.revert ) {
- var that = this,
- cur = this.placeholder.offset(),
- axis = this.options.axis,
- animation = {};
-
- if ( !axis || axis === "x" ) {
- animation.left = cur.left - this.offset.parent.left - this.margins.left +
- ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
- 0 :
- this.offsetParent[ 0 ].scrollLeft
- );
- }
- if ( !axis || axis === "y" ) {
- animation.top = cur.top - this.offset.parent.top - this.margins.top +
- ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
- 0 :
- this.offsetParent[ 0 ].scrollTop
- );
- }
- this.reverting = true;
- $( this.helper ).animate(
- animation,
- parseInt( this.options.revert, 10 ) || 500,
- function() {
- that._clear( event );
- }
- );
- } else {
- this._clear( event, noPropagation );
- }
-
- return false;
-
- },
-
- cancel: function() {
-
- if ( this.dragging ) {
-
- this._mouseUp( new $.Event( "mouseup", { target: null } ) );
-
- if ( this.options.helper === "original" ) {
- this.currentItem.css( this._storedCSS );
- this._removeClass( this.currentItem, "ui-sortable-helper" );
- } else {
- this.currentItem.show();
- }
-
- //Post deactivating events to containers
- for ( var i = this.containers.length - 1; i >= 0; i-- ) {
- this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
- if ( this.containers[ i ].containerCache.over ) {
- this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
- this.containers[ i ].containerCache.over = 0;
- }
- }
-
- }
-
- if ( this.placeholder ) {
-
- //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
- // it unbinds ALL events from the original node!
- if ( this.placeholder[ 0 ].parentNode ) {
- this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
- }
- if ( this.options.helper !== "original" && this.helper &&
- this.helper[ 0 ].parentNode ) {
- this.helper.remove();
- }
-
- $.extend( this, {
- helper: null,
- dragging: false,
- reverting: false,
- _noFinalSort: null
- } );
-
- if ( this.domPosition.prev ) {
- $( this.domPosition.prev ).after( this.currentItem );
- } else {
- $( this.domPosition.parent ).prepend( this.currentItem );
- }
- }
-
- return this;
-
- },
-
- serialize: function( o ) {
-
- var items = this._getItemsAsjQuery( o && o.connected ),
- str = [];
- o = o || {};
-
- $( items ).each( function() {
- var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
- .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
- if ( res ) {
- str.push(
- ( o.key || res[ 1 ] + "[]" ) +
- "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
- }
- } );
-
- if ( !str.length && o.key ) {
- str.push( o.key + "=" );
- }
-
- return str.join( "&" );
-
- },
-
- toArray: function( o ) {
-
- var items = this._getItemsAsjQuery( o && o.connected ),
- ret = [];
-
- o = o || {};
-
- items.each( function() {
- ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
- } );
- return ret;
-
- },
-
- /* Be careful with the following core functions */
- _intersectsWith: function( item ) {
-
- var x1 = this.positionAbs.left,
- x2 = x1 + this.helperProportions.width,
- y1 = this.positionAbs.top,
- y2 = y1 + this.helperProportions.height,
- l = item.left,
- r = l + item.width,
- t = item.top,
- b = t + item.height,
- dyClick = this.offset.click.top,
- dxClick = this.offset.click.left,
- isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
- ( y1 + dyClick ) < b ),
- isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
- ( x1 + dxClick ) < r ),
- isOverElement = isOverElementHeight && isOverElementWidth;
-
- if ( this.options.tolerance === "pointer" ||
- this.options.forcePointerForContainers ||
- ( this.options.tolerance !== "pointer" &&
- this.helperProportions[ this.floating ? "width" : "height" ] >
- item[ this.floating ? "width" : "height" ] )
- ) {
- return isOverElement;
- } else {
-
- return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
- x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
- t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
- y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
-
- }
- },
-
- _intersectsWithPointer: function( item ) {
- var verticalDirection, horizontalDirection,
- isOverElementHeight = ( this.options.axis === "x" ) ||
- this._isOverAxis(
- this.positionAbs.top + this.offset.click.top, item.top, item.height ),
- isOverElementWidth = ( this.options.axis === "y" ) ||
- this._isOverAxis(
- this.positionAbs.left + this.offset.click.left, item.left, item.width ),
- isOverElement = isOverElementHeight && isOverElementWidth;
-
- if ( !isOverElement ) {
- return false;
- }
-
- verticalDirection = this._getDragVerticalDirection();
- horizontalDirection = this._getDragHorizontalDirection();
-
- return this.floating ?
- ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
- : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
-
- },
-
- _intersectsWithSides: function( item ) {
-
- var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
- this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
- isOverRightHalf = this._isOverAxis( this.positionAbs.left +
- this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
- verticalDirection = this._getDragVerticalDirection(),
- horizontalDirection = this._getDragHorizontalDirection();
-
- if ( this.floating && horizontalDirection ) {
- return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
- ( horizontalDirection === "left" && !isOverRightHalf ) );
- } else {
- return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
- ( verticalDirection === "up" && !isOverBottomHalf ) );
- }
-
- },
-
- _getDragVerticalDirection: function() {
- var delta = this.positionAbs.top - this.lastPositionAbs.top;
- return delta !== 0 && ( delta > 0 ? "down" : "up" );
- },
-
- _getDragHorizontalDirection: function() {
- var delta = this.positionAbs.left - this.lastPositionAbs.left;
- return delta !== 0 && ( delta > 0 ? "right" : "left" );
- },
-
- refresh: function( event ) {
- this._refreshItems( event );
- this._setHandleClassName();
- this.refreshPositions();
- return this;
- },
-
- _connectWith: function() {
- var options = this.options;
- return options.connectWith.constructor === String ?
- [ options.connectWith ] :
- options.connectWith;
- },
-
- _getItemsAsjQuery: function( connected ) {
-
- var i, j, cur, inst,
- items = [],
- queries = [],
- connectWith = this._connectWith();
-
- if ( connectWith && connected ) {
- for ( i = connectWith.length - 1; i >= 0; i-- ) {
- cur = $( connectWith[ i ], this.document[ 0 ] );
- for ( j = cur.length - 1; j >= 0; j-- ) {
- inst = $.data( cur[ j ], this.widgetFullName );
- if ( inst && inst !== this && !inst.options.disabled ) {
- queries.push( [ $.isFunction( inst.options.items ) ?
- inst.options.items.call( inst.element ) :
- $( inst.options.items, inst.element )
- .not( ".ui-sortable-helper" )
- .not( ".ui-sortable-placeholder" ), inst ] );
- }
- }
- }
- }
-
- queries.push( [ $.isFunction( this.options.items ) ?
- this.options.items
- .call( this.element, null, { options: this.options, item: this.currentItem } ) :
- $( this.options.items, this.element )
- .not( ".ui-sortable-helper" )
- .not( ".ui-sortable-placeholder" ), this ] );
-
- function addItems() {
- items.push( this );
- }
- for ( i = queries.length - 1; i >= 0; i-- ) {
- queries[ i ][ 0 ].each( addItems );
- }
-
- return $( items );
-
- },
-
- _removeCurrentsFromItems: function() {
-
- var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
-
- this.items = $.grep( this.items, function( item ) {
- for ( var j = 0; j < list.length; j++ ) {
- if ( list[ j ] === item.item[ 0 ] ) {
- return false;
- }
- }
- return true;
- } );
-
- },
-
- _refreshItems: function( event ) {
-
- this.items = [];
- this.containers = [ this ];
-
- var i, j, cur, inst, targetData, _queries, item, queriesLength,
- items = this.items,
- queries = [ [ $.isFunction( this.options.items ) ?
- this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
- $( this.options.items, this.element ), this ] ],
- connectWith = this._connectWith();
-
- //Shouldn't be run the first time through due to massive slow-down
- if ( connectWith && this.ready ) {
- for ( i = connectWith.length - 1; i >= 0; i-- ) {
- cur = $( connectWith[ i ], this.document[ 0 ] );
- for ( j = cur.length - 1; j >= 0; j-- ) {
- inst = $.data( cur[ j ], this.widgetFullName );
- if ( inst && inst !== this && !inst.options.disabled ) {
- queries.push( [ $.isFunction( inst.options.items ) ?
- inst.options.items
- .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
- $( inst.options.items, inst.element ), inst ] );
- this.containers.push( inst );
- }
- }
- }
- }
-
- for ( i = queries.length - 1; i >= 0; i-- ) {
- targetData = queries[ i ][ 1 ];
- _queries = queries[ i ][ 0 ];
-
- for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
- item = $( _queries[ j ] );
-
- // Data for target checking (mouse manager)
- item.data( this.widgetName + "-item", targetData );
-
- items.push( {
- item: item,
- instance: targetData,
- width: 0, height: 0,
- left: 0, top: 0
- } );
- }
- }
-
- },
-
- refreshPositions: function( fast ) {
-
- // Determine whether items are being displayed horizontally
- this.floating = this.items.length ?
- this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
- false;
-
- //This has to be redone because due to the item being moved out/into the offsetParent,
- // the offsetParent's position will change
- if ( this.offsetParent && this.helper ) {
- this.offset.parent = this._getParentOffset();
- }
-
- var i, item, t, p;
-
- for ( i = this.items.length - 1; i >= 0; i-- ) {
- item = this.items[ i ];
-
- //We ignore calculating positions of all connected containers when we're not over them
- if ( item.instance !== this.currentContainer && this.currentContainer &&
- item.item[ 0 ] !== this.currentItem[ 0 ] ) {
- continue;
- }
-
- t = this.options.toleranceElement ?
- $( this.options.toleranceElement, item.item ) :
- item.item;
-
- if ( !fast ) {
- item.width = t.outerWidth();
- item.height = t.outerHeight();
- }
-
- p = t.offset();
- item.left = p.left;
- item.top = p.top;
- }
-
- if ( this.options.custom && this.options.custom.refreshContainers ) {
- this.options.custom.refreshContainers.call( this );
- } else {
- for ( i = this.containers.length - 1; i >= 0; i-- ) {
- p = this.containers[ i ].element.offset();
- this.containers[ i ].containerCache.left = p.left;
- this.containers[ i ].containerCache.top = p.top;
- this.containers[ i ].containerCache.width =
- this.containers[ i ].element.outerWidth();
- this.containers[ i ].containerCache.height =
- this.containers[ i ].element.outerHeight();
- }
- }
-
- return this;
- },
-
- _createPlaceholder: function( that ) {
- that = that || this;
- var className,
- o = that.options;
-
- if ( !o.placeholder || o.placeholder.constructor === String ) {
- className = o.placeholder;
- o.placeholder = {
- element: function() {
-
- var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
- element = $( "<" + nodeName + ">", that.document[ 0 ] );
-
- that._addClass( element, "ui-sortable-placeholder",
- className || that.currentItem[ 0 ].className )
- ._removeClass( element, "ui-sortable-helper" );
-
- if ( nodeName === "tbody" ) {
- that._createTrPlaceholder(
- that.currentItem.find( "tr" ).eq( 0 ),
- $( "<tr>", that.document[ 0 ] ).appendTo( element )
- );
- } else if ( nodeName === "tr" ) {
- that._createTrPlaceholder( that.currentItem, element );
- } else if ( nodeName === "img" ) {
- element.attr( "src", that.currentItem.attr( "src" ) );
- }
-
- if ( !className ) {
- element.css( "visibility", "hidden" );
- }
-
- return element;
- },
- update: function( container, p ) {
-
- // 1. If a className is set as 'placeholder option, we don't force sizes -
- // the class is responsible for that
- // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
- // class name is specified
- if ( className && !o.forcePlaceholderSize ) {
- return;
- }
-
- //If the element doesn't have a actual height by itself (without styles coming
- // from a stylesheet), it receives the inline height from the dragged item
- if ( !p.height() ) {
- p.height(
- that.currentItem.innerHeight() -
- parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
- parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
- }
- if ( !p.width() ) {
- p.width(
- that.currentItem.innerWidth() -
- parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
- parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
- }
- }
- };
- }
-
- //Create the placeholder
- that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
-
- //Append it after the actual current item
- that.currentItem.after( that.placeholder );
-
- //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
- o.placeholder.update( that, that.placeholder );
-
- },
-
- _createTrPlaceholder: function( sourceTr, targetTr ) {
- var that = this;
-
- sourceTr.children().each( function() {
- $( "<td> </td>", that.document[ 0 ] )
- .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
- .appendTo( targetTr );
- } );
- },
-
- _contactContainers: function( event ) {
- var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
- floating, axis,
- innermostContainer = null,
- innermostIndex = null;
-
- // Get innermost container that intersects with item
- for ( i = this.containers.length - 1; i >= 0; i-- ) {
-
- // Never consider a container that's located within the item itself
- if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
- continue;
- }
-
- if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
-
- // If we've already found a container and it's more "inner" than this, then continue
- if ( innermostContainer &&
- $.contains(
- this.containers[ i ].element[ 0 ],
- innermostContainer.element[ 0 ] ) ) {
- continue;
- }
-
- innermostContainer = this.containers[ i ];
- innermostIndex = i;
-
- } else {
-
- // container doesn't intersect. trigger "out" event if necessary
- if ( this.containers[ i ].containerCache.over ) {
- this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
- this.containers[ i ].containerCache.over = 0;
- }
- }
-
- }
-
- // If no intersecting containers found, return
- if ( !innermostContainer ) {
- return;
- }
-
- // Move the item into the container if it's not there already
- if ( this.containers.length === 1 ) {
- if ( !this.containers[ innermostIndex ].containerCache.over ) {
- this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
- this.containers[ innermostIndex ].containerCache.over = 1;
- }
- } else {
-
- // When entering a new container, we will find the item with the least distance and
- // append our item near it
- dist = 10000;
- itemWithLeastDistance = null;
- floating = innermostContainer.floating || this._isFloating( this.currentItem );
- posProperty = floating ? "left" : "top";
- sizeProperty = floating ? "width" : "height";
- axis = floating ? "pageX" : "pageY";
-
- for ( j = this.items.length - 1; j >= 0; j-- ) {
- if ( !$.contains(
- this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
- ) {
- continue;
- }
- if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
- continue;
- }
-
- cur = this.items[ j ].item.offset()[ posProperty ];
- nearBottom = false;
- if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
- nearBottom = true;
- }
-
- if ( Math.abs( event[ axis ] - cur ) < dist ) {
- dist = Math.abs( event[ axis ] - cur );
- itemWithLeastDistance = this.items[ j ];
- this.direction = nearBottom ? "up" : "down";
- }
- }
-
- //Check if dropOnEmpty is enabled
- if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
- return;
- }
-
- if ( this.currentContainer === this.containers[ innermostIndex ] ) {
- if ( !this.currentContainer.containerCache.over ) {
- this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
- this.currentContainer.containerCache.over = 1;
- }
- return;
- }
-
- itemWithLeastDistance ?
- this._rearrange( event, itemWithLeastDistance, null, true ) :
- this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
- this._trigger( "change", event, this._uiHash() );
- this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
- this.currentContainer = this.containers[ innermostIndex ];
-
- //Update the placeholder
- this.options.placeholder.update( this.currentContainer, this.placeholder );
-
- this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
- this.containers[ innermostIndex ].containerCache.over = 1;
- }
-
- },
-
- _createHelper: function( event ) {
-
- var o = this.options,
- helper = $.isFunction( o.helper ) ?
- $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
- ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
-
- //Add the helper to the DOM if that didn't happen already
- if ( !helper.parents( "body" ).length ) {
- $( o.appendTo !== "parent" ?
- o.appendTo :
- this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
- }
-
- if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
- this._storedCSS = {
- width: this.currentItem[ 0 ].style.width,
- height: this.currentItem[ 0 ].style.height,
- position: this.currentItem.css( "position" ),
- top: this.currentItem.css( "top" ),
- left: this.currentItem.css( "left" )
- };
- }
-
- if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
- helper.width( this.currentItem.width() );
- }
- if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
- helper.height( this.currentItem.height() );
- }
-
- return helper;
-
- },
-
- _adjustOffsetFromHelper: function( obj ) {
- if ( typeof obj === "string" ) {
- obj = obj.split( " " );
- }
- if ( $.isArray( obj ) ) {
- obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
- }
- if ( "left" in obj ) {
- this.offset.click.left = obj.left + this.margins.left;
- }
- if ( "right" in obj ) {
- this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
- }
- if ( "top" in obj ) {
- this.offset.click.top = obj.top + this.margins.top;
- }
- if ( "bottom" in obj ) {
- this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
- }
- },
-
- _getParentOffset: function() {
-
- //Get the offsetParent and cache its position
- this.offsetParent = this.helper.offsetParent();
- var po = this.offsetParent.offset();
-
- // This is a special case where we need to modify a offset calculated on start, since the
- // following happened:
- // 1. The position of the helper is absolute, so it's position is calculated based on the
- // next positioned parent
- // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
- // the document, which means that the scroll is included in the initial calculation of the
- // offset of the parent, and never recalculated upon drag
- if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
- po.left += this.scrollParent.scrollLeft();
- po.top += this.scrollParent.scrollTop();
- }
-
- // This needs to be actually done for all browsers, since pageX/pageY includes this
- // information with an ugly IE fix
- if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
- ( this.offsetParent[ 0 ].tagName &&
- this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
- po = { top: 0, left: 0 };
- }
-
- return {
- top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
- left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
- };
-
- },
-
- _getRelativeOffset: function() {
-
- if ( this.cssPosition === "relative" ) {
- var p = this.currentItem.position();
- return {
- top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
- this.scrollParent.scrollTop(),
- left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
- this.scrollParent.scrollLeft()
- };
- } else {
- return { top: 0, left: 0 };
- }
-
- },
-
- _cacheMargins: function() {
- this.margins = {
- left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
- top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
- };
- },
-
- _cacheHelperProportions: function() {
- this.helperProportions = {
- width: this.helper.outerWidth(),
- height: this.helper.outerHeight()
- };
- },
-
- _setContainment: function() {
-
- var ce, co, over,
- o = this.options;
- if ( o.containment === "parent" ) {
- o.containment = this.helper[ 0 ].parentNode;
- }
- if ( o.containment === "document" || o.containment === "window" ) {
- this.containment = [
- 0 - this.offset.relative.left - this.offset.parent.left,
- 0 - this.offset.relative.top - this.offset.parent.top,
- o.containment === "document" ?
- this.document.width() :
- this.window.width() - this.helperProportions.width - this.margins.left,
- ( o.containment === "document" ?
- ( this.document.height() || document.body.parentNode.scrollHeight ) :
- this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
- ) - this.helperProportions.height - this.margins.top
- ];
- }
-
- if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
- ce = $( o.containment )[ 0 ];
- co = $( o.containment ).offset();
- over = ( $( ce ).css( "overflow" ) !== "hidden" );
-
- this.containment = [
- co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
- ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
- co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
- ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
- co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
- ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
- ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
- this.helperProportions.width - this.margins.left,
- co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
- ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
- ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
- this.helperProportions.height - this.margins.top
- ];
- }
-
- },
-
- _convertPositionTo: function( d, pos ) {
-
- if ( !pos ) {
- pos = this.position;
- }
- var mod = d === "absolute" ? 1 : -1,
- scroll = this.cssPosition === "absolute" &&
- !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
- this.offsetParent :
- this.scrollParent,
- scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
-
- return {
- top: (
-
- // The absolute mouse position
- pos.top +
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.top * mod +
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.top * mod -
- ( ( this.cssPosition === "fixed" ?
- -this.scrollParent.scrollTop() :
- ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
- ),
- left: (
-
- // The absolute mouse position
- pos.left +
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.left * mod +
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.left * mod -
- ( ( this.cssPosition === "fixed" ?
- -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
- scroll.scrollLeft() ) * mod )
- )
- };
-
- },
-
- _generatePosition: function( event ) {
-
- var top, left,
- o = this.options,
- pageX = event.pageX,
- pageY = event.pageY,
- scroll = this.cssPosition === "absolute" &&
- !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
- this.offsetParent :
- this.scrollParent,
- scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
-
- // This is another very weird special case that only happens for relative elements:
- // 1. If the css position is relative
- // 2. and the scroll parent is the document or similar to the offset parent
- // we have to refresh the relative offset during the scroll so there are no jumps
- if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
- this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
- this.offset.relative = this._getRelativeOffset();
- }
-
- /*
- * - Position constraining -
- * Constrain the position to a mix of grid, containment.
- */
-
- if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
-
- if ( this.containment ) {
- if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
- pageX = this.containment[ 0 ] + this.offset.click.left;
- }
- if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
- pageY = this.containment[ 1 ] + this.offset.click.top;
- }
- if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
- pageX = this.containment[ 2 ] + this.offset.click.left;
- }
- if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
- pageY = this.containment[ 3 ] + this.offset.click.top;
- }
- }
-
- if ( o.grid ) {
- top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
- o.grid[ 1 ] ) * o.grid[ 1 ];
- pageY = this.containment ?
- ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
- top - this.offset.click.top <= this.containment[ 3 ] ) ?
- top :
- ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
- top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
- top;
-
- left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
- o.grid[ 0 ] ) * o.grid[ 0 ];
- pageX = this.containment ?
- ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
- left - this.offset.click.left <= this.containment[ 2 ] ) ?
- left :
- ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
- left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
- left;
- }
-
- }
-
- return {
- top: (
-
- // The absolute mouse position
- pageY -
-
- // Click offset (relative to the element)
- this.offset.click.top -
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.top -
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.top +
- ( ( this.cssPosition === "fixed" ?
- -this.scrollParent.scrollTop() :
- ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
- ),
- left: (
-
- // The absolute mouse position
- pageX -
-
- // Click offset (relative to the element)
- this.offset.click.left -
-
- // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.relative.left -
-
- // The offsetParent's offset without borders (offset + border)
- this.offset.parent.left +
- ( ( this.cssPosition === "fixed" ?
- -this.scrollParent.scrollLeft() :
- scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
- )
- };
-
- },
-
- _rearrange: function( event, i, a, hardRefresh ) {
-
- a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
- i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
- ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
-
- //Various things done here to improve the performance:
- // 1. we create a setTimeout, that calls refreshPositions
- // 2. on the instance, we have a counter variable, that get's higher after every append
- // 3. on the local scope, we copy the counter variable, and check in the timeout,
- // if it's still the same
- // 4. this lets only the last addition to the timeout stack through
- this.counter = this.counter ? ++this.counter : 1;
- var counter = this.counter;
-
- this._delay( function() {
- if ( counter === this.counter ) {
-
- //Precompute after each DOM insertion, NOT on mousemove
- this.refreshPositions( !hardRefresh );
- }
- } );
-
- },
-
- _clear: function( event, noPropagation ) {
-
- this.reverting = false;
-
- // We delay all events that have to be triggered to after the point where the placeholder
- // has been removed and everything else normalized again
- var i,
- delayedTriggers = [];
-
- // We first have to update the dom position of the actual currentItem
- // Note: don't do it if the current item is already removed (by a user), or it gets
- // reappended (see #4088)
- if ( !this._noFinalSort && this.currentItem.parent().length ) {
- this.placeholder.before( this.currentItem );
- }
- this._noFinalSort = null;
-
- if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
- for ( i in this._storedCSS ) {
- if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
- this._storedCSS[ i ] = "";
- }
- }
- this.currentItem.css( this._storedCSS );
- this._removeClass( this.currentItem, "ui-sortable-helper" );
- } else {
- this.currentItem.show();
- }
-
- if ( this.fromOutside && !noPropagation ) {
- delayedTriggers.push( function( event ) {
- this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
- } );
- }
- if ( ( this.fromOutside ||
- this.domPosition.prev !==
- this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
- this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
-
- // Trigger update callback if the DOM position has changed
- delayedTriggers.push( function( event ) {
- this._trigger( "update", event, this._uiHash() );
- } );
- }
-
- // Check if the items Container has Changed and trigger appropriate
- // events.
- if ( this !== this.currentContainer ) {
- if ( !noPropagation ) {
- delayedTriggers.push( function( event ) {
- this._trigger( "remove", event, this._uiHash() );
- } );
- delayedTriggers.push( ( function( c ) {
- return function( event ) {
- c._trigger( "receive", event, this._uiHash( this ) );
- };
- } ).call( this, this.currentContainer ) );
- delayedTriggers.push( ( function( c ) {
- return function( event ) {
- c._trigger( "update", event, this._uiHash( this ) );
- };
- } ).call( this, this.currentContainer ) );
- }
- }
-
- //Post events to containers
- function delayEvent( type, instance, container ) {
- return function( event ) {
- container._trigger( type, event, instance._uiHash( instance ) );
- };
- }
- for ( i = this.containers.length - 1; i >= 0; i-- ) {
- if ( !noPropagation ) {
- delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
- }
- if ( this.containers[ i ].containerCache.over ) {
- delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
- this.containers[ i ].containerCache.over = 0;
- }
- }
-
- //Do what was originally in plugins
- if ( this.storedCursor ) {
- this.document.find( "body" ).css( "cursor", this.storedCursor );
- this.storedStylesheet.remove();
- }
- if ( this._storedOpacity ) {
- this.helper.css( "opacity", this._storedOpacity );
- }
- if ( this._storedZIndex ) {
- this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
- }
-
- this.dragging = false;
-
- if ( !noPropagation ) {
- this._trigger( "beforeStop", event, this._uiHash() );
- }
-
- //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
- // it unbinds ALL events from the original node!
- this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
-
- if ( !this.cancelHelperRemoval ) {
- if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
- this.helper.remove();
- }
- this.helper = null;
- }
-
- if ( !noPropagation ) {
- for ( i = 0; i < delayedTriggers.length; i++ ) {
-
- // Trigger all delayed events
- delayedTriggers[ i ].call( this, event );
- }
- this._trigger( "stop", event, this._uiHash() );
- }
-
- this.fromOutside = false;
- return !this.cancelHelperRemoval;
-
- },
-
- _trigger: function() {
- if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
- this.cancel();
- }
- },
-
- _uiHash: function( _inst ) {
- var inst = _inst || this;
- return {
- helper: inst.helper,
- placeholder: inst.placeholder || $( [] ),
- position: inst.position,
- originalPosition: inst.originalPosition,
- offset: inst.positionAbs,
- item: inst.currentItem,
- sender: _inst ? _inst.element : null
- };
- }
-
-} );
-
-
-/*!
- * jQuery UI Spinner 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Spinner
-//>>group: Widgets
-//>>description: Displays buttons to easily input numbers via the keyboard or mouse.
-//>>docs: http://api.jqueryui.com/spinner/
-//>>demos: http://jqueryui.com/spinner/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/spinner.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-function spinnerModifer( fn ) {
- return function() {
- var previous = this.element.val();
- fn.apply( this, arguments );
- this._refresh();
- if ( previous !== this.element.val() ) {
- this._trigger( "change" );
- }
- };
-}
-
-$.widget( "ui.spinner", {
- version: "1.12.1",
- defaultElement: "<input>",
- widgetEventPrefix: "spin",
- options: {
- classes: {
- "ui-spinner": "ui-corner-all",
- "ui-spinner-down": "ui-corner-br",
- "ui-spinner-up": "ui-corner-tr"
- },
- culture: null,
- icons: {
- down: "ui-icon-triangle-1-s",
- up: "ui-icon-triangle-1-n"
- },
- incremental: true,
- max: null,
- min: null,
- numberFormat: null,
- page: 10,
- step: 1,
-
- change: null,
- spin: null,
- start: null,
- stop: null
- },
-
- _create: function() {
-
- // handle string values that need to be parsed
- this._setOption( "max", this.options.max );
- this._setOption( "min", this.options.min );
- this._setOption( "step", this.options.step );
-
- // Only format if there is a value, prevents the field from being marked
- // as invalid in Firefox, see #9573.
- if ( this.value() !== "" ) {
-
- // Format the value, but don't constrain.
- this._value( this.element.val(), true );
- }
-
- this._draw();
- this._on( this._events );
- this._refresh();
-
- // Turning off autocomplete prevents the browser from remembering the
- // value when navigating through history, so we re-enable autocomplete
- // if the page is unloaded before the widget is destroyed. #7790
- this._on( this.window, {
- beforeunload: function() {
- this.element.removeAttr( "autocomplete" );
- }
- } );
- },
-
- _getCreateOptions: function() {
- var options = this._super();
- var element = this.element;
-
- $.each( [ "min", "max", "step" ], function( i, option ) {
- var value = element.attr( option );
- if ( value != null && value.length ) {
- options[ option ] = value;
- }
- } );
-
- return options;
- },
-
- _events: {
- keydown: function( event ) {
- if ( this._start( event ) && this._keydown( event ) ) {
- event.preventDefault();
- }
- },
- keyup: "_stop",
- focus: function() {
- this.previous = this.element.val();
- },
- blur: function( event ) {
- if ( this.cancelBlur ) {
- delete this.cancelBlur;
- return;
- }
-
- this._stop();
- this._refresh();
- if ( this.previous !== this.element.val() ) {
- this._trigger( "change", event );
- }
- },
- mousewheel: function( event, delta ) {
- if ( !delta ) {
- return;
- }
- if ( !this.spinning && !this._start( event ) ) {
- return false;
- }
-
- this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
- clearTimeout( this.mousewheelTimer );
- this.mousewheelTimer = this._delay( function() {
- if ( this.spinning ) {
- this._stop( event );
- }
- }, 100 );
- event.preventDefault();
- },
- "mousedown .ui-spinner-button": function( event ) {
- var previous;
-
- // We never want the buttons to have focus; whenever the user is
- // interacting with the spinner, the focus should be on the input.
- // If the input is focused then this.previous is properly set from
- // when the input first received focus. If the input is not focused
- // then we need to set this.previous based on the value before spinning.
- previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
- this.previous : this.element.val();
- function checkFocus() {
- var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
- if ( !isActive ) {
- this.element.trigger( "focus" );
- this.previous = previous;
-
- // support: IE
- // IE sets focus asynchronously, so we need to check if focus
- // moved off of the input because the user clicked on the button.
- this._delay( function() {
- this.previous = previous;
- } );
- }
- }
-
- // Ensure focus is on (or stays on) the text field
- event.preventDefault();
- checkFocus.call( this );
-
- // Support: IE
- // IE doesn't prevent moving focus even with event.preventDefault()
- // so we set a flag to know when we should ignore the blur event
- // and check (again) if focus moved off of the input.
- this.cancelBlur = true;
- this._delay( function() {
- delete this.cancelBlur;
- checkFocus.call( this );
- } );
-
- if ( this._start( event ) === false ) {
- return;
- }
-
- this._repeat( null, $( event.currentTarget )
- .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
- },
- "mouseup .ui-spinner-button": "_stop",
- "mouseenter .ui-spinner-button": function( event ) {
-
- // button will add ui-state-active if mouse was down while mouseleave and kept down
- if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
- return;
- }
-
- if ( this._start( event ) === false ) {
- return false;
- }
- this._repeat( null, $( event.currentTarget )
- .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
- },
-
- // TODO: do we really want to consider this a stop?
- // shouldn't we just stop the repeater and wait until mouseup before
- // we trigger the stop event?
- "mouseleave .ui-spinner-button": "_stop"
- },
-
- // Support mobile enhanced option and make backcompat more sane
- _enhance: function() {
- this.uiSpinner = this.element
- .attr( "autocomplete", "off" )
- .wrap( "<span>" )
- .parent()
-
- // Add buttons
- .append(
- "<a></a><a></a>"
- );
- },
-
- _draw: function() {
- this._enhance();
-
- this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
- this._addClass( "ui-spinner-input" );
-
- this.element.attr( "role", "spinbutton" );
-
- // Button bindings
- this.buttons = this.uiSpinner.children( "a" )
- .attr( "tabIndex", -1 )
- .attr( "aria-hidden", true )
- .button( {
- classes: {
- "ui-button": ""
- }
- } );
-
- // TODO: Right now button does not support classes this is already updated in button PR
- this._removeClass( this.buttons, "ui-corner-all" );
-
- this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
- this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
- this.buttons.first().button( {
- "icon": this.options.icons.up,
- "showLabel": false
- } );
- this.buttons.last().button( {
- "icon": this.options.icons.down,
- "showLabel": false
- } );
-
- // IE 6 doesn't understand height: 50% for the buttons
- // unless the wrapper has an explicit height
- if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
- this.uiSpinner.height() > 0 ) {
- this.uiSpinner.height( this.uiSpinner.height() );
- }
- },
-
- _keydown: function( event ) {
- var options = this.options,
- keyCode = $.ui.keyCode;
-
- switch ( event.keyCode ) {
- case keyCode.UP:
- this._repeat( null, 1, event );
- return true;
- case keyCode.DOWN:
- this._repeat( null, -1, event );
- return true;
- case keyCode.PAGE_UP:
- this._repeat( null, options.page, event );
- return true;
- case keyCode.PAGE_DOWN:
- this._repeat( null, -options.page, event );
- return true;
- }
-
- return false;
- },
-
- _start: function( event ) {
- if ( !this.spinning && this._trigger( "start", event ) === false ) {
- return false;
- }
-
- if ( !this.counter ) {
- this.counter = 1;
- }
- this.spinning = true;
- return true;
- },
-
- _repeat: function( i, steps, event ) {
- i = i || 500;
-
- clearTimeout( this.timer );
- this.timer = this._delay( function() {
- this._repeat( 40, steps, event );
- }, i );
-
- this._spin( steps * this.options.step, event );
- },
-
- _spin: function( step, event ) {
- var value = this.value() || 0;
-
- if ( !this.counter ) {
- this.counter = 1;
- }
-
- value = this._adjustValue( value + step * this._increment( this.counter ) );
-
- if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
- this._value( value );
- this.counter++;
- }
- },
-
- _increment: function( i ) {
- var incremental = this.options.incremental;
-
- if ( incremental ) {
- return $.isFunction( incremental ) ?
- incremental( i ) :
- Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
- }
-
- return 1;
- },
-
- _precision: function() {
- var precision = this._precisionOf( this.options.step );
- if ( this.options.min !== null ) {
- precision = Math.max( precision, this._precisionOf( this.options.min ) );
- }
- return precision;
- },
-
- _precisionOf: function( num ) {
- var str = num.toString(),
- decimal = str.indexOf( "." );
- return decimal === -1 ? 0 : str.length - decimal - 1;
- },
-
- _adjustValue: function( value ) {
- var base, aboveMin,
- options = this.options;
-
- // Make sure we're at a valid step
- // - find out where we are relative to the base (min or 0)
- base = options.min !== null ? options.min : 0;
- aboveMin = value - base;
-
- // - round to the nearest step
- aboveMin = Math.round( aboveMin / options.step ) * options.step;
-
- // - rounding is based on 0, so adjust back to our base
- value = base + aboveMin;
-
- // Fix precision from bad JS floating point math
- value = parseFloat( value.toFixed( this._precision() ) );
-
- // Clamp the value
- if ( options.max !== null && value > options.max ) {
- return options.max;
- }
- if ( options.min !== null && value < options.min ) {
- return options.min;
- }
-
- return value;
- },
-
- _stop: function( event ) {
- if ( !this.spinning ) {
- return;
- }
-
- clearTimeout( this.timer );
- clearTimeout( this.mousewheelTimer );
- this.counter = 0;
- this.spinning = false;
- this._trigger( "stop", event );
- },
-
- _setOption: function( key, value ) {
- var prevValue, first, last;
-
- if ( key === "culture" || key === "numberFormat" ) {
- prevValue = this._parse( this.element.val() );
- this.options[ key ] = value;
- this.element.val( this._format( prevValue ) );
- return;
- }
-
- if ( key === "max" || key === "min" || key === "step" ) {
- if ( typeof value === "string" ) {
- value = this._parse( value );
- }
- }
- if ( key === "icons" ) {
- first = this.buttons.first().find( ".ui-icon" );
- this._removeClass( first, null, this.options.icons.up );
- this._addClass( first, null, value.up );
- last = this.buttons.last().find( ".ui-icon" );
- this._removeClass( last, null, this.options.icons.down );
- this._addClass( last, null, value.down );
- }
-
- this._super( key, value );
- },
-
- _setOptionDisabled: function( value ) {
- this._super( value );
-
- this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
- this.element.prop( "disabled", !!value );
- this.buttons.button( value ? "disable" : "enable" );
- },
-
- _setOptions: spinnerModifer( function( options ) {
- this._super( options );
- } ),
-
- _parse: function( val ) {
- if ( typeof val === "string" && val !== "" ) {
- val = window.Globalize && this.options.numberFormat ?
- Globalize.parseFloat( val, 10, this.options.culture ) : +val;
- }
- return val === "" || isNaN( val ) ? null : val;
- },
-
- _format: function( value ) {
- if ( value === "" ) {
- return "";
- }
- return window.Globalize && this.options.numberFormat ?
- Globalize.format( value, this.options.numberFormat, this.options.culture ) :
- value;
- },
-
- _refresh: function() {
- this.element.attr( {
- "aria-valuemin": this.options.min,
- "aria-valuemax": this.options.max,
-
- // TODO: what should we do with values that can't be parsed?
- "aria-valuenow": this._parse( this.element.val() )
- } );
- },
-
- isValid: function() {
- var value = this.value();
-
- // Null is invalid
- if ( value === null ) {
- return false;
- }
-
- // If value gets adjusted, it's invalid
- return value === this._adjustValue( value );
- },
-
- // Update the value without triggering change
- _value: function( value, allowAny ) {
- var parsed;
- if ( value !== "" ) {
- parsed = this._parse( value );
- if ( parsed !== null ) {
- if ( !allowAny ) {
- parsed = this._adjustValue( parsed );
- }
- value = this._format( parsed );
- }
- }
- this.element.val( value );
- this._refresh();
- },
-
- _destroy: function() {
- this.element
- .prop( "disabled", false )
- .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
-
- this.uiSpinner.replaceWith( this.element );
- },
-
- stepUp: spinnerModifer( function( steps ) {
- this._stepUp( steps );
- } ),
- _stepUp: function( steps ) {
- if ( this._start() ) {
- this._spin( ( steps || 1 ) * this.options.step );
- this._stop();
- }
- },
-
- stepDown: spinnerModifer( function( steps ) {
- this._stepDown( steps );
- } ),
- _stepDown: function( steps ) {
- if ( this._start() ) {
- this._spin( ( steps || 1 ) * -this.options.step );
- this._stop();
- }
- },
-
- pageUp: spinnerModifer( function( pages ) {
- this._stepUp( ( pages || 1 ) * this.options.page );
- } ),
-
- pageDown: spinnerModifer( function( pages ) {
- this._stepDown( ( pages || 1 ) * this.options.page );
- } ),
-
- value: function( newVal ) {
- if ( !arguments.length ) {
- return this._parse( this.element.val() );
- }
- spinnerModifer( this._value ).call( this, newVal );
- },
-
- widget: function() {
- return this.uiSpinner;
- }
-} );
-
-// DEPRECATED
-// TODO: switch return back to widget declaration at top of file when this is removed
-if ( $.uiBackCompat !== false ) {
-
- // Backcompat for spinner html extension points
- $.widget( "ui.spinner", $.ui.spinner, {
- _enhance: function() {
- this.uiSpinner = this.element
- .attr( "autocomplete", "off" )
- .wrap( this._uiSpinnerHtml() )
- .parent()
-
- // Add buttons
- .append( this._buttonHtml() );
- },
- _uiSpinnerHtml: function() {
- return "<span>";
- },
-
- _buttonHtml: function() {
- return "<a></a><a></a>";
- }
- } );
-}
-
-var widgetsSpinner = $.ui.spinner;
-
-
-/*!
- * jQuery UI Tabs 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Tabs
-//>>group: Widgets
-//>>description: Transforms a set of container elements into a tab structure.
-//>>docs: http://api.jqueryui.com/tabs/
-//>>demos: http://jqueryui.com/tabs/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/tabs.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.tabs", {
- version: "1.12.1",
- delay: 300,
- options: {
- active: null,
- classes: {
- "ui-tabs": "ui-corner-all",
- "ui-tabs-nav": "ui-corner-all",
- "ui-tabs-panel": "ui-corner-bottom",
- "ui-tabs-tab": "ui-corner-top"
- },
- collapsible: false,
- event: "click",
- heightStyle: "content",
- hide: null,
- show: null,
-
- // Callbacks
- activate: null,
- beforeActivate: null,
- beforeLoad: null,
- load: null
- },
-
- _isLocal: ( function() {
- var rhash = /#.*$/;
-
- return function( anchor ) {
- var anchorUrl, locationUrl;
-
- anchorUrl = anchor.href.replace( rhash, "" );
- locationUrl = location.href.replace( rhash, "" );
-
- // Decoding may throw an error if the URL isn't UTF-8 (#9518)
- try {
- anchorUrl = decodeURIComponent( anchorUrl );
- } catch ( error ) {}
- try {
- locationUrl = decodeURIComponent( locationUrl );
- } catch ( error ) {}
-
- return anchor.hash.length > 1 && anchorUrl === locationUrl;
- };
- } )(),
-
- _create: function() {
- var that = this,
- options = this.options;
-
- this.running = false;
-
- this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
- this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
-
- this._processTabs();
- options.active = this._initialActive();
-
- // Take disabling tabs via class attribute from HTML
- // into account and update option properly.
- if ( $.isArray( options.disabled ) ) {
- options.disabled = $.unique( options.disabled.concat(
- $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
- return that.tabs.index( li );
- } )
- ) ).sort();
- }
-
- // Check for length avoids error when initializing empty list
- if ( this.options.active !== false && this.anchors.length ) {
- this.active = this._findActive( options.active );
- } else {
- this.active = $();
- }
-
- this._refresh();
-
- if ( this.active.length ) {
- this.load( options.active );
- }
- },
-
- _initialActive: function() {
- var active = this.options.active,
- collapsible = this.options.collapsible,
- locationHash = location.hash.substring( 1 );
-
- if ( active === null ) {
-
- // check the fragment identifier in the URL
- if ( locationHash ) {
- this.tabs.each( function( i, tab ) {
- if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
- active = i;
- return false;
- }
- } );
- }
-
- // Check for a tab marked active via a class
- if ( active === null ) {
- active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
- }
-
- // No active tab, set to false
- if ( active === null || active === -1 ) {
- active = this.tabs.length ? 0 : false;
- }
- }
-
- // Handle numbers: negative, out of range
- if ( active !== false ) {
- active = this.tabs.index( this.tabs.eq( active ) );
- if ( active === -1 ) {
- active = collapsible ? false : 0;
- }
- }
-
- // Don't allow collapsible: false and active: false
- if ( !collapsible && active === false && this.anchors.length ) {
- active = 0;
- }
-
- return active;
- },
-
- _getCreateEventData: function() {
- return {
- tab: this.active,
- panel: !this.active.length ? $() : this._getPanelForTab( this.active )
- };
- },
-
- _tabKeydown: function( event ) {
- var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
- selectedIndex = this.tabs.index( focusedTab ),
- goingForward = true;
-
- if ( this._handlePageNav( event ) ) {
- return;
- }
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.RIGHT:
- case $.ui.keyCode.DOWN:
- selectedIndex++;
- break;
- case $.ui.keyCode.UP:
- case $.ui.keyCode.LEFT:
- goingForward = false;
- selectedIndex--;
- break;
- case $.ui.keyCode.END:
- selectedIndex = this.anchors.length - 1;
- break;
- case $.ui.keyCode.HOME:
- selectedIndex = 0;
- break;
- case $.ui.keyCode.SPACE:
-
- // Activate only, no collapsing
- event.preventDefault();
- clearTimeout( this.activating );
- this._activate( selectedIndex );
- return;
- case $.ui.keyCode.ENTER:
-
- // Toggle (cancel delayed activation, allow collapsing)
- event.preventDefault();
- clearTimeout( this.activating );
-
- // Determine if we should collapse or activate
- this._activate( selectedIndex === this.options.active ? false : selectedIndex );
- return;
- default:
- return;
- }
-
- // Focus the appropriate tab, based on which key was pressed
- event.preventDefault();
- clearTimeout( this.activating );
- selectedIndex = this._focusNextTab( selectedIndex, goingForward );
-
- // Navigating with control/command key will prevent automatic activation
- if ( !event.ctrlKey && !event.metaKey ) {
-
- // Update aria-selected immediately so that AT think the tab is already selected.
- // Otherwise AT may confuse the user by stating that they need to activate the tab,
- // but the tab will already be activated by the time the announcement finishes.
- focusedTab.attr( "aria-selected", "false" );
- this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
-
- this.activating = this._delay( function() {
- this.option( "active", selectedIndex );
- }, this.delay );
- }
- },
-
- _panelKeydown: function( event ) {
- if ( this._handlePageNav( event ) ) {
- return;
- }
-
- // Ctrl+up moves focus to the current tab
- if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
- event.preventDefault();
- this.active.trigger( "focus" );
- }
- },
-
- // Alt+page up/down moves focus to the previous/next tab (and activates)
- _handlePageNav: function( event ) {
- if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
- this._activate( this._focusNextTab( this.options.active - 1, false ) );
- return true;
- }
- if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
- this._activate( this._focusNextTab( this.options.active + 1, true ) );
- return true;
- }
- },
-
- _findNextTab: function( index, goingForward ) {
- var lastTabIndex = this.tabs.length - 1;
-
- function constrain() {
- if ( index > lastTabIndex ) {
- index = 0;
- }
- if ( index < 0 ) {
- index = lastTabIndex;
- }
- return index;
- }
-
- while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
- index = goingForward ? index + 1 : index - 1;
- }
-
- return index;
- },
-
- _focusNextTab: function( index, goingForward ) {
- index = this._findNextTab( index, goingForward );
- this.tabs.eq( index ).trigger( "focus" );
- return index;
- },
-
- _setOption: function( key, value ) {
- if ( key === "active" ) {
-
- // _activate() will handle invalid values and update this.options
- this._activate( value );
- return;
- }
-
- this._super( key, value );
-
- if ( key === "collapsible" ) {
- this._toggleClass( "ui-tabs-collapsible", null, value );
-
- // Setting collapsible: false while collapsed; open first panel
- if ( !value && this.options.active === false ) {
- this._activate( 0 );
- }
- }
-
- if ( key === "event" ) {
- this._setupEvents( value );
- }
-
- if ( key === "heightStyle" ) {
- this._setupHeightStyle( value );
- }
- },
-
- _sanitizeSelector: function( hash ) {
- return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
- },
-
- refresh: function() {
- var options = this.options,
- lis = this.tablist.children( ":has(a[href])" );
-
- // Get disabled tabs from class attribute from HTML
- // this will get converted to a boolean if needed in _refresh()
- options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
- return lis.index( tab );
- } );
-
- this._processTabs();
-
- // Was collapsed or no tabs
- if ( options.active === false || !this.anchors.length ) {
- options.active = false;
- this.active = $();
-
- // was active, but active tab is gone
- } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
-
- // all remaining tabs are disabled
- if ( this.tabs.length === options.disabled.length ) {
- options.active = false;
- this.active = $();
-
- // activate previous tab
- } else {
- this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
- }
-
- // was active, active tab still exists
- } else {
-
- // make sure active index is correct
- options.active = this.tabs.index( this.active );
- }
-
- this._refresh();
- },
-
- _refresh: function() {
- this._setOptionDisabled( this.options.disabled );
- this._setupEvents( this.options.event );
- this._setupHeightStyle( this.options.heightStyle );
-
- this.tabs.not( this.active ).attr( {
- "aria-selected": "false",
- "aria-expanded": "false",
- tabIndex: -1
- } );
- this.panels.not( this._getPanelForTab( this.active ) )
- .hide()
- .attr( {
- "aria-hidden": "true"
- } );
-
- // Make sure one tab is in the tab order
- if ( !this.active.length ) {
- this.tabs.eq( 0 ).attr( "tabIndex", 0 );
- } else {
- this.active
- .attr( {
- "aria-selected": "true",
- "aria-expanded": "true",
- tabIndex: 0
- } );
- this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
- this._getPanelForTab( this.active )
- .show()
- .attr( {
- "aria-hidden": "false"
- } );
- }
- },
-
- _processTabs: function() {
- var that = this,
- prevTabs = this.tabs,
- prevAnchors = this.anchors,
- prevPanels = this.panels;
-
- this.tablist = this._getList().attr( "role", "tablist" );
- this._addClass( this.tablist, "ui-tabs-nav",
- "ui-helper-reset ui-helper-clearfix ui-widget-header" );
-
- // Prevent users from focusing disabled tabs via click
- this.tablist
- .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
- if ( $( this ).is( ".ui-state-disabled" ) ) {
- event.preventDefault();
- }
- } )
-
- // Support: IE <9
- // Preventing the default action in mousedown doesn't prevent IE
- // from focusing the element, so if the anchor gets focused, blur.
- // We don't have to worry about focusing the previously focused
- // element since clicking on a non-focusable element should focus
- // the body anyway.
- .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
- if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
- this.blur();
- }
- } );
-
- this.tabs = this.tablist.find( "> li:has(a[href])" )
- .attr( {
- role: "tab",
- tabIndex: -1
- } );
- this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
-
- this.anchors = this.tabs.map( function() {
- return $( "a", this )[ 0 ];
- } )
- .attr( {
- role: "presentation",
- tabIndex: -1
- } );
- this._addClass( this.anchors, "ui-tabs-anchor" );
-
- this.panels = $();
-
- this.anchors.each( function( i, anchor ) {
- var selector, panel, panelId,
- anchorId = $( anchor ).uniqueId().attr( "id" ),
- tab = $( anchor ).closest( "li" ),
- originalAriaControls = tab.attr( "aria-controls" );
-
- // Inline tab
- if ( that._isLocal( anchor ) ) {
- selector = anchor.hash;
- panelId = selector.substring( 1 );
- panel = that.element.find( that._sanitizeSelector( selector ) );
-
- // remote tab
- } else {
-
- // If the tab doesn't already have aria-controls,
- // generate an id by using a throw-away element
- panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
- selector = "#" + panelId;
- panel = that.element.find( selector );
- if ( !panel.length ) {
- panel = that._createPanel( panelId );
- panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
- }
- panel.attr( "aria-live", "polite" );
- }
-
- if ( panel.length ) {
- that.panels = that.panels.add( panel );
- }
- if ( originalAriaControls ) {
- tab.data( "ui-tabs-aria-controls", originalAriaControls );
- }
- tab.attr( {
- "aria-controls": panelId,
- "aria-labelledby": anchorId
- } );
- panel.attr( "aria-labelledby", anchorId );
- } );
-
- this.panels.attr( "role", "tabpanel" );
- this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
-
- // Avoid memory leaks (#10056)
- if ( prevTabs ) {
- this._off( prevTabs.not( this.tabs ) );
- this._off( prevAnchors.not( this.anchors ) );
- this._off( prevPanels.not( this.panels ) );
- }
- },
-
- // Allow overriding how to find the list for rare usage scenarios (#7715)
- _getList: function() {
- return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
- },
-
- _createPanel: function( id ) {
- return $( "<div>" )
- .attr( "id", id )
- .data( "ui-tabs-destroy", true );
- },
-
- _setOptionDisabled: function( disabled ) {
- var currentItem, li, i;
-
- if ( $.isArray( disabled ) ) {
- if ( !disabled.length ) {
- disabled = false;
- } else if ( disabled.length === this.anchors.length ) {
- disabled = true;
- }
- }
-
- // Disable tabs
- for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
- currentItem = $( li );
- if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
- currentItem.attr( "aria-disabled", "true" );
- this._addClass( currentItem, null, "ui-state-disabled" );
- } else {
- currentItem.removeAttr( "aria-disabled" );
- this._removeClass( currentItem, null, "ui-state-disabled" );
- }
- }
-
- this.options.disabled = disabled;
-
- this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
- disabled === true );
- },
-
- _setupEvents: function( event ) {
- var events = {};
- if ( event ) {
- $.each( event.split( " " ), function( index, eventName ) {
- events[ eventName ] = "_eventHandler";
- } );
- }
-
- this._off( this.anchors.add( this.tabs ).add( this.panels ) );
-
- // Always prevent the default action, even when disabled
- this._on( true, this.anchors, {
- click: function( event ) {
- event.preventDefault();
- }
- } );
- this._on( this.anchors, events );
- this._on( this.tabs, { keydown: "_tabKeydown" } );
- this._on( this.panels, { keydown: "_panelKeydown" } );
-
- this._focusable( this.tabs );
- this._hoverable( this.tabs );
- },
-
- _setupHeightStyle: function( heightStyle ) {
- var maxHeight,
- parent = this.element.parent();
-
- if ( heightStyle === "fill" ) {
- maxHeight = parent.height();
- maxHeight -= this.element.outerHeight() - this.element.height();
-
- this.element.siblings( ":visible" ).each( function() {
- var elem = $( this ),
- position = elem.css( "position" );
-
- if ( position === "absolute" || position === "fixed" ) {
- return;
- }
- maxHeight -= elem.outerHeight( true );
- } );
-
- this.element.children().not( this.panels ).each( function() {
- maxHeight -= $( this ).outerHeight( true );
- } );
-
- this.panels.each( function() {
- $( this ).height( Math.max( 0, maxHeight -
- $( this ).innerHeight() + $( this ).height() ) );
- } )
- .css( "overflow", "auto" );
- } else if ( heightStyle === "auto" ) {
- maxHeight = 0;
- this.panels.each( function() {
- maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
- } ).height( maxHeight );
- }
- },
-
- _eventHandler: function( event ) {
- var options = this.options,
- active = this.active,
- anchor = $( event.currentTarget ),
- tab = anchor.closest( "li" ),
- clickedIsActive = tab[ 0 ] === active[ 0 ],
- collapsing = clickedIsActive && options.collapsible,
- toShow = collapsing ? $() : this._getPanelForTab( tab ),
- toHide = !active.length ? $() : this._getPanelForTab( active ),
- eventData = {
- oldTab: active,
- oldPanel: toHide,
- newTab: collapsing ? $() : tab,
- newPanel: toShow
- };
-
- event.preventDefault();
-
- if ( tab.hasClass( "ui-state-disabled" ) ||
-
- // tab is already loading
- tab.hasClass( "ui-tabs-loading" ) ||
-
- // can't switch durning an animation
- this.running ||
-
- // click on active header, but not collapsible
- ( clickedIsActive && !options.collapsible ) ||
-
- // allow canceling activation
- ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
- return;
- }
-
- options.active = collapsing ? false : this.tabs.index( tab );
-
- this.active = clickedIsActive ? $() : tab;
- if ( this.xhr ) {
- this.xhr.abort();
- }
-
- if ( !toHide.length && !toShow.length ) {
- $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
- }
-
- if ( toShow.length ) {
- this.load( this.tabs.index( tab ), event );
- }
- this._toggle( event, eventData );
- },
-
- // Handles show/hide for selecting tabs
- _toggle: function( event, eventData ) {
- var that = this,
- toShow = eventData.newPanel,
- toHide = eventData.oldPanel;
-
- this.running = true;
-
- function complete() {
- that.running = false;
- that._trigger( "activate", event, eventData );
- }
-
- function show() {
- that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
-
- if ( toShow.length && that.options.show ) {
- that._show( toShow, that.options.show, complete );
- } else {
- toShow.show();
- complete();
- }
- }
-
- // Start out by hiding, then showing, then completing
- if ( toHide.length && this.options.hide ) {
- this._hide( toHide, this.options.hide, function() {
- that._removeClass( eventData.oldTab.closest( "li" ),
- "ui-tabs-active", "ui-state-active" );
- show();
- } );
- } else {
- this._removeClass( eventData.oldTab.closest( "li" ),
- "ui-tabs-active", "ui-state-active" );
- toHide.hide();
- show();
- }
-
- toHide.attr( "aria-hidden", "true" );
- eventData.oldTab.attr( {
- "aria-selected": "false",
- "aria-expanded": "false"
- } );
-
- // If we're switching tabs, remove the old tab from the tab order.
- // If we're opening from collapsed state, remove the previous tab from the tab order.
- // If we're collapsing, then keep the collapsing tab in the tab order.
- if ( toShow.length && toHide.length ) {
- eventData.oldTab.attr( "tabIndex", -1 );
- } else if ( toShow.length ) {
- this.tabs.filter( function() {
- return $( this ).attr( "tabIndex" ) === 0;
- } )
- .attr( "tabIndex", -1 );
- }
-
- toShow.attr( "aria-hidden", "false" );
- eventData.newTab.attr( {
- "aria-selected": "true",
- "aria-expanded": "true",
- tabIndex: 0
- } );
- },
-
- _activate: function( index ) {
- var anchor,
- active = this._findActive( index );
-
- // Trying to activate the already active panel
- if ( active[ 0 ] === this.active[ 0 ] ) {
- return;
- }
-
- // Trying to collapse, simulate a click on the current active header
- if ( !active.length ) {
- active = this.active;
- }
-
- anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
- this._eventHandler( {
- target: anchor,
- currentTarget: anchor,
- preventDefault: $.noop
- } );
- },
-
- _findActive: function( index ) {
- return index === false ? $() : this.tabs.eq( index );
- },
-
- _getIndex: function( index ) {
-
- // meta-function to give users option to provide a href string instead of a numerical index.
- if ( typeof index === "string" ) {
- index = this.anchors.index( this.anchors.filter( "[href$='" +
- $.ui.escapeSelector( index ) + "']" ) );
- }
-
- return index;
- },
-
- _destroy: function() {
- if ( this.xhr ) {
- this.xhr.abort();
- }
-
- this.tablist
- .removeAttr( "role" )
- .off( this.eventNamespace );
-
- this.anchors
- .removeAttr( "role tabIndex" )
- .removeUniqueId();
-
- this.tabs.add( this.panels ).each( function() {
- if ( $.data( this, "ui-tabs-destroy" ) ) {
- $( this ).remove();
- } else {
- $( this ).removeAttr( "role tabIndex " +
- "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
- }
- } );
-
- this.tabs.each( function() {
- var li = $( this ),
- prev = li.data( "ui-tabs-aria-controls" );
- if ( prev ) {
- li
- .attr( "aria-controls", prev )
- .removeData( "ui-tabs-aria-controls" );
- } else {
- li.removeAttr( "aria-controls" );
- }
- } );
-
- this.panels.show();
-
- if ( this.options.heightStyle !== "content" ) {
- this.panels.css( "height", "" );
- }
- },
-
- enable: function( index ) {
- var disabled = this.options.disabled;
- if ( disabled === false ) {
- return;
- }
-
- if ( index === undefined ) {
- disabled = false;
- } else {
- index = this._getIndex( index );
- if ( $.isArray( disabled ) ) {
- disabled = $.map( disabled, function( num ) {
- return num !== index ? num : null;
- } );
- } else {
- disabled = $.map( this.tabs, function( li, num ) {
- return num !== index ? num : null;
- } );
- }
- }
- this._setOptionDisabled( disabled );
- },
-
- disable: function( index ) {
- var disabled = this.options.disabled;
- if ( disabled === true ) {
- return;
- }
-
- if ( index === undefined ) {
- disabled = true;
- } else {
- index = this._getIndex( index );
- if ( $.inArray( index, disabled ) !== -1 ) {
- return;
- }
- if ( $.isArray( disabled ) ) {
- disabled = $.merge( [ index ], disabled ).sort();
- } else {
- disabled = [ index ];
- }
- }
- this._setOptionDisabled( disabled );
- },
-
- load: function( index, event ) {
- index = this._getIndex( index );
- var that = this,
- tab = this.tabs.eq( index ),
- anchor = tab.find( ".ui-tabs-anchor" ),
- panel = this._getPanelForTab( tab ),
- eventData = {
- tab: tab,
- panel: panel
- },
- complete = function( jqXHR, status ) {
- if ( status === "abort" ) {
- that.panels.stop( false, true );
- }
-
- that._removeClass( tab, "ui-tabs-loading" );
- panel.removeAttr( "aria-busy" );
-
- if ( jqXHR === that.xhr ) {
- delete that.xhr;
- }
- };
-
- // Not remote
- if ( this._isLocal( anchor[ 0 ] ) ) {
- return;
- }
-
- this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
-
- // Support: jQuery <1.8
- // jQuery <1.8 returns false if the request is canceled in beforeSend,
- // but as of 1.8, $.ajax() always returns a jqXHR object.
- if ( this.xhr && this.xhr.statusText !== "canceled" ) {
- this._addClass( tab, "ui-tabs-loading" );
- panel.attr( "aria-busy", "true" );
-
- this.xhr
- .done( function( response, status, jqXHR ) {
-
- // support: jQuery <1.8
- // http://bugs.jquery.com/ticket/11778
- setTimeout( function() {
- panel.html( response );
- that._trigger( "load", event, eventData );
-
- complete( jqXHR, status );
- }, 1 );
- } )
- .fail( function( jqXHR, status ) {
-
- // support: jQuery <1.8
- // http://bugs.jquery.com/ticket/11778
- setTimeout( function() {
- complete( jqXHR, status );
- }, 1 );
- } );
- }
- },
-
- _ajaxSettings: function( anchor, event, eventData ) {
- var that = this;
- return {
-
- // Support: IE <11 only
- // Strip any hash that exists to prevent errors with the Ajax request
- url: anchor.attr( "href" ).replace( /#.*$/, "" ),
- beforeSend: function( jqXHR, settings ) {
- return that._trigger( "beforeLoad", event,
- $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
- }
- };
- },
-
- _getPanelForTab: function( tab ) {
- var id = $( tab ).attr( "aria-controls" );
- return this.element.find( this._sanitizeSelector( "#" + id ) );
- }
-} );
-
-// DEPRECATED
-// TODO: Switch return back to widget declaration at top of file when this is removed
-if ( $.uiBackCompat !== false ) {
-
- // Backcompat for ui-tab class (now ui-tabs-tab)
- $.widget( "ui.tabs", $.ui.tabs, {
- _processTabs: function() {
- this._superApply( arguments );
- this._addClass( this.tabs, "ui-tab" );
- }
- } );
-}
-
-var widgetsTabs = $.ui.tabs;
-
-
-/*!
- * jQuery UI Tooltip 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Tooltip
-//>>group: Widgets
-//>>description: Shows additional information for any element on hover or focus.
-//>>docs: http://api.jqueryui.com/tooltip/
-//>>demos: http://jqueryui.com/tooltip/
-//>>css.structure: ../../themes/base/core.css
-//>>css.structure: ../../themes/base/tooltip.css
-//>>css.theme: ../../themes/base/theme.css
-
-
-
-$.widget( "ui.tooltip", {
- version: "1.12.1",
- options: {
- classes: {
- "ui-tooltip": "ui-corner-all ui-widget-shadow"
- },
- content: function() {
-
- // support: IE<9, Opera in jQuery <1.7
- // .text() can't accept undefined, so coerce to a string
- var title = $( this ).attr( "title" ) || "";
-
- // Escape title, since we're going from an attribute to raw HTML
- return $( "<a>" ).text( title ).html();
- },
- hide: true,
-
- // Disabled elements have inconsistent behavior across browsers (#8661)
- items: "[title]:not([disabled])",
- position: {
- my: "left top+15",
- at: "left bottom",
- collision: "flipfit flip"
- },
- show: true,
- track: false,
-
- // Callbacks
- close: null,
- open: null
- },
-
- _addDescribedBy: function( elem, id ) {
- var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
- describedby.push( id );
- elem
- .data( "ui-tooltip-id", id )
- .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
- },
-
- _removeDescribedBy: function( elem ) {
- var id = elem.data( "ui-tooltip-id" ),
- describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
- index = $.inArray( id, describedby );
-
- if ( index !== -1 ) {
- describedby.splice( index, 1 );
- }
-
- elem.removeData( "ui-tooltip-id" );
- describedby = $.trim( describedby.join( " " ) );
- if ( describedby ) {
- elem.attr( "aria-describedby", describedby );
- } else {
- elem.removeAttr( "aria-describedby" );
- }
- },
-
- _create: function() {
- this._on( {
- mouseover: "open",
- focusin: "open"
- } );
-
- // IDs of generated tooltips, needed for destroy
- this.tooltips = {};
-
- // IDs of parent tooltips where we removed the title attribute
- this.parents = {};
-
- // Append the aria-live region so tooltips announce correctly
- this.liveRegion = $( "<div>" )
- .attr( {
- role: "log",
- "aria-live": "assertive",
- "aria-relevant": "additions"
- } )
- .appendTo( this.document[ 0 ].body );
- this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
-
- this.disabledTitles = $( [] );
- },
-
- _setOption: function( key, value ) {
- var that = this;
-
- this._super( key, value );
-
- if ( key === "content" ) {
- $.each( this.tooltips, function( id, tooltipData ) {
- that._updateContent( tooltipData.element );
- } );
- }
- },
-
- _setOptionDisabled: function( value ) {
- this[ value ? "_disable" : "_enable" ]();
- },
-
- _disable: function() {
- var that = this;
-
- // Close open tooltips
- $.each( this.tooltips, function( id, tooltipData ) {
- var event = $.Event( "blur" );
- event.target = event.currentTarget = tooltipData.element[ 0 ];
- that.close( event, true );
- } );
-
- // Remove title attributes to prevent native tooltips
- this.disabledTitles = this.disabledTitles.add(
- this.element.find( this.options.items ).addBack()
- .filter( function() {
- var element = $( this );
- if ( element.is( "[title]" ) ) {
- return element
- .data( "ui-tooltip-title", element.attr( "title" ) )
- .removeAttr( "title" );
- }
- } )
- );
- },
-
- _enable: function() {
-
- // restore title attributes
- this.disabledTitles.each( function() {
- var element = $( this );
- if ( element.data( "ui-tooltip-title" ) ) {
- element.attr( "title", element.data( "ui-tooltip-title" ) );
- }
- } );
- this.disabledTitles = $( [] );
- },
-
- open: function( event ) {
- var that = this,
- target = $( event ? event.target : this.element )
-
- // we need closest here due to mouseover bubbling,
- // but always pointing at the same event target
- .closest( this.options.items );
-
- // No element to show a tooltip for or the tooltip is already open
- if ( !target.length || target.data( "ui-tooltip-id" ) ) {
- return;
- }
-
- if ( target.attr( "title" ) ) {
- target.data( "ui-tooltip-title", target.attr( "title" ) );
- }
-
- target.data( "ui-tooltip-open", true );
-
- // Kill parent tooltips, custom or native, for hover
- if ( event && event.type === "mouseover" ) {
- target.parents().each( function() {
- var parent = $( this ),
- blurEvent;
- if ( parent.data( "ui-tooltip-open" ) ) {
- blurEvent = $.Event( "blur" );
- blurEvent.target = blurEvent.currentTarget = this;
- that.close( blurEvent, true );
- }
- if ( parent.attr( "title" ) ) {
- parent.uniqueId();
- that.parents[ this.id ] = {
- element: this,
- title: parent.attr( "title" )
- };
- parent.attr( "title", "" );
- }
- } );
- }
-
- this._registerCloseHandlers( event, target );
- this._updateContent( target, event );
- },
-
- _updateContent: function( target, event ) {
- var content,
- contentOption = this.options.content,
- that = this,
- eventType = event ? event.type : null;
-
- if ( typeof contentOption === "string" || contentOption.nodeType ||
- contentOption.jquery ) {
- return this._open( event, target, contentOption );
- }
-
- content = contentOption.call( target[ 0 ], function( response ) {
-
- // IE may instantly serve a cached response for ajax requests
- // delay this call to _open so the other call to _open runs first
- that._delay( function() {
-
- // Ignore async response if tooltip was closed already
- if ( !target.data( "ui-tooltip-open" ) ) {
- return;
- }
-
- // JQuery creates a special event for focusin when it doesn't
- // exist natively. To improve performance, the native event
- // object is reused and the type is changed. Therefore, we can't
- // rely on the type being correct after the event finished
- // bubbling, so we set it back to the previous value. (#8740)
- if ( event ) {
- event.type = eventType;
- }
- this._open( event, target, response );
- } );
- } );
- if ( content ) {
- this._open( event, target, content );
- }
- },
-
- _open: function( event, target, content ) {
- var tooltipData, tooltip, delayedShow, a11yContent,
- positionOption = $.extend( {}, this.options.position );
-
- if ( !content ) {
- return;
- }
-
- // Content can be updated multiple times. If the tooltip already
- // exists, then just update the content and bail.
- tooltipData = this._find( target );
- if ( tooltipData ) {
- tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
- return;
- }
-
- // If we have a title, clear it to prevent the native tooltip
- // we have to check first to avoid defining a title if none exists
- // (we don't want to cause an element to start matching [title])
- //
- // We use removeAttr only for key events, to allow IE to export the correct
- // accessible attributes. For mouse events, set to empty string to avoid
- // native tooltip showing up (happens only when removing inside mouseover).
- if ( target.is( "[title]" ) ) {
- if ( event && event.type === "mouseover" ) {
- target.attr( "title", "" );
- } else {
- target.removeAttr( "title" );
- }
- }
-
- tooltipData = this._tooltip( target );
- tooltip = tooltipData.tooltip;
- this._addDescribedBy( target, tooltip.attr( "id" ) );
- tooltip.find( ".ui-tooltip-content" ).html( content );
-
- // Support: Voiceover on OS X, JAWS on IE <= 9
- // JAWS announces deletions even when aria-relevant="additions"
- // Voiceover will sometimes re-read the entire log region's contents from the beginning
- this.liveRegion.children().hide();
- a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
- a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
- a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
- a11yContent.appendTo( this.liveRegion );
-
- function position( event ) {
- positionOption.of = event;
- if ( tooltip.is( ":hidden" ) ) {
- return;
- }
- tooltip.position( positionOption );
- }
- if ( this.options.track && event && /^mouse/.test( event.type ) ) {
- this._on( this.document, {
- mousemove: position
- } );
-
- // trigger once to override element-relative positioning
- position( event );
- } else {
- tooltip.position( $.extend( {
- of: target
- }, this.options.position ) );
- }
-
- tooltip.hide();
-
- this._show( tooltip, this.options.show );
-
- // Handle tracking tooltips that are shown with a delay (#8644). As soon
- // as the tooltip is visible, position the tooltip using the most recent
- // event.
- // Adds the check to add the timers only when both delay and track options are set (#14682)
- if ( this.options.track && this.options.show && this.options.show.delay ) {
- delayedShow = this.delayedShow = setInterval( function() {
- if ( tooltip.is( ":visible" ) ) {
- position( positionOption.of );
- clearInterval( delayedShow );
- }
- }, $.fx.interval );
- }
-
- this._trigger( "open", event, { tooltip: tooltip } );
- },
-
- _registerCloseHandlers: function( event, target ) {
- var events = {
- keyup: function( event ) {
- if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
- var fakeEvent = $.Event( event );
- fakeEvent.currentTarget = target[ 0 ];
- this.close( fakeEvent, true );
- }
- }
- };
-
- // Only bind remove handler for delegated targets. Non-delegated
- // tooltips will handle this in destroy.
- if ( target[ 0 ] !== this.element[ 0 ] ) {
- events.remove = function() {
- this._removeTooltip( this._find( target ).tooltip );
- };
- }
-
- if ( !event || event.type === "mouseover" ) {
- events.mouseleave = "close";
- }
- if ( !event || event.type === "focusin" ) {
- events.focusout = "close";
- }
- this._on( true, target, events );
- },
-
- close: function( event ) {
- var tooltip,
- that = this,
- target = $( event ? event.currentTarget : this.element ),
- tooltipData = this._find( target );
-
- // The tooltip may already be closed
- if ( !tooltipData ) {
-
- // We set ui-tooltip-open immediately upon open (in open()), but only set the
- // additional data once there's actually content to show (in _open()). So even if the
- // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
- // the period between open() and _open().
- target.removeData( "ui-tooltip-open" );
- return;
- }
-
- tooltip = tooltipData.tooltip;
-
- // Disabling closes the tooltip, so we need to track when we're closing
- // to avoid an infinite loop in case the tooltip becomes disabled on close
- if ( tooltipData.closing ) {
- return;
- }
-
- // Clear the interval for delayed tracking tooltips
- clearInterval( this.delayedShow );
-
- // Only set title if we had one before (see comment in _open())
- // If the title attribute has changed since open(), don't restore
- if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
- target.attr( "title", target.data( "ui-tooltip-title" ) );
- }
-
- this._removeDescribedBy( target );
-
- tooltipData.hiding = true;
- tooltip.stop( true );
- this._hide( tooltip, this.options.hide, function() {
- that._removeTooltip( $( this ) );
- } );
-
- target.removeData( "ui-tooltip-open" );
- this._off( target, "mouseleave focusout keyup" );
-
- // Remove 'remove' binding only on delegated targets
- if ( target[ 0 ] !== this.element[ 0 ] ) {
- this._off( target, "remove" );
- }
- this._off( this.document, "mousemove" );
-
- if ( event && event.type === "mouseleave" ) {
- $.each( this.parents, function( id, parent ) {
- $( parent.element ).attr( "title", parent.title );
- delete that.parents[ id ];
- } );
- }
-
- tooltipData.closing = true;
- this._trigger( "close", event, { tooltip: tooltip } );
- if ( !tooltipData.hiding ) {
- tooltipData.closing = false;
- }
- },
-
- _tooltip: function( element ) {
- var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
- content = $( "<div>" ).appendTo( tooltip ),
- id = tooltip.uniqueId().attr( "id" );
-
- this._addClass( content, "ui-tooltip-content" );
- this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
-
- tooltip.appendTo( this._appendTo( element ) );
-
- return this.tooltips[ id ] = {
- element: element,
- tooltip: tooltip
- };
- },
-
- _find: function( target ) {
- var id = target.data( "ui-tooltip-id" );
- return id ? this.tooltips[ id ] : null;
- },
-
- _removeTooltip: function( tooltip ) {
- tooltip.remove();
- delete this.tooltips[ tooltip.attr( "id" ) ];
- },
-
- _appendTo: function( target ) {
- var element = target.closest( ".ui-front, dialog" );
-
- if ( !element.length ) {
- element = this.document[ 0 ].body;
- }
-
- return element;
- },
-
- _destroy: function() {
- var that = this;
-
- // Close open tooltips
- $.each( this.tooltips, function( id, tooltipData ) {
-
- // Delegate to close method to handle common cleanup
- var event = $.Event( "blur" ),
- element = tooltipData.element;
- event.target = event.currentTarget = element[ 0 ];
- that.close( event, true );
-
- // Remove immediately; destroying an open tooltip doesn't use the
- // hide animation
- $( "#" + id ).remove();
-
- // Restore the title
- if ( element.data( "ui-tooltip-title" ) ) {
-
- // If the title attribute has changed since open(), don't restore
- if ( !element.attr( "title" ) ) {
- element.attr( "title", element.data( "ui-tooltip-title" ) );
- }
- element.removeData( "ui-tooltip-title" );
- }
- } );
- this.liveRegion.remove();
- }
-} );
-
-// DEPRECATED
-// TODO: Switch return back to widget declaration at top of file when this is removed
-if ( $.uiBackCompat !== false ) {
-
- // Backcompat for tooltipClass option
- $.widget( "ui.tooltip", $.ui.tooltip, {
- options: {
- tooltipClass: null
- },
- _tooltip: function() {
- var tooltipData = this._superApply( arguments );
- if ( this.options.tooltipClass ) {
- tooltipData.tooltip.addClass( this.options.tooltipClass );
- }
- return tooltipData;
- }
- } );
-}
-
-var widgetsTooltip = $.ui.tooltip;
-
-
-
-
-}));
\ No newline at end of file
--- a/domino/jqueryui/tabs.html
+++ /dev/null
@@ -1,39 +1,0 @@
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>jQuery UI Tabs - Default functionality</title>
- <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
- <link rel="stylesheet" href="/resources/demos/style.css">
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
- <script>
- $( function() {
- $( "#tabs" ).tabs();
- } );
- </script>
-</head>
-<body>
-
-<div id="tabs">
- <ul>
- <li><a href="#tabs-1">Nunc tincidunt</a></li>
- <li><a href="#tabs-2">Proin dolor</a></li>
- <li><a href="#tabs-3">Aenean lacinia</a></li>
- </ul>
- <div id="tabs-1">
- <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
- </div>
- <div id="tabs-2">
- <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
- </div>
- <div id="tabs-3">
- <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
- <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
- </div>
-</div>
-
-
-</body>
-</html>
--- a/domino/jqueryui/tabs.js
+++ /dev/null
@@ -1,3 +1,0 @@
-$( function() {
- $( "#tabs" ).tabs();
-} );
--- a/go.mod
+++ b/go.mod
@@ -2,9 +2,9 @@
go 1.16
-replace 9fans.net/go v0.0.0-00010101000000-000000000000 => github.com/psilva261/go v0.0.0-20210409105224-1f229ca22d72
+replace 9fans.net/go v0.0.0-00010101000000-000000000000 => github.com/psilva261/go v0.0.0-20210627170947-30c070af4b5f
-replace 9fans.net/go v0.0.2 => github.com/psilva261/go v0.0.0-20210409105224-1f229ca22d72
+replace 9fans.net/go v0.0.2 => github.com/psilva261/go v0.0.0-20210627170947-30c070af4b5f
replace github.com/mjl-/duit v0.0.0-20200330125617-580cb0b2843f => github.com/psilva261/duit v0.0.0-20210627123547-8bc19650d4a2
--- a/go.sum
+++ b/go.sum
@@ -26,8 +26,8 @@
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/psilva261/duit v0.0.0-20210627123547-8bc19650d4a2 h1:XVUpKOs8MDCaGCyyrpr5an4rflKIpJpMq/76XhqdC5I=
github.com/psilva261/duit v0.0.0-20210627123547-8bc19650d4a2/go.mod h1:bCuFm7lhAl9wLyLCC6E4RVLDpAv7bWfnTMeDd+C4OQ8=
-github.com/psilva261/go v0.0.0-20210409105224-1f229ca22d72 h1:uWLLj4IgtIj4iPHyiVOQLT+Qklxos2Uc7MyRP9Yo5Mc=
-github.com/psilva261/go v0.0.0-20210409105224-1f229ca22d72/go.mod h1:AWpRSZZ474OlNPxa7mOyFZ6Ceg9FRel9f+EONmhPbu0=
+github.com/psilva261/go v0.0.0-20210627170947-30c070af4b5f h1:5CueYn5/w2szKF7GYt2EKPY6dqkcARbKgZlERlKsgYc=
+github.com/psilva261/go v0.0.0-20210627170947-30c070af4b5f/go.mod h1:AWpRSZZ474OlNPxa7mOyFZ6Ceg9FRel9f+EONmhPbu0=
github.com/psilva261/go9p-1 v1.17.1-0.20210620075710-0428cf31f72f h1:gJVK1NhzFXZye5ki4bvyu8dzo0qIckxTf68Vm+Qh4BI=
github.com/psilva261/go9p-1 v1.17.1-0.20210620075710-0428cf31f72f/go.mod h1:HtMoJKqZUe1Oqag5uJqG5RKQ9gWPSP+wolsnLLv44r8=
github.com/srwiley/oksvg v0.0.0-20210320200257-875f767ac39a h1:Lhe6HPtH4ndWfV56fWc4/yQhOP3vEGlwl5nfPyBxUAg=
--- /dev/null
+++ b/js/godoc/godocs.js
@@ -1,0 +1,381 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+/* A little code to ease navigation of these documents.
+ *
+ * On window load we:
+ * + Generate a table of contents (generateTOC)
+ * + Bind foldable sections (bindToggles)
+ * + Bind links to foldable sections (bindToggleLinks)
+ */
+
+(function() {
+ 'use strict';
+
+ var headerEl = document.querySelector('.js-header');
+ var menuButtonEl = document.querySelector('.js-headerMenuButton');
+ menuButtonEl.addEventListener('click', function(e) {
+ e.preventDefault();
+ headerEl.classList.toggle('is-active');
+ menuButtonEl.setAttribute(
+ 'aria-expanded',
+ headerEl.classList.contains('is-active')
+ );
+ });
+
+ /* Generates a table of contents: looks for h2 and h3 elements and generates
+ * links. "Decorates" the element with id=="nav" with this table of contents.
+ */
+ function generateTOC() {
+ if ($('#manual-nav').length > 0) {
+ return;
+ }
+
+ // For search, we send the toc precomputed from server-side.
+ // TODO: Ideally, this should always be precomputed for all pages, but then
+ // we need to do HTML parsing on the server-side.
+ if (location.pathname === '/search') {
+ return;
+ }
+
+ var nav = $('#nav');
+ if (nav.length === 0) {
+ return;
+ }
+
+ var toc_items = [];
+ $(nav)
+ .nextAll('h2, h3')
+ .each(function() {
+ var node = this;
+ if (node.id == '') node.id = 'tmp_' + toc_items.length;
+ var link = $('<a/>')
+ .attr('href', '#' + node.id)
+ .text($(node).text());
+ var item;
+ if ($(node).is('h2')) {
+ item = $('<dt/>');
+ } else {
+ // h3
+ item = $('<dd class="indent"/>');
+ }
+ item.append(link);
+ toc_items.push(item);
+ });
+ if (toc_items.length <= 1) {
+ return;
+ }
+ var dl1 = $('<dl/>');
+ var dl2 = $('<dl/>');
+
+ var split_index = toc_items.length / 2 + 1;
+ if (split_index < 8) {
+ split_index = toc_items.length;
+ }
+ for (var i = 0; i < split_index; i++) {
+ dl1.append(toc_items[i]);
+ }
+ for (; /* keep using i */ i < toc_items.length; i++) {
+ dl2.append(toc_items[i]);
+ }
+
+ var tocTable = $('<table class="unruled"/>').appendTo(nav);
+ var tocBody = $('<tbody/>').appendTo(tocTable);
+ var tocRow = $('<tr/>').appendTo(tocBody);
+
+ // 1st column
+ $('<td class="first"/>')
+ .appendTo(tocRow)
+ .append(dl1);
+ // 2nd column
+ $('<td/>')
+ .appendTo(tocRow)
+ .append(dl2);
+ }
+
+ function bindToggle(el) {
+ $('.toggleButton', el).click(function() {
+ if ($(this).closest('.toggle, .toggleVisible')[0] != el) {
+ // Only trigger the closest toggle header.
+ return;
+ }
+
+ if ($(el).is('.toggle')) {
+ $(el)
+ .addClass('toggleVisible')
+ .removeClass('toggle');
+ } else {
+ $(el)
+ .addClass('toggle')
+ .removeClass('toggleVisible');
+ }
+ });
+ }
+
+ function bindToggles(selector) {
+ $(selector).each(function(i, el) {
+ bindToggle(el);
+ });
+ }
+
+ function bindToggleLink(el, prefix) {
+ $(el).click(function() {
+ var href = $(el).attr('href');
+ var i = href.indexOf('#' + prefix);
+ if (i < 0) {
+ return;
+ }
+ var id = '#' + prefix + href.slice(i + 1 + prefix.length);
+ if ($(id).is('.toggle')) {
+ $(id)
+ .find('.toggleButton')
+ .first()
+ .click();
+ }
+ });
+ }
+ function bindToggleLinks(selector, prefix) {
+ $(selector).each(function(i, el) {
+ bindToggleLink(el, prefix);
+ });
+ }
+
+ function setupInlinePlayground() {
+ 'use strict';
+ // Set up playground when each element is toggled.
+ $('div.play').each(function(i, el) {
+ // Set up playground for this example.
+ var setup = function() {
+ var code = $('.code', el);
+ playground({
+ codeEl: code,
+ outputEl: $('.output', el),
+ runEl: $('.run', el),
+ fmtEl: $('.fmt', el),
+ shareEl: $('.share', el),
+ shareRedirect: '//play.golang.org/p/',
+ });
+
+ // Make the code textarea resize to fit content.
+ var resize = function() {
+ code.height(0);
+ var h = code[0].scrollHeight;
+ code.height(h + 20); // minimize bouncing.
+ code.closest('.input').height(h);
+ };
+ code.on('keydown', resize);
+ code.on('keyup', resize);
+ code.keyup(); // resize now.
+ };
+
+ // If example already visible, set up playground now.
+ if ($(el).is(':visible')) {
+ setup();
+ return;
+ }
+
+ // Otherwise, set up playground when example is expanded.
+ var built = false;
+ $(el)
+ .closest('.toggle')
+ .click(function() {
+ // Only set up once.
+ if (!built) {
+ setup();
+ built = true;
+ }
+ });
+ });
+ }
+
+ // fixFocus tries to put focus to #page so that keyboard navigation works.
+ function fixFocus() {
+ var page = $('#page');
+ var topbar = $('div#topbar');
+ page.css('outline', 0); // disable outline when focused
+ page.attr('tabindex', -1); // and set tabindex so that it is focusable
+ $(window)
+ .resize(function(evt) {
+ // only focus page when the topbar is at fixed position (that is, it's in
+ // front of page, and keyboard event will go to the former by default.)
+ // by focusing page, keyboard event will go to page so that up/down arrow,
+ // space, etc. will work as expected.
+ if (topbar.css('position') == 'fixed') page.focus();
+ })
+ .resize();
+ }
+
+ function toggleHash() {
+ var id = window.location.hash.substring(1);
+ // Open all of the toggles for a particular hash.
+ var els = $(
+ document.getElementById(id),
+ $('a[name]').filter(function() {
+ return $(this).attr('name') == id;
+ })
+ );
+
+ while (els.length) {
+ for (var i = 0; i < els.length; i++) {
+ var el = $(els[i]);
+ if (el.is('.toggle')) {
+ el.find('.toggleButton')
+ .first()
+ .click();
+ }
+ }
+ els = el.parent();
+ }
+ }
+
+ function personalizeInstallInstructions() {
+ var prefix = '?download=';
+ var s = window.location.search;
+ if (s.indexOf(prefix) != 0) {
+ // No 'download' query string; detect "test" instructions from User Agent.
+ if (navigator.platform.indexOf('Win') != -1) {
+ $('.testUnix').hide();
+ $('.testWindows').show();
+ } else {
+ $('.testUnix').show();
+ $('.testWindows').hide();
+ }
+ return;
+ }
+
+ var filename = s.substr(prefix.length);
+ var filenameRE = /^go1\.\d+(\.\d+)?([a-z0-9]+)?\.([a-z0-9]+)(-[a-z0-9]+)?(-osx10\.[68])?\.([a-z.]+)$/;
+ var m = filenameRE.exec(filename);
+ if (!m) {
+ // Can't interpret file name; bail.
+ return;
+ }
+ $('.downloadFilename').text(filename);
+ $('.hideFromDownload').hide();
+
+ var os = m[3];
+ var ext = m[6];
+ if (ext != 'tar.gz') {
+ $('#tarballInstructions').hide();
+ }
+ if (os != 'darwin' || ext != 'pkg') {
+ $('#darwinPackageInstructions').hide();
+ }
+ if (os != 'windows') {
+ $('#windowsInstructions').hide();
+ $('.testUnix').show();
+ $('.testWindows').hide();
+ } else {
+ if (ext != 'msi') {
+ $('#windowsInstallerInstructions').hide();
+ }
+ if (ext != 'zip') {
+ $('#windowsZipInstructions').hide();
+ }
+ $('.testUnix').hide();
+ $('.testWindows').show();
+ }
+
+ var download = '/dl/' + filename;
+
+ var message = $(
+ '<p class="downloading">' +
+ 'Your download should begin shortly. ' +
+ 'If it does not, click <a>this link</a>.</p>'
+ );
+ message.find('a').attr('href', download);
+ message.insertAfter('#nav');
+
+ window.location = download;
+ }
+
+ function updateVersionTags() {
+ var v = window.goVersion;
+ if (/^go[0-9.]+$/.test(v)) {
+ $('.versionTag')
+ .empty()
+ .text(v);
+ $('.whereTag').hide();
+ }
+ }
+
+ function addPermalinks() {
+ function addPermalink(source, parent) {
+ var id = source.attr('id');
+ if (id == '' || id.indexOf('tmp_') === 0) {
+ // Auto-generated permalink.
+ return;
+ }
+ if (parent.find('> .permalink').length) {
+ // Already attached.
+ return;
+ }
+ parent
+ .append(' ')
+ .append($("<a class='permalink'>¶</a>").attr('href', '#' + id));
+ }
+
+ $('#page .container')
+ .find('h2[id], h3[id]')
+ .each(function() {
+ var el = $(this);
+ addPermalink(el, el);
+ });
+
+ $('#page .container')
+ .find('dl[id]')
+ .each(function() {
+ var el = $(this);
+ // Add the anchor to the "dt" element.
+ addPermalink(el, el.find('> dt').first());
+ });
+ }
+
+ $('.js-expandAll').click(function() {
+ if ($(this).hasClass('collapsed')) {
+ toggleExamples('toggle');
+ $(this).text('(Collapse All)');
+ } else {
+ toggleExamples('toggleVisible');
+ $(this).text('(Expand All)');
+ }
+ $(this).toggleClass('collapsed');
+ });
+
+ function toggleExamples(className) {
+ // We need to explicitly iterate through divs starting with "example_"
+ // to avoid toggling Overview and Index collapsibles.
+ $("[id^='example_']").each(function() {
+ // Check for state and click it only if required.
+ if ($(this).hasClass(className)) {
+ $(this)
+ .find('.toggleButton')
+ .first()
+ .click();
+ }
+ });
+ }
+
+ $(document).ready(function() {
+ generateTOC();
+ addPermalinks();
+ bindToggles('.toggle');
+ bindToggles('.toggleVisible');
+ bindToggleLinks('.exampleLink', 'example_');
+ bindToggleLinks('.overviewLink', '');
+ bindToggleLinks('.examplesLink', '');
+ bindToggleLinks('.indexLink', '');
+ setupInlinePlayground();
+ fixFocus();
+ toggleHash();
+ personalizeInstallInstructions();
+ updateVersionTags();
+
+ // godoc.html defines window.initFuncs in the <head> tag, and root.html and
+ // codewalk.js push their on-page-ready functions to the list.
+ // We execute those functions here, to avoid loading jQuery until the page
+ // content is loaded.
+ for (var i = 0; i < window.initFuncs.length; i++) window.initFuncs[i]();
+ });
+})();
--- /dev/null
+++ b/js/godoc/golang.html
@@ -1,0 +1,299 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8">
+<meta name="description" content="Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta name="theme-color" content="#00ADD8">
+
+ <title>The Go Programming Language</title>
+
+<link href="https://fonts.googleapis.com/css?family=Work+Sans:600|Roboto:400,700" rel="stylesheet">
+<link href="https://fonts.googleapis.com/css?family=Product+Sans&text=Supported%20by%20Google&display=swap" rel="stylesheet">
+<link type="text/css" rel="stylesheet" href="/lib/godoc/style.css">
+
+<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
+
+<script>window.initFuncs = [];</script>
+
+<script>
+var _gaq = _gaq || [];
+_gaq.push(["_setAccount", "UA-11222381-2"]);
+window.trackPageview = function() {
+ _gaq.push(["_trackPageview", location.pathname+location.hash]);
+};
+window.trackPageview();
+window.trackEvent = function(category, action, opt_label, opt_value, opt_noninteraction) {
+ _gaq.push(["_trackEvent", category, action, opt_label, opt_value, opt_noninteraction]);
+};
+</script>
+
+<script src="/lib/godoc/jquery.js" defer></script>
+
+
+<script src="/lib/godoc/playground.js" defer></script>
+
+<script>var goVersion = "go1.15.8";</script>
+<script src="/lib/godoc/godocs.js" defer></script>
+
+<body class="Site">
+<header class="Header js-header">
+ <div class="Header-banner">
+ Black Lives Matter.
+ <a href="https://support.eji.org/give/153413/#!/donation/checkout"
+ target="_blank"
+ rel="noopener">Support the Equal Justice Initiative.</a>
+ </div>
+ <nav class="Header-nav ">
+ <a href="/"><img class="Header-logo" src="/lib/godoc/images/go-logo-blue.svg" alt="Go"></a>
+ <button class="Header-menuButton js-headerMenuButton" aria-label="Main menu" aria-expanded="false">
+ <div class="Header-menuButtonInner"></div>
+ </button>
+ <ul class="Header-menu">
+ <li class="Header-menuItem"><a href="/doc/">Documents</a></li>
+ <li class="Header-menuItem"><a href="/pkg/">Packages</a></li>
+ <li class="Header-menuItem"><a href="/project/">The Project</a></li>
+ <li class="Header-menuItem"><a href="/help/">Help</a></li>
+
+ <li class="Header-menuItem"><a href="/blog/">Blog</a></li>
+
+ <li class="Header-menuItem"><a href="https://play.golang.org/">Play</a></li>
+
+
+ <li class="Header-menuItem Header-menuItem--search">
+ <form class="HeaderSearch" role="search" action="/search">
+ <input class="HeaderSearch-input"
+ type="search"
+ name="q"
+ placeholder="Search"
+ aria-label="Search"
+ autocapitalize="off"
+ autocomplete="off"
+ autocorrect="off"
+ spellcheck="false"
+ required>
+ <button class="HeaderSearch-submit">
+ <!-- magnifying glass: --><svg class="HeaderSearch-icon" width="24" height="24" viewBox="0 0 24 24"><title>Search</title><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
+ </button>
+ </form>
+ </li>
+ </ul>
+ </nav>
+</header>
+
+<main id="page" class="Site-content">
+<div class="container">
+
+
+
+
+
+
+
+
+<div id="nav"></div>
+
+
+
+
+<div class="HomeContainer">
+ <section class="HomeSection Hero">
+ <h1 class="Hero-header">
+ Go is an open source programming language that makes it easy to build
+ <strong>simple</strong>, <strong>reliable</strong>, and <strong>efficient</strong> software.
+ </h1>
+ <i class="Hero-gopher"></i>
+ <a href="/dl/" class="Button Button--big HeroDownloadButton">
+ <img class="HeroDownloadButton-image" src="/lib/godoc/images/cloud-download.svg" alt="">
+ Download Go
+ </a>
+ <p class="Hero-description">
+ Binary distributions available for<br>
+ Linux, macOS, Windows, and more.
+ </p>
+ </section>
+
+ <section class="HomeSection Playground">
+ <div class="Playground-headerContainer">
+ <h2 class="HomeSection-header">Try Go</h2>
+
+ <a class="Playground-popout js-playgroundShareEl">Open in Playground</a>
+
+ </div>
+ <div class="Playground-inputContainer">
+ <textarea class="Playground-input js-playgroundCodeEl" spellcheck="false" aria-label="Try Go">// You can edit this code!
+// Click here and start typing.
+package main
+
+import "fmt"
+
+func main() {
+ fmt.Println("Hello, 世界")
+}
+</textarea>
+ </div>
+ <div class="Playground-outputContainer js-playgroundOutputEl">
+ <pre class="Playground-output"><noscript>Hello, 世界</noscript></pre>
+ </div>
+ <div class="Playground-controls">
+ <select class="Playground-selectExample js-playgroundToysEl" aria-label="Code examples">
+ <option value="hello.go">Hello, World!</option>
+ <option value="life.go">Conway's Game of Life</option>
+ <option value="fib.go">Fibonacci Closure</option>
+ <option value="peano.go">Peano Integers</option>
+ <option value="pi.go">Concurrent pi</option>
+ <option value="sieve.go">Concurrent Prime Sieve</option>
+ <option value="solitaire.go">Peg Solitaire Solver</option>
+ <option value="tree.go">Tree Comparison</option>
+ </select>
+ <div class="Playground-buttons">
+ <button class="Button Button--primary js-playgroundRunEl" title="Run this code [shift-enter]">Run</button>
+ <div class="Playground-secondaryButtons">
+
+ <button class="Button js-playgroundShareEl" title="Share this code">Share</button>
+ <a class="Button tour" href="https://tour.golang.org/" title="Playground Go from your browser">Tour</a>
+
+ </div>
+ </div>
+ </div>
+ </section>
+
+
+ <section class="HomeSection Blog js-blogContainerEl">
+ <h2 class="HomeSection-header">Featured articles</h2>
+ <div class="Blog-footer js-blogFooterEl"><a class="Button Button--primary" href="https://blog.golang.org/">Read more ></a></div>
+ </section>
+
+ <section class="HomeSection">
+ <h2 class="HomeSection-header">Featured video</h2>
+ <div class="js-videoContainer" style="--aspect-ratio-padding: 58.07%;">
+ <iframe width="415" height="241" src="https://www.youtube.com/embed/rFejpH_tAHM" frameborder="0" allowfullscreen></iframe>
+ </div>
+ </section>
+
+</div>
+<script>
+(function() {
+ 'use strict';
+
+ window.initFuncs.push(function() {
+ // Set up playground if enabled.
+ if (window.playground) {
+ window.playground({
+ "codeEl": ".js-playgroundCodeEl",
+ "outputEl": ".js-playgroundOutputEl",
+ "runEl": ".js-playgroundRunEl",
+ "shareEl": ".js-playgroundShareEl",
+ "shareRedirect": "//play.golang.org/p/",
+ "toysEl": ".js-playgroundToysEl"
+ });
+
+ // The pre matched below is added by the code above. Style it appropriately.
+ document.querySelector(".js-playgroundOutputEl pre").classList.add("Playground-output");
+ } else {
+ $(".Playground").hide();
+ }
+ });
+
+
+ function readableTime(t) {
+ var m = ["January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"];
+ var p = t.substring(0, t.indexOf("T")).split("-");
+ var d = new Date(p[0], p[1]-1, p[2]);
+ return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
+ }
+
+ window.feedLoaded = function(result) {
+ var read = document.querySelector(".js-blogFooterEl");
+ for (var i = 0; i < result.length && i < 2; i++) {
+ var entry = result[i];
+ var header = document.createElement("h3");
+ header.className = "Blog-title";
+ var titleLink = document.createElement("a");
+ titleLink.href = entry.Link;
+ titleLink.rel = "noopener";
+ titleLink.textContent = entry.Title;
+ header.appendChild(titleLink);
+ read.parentNode.insertBefore(header, read);
+ var extract = document.createElement("div");
+ extract.className = "Blog-extract";
+ extract.innerHTML = entry.Summary;
+ // Ensure any cross-origin links have rel=noopener set.
+ var links = extract.querySelectorAll("a");
+ for (var j = 0; j < links.length; j++) {
+ links[j].rel = "noopener";
+ links[j].classList.add("Blog-link");
+ }
+ read.parentNode.insertBefore(extract, read);
+ var when = document.createElement("div");
+ when.className = "Blog-when";
+ when.textContent = "Published " + readableTime(entry.Time);
+ read.parentNode.insertBefore(when, read);
+ }
+ }
+
+ window.initFuncs.push(function() {
+ // Load blog feed.
+ $("<script/>")
+ .attr("src", "//blog.golang.org/.json?jsonp=feedLoaded")
+ .appendTo("body");
+
+ // Set the video at random.
+ var videos = [
+ {
+ s: "https://www.youtube.com/embed/rFejpH_tAHM",
+ title: "dotGo 2015 - Rob Pike - Simplicity is Complicated",
+ },
+ {
+ s: "https://www.youtube.com/embed/0ReKdcpNyQg",
+ title: "GopherCon 2015: Robert Griesemer - The Evolution of Go",
+ },
+ {
+ s: "https://www.youtube.com/embed/sX8r6zATHGU",
+ title: "Steve Francia - Go: building on the shoulders of giants and stepping on a few toes",
+ },
+ {
+ s: "https://www.youtube.com/embed/rWJHbh6qO_Y",
+ title: "Brad Fitzpatrick Go 1.11 and beyond",
+ },
+ {
+ s: "https://www.youtube.com/embed/bmZNaUcwBt4",
+ title: "The Why of Go",
+ },
+ {
+ s: "https://www.youtube.com/embed/0Zbh_vmAKvk",
+ title: "GopherCon 2017: Russ Cox - The Future of Go",
+ },
+ ];
+ var v = videos[Math.floor(Math.random()*videos.length)];
+ $(".js-videoContainer iframe").attr("src", v.s).attr("title", v.title);
+ });
+
+})();
+</script>
+
+
+</div><!-- .container -->
+</main><!-- #page -->
+<footer>
+ <div class="Footer ">
+ <img class="Footer-gopher" src="/lib/godoc/images/footer-gopher.jpg" alt="The Go Gopher">
+ <ul class="Footer-links">
+ <li class="Footer-link"><a href="/doc/copyright.html">Copyright</a></li>
+ <li class="Footer-link"><a href="/doc/tos.html">Terms of Service</a></li>
+ <li class="Footer-link"><a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a></li>
+ <li class="Footer-link"><a href="http://golang.org/issues/new?title=x/website:" target="_blank" rel="noopener">Report a website issue</a></li>
+ </ul>
+ <a class="Footer-supportedBy" href="https://google.com">Supported by Google</a>
+ </div>
+</footer>
+
+<script>
+(function() {
+ var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
+ ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
+ var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+
--- /dev/null
+++ b/js/godoc/golang.js
@@ -1,0 +1,97 @@
+(function() {
+ 'use strict';
+ window.initFuncs.push(function() {
+ // Set up playground if enabled.
+ if (window.playground) {
+ window.playground({
+ "codeEl": ".js-playgroundCodeEl",
+ "outputEl": ".js-playgroundOutputEl",
+ "runEl": ".js-playgroundRunEl",
+ "shareEl": ".js-playgroundShareEl",
+ "shareRedirect": "//play.golang.org/p/",
+ "toysEl": ".js-playgroundToysEl"
+ });
+
+ // The pre matched below is added by the code above. Style it appropriately.
+ document.querySelector(".js-playgroundOutputEl pre").classList.add("Playground-output");
+ } else {
+ $(".Playground").hide();
+ }
+ });
+
+
+ function readableTime(t) {
+ var m = ["January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"];
+ var p = t.substring(0, t.indexOf("T")).split("-");
+ var d = new Date(p[0], p[1]-1, p[2]);
+ return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
+ }
+
+ window.feedLoaded = function(result) {
+ var read = document.querySelector(".js-blogFooterEl");
+ for (var i = 0; i < result.length && i < 2; i++) {
+ var entry = result[i];
+ var header = document.createElement("h3");
+ header.className = "Blog-title";
+ var titleLink = document.createElement("a");
+ titleLink.href = entry.Link;
+ titleLink.rel = "noopener";
+ titleLink.textContent = entry.Title;
+ header.appendChild(titleLink);
+ read.parentNode.insertBefore(header, read);
+ var extract = document.createElement("div");
+ extract.className = "Blog-extract";
+ extract.innerHTML = entry.Summary;
+ // Ensure any cross-origin links have rel=noopener set.
+ var links = extract.querySelectorAll("a");
+ for (var j = 0; j < links.length; j++) {
+ links[j].rel = "noopener";
+ links[j].classList.add("Blog-link");
+ }
+ read.parentNode.insertBefore(extract, read);
+ var when = document.createElement("div");
+ when.className = "Blog-when";
+ when.textContent = "Published " + readableTime(entry.Time);
+ read.parentNode.insertBefore(when, read);
+ }
+ }
+
+ window.initFuncs.push(function() {
+ // Load blog feed.
+ $("<script/>")
+ .attr("src", "//blog.golang.org/.json?jsonp=feedLoaded")
+ .appendTo("body");
+
+ // Set the video at random.
+ var videos = [
+ {
+ s: "https://www.youtube.com/embed/rFejpH_tAHM",
+ title: "dotGo 2015 - Rob Pike - Simplicity is Complicated",
+ },
+ {
+ s: "https://www.youtube.com/embed/0ReKdcpNyQg",
+ title: "GopherCon 2015: Robert Griesemer - The Evolution of Go",
+ },
+ {
+ s: "https://www.youtube.com/embed/sX8r6zATHGU",
+ title: "Steve Francia - Go: building on the shoulders of giants and stepping on a few toes",
+ },
+ {
+ s: "https://www.youtube.com/embed/rWJHbh6qO_Y",
+ title: "Brad Fitzpatrick Go 1.11 and beyond",
+ },
+ {
+ s: "https://www.youtube.com/embed/bmZNaUcwBt4",
+ title: "The Why of Go",
+ },
+ {
+ s: "https://www.youtube.com/embed/0Zbh_vmAKvk",
+ title: "GopherCon 2017: Russ Cox - The Future of Go",
+ },
+ ];
+ var v = videos[Math.floor(Math.random()*videos.length)];
+ $(".js-videoContainer iframe").attr("src", v.s).attr("title", v.title);
+ });
+
+})();
\ No newline at end of file
--- /dev/null
+++ b/js/godoc/goversion.js
@@ -1,0 +1,2 @@
+var goVersion = "go1.15.6";
+
--- /dev/null
+++ b/js/godoc/initfuncs.js
@@ -1,0 +1,2 @@
+window.initFuncs = [];
+
--- /dev/null
+++ b/js/godoc/jquery-1.8.2.js
@@ -1,0 +1,9440 @@
+/*!
+ * jQuery JavaScript Library v1.8.2
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time)
+ */
+(function( window, undefined ) {
+var
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // The deferred used on DOM ready
+ readyList,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+ location = window.location,
+ navigator = window.navigator,
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Save a reference to some core methods
+ core_push = Array.prototype.push,
+ core_slice = Array.prototype.slice,
+ core_indexOf = Array.prototype.indexOf,
+ core_toString = Object.prototype.toString,
+ core_hasOwn = Object.prototype.hasOwnProperty,
+ core_trim = String.prototype.trim,
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context, rootjQuery );
+ },
+
+ // Used for matching numbers
+ core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
+
+ // Used for detecting and trimming whitespace
+ core_rnotwhite = /\S/,
+ core_rspace = /\s+/,
+
+ // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+ rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
+
+ // Matches dashed string for camelizing
+ rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([\da-z])/gi,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return ( letter + "" ).toUpperCase();
+ },
+
+ // The ready event handler and self cleanup method
+ DOMContentLoaded = function() {
+ if ( document.addEventListener ) {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ } else if ( document.readyState === "complete" ) {
+ // we're here because readyState === "complete" in oldIE
+ // which is good enough for us to call the dom ready!
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ },
+
+ // [[Class]] -> type pairs
+ class2type = {};
+
+jQuery.fn = jQuery.prototype = {
+ constructor: jQuery,
+ init: function( selector, context, rootjQuery ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ context = context instanceof jQuery ? context[0] : context;
+ doc = ( context && context.nodeType ? context.ownerDocument || context : document );
+
+ // scripts is true for back-compat
+ selector = jQuery.parseHTML( match[1], doc, true );
+ if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+ this.attr.call( selector, context, true );
+ }
+
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || rootjQuery ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if ( selector.selector !== undefined ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.8.2",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return core_slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+ },
+
+ eq: function( i ) {
+ i = +i;
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( core_slice.apply( this, arguments ),
+ "slice", core_slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: core_push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger("ready").off("ready");
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ isWindow: function( obj ) {
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function( obj ) {
+ return !isNaN( parseFloat(obj) ) && isFinite( obj );
+ },
+
+ type: function( obj ) {
+ return obj == null ?
+ String( obj ) :
+ class2type[ core_toString.call(obj) ] || "object";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ try {
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !core_hasOwn.call(obj, "constructor") &&
+ !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+ } catch ( e ) {
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || core_hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ // data: string of html
+ // context (optional): If specified, the fragment will be created in this context, defaults to document
+ // scripts (optional): If true, will include scripts passed in the html string
+ parseHTML: function( data, context, scripts ) {
+ var parsed;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ if ( typeof context === "boolean" ) {
+ scripts = context;
+ context = 0;
+ }
+ context = context || document;
+
+ // Single tag
+ if ( (parsed = rsingleTag.exec( data )) ) {
+ return [ context.createElement( parsed[1] ) ];
+ }
+
+ parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
+ return jQuery.merge( [],
+ (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
+ },
+
+ parseJSON: function( data ) {
+ if ( !data || typeof data !== "string") {
+ return null;
+ }
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ return window.JSON.parse( data );
+ }
+
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+ .replace( rvalidtokens, "]" )
+ .replace( rvalidbraces, "")) ) {
+
+ return ( new Function( "return " + data ) )();
+
+ }
+ jQuery.error( "Invalid JSON: " + data );
+ },
+
+ // Cross-browser xml parsing
+ parseXML: function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ try {
+ if ( window.DOMParser ) { // Standard
+ tmp = new DOMParser();
+ xml = tmp.parseFromString( data , "text/xml" );
+ } else { // IE
+ xml = new ActiveXObject( "Microsoft.XMLDOM" );
+ xml.async = "false";
+ xml.loadXML( data );
+ }
+ } catch( e ) {
+ xml = undefined;
+ }
+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+ },
+
+ noop: function() {},
+
+ // Evaluates a script in a global context
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function( data ) {
+ if ( data && core_rnotwhite.test( data ) ) {
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function( data ) {
+ window[ "eval" ].call( window, data );
+ } )( data );
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ // args is for internal usage only
+ each: function( obj, callback, args ) {
+ var name,
+ i = 0,
+ length = obj.length,
+ isObj = length === undefined || jQuery.isFunction( obj );
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in obj ) {
+ if ( callback.apply( obj[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( obj[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in obj ) {
+ if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
+ function( text ) {
+ return text == null ?
+ "" :
+ core_trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var type,
+ ret = results || [];
+
+ if ( arr != null ) {
+ // The window, strings (and functions) also have 'length'
+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
+ type = jQuery.type( arr );
+
+ if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
+ core_push.call( ret, arr );
+ } else {
+ jQuery.merge( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ var len;
+
+ if ( arr ) {
+ if ( core_indexOf ) {
+ return core_indexOf.call( arr, elem, i );
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+ for ( ; i < len; i++ ) {
+ // Skip accessing in sparse arrays
+ if ( i in arr && arr[ i ] === elem ) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var l = second.length,
+ i = first.length,
+ j = 0;
+
+ if ( typeof l === "number" ) {
+ for ( ; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var retVal,
+ ret = [],
+ i = 0,
+ length = elems.length;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var value, key,
+ ret = [],
+ i = 0,
+ length = elems.length,
+ // jquery objects are treated as arrays
+ isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
+
+ // Go through the array, translating each of the items to their
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( key in elems ) {
+ value = callback( elems[ key ], key, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function( fn, context ) {
+ var tmp, args, proxy;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !jQuery.isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = core_slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ // Multifunctional method to get and set values of a collection
+ // The value/s can optionally be executed if it's a function
+ access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
+ var exec,
+ bulk = key == null,
+ i = 0,
+ length = elems.length;
+
+ // Sets many values
+ if ( key && typeof key === "object" ) {
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
+ }
+ chainable = 1;
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = pass === undefined && jQuery.isFunction( value );
+
+ if ( bulk ) {
+ // Bulk operations only iterate when executing function values
+ if ( exec ) {
+ exec = fn;
+ fn = function( elem, key, value ) {
+ return exec.call( jQuery( elem ), value );
+ };
+
+ // Otherwise they run against the entire set
+ } else {
+ fn.call( elems, value );
+ fn = null;
+ }
+ }
+
+ if ( fn ) {
+ for (; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+ }
+
+ chainable = 1;
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[0], key ) : emptyGet;
+ },
+
+ now: function() {
+ return ( new Date() ).getTime();
+ }
+});
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout( jQuery.ready, 1 );
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else {
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", DOMContentLoaded );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch(e) {}
+
+ if ( top && top.doScroll ) {
+ (function doScrollCheck() {
+ if ( !jQuery.isReady ) {
+
+ try {
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll("left");
+ } catch(e) {
+ return setTimeout( doScrollCheck, 50 );
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ })();
+ }
+ }
+ }
+ return readyList.promise( obj );
+};
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+// String to Object options format cache
+var optionsCache = {};
+
+// Convert String-formatted options into Object-formatted ones and store in cache
+function createOptions( options ) {
+ var object = optionsCache[ options ] = {};
+ jQuery.each( options.split( core_rspace ), function( _, flag ) {
+ object[ flag ] = true;
+ });
+ return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ ( optionsCache[ options ] || createOptions( options ) ) :
+ jQuery.extend( {}, options );
+
+ var // Last fire value (for non-forgettable lists)
+ memory,
+ // Flag to know if list was already fired
+ fired,
+ // Flag to know if list is currently firing
+ firing,
+ // First callback to fire (used internally by add and fireWith)
+ firingStart,
+ // End of the loop when firing
+ firingLength,
+ // Index of currently firing callback (modified by remove if needed)
+ firingIndex,
+ // Actual callback list
+ list = [],
+ // Stack of fire calls for repeatable lists
+ stack = !options.once && [],
+ // Fire callbacks
+ fire = function( data ) {
+ memory = options.memory && data;
+ fired = true;
+ firingIndex = firingStart || 0;
+ firingStart = 0;
+ firingLength = list.length;
+ firing = true;
+ for ( ; list && firingIndex < firingLength; firingIndex++ ) {
+ if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
+ memory = false; // To prevent further calls using add
+ break;
+ }
+ }
+ firing = false;
+ if ( list ) {
+ if ( stack ) {
+ if ( stack.length ) {
+ fire( stack.shift() );
+ }
+ } else if ( memory ) {
+ list = [];
+ } else {
+ self.disable();
+ }
+ }
+ },
+ // Actual Callbacks object
+ self = {
+ // Add a callback or a collection of callbacks to the list
+ add: function() {
+ if ( list ) {
+ // First, we save the current length
+ var start = list.length;
+ (function add( args ) {
+ jQuery.each( args, function( _, arg ) {
+ var type = jQuery.type( arg );
+ if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
+ list.push( arg );
+ } else if ( arg && arg.length && type !== "string" ) {
+ // Inspect recursively
+ add( arg );
+ }
+ });
+ })( arguments );
+ // Do we need to add the callbacks to the
+ // current firing batch?
+ if ( firing ) {
+ firingLength = list.length;
+ // With memory, if we're not firing then
+ // we should call right away
+ } else if ( memory ) {
+ firingStart = start;
+ fire( memory );
+ }
+ }
+ return this;
+ },
+ // Remove a callback from the list
+ remove: function() {
+ if ( list ) {
+ jQuery.each( arguments, function( _, arg ) {
+ var index;
+ while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+ list.splice( index, 1 );
+ // Handle firing indexes
+ if ( firing ) {
+ if ( index <= firingLength ) {
+ firingLength--;
+ }
+ if ( index <= firingIndex ) {
+ firingIndex--;
+ }
+ }
+ }
+ });
+ }
+ return this;
+ },
+ // Control if a given callback is in the list
+ has: function( fn ) {
+ return jQuery.inArray( fn, list ) > -1;
+ },
+ // Remove all callbacks from the list
+ empty: function() {
+ list = [];
+ return this;
+ },
+ // Have the list do nothing anymore
+ disable: function() {
+ list = stack = memory = undefined;
+ return this;
+ },
+ // Is it disabled?
+ disabled: function() {
+ return !list;
+ },
+ // Lock the list in its current state
+ lock: function() {
+ stack = undefined;
+ if ( !memory ) {
+ self.disable();
+ }
+ return this;
+ },
+ // Is it locked?
+ locked: function() {
+ return !stack;
+ },
+ // Call all callbacks with the given context and arguments
+ fireWith: function( context, args ) {
+ args = args || [];
+ args = [ context, args.slice ? args.slice() : args ];
+ if ( list && ( !fired || stack ) ) {
+ if ( firing ) {
+ stack.push( args );
+ } else {
+ fire( args );
+ }
+ }
+ return this;
+ },
+ // Call all the callbacks with the given arguments
+ fire: function() {
+ self.fireWith( this, arguments );
+ return this;
+ },
+ // To know if the callbacks have already been called at least once
+ fired: function() {
+ return !!fired;
+ }
+ };
+
+ return self;
+};
+jQuery.extend({
+
+ Deferred: function( func ) {
+ var tuples = [
+ // action, add listener, listener list, final state
+ [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
+ [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
+ [ "notify", "progress", jQuery.Callbacks("memory") ]
+ ],
+ state = "pending",
+ promise = {
+ state: function() {
+ return state;
+ },
+ always: function() {
+ deferred.done( arguments ).fail( arguments );
+ return this;
+ },
+ then: function( /* fnDone, fnFail, fnProgress */ ) {
+ var fns = arguments;
+ return jQuery.Deferred(function( newDefer ) {
+ jQuery.each( tuples, function( i, tuple ) {
+ var action = tuple[ 0 ],
+ fn = fns[ i ];
+ // deferred[ done | fail | progress ] for forwarding actions to newDefer
+ deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
+ function() {
+ var returned = fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise()
+ .done( newDefer.resolve )
+ .fail( newDefer.reject )
+ .progress( newDefer.notify );
+ } else {
+ newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
+ }
+ } :
+ newDefer[ action ]
+ );
+ });
+ fns = null;
+ }).promise();
+ },
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
+ }
+ },
+ deferred = {};
+
+ // Keep pipe for back-compat
+ promise.pipe = promise.then;
+
+ // Add list-specific methods
+ jQuery.each( tuples, function( i, tuple ) {
+ var list = tuple[ 2 ],
+ stateString = tuple[ 3 ];
+
+ // promise[ done | fail | progress ] = list.add
+ promise[ tuple[1] ] = list.add;
+
+ // Handle state
+ if ( stateString ) {
+ list.add(function() {
+ // state = [ resolved | rejected ]
+ state = stateString;
+
+ // [ reject_list | resolve_list ].disable; progress_list.lock
+ }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
+ }
+
+ // deferred[ resolve | reject | notify ] = list.fire
+ deferred[ tuple[0] ] = list.fire;
+ deferred[ tuple[0] + "With" ] = list.fireWith;
+ });
+
+ // Make the deferred a promise
+ promise.promise( deferred );
+
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( subordinate /* , ..., subordinateN */ ) {
+ var i = 0,
+ resolveValues = core_slice.call( arguments ),
+ length = resolveValues.length,
+
+ // the count of uncompleted subordinates
+ remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
+
+ // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
+ deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+ // Update function for both resolve and progress values
+ updateFunc = function( i, contexts, values ) {
+ return function( value ) {
+ contexts[ i ] = this;
+ values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
+ if( values === progressValues ) {
+ deferred.notifyWith( contexts, values );
+ } else if ( !( --remaining ) ) {
+ deferred.resolveWith( contexts, values );
+ }
+ };
+ },
+
+ progressValues, progressContexts, resolveContexts;
+
+ // add listeners to Deferred subordinates; treat others as resolved
+ if ( length > 1 ) {
+ progressValues = new Array( length );
+ progressContexts = new Array( length );
+ resolveContexts = new Array( length );
+ for ( ; i < length; i++ ) {
+ if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
+ resolveValues[ i ].promise()
+ .done( updateFunc( i, resolveContexts, resolveValues ) )
+ .fail( deferred.reject )
+ .progress( updateFunc( i, progressContexts, progressValues ) );
+ } else {
+ --remaining;
+ }
+ }
+ }
+
+ // if we're not waiting on anything, resolve the master
+ if ( !remaining ) {
+ deferred.resolveWith( resolveContexts, resolveValues );
+ }
+
+ return deferred.promise();
+ }
+});
+jQuery.support = (function() {
+
+ var support,
+ all,
+ a,
+ select,
+ opt,
+ input,
+ fragment,
+ eventName,
+ i,
+ isSupported,
+ clickFn,
+ div = document.createElement("div");
+
+ // Preliminary tests
+ div.setAttribute( "className", "t" );
+ div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+
+ all = div.getElementsByTagName("*");
+ a = div.getElementsByTagName("a")[ 0 ];
+ a.style.cssText = "top:1px;float:left;opacity:.5";
+
+ // Can't get basic test support
+ if ( !all || !all.length ) {
+ return {};
+ }
+
+ // First batch of supports tests
+ select = document.createElement("select");
+ opt = select.appendChild( document.createElement("option") );
+ input = div.getElementsByTagName("input")[ 0 ];
+
+ support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: ( div.firstChild.nodeType === 3 ),
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ style: /top/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: ( a.getAttribute("href") === "/a" ),
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.5/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: ( input.value === "on" ),
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: opt.selected,
+
+ // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ getSetAttribute: div.className !== "t",
+
+ // Tests for enctype support on a form(#6743)
+ enctype: !!document.createElement("form").enctype,
+
+ // Makes sure cloning an html5 element does not cause problems
+ // Where outerHTML is undefined, this still works
+ html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
+
+ // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
+ boxModel: ( document.compatMode === "CSS1Compat" ),
+
+ // Will be defined later
+ submitBubbles: true,
+ changeBubbles: true,
+ focusinBubbles: false,
+ deleteExpando: true,
+ noCloneEvent: true,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableMarginRight: true,
+ boxSizingReliable: true,
+ pixelPosition: false
+ };
+
+ // Make sure checked status is properly cloned
+ input.checked = true;
+ support.noCloneChecked = input.cloneNode( true ).checked;
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as disabled)
+ select.disabled = true;
+ support.optDisabled = !opt.disabled;
+
+ // Test to see if it's possible to delete an expando from an element
+ // Fails in Internet Explorer
+ try {
+ delete div.test;
+ } catch( e ) {
+ support.deleteExpando = false;
+ }
+
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
+ div.attachEvent( "onclick", clickFn = function() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ support.noCloneEvent = false;
+ });
+ div.cloneNode( true ).fireEvent("onclick");
+ div.detachEvent( "onclick", clickFn );
+ }
+
+ // Check if a radio maintains its value
+ // after being appended to the DOM
+ input = document.createElement("input");
+ input.value = "t";
+ input.setAttribute( "type", "radio" );
+ support.radioValue = input.value === "t";
+
+ input.setAttribute( "checked", "checked" );
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ input.setAttribute( "name", "t" );
+
+ div.appendChild( input );
+ fragment = document.createDocumentFragment();
+ fragment.appendChild( div.lastChild );
+
+ // WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ support.appendChecked = input.checked;
+
+ fragment.removeChild( input );
+ fragment.appendChild( div );
+
+ // Technique from Juriy Zaytsev
+ // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
+ // We only care about the case where non-standard event systems
+ // are used, namely in IE. Short-circuiting here helps us to
+ // avoid an eval call (in setAttribute) which can cause CSP
+ // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
+ if ( div.attachEvent ) {
+ for ( i in {
+ submit: true,
+ change: true,
+ focusin: true
+ }) {
+ eventName = "on" + i;
+ isSupported = ( eventName in div );
+ if ( !isSupported ) {
+ div.setAttribute( eventName, "return;" );
+ isSupported = ( typeof div[ eventName ] === "function" );
+ }
+ support[ i + "Bubbles" ] = isSupported;
+ }
+ }
+
+ // Run tests that need a body at doc ready
+ jQuery(function() {
+ var container, div, tds, marginDiv,
+ divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
+ body = document.getElementsByTagName("body")[0];
+
+ if ( !body ) {
+ // Return for frameset docs that don't have a body
+ return;
+ }
+
+ container = document.createElement("div");
+ container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
+ body.insertBefore( container, body.firstChild );
+
+ // Construct the test element
+ div = document.createElement("div");
+ container.appendChild( div );
+
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ // (only IE 8 fails this test)
+ div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
+ tds = div.getElementsByTagName("td");
+ tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
+ isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+ tds[ 0 ].style.display = "";
+ tds[ 1 ].style.display = "none";
+
+ // Check if empty table cells still have offsetWidth/Height
+ // (IE <= 8 fail this test)
+ support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
+
+ // Check box-sizing and margin behavior
+ div.innerHTML = "";
+ div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
+ support.boxSizing = ( div.offsetWidth === 4 );
+ support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
+
+ // NOTE: To any future maintainer, we've window.getComputedStyle
+ // because jsdom on node.js will break without it.
+ if ( window.getComputedStyle ) {
+ support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
+ support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
+
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. For more
+ // info see bug #3333
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ marginDiv = document.createElement("div");
+ marginDiv.style.cssText = div.style.cssText = divReset;
+ marginDiv.style.marginRight = marginDiv.style.width = "0";
+ div.style.width = "1px";
+ div.appendChild( marginDiv );
+ support.reliableMarginRight =
+ !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
+ }
+
+ if ( typeof div.style.zoom !== "undefined" ) {
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ // (IE < 8 does this)
+ div.innerHTML = "";
+ div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
+
+ // Check if elements with layout shrink-wrap their children
+ // (IE 6 does this)
+ div.style.display = "block";
+ div.style.overflow = "visible";
+ div.innerHTML = "<div></div>";
+ div.firstChild.style.width = "5px";
+ support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
+
+ container.style.zoom = 1;
+ }
+
+ // Null elements to avoid leaks in IE
+ body.removeChild( container );
+ container = div = tds = marginDiv = null;
+ });
+
+ // Null elements to avoid leaks in IE
+ fragment.removeChild( div );
+ all = a = select = opt = input = fragment = div = null;
+
+ return support;
+})();
+var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+jQuery.extend({
+ cache: {},
+
+ deletedIds: [],
+
+ // Remove at next major release (1.9/2.0)
+ uuid: 0,
+
+ // Unique for each copy of jQuery on the page
+ // Non-digits removed to match rinlinejQuery
+ expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ hasData: function( elem ) {
+ elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+ return !!elem && !isEmptyDataObject( elem );
+ },
+
+ data: function( elem, name, data, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, ret,
+ internalKey = jQuery.expando,
+ getByName = typeof name === "string",
+
+ // We have to handle DOM nodes and JS objects differently because IE6-7
+ // can't GC object references properly across the DOM-JS boundary
+ isNode = elem.nodeType,
+
+ // Only DOM nodes need the global jQuery cache; JS object data is
+ // attached directly to the object so GC can occur automatically
+ cache = isNode ? jQuery.cache : elem,
+
+ // Only defining an ID for JS objects if its cache already exists allows
+ // the code to shortcut on the same path as a DOM node with no cache
+ id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
+
+ // Avoid doing any more work than we need to when trying to get data on an
+ // object that has no data at all
+ if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
+ return;
+ }
+
+ if ( !id ) {
+ // Only DOM nodes need a new unique ID for each element since their data
+ // ends up in the global cache
+ if ( isNode ) {
+ elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
+ } else {
+ id = internalKey;
+ }
+ }
+
+ if ( !cache[ id ] ) {
+ cache[ id ] = {};
+
+ // Avoids exposing jQuery metadata on plain JS objects when the object
+ // is serialized using JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+ }
+
+ // An object can be passed to jQuery.data instead of a key/value pair; this gets
+ // shallow copied over onto the existing cache
+ if ( typeof name === "object" || typeof name === "function" ) {
+ if ( pvt ) {
+ cache[ id ] = jQuery.extend( cache[ id ], name );
+ } else {
+ cache[ id ].data = jQuery.extend( cache[ id ].data, name );
+ }
+ }
+
+ thisCache = cache[ id ];
+
+ // jQuery data() is stored in a separate object inside the object's internal data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data.
+ if ( !pvt ) {
+ if ( !thisCache.data ) {
+ thisCache.data = {};
+ }
+
+ thisCache = thisCache.data;
+ }
+
+ if ( data !== undefined ) {
+ thisCache[ jQuery.camelCase( name ) ] = data;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( getByName ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == null ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+ },
+
+ removeData: function( elem, name, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, i, l,
+
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+ id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
+
+ // If there is already no cache entry for this object, there is no
+ // purpose in continuing
+ if ( !cache[ id ] ) {
+ return;
+ }
+
+ if ( name ) {
+
+ thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+ if ( thisCache ) {
+
+ // Support array or space separated string names for data keys
+ if ( !jQuery.isArray( name ) ) {
+
+ // try the string as a key before any manipulation
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+
+ // split the camel cased version by spaces unless a key with the spaces exists
+ name = jQuery.camelCase( name );
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+ name = name.split(" ");
+ }
+ }
+ }
+
+ for ( i = 0, l = name.length; i < l; i++ ) {
+ delete thisCache[ name[i] ];
+ }
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if ( !pvt ) {
+ delete cache[ id ].data;
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if ( !isEmptyDataObject( cache[ id ] ) ) {
+ return;
+ }
+ }
+
+ // Destroy the cache
+ if ( isNode ) {
+ jQuery.cleanData( [ elem ], true );
+
+ // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+ } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
+ delete cache[ id ];
+
+ // When all else fails, null
+ } else {
+ cache[ id ] = null;
+ }
+ },
+
+ // For internal use only.
+ _data: function( elem, name, data ) {
+ return jQuery.data( elem, name, data, true );
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ // nodes accept data unless otherwise specified; rejection can be conditional
+ return !noData || noData !== true && elem.getAttribute("classid") === noData;
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ var parts, part, attr, name, l,
+ elem = this[0],
+ i = 0,
+ data = null;
+
+ // Gets all values
+ if ( key === undefined ) {
+ if ( this.length ) {
+ data = jQuery.data( elem );
+
+ if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+ attr = elem.attributes;
+ for ( l = attr.length; i < l; i++ ) {
+ name = attr[i].name;
+
+ if ( !name.indexOf( "data-" ) ) {
+ name = jQuery.camelCase( name.substring(5) );
+
+ dataAttr( elem, name, data[ name ] );
+ }
+ }
+ jQuery._data( elem, "parsedAttrs", true );
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ parts = key.split( ".", 2 );
+ parts[1] = parts[1] ? "." + parts[1] : "";
+ part = parts[1] + "!";
+
+ return jQuery.access( this, function( value ) {
+
+ if ( value === undefined ) {
+ data = this.triggerHandler( "getData" + part, [ parts[0] ] );
+
+ // Try to fetch any internally stored data first
+ if ( data === undefined && elem ) {
+ data = jQuery.data( elem, key );
+ data = dataAttr( elem, key, data );
+ }
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ }
+
+ parts[1] = value;
+ this.each(function() {
+ var self = jQuery( this );
+
+ self.triggerHandler( "setData" + part, parts );
+ jQuery.data( this, key, value );
+ self.triggerHandler( "changeData" + part, parts );
+ });
+ }, null, value, arguments.length > 1, null, false );
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+
+function dataAttr( elem, key, data ) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+
+ var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
+
+ data = elem.getAttribute( name );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ // Only convert to a number if it doesn't change the string
+ +data + "" === data ? +data :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+ var name;
+ for ( name in obj ) {
+
+ // if the public data object is empty, the private is still empty
+ if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+ continue;
+ }
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ var queue;
+
+ if ( elem ) {
+ type = ( type || "fx" ) + "queue";
+ queue = jQuery._data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !queue || jQuery.isArray(data) ) {
+ queue = jQuery._data( elem, type, jQuery.makeArray(data) );
+ } else {
+ queue.push( data );
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks( elem, type ),
+ next = function() {
+ jQuery.dequeue( elem, type );
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ if ( fn ) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift( "inprogress" );
+ }
+
+ // clear up the last queue stop function
+ delete hooks.stop;
+ fn.call( elem, next, hooks );
+ }
+
+ if ( !startLength && hooks ) {
+ hooks.empty.fire();
+ }
+ },
+
+ // not intended for public consumption - generates a queueHooks object, or returns the current one
+ _queueHooks: function( elem, type ) {
+ var key = type + "queueHooks";
+ return jQuery._data( elem, key ) || jQuery._data( elem, key, {
+ empty: jQuery.Callbacks("once memory").add(function() {
+ jQuery.removeData( elem, type + "queue", true );
+ jQuery.removeData( elem, key, true );
+ })
+ });
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ var setter = 2;
+
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if ( arguments.length < setter ) {
+ return jQuery.queue( this[0], type );
+ }
+
+ return data === undefined ?
+ this :
+ this.each(function() {
+ var queue = jQuery.queue( this, type, data );
+
+ // ensure a hooks for this queue
+ jQuery._queueHooks( this, type );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = setTimeout( next, time );
+ hooks.stop = function() {
+ clearTimeout( timeout );
+ };
+ });
+ },
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ },
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function( type, obj ) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ };
+
+ if ( typeof type !== "string" ) {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while( i-- ) {
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
+ count++;
+ tmp.empty.add( resolve );
+ }
+ }
+ resolve();
+ return defer.promise( obj );
+ }
+});
+var nodeHook, boolHook, fixSpecified,
+ rclass = /[\t\r\n]/g,
+ rreturn = /\r/g,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea|)$/i,
+ rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
+ getSetAttribute = jQuery.support.getSetAttribute;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each(function() {
+ jQuery.removeAttr( this, name );
+ });
+ },
+
+ prop: function( name, value ) {
+ return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ name = jQuery.propFix[ name ] || name;
+ return this.each(function() {
+ // try/catch handles cases where IE balks (such as removing a property on window)
+ try {
+ this[ name ] = undefined;
+ delete this[ name ];
+ } catch( e ) {}
+ });
+ },
+
+ addClass: function( value ) {
+ var classNames, i, l, elem,
+ setClass, c, cl;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).addClass( value.call(this, j, this.className) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ classNames = value.split( core_rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className && classNames.length === 1 ) {
+ elem.className = value;
+
+ } else {
+ setClass = " " + elem.className + " ";
+
+ for ( c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
+ setClass += classNames[ c ] + " ";
+ }
+ }
+ elem.className = jQuery.trim( setClass );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var removes, className, elem, c, cl, i, l;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).removeClass( value.call(this, j, this.className) );
+ });
+ }
+ if ( (value && typeof value === "string") || value === undefined ) {
+ removes = ( value || "" ).split( core_rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+ if ( elem.nodeType === 1 && elem.className ) {
+
+ className = (" " + elem.className + " ").replace( rclass, " " );
+
+ // loop over each item in the removal list
+ for ( c = 0, cl = removes.length; c < cl; c++ ) {
+ // Remove until there is nothing to remove,
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
+ className = className.replace( " " + removes[ c ] + " " , " " );
+ }
+ }
+ elem.className = value ? jQuery.trim( className ) : "";
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( i ) {
+ jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ state = stateVal,
+ classNames = value.split( core_rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space separated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery._data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ",
+ i = 0,
+ l = this.length;
+ for ( ; i < l; i++ ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ var hooks, ret, isFunction,
+ elem = this[0];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction( value );
+
+ return this.each(function( i ) {
+ var val,
+ self = jQuery(this);
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, self.val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map(val, function ( value ) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ valHooks: {
+ option: {
+ get: function( elem ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, i, max, option,
+ index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ i = one ? index : 0;
+ max = one ? index + 1 : options.length;
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // Don't return options that are disabled or in a disabled optgroup
+ if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
+ (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
+ if ( one && !values.length && options.length ) {
+ return jQuery( options[ index ] ).val();
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var values = jQuery.makeArray( value );
+
+ jQuery(elem).find("option").each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ },
+
+ // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
+ attrFn: {},
+
+ attr: function( elem, name, value, pass ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
+ return jQuery( elem )[ name ]( value );
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === "undefined" ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if ( notxml ) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
+ }
+
+ if ( value !== undefined ) {
+
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+ return;
+
+ } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+
+ ret = elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret === null ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var propName, attrNames, name, isBool,
+ i = 0;
+
+ if ( value && elem.nodeType === 1 ) {
+
+ attrNames = value.split( core_rspace );
+
+ for ( ; i < attrNames.length; i++ ) {
+ name = attrNames[ i ];
+
+ if ( name ) {
+ propName = jQuery.propFix[ name ] || name;
+ isBool = rboolean.test( name );
+
+ // See #9699 for explanation of this approach (setting first, then removal)
+ // Do not do this for boolean attributes (see #10870)
+ if ( !isBool ) {
+ jQuery.attr( elem, name, "" );
+ }
+ elem.removeAttribute( getSetAttribute ? name : propName );
+
+ // Set corresponding property to false for boolean attributes
+ if ( isBool && propName in elem ) {
+ elem[ propName ] = false;
+ }
+ }
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
+ jQuery.error( "type property can't be changed" );
+ } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
+ // Setting the type on a radio button after the value resets the value in IE6-9
+ // Reset value to it's default in case type is set after value
+ // This is for element creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ },
+ // Use the value property for back compat
+ // Use the nodeHook for button elements in IE6/7 (#1954)
+ value: {
+ get: function( elem, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.get( elem, name );
+ }
+ return name in elem ?
+ elem.value :
+ null;
+ },
+ set: function( elem, value, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.set( elem, value, name );
+ }
+ // Does not return so that setAttribute is also used
+ elem.value = value;
+ }
+ }
+ },
+
+ propFix: {
+ tabindex: "tabIndex",
+ readonly: "readOnly",
+ "for": "htmlFor",
+ "class": "className",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ cellpadding: "cellPadding",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ usemap: "useMap",
+ frameborder: "frameBorder",
+ contenteditable: "contentEditable"
+ },
+
+ prop: function( elem, name, value ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ if ( notxml ) {
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ return ( elem[ name ] = value );
+ }
+
+ } else {
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+ return elem[ name ];
+ }
+ }
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ var attributeNode = elem.getAttributeNode("tabindex");
+
+ return attributeNode && attributeNode.specified ?
+ parseInt( attributeNode.value, 10 ) :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+ }
+ }
+});
+
+// Hook for boolean attributes
+boolHook = {
+ get: function( elem, name ) {
+ // Align boolean attributes with corresponding properties
+ // Fall back to attribute presence where some booleans are not supported
+ var attrNode,
+ property = jQuery.prop( elem, name );
+ return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
+ name.toLowerCase() :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ var propName;
+ if ( value === false ) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else {
+ // value is true since we know at this point it's type boolean and not false
+ // Set boolean attributes to the same name and set the DOM property
+ propName = jQuery.propFix[ name ] || name;
+ if ( propName in elem ) {
+ // Only set the IDL specifically if it already exists on the element
+ elem[ propName ] = true;
+ }
+
+ elem.setAttribute( name, name.toLowerCase() );
+ }
+ return name;
+ }
+};
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+ fixSpecified = {
+ name: true,
+ id: true,
+ coords: true
+ };
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = jQuery.valHooks.button = {
+ get: function( elem, name ) {
+ var ret;
+ ret = elem.getAttributeNode( name );
+ return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
+ ret.value :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode( name );
+ if ( !ret ) {
+ ret = document.createAttribute( name );
+ elem.setAttributeNode( ret );
+ }
+ return ( ret.value = value + "" );
+ }
+ };
+
+ // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+ // This is for removals
+ jQuery.each([ "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ set: function( elem, value ) {
+ if ( value === "" ) {
+ elem.setAttribute( name, "auto" );
+ return value;
+ }
+ }
+ });
+ });
+
+ // Set contenteditable to false on removals(#10429)
+ // Setting to empty string throws an error as an invalid value
+ jQuery.attrHooks.contenteditable = {
+ get: nodeHook.get,
+ set: function( elem, value, name ) {
+ if ( value === "" ) {
+ value = "false";
+ }
+ nodeHook.set( elem, value, name );
+ }
+ };
+}
+
+
+// Some attributes require a special call on IE
+if ( !jQuery.support.hrefNormalized ) {
+ jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ get: function( elem ) {
+ var ret = elem.getAttribute( name, 2 );
+ return ret === null ? undefined : ret;
+ }
+ });
+ });
+}
+
+if ( !jQuery.support.style ) {
+ jQuery.attrHooks.style = {
+ get: function( elem ) {
+ // Return undefined in the case of empty string
+ // Normalize to lowercase since IE uppercases css property names
+ return elem.style.cssText.toLowerCase() || undefined;
+ },
+ set: function( elem, value ) {
+ return ( elem.style.cssText = value + "" );
+ }
+ };
+}
+
+// Safari mis-reports the default selected property of an option
+// Accessing the parent's selectedIndex property fixes it
+if ( !jQuery.support.optSelected ) {
+ jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
+ get: function( elem ) {
+ var parent = elem.parentNode;
+
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ return null;
+ }
+ });
+}
+
+// IE6/7 call enctype encoding
+if ( !jQuery.support.enctype ) {
+ jQuery.propFix.enctype = "encoding";
+}
+
+// Radios and checkboxes getter/setter
+if ( !jQuery.support.checkOn ) {
+ jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ get: function( elem ) {
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+ };
+ });
+}
+jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
+ }
+ }
+ });
+});
+var rformElems = /^(?:textarea|input|select)$/i,
+ rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
+ rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|contextmenu)|click/,
+ rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ hoverHack = function( events ) {
+ return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
+ };
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+ add: function( elem, types, handler, data, selector ) {
+
+ var elemData, eventHandle, events,
+ t, tns, type, namespaces, handleObj,
+ handleObjIn, handlers, special;
+
+ // Don't attach events to noData or text/comment nodes (allow plain objects tho)
+ if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ events = elemData.events;
+ if ( !events ) {
+ elemData.events = events = {};
+ }
+ eventHandle = elemData.handle;
+ if ( !eventHandle ) {
+ elemData.handle = eventHandle = function( e ) {
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
+ jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
+ eventHandle.elem = elem;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = jQuery.trim( hoverHack(types) ).split( " " );
+ for ( t = 0; t < types.length; t++ ) {
+
+ tns = rtypenamespace.exec( types[t] ) || [];
+ type = tns[1];
+ namespaces = ( tns[2] || "" ).split( "." ).sort();
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[ type ] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[ type ] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend({
+ type: type,
+ origType: tns[1],
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+ namespace: namespaces.join(".")
+ }, handleObjIn );
+
+ // Init the event handler queue if we're the first
+ handlers = events[ type ];
+ if ( !handlers ) {
+ handlers = events[ type ] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener/attachEvent if the special events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if ( selector ) {
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
+ } else {
+ handlers.push( handleObj );
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, selector, mappedTypes ) {
+
+ var t, tns, type, origType, namespaces, origCount,
+ j, events, special, eventType, handleObj,
+ elemData = jQuery.hasData( elem ) && jQuery._data( elem );
+
+ if ( !elemData || !(events = elemData.events) ) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
+ for ( t = 0; t < types.length; t++ ) {
+ tns = rtypenamespace.exec( types[t] ) || [];
+ type = origType = tns[1];
+ namespaces = tns[2];
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if ( !type ) {
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+ type = ( selector? special.delegateType : special.bindType ) || type;
+ eventType = events[ type ] || [];
+ origCount = eventType.length;
+ namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
+
+ // Remove matching events
+ for ( j = 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( ( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
+ ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
+ eventType.splice( j--, 1 );
+
+ if ( handleObj.selector ) {
+ eventType.delegateCount--;
+ }
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if ( eventType.length === 0 && origCount !== eventType.length ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ delete elemData.handle;
+
+ // removeData also checks for emptiness and clears the expando if empty
+ // so use it instead of delete
+ jQuery.removeData( elem, "events", true );
+ }
+ },
+
+ // Events that are safe to short-circuit if no handlers are attached.
+ // Native DOM events should not be added, they may have inline handlers.
+ customEvent: {
+ "getData": true,
+ "setData": true,
+ "changeData": true
+ },
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+ // Don't do events on text and comment nodes
+ if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
+ return;
+ }
+
+ // Event object or event type
+ var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
+ type = event.type || event,
+ namespaces = [];
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+ return;
+ }
+
+ if ( type.indexOf( "!" ) >= 0 ) {
+ // Exclusive events trigger only for the exact event (no namespaces)
+ type = type.slice(0, -1);
+ exclusive = true;
+ }
+
+ if ( type.indexOf( "." ) >= 0 ) {
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+
+ if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
+ // No jQuery handlers for this event type, and it can't have inline handlers
+ return;
+ }
+
+ // Caller can pass in an Event, Object, or just an event type string
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[ jQuery.expando ] ? event :
+ // Object literal
+ new jQuery.Event( type, event ) :
+ // Just the event type (string)
+ new jQuery.Event( type );
+
+ event.type = type;
+ event.isTrigger = true;
+ event.exclusive = exclusive;
+ event.namespace = namespaces.join( "." );
+ event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
+ ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
+
+ // Handle a global trigger
+ if ( !elem ) {
+
+ // TODO: Stop taunting the data cache; remove global events and always attach to document
+ cache = jQuery.cache;
+ for ( i in cache ) {
+ if ( cache[ i ].events && cache[ i ].events[ type ] ) {
+ jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
+ }
+ }
+ return;
+ }
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if ( !event.target ) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data != null ? jQuery.makeArray( data ) : [];
+ data.unshift( event );
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[ type ] || {};
+ if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ eventPath = [[ elem, special.bindType || type ]];
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
+
+ bubbleType = special.delegateType || type;
+ cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
+ for ( old = elem; cur; cur = cur.parentNode ) {
+ eventPath.push([ cur, bubbleType ]);
+ old = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if ( old === (elem.ownerDocument || document) ) {
+ eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
+ }
+ }
+
+ // Fire handlers on the event path
+ for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
+
+ cur = eventPath[i][0];
+ event.type = eventPath[i][1];
+
+ handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+ // Note that this is a bare JS function and not a jQuery handler
+ handle = ontype && cur[ ontype ];
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
+ event.preventDefault();
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+ if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
+ !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
+
+ // Call a native DOM method on the target with the same name name as the event.
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ // IE<9 dies on focus/blur to hidden element (#1486)
+ if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ old = elem[ ontype ];
+
+ if ( old ) {
+ elem[ ontype ] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+ elem[ type ]();
+ jQuery.event.triggered = undefined;
+
+ if ( old ) {
+ elem[ ontype ] = old;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ dispatch: function( event ) {
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix( event || window.event );
+
+ var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
+ handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
+ delegateCount = handlers.delegateCount,
+ args = core_slice.call( arguments ),
+ run_all = !event.exclusive && !event.namespace,
+ special = jQuery.event.special[ event.type ] || {},
+ handlerQueue = [];
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[0] = event;
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
+ // Determine handlers that should run if there are delegated events
+ // Avoid non-left-click bubbling in Firefox (#3861)
+ if ( delegateCount && !(event.button && event.type === "click") ) {
+
+ for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
+
+ // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.disabled !== true || event.type !== "click" ) {
+ selMatch = {};
+ matches = [];
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+ sel = handleObj.selector;
+
+ if ( selMatch[ sel ] === undefined ) {
+ selMatch[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( selMatch[ sel ] ) {
+ matches.push( handleObj );
+ }
+ }
+ if ( matches.length ) {
+ handlerQueue.push({ elem: cur, matches: matches });
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ if ( handlers.length > delegateCount ) {
+ handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
+ }
+
+ // Run delegates first; they may want to stop propagation beneath us
+ for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
+ matched = handlerQueue[ i ];
+ event.currentTarget = matched.elem;
+
+ for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
+ handleObj = matched.matches[ j ];
+
+ // Triggered event must either 1) be non-exclusive and have no namespace, or
+ // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
+ if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
+
+ event.data = handleObj.data;
+ event.handleObj = handleObj;
+
+ ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
+ .apply( matched.elem, args );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
+ return event.result;
+ },
+
+ // Includes some event props shared by KeyEvent and MouseEvent
+ // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
+ props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+
+ fixHooks: {},
+
+ keyHooks: {
+ props: "char charCode key keyCode".split(" "),
+ filter: function( event, original ) {
+
+ // Add which for key events
+ if ( event.which == null ) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+
+ return event;
+ }
+ },
+
+ mouseHooks: {
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+ filter: function( event, original ) {
+ var eventDoc, doc, body,
+ button = original.button,
+ fromElement = original.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && original.clientX != null ) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+
+ event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+ event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && fromElement ) {
+ event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && button !== undefined ) {
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+ }
+
+ return event;
+ }
+ },
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // Create a writable copy of the event object and normalize some properties
+ var i, prop,
+ originalEvent = event,
+ fixHook = jQuery.event.fixHooks[ event.type ] || {},
+ copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
+
+ event = jQuery.Event( originalEvent );
+
+ for ( i = copy.length; i; ) {
+ prop = copy[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
+ if ( !event.target ) {
+ event.target = originalEvent.srcElement || document;
+ }
+
+ // Target should not be a text node (#504, Safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
+ event.metaKey = !!event.metaKey;
+
+ return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
+ },
+
+ special: {
+ load: {
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+
+ focus: {
+ delegateType: "focusin"
+ },
+ blur: {
+ delegateType: "focusout"
+ },
+
+ beforeunload: {
+ setup: function( data, namespaces, eventHandle ) {
+ // We only want to do this special case on windows
+ if ( jQuery.isWindow( this ) ) {
+ this.onbeforeunload = eventHandle;
+ }
+ },
+
+ teardown: function( namespaces, eventHandle ) {
+ if ( this.onbeforeunload === eventHandle ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ },
+
+ simulate: function( type, elem, event, bubble ) {
+ // Piggyback on a donor event to simulate a different one.
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
+ // simulated event prevents default then we do the same on the donor.
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ { type: type,
+ isSimulated: true,
+ originalEvent: {}
+ }
+ );
+ if ( bubble ) {
+ jQuery.event.trigger( e, null, elem );
+ } else {
+ jQuery.event.dispatch.call( elem, e );
+ }
+ if ( e.isDefaultPrevented() ) {
+ event.preventDefault();
+ }
+ }
+};
+
+// Some plugins are using, but it's undocumented/deprecated and will be removed.
+// The 1.7 special event interface should provide all the hooks needed now.
+jQuery.event.handle = jQuery.event.dispatch;
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ var name = "on" + type;
+
+ if ( elem.detachEvent ) {
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
+ // detachEvent needed property on element, by name of that event, to properly expose it to GC
+ if ( typeof elem[ name ] === "undefined" ) {
+ elem[ name ] = null;
+ }
+
+ elem.detachEvent( name, handle );
+ }
+ };
+
+jQuery.Event = function( src, props ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !(this instanceof jQuery.Event) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
+ src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // otherwise set the returnValue property of the original event to false (IE)
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj,
+ selector = handleObj.selector;
+
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+});
+
+// IE submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
+ jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
+ // Node name check avoids a VML-related crash in IE (#9807)
+ var elem = e.target,
+ form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
+ if ( form && !jQuery._data( form, "_submit_attached" ) ) {
+ jQuery.event.add( form, "submit._submit", function( event ) {
+ event._submit_bubble = true;
+ });
+ jQuery._data( form, "_submit_attached", true );
+ }
+ });
+ // return undefined since we don't need an event listener
+ },
+
+ postDispatch: function( event ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submit_bubble ) {
+ delete event._submit_bubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
+ }
+ }
+ },
+
+ teardown: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+ jQuery.event.remove( this, "._submit" );
+ }
+ };
+}
+
+// IE change delegation and checkbox/radio fix
+if ( !jQuery.support.changeBubbles ) {
+
+ jQuery.event.special.change = {
+
+ setup: function() {
+
+ if ( rformElems.test( this.nodeName ) ) {
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
+ // after a propertychange. Eat the blur-change in special.change.handle.
+ // This still fires onchange a second time for check/radio after blur.
+ if ( this.type === "checkbox" || this.type === "radio" ) {
+ jQuery.event.add( this, "propertychange._change", function( event ) {
+ if ( event.originalEvent.propertyName === "checked" ) {
+ this._just_changed = true;
+ }
+ });
+ jQuery.event.add( this, "click._change", function( event ) {
+ if ( this._just_changed && !event.isTrigger ) {
+ this._just_changed = false;
+ }
+ // Allow triggered, simulated change events (#11500)
+ jQuery.event.simulate( "change", this, event, true );
+ });
+ }
+ return false;
+ }
+ // Delegated event; lazy-add a change handler on descendant inputs
+ jQuery.event.add( this, "beforeactivate._change", function( e ) {
+ var elem = e.target;
+
+ if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
+ jQuery.event.add( elem, "change._change", function( event ) {
+ if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
+ jQuery.event.simulate( "change", this.parentNode, event, true );
+ }
+ });
+ jQuery._data( elem, "_change_attached", true );
+ }
+ });
+ },
+
+ handle: function( event ) {
+ var elem = event.target;
+
+ // Swallow native change events from checkbox/radio, we already triggered them above
+ if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
+ return event.handleObj.handler.apply( this, arguments );
+ }
+ },
+
+ teardown: function() {
+ jQuery.event.remove( this, "._change" );
+
+ return !rformElems.test( this.nodeName );
+ }
+ };
+}
+
+// Create "bubbling" focus and blur events
+if ( !jQuery.support.focusinBubbles ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler while someone wants focusin/focusout
+ var attaches = 0,
+ handler = function( event ) {
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
+ };
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( attaches++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --attaches === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+ });
+}
+
+jQuery.fn.extend({
+
+ on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
+ var origFn, type;
+
+ // Types can be a map of types/handlers
+ if ( typeof types === "object" ) {
+ // ( types-Object, selector, data )
+ if ( typeof selector !== "string" ) { // && selector != null
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for ( type in types ) {
+ this.on( type, selector, data, types[ type ], one );
+ }
+ return this;
+ }
+
+ if ( data == null && fn == null ) {
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if ( fn == null ) {
+ if ( typeof selector === "string" ) {
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ } else if ( !fn ) {
+ return this;
+ }
+
+ if ( one === 1 ) {
+ origFn = fn;
+ fn = function( event ) {
+ // Can use an empty set, since event contains the info
+ jQuery().off( event );
+ return origFn.apply( this, arguments );
+ };
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return this.each( function() {
+ jQuery.event.add( this, types, fn, data, selector );
+ });
+ },
+ one: function( types, selector, data, fn ) {
+ return this.on( types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each(function() {
+ jQuery.event.remove( this, types, fn, selector );
+ });
+ },
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ live: function( types, data, fn ) {
+ jQuery( this.context ).on( types, this.selector, data, fn );
+ return this;
+ },
+ die: function( types, fn ) {
+ jQuery( this.context ).off( types, this.selector || "**", fn );
+ return this;
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ return jQuery.event.trigger( type, data, this[0], true );
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments,
+ guid = fn.guid || jQuery.guid++,
+ i = 0,
+ toggler = function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ };
+
+ // link all the functions, so any of them can unbind this click handler
+ toggler.guid = guid;
+ while ( i < args.length ) {
+ args[ i++ ].guid = guid;
+ }
+
+ return this.click( toggler );
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+});
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ if ( fn == null ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+
+ if ( rkeyEvent.test( name ) ) {
+ jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
+ }
+
+ if ( rmouseEvent.test( name ) ) {
+ jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
+ }
+});
+/*!
+ * Sizzle CSS Selector Engine
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://sizzlejs.com/
+ */
+(function( window, undefined ) {
+
+var cachedruns,
+ assertGetIdNotName,
+ Expr,
+ getText,
+ isXML,
+ contains,
+ compile,
+ sortOrder,
+ hasDuplicate,
+ outermostContext,
+
+ baseHasDuplicate = true,
+ strundefined = "undefined",
+
+ expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
+
+ Token = String,
+ document = window.document,
+ docElem = document.documentElement,
+ dirruns = 0,
+ done = 0,
+ pop = [].pop,
+ push = [].push,
+ slice = [].slice,
+ // Use a stripped-down indexOf if a native one is unavailable
+ indexOf = [].indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ // Augment a function for special use by Sizzle
+ markFunction = function( fn, value ) {
+ fn[ expando ] = value == null || value;
+ return fn;
+ },
+
+ createCache = function() {
+ var cache = {},
+ keys = [];
+
+ return markFunction(function( key, value ) {
+ // Only keep the most recent entries
+ if ( keys.push( key ) > Expr.cacheLength ) {
+ delete cache[ keys.shift() ];
+ }
+
+ return (cache[ key ] = value);
+ }, cache );
+ },
+
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+
+ // Regex
+
+ // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+ // http://www.w3.org/TR/css3-syntax/#characters
+ characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
+
+ // Loosely modeled on CSS identifier characters
+ // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
+ // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = characterEncoding.replace( "w", "w#" ),
+
+ // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
+ operators = "([*^$|!~]?=)",
+ attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
+ "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
+
+ // Prefer arguments not in parens/brackets,
+ // then attribute selectors and non-pseudos (denoted by :),
+ // then anything else
+ // These preferences are here to reduce the number of selectors
+ // needing tokenize in the PSEUDO preFilter
+ pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
+
+ // For matchExpr.POS and matchExpr.needsContext
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
+ rpseudo = new RegExp( pseudos ),
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
+
+ rnot = /^:not/,
+ rsibling = /[\x20\t\r\n\f]*[+~]/,
+ rendsWithNot = /:not\($/,
+
+ rheader = /h\d/i,
+ rinputs = /input|select|textarea|button/i,
+
+ rbackslash = /\\(?!\\)/g,
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + characterEncoding + ")" ),
+ "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
+ "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
+ "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "POS": new RegExp( pos, "i" ),
+ "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ // For use in libraries implementing .is()
+ "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
+ },
+
+ // Support
+
+ // Used for testing something on an element
+ assert = function( fn ) {
+ var div = document.createElement("div");
+
+ try {
+ return fn( div );
+ } catch (e) {
+ return false;
+ } finally {
+ // release memory in IE
+ div = null;
+ }
+ },
+
+ // Check if getElementsByTagName("*") returns only elements
+ assertTagNameNoComments = assert(function( div ) {
+ div.appendChild( document.createComment("") );
+ return !div.getElementsByTagName("*").length;
+ }),
+
+ // Check if getAttribute returns normalized href attributes
+ assertHrefNotNormalized = assert(function( div ) {
+ div.innerHTML = "<a href='#'></a>";
+ return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
+ div.firstChild.getAttribute("href") === "#";
+ }),
+
+ // Check if attributes should be retrieved by attribute nodes
+ assertAttributes = assert(function( div ) {
+ div.innerHTML = "<select></select>";
+ var type = typeof div.lastChild.getAttribute("multiple");
+ // IE8 returns a string for some attributes even when not present
+ return type !== "boolean" && type !== "string";
+ }),
+
+ // Check if getElementsByClassName can be trusted
+ assertUsableClassName = assert(function( div ) {
+ // Opera can't find a second classname (in 9.6)
+ div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
+ if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
+ return false;
+ }
+
+ // Safari 3.2 caches class attributes and doesn't catch changes
+ div.lastChild.className = "e";
+ return div.getElementsByClassName("e").length === 2;
+ }),
+
+ // Check if getElementById returns elements by name
+ // Check if getElementsByName privileges form controls or returns elements by ID
+ assertUsableName = assert(function( div ) {
+ // Inject content
+ div.id = expando + 0;
+ div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
+ docElem.insertBefore( div, docElem.firstChild );
+
+ // Test
+ var pass = document.getElementsByName &&
+ // buggy browsers will return fewer than the correct 2
+ document.getElementsByName( expando ).length === 2 +
+ // buggy browsers will return more than the correct 0
+ document.getElementsByName( expando + 0 ).length;
+ assertGetIdNotName = !document.getElementById( expando );
+
+ // Cleanup
+ docElem.removeChild( div );
+
+ return pass;
+ });
+
+// If slice is not available, provide a backup
+try {
+ slice.call( docElem.childNodes, 0 )[0].nodeType;
+} catch ( e ) {
+ slice = function( i ) {
+ var elem,
+ results = [];
+ for ( ; (elem = this[i]); i++ ) {
+ results.push( elem );
+ }
+ return results;
+ };
+}
+
+function Sizzle( selector, context, results, seed ) {
+ results = results || [];
+ context = context || document;
+ var match, elem, xml, m,
+ nodeType = context.nodeType;
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ if ( nodeType !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
+ xml = isXML( context );
+
+ if ( !xml && !seed ) {
+ if ( (match = rquickExpr.exec( selector )) ) {
+ // Speed-up: Sizzle("#ID")
+ if ( (m = match[1]) ) {
+ if ( nodeType === 9 ) {
+ elem = context.getElementById( m );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE, Opera, and Webkit return items
+ // by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ // Context is not a document
+ if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
+ contains( context, elem ) && elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Speed-up: Sizzle("TAG")
+ } else if ( match[2] ) {
+ push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
+ return results;
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
+ push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
+ return results;
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
+}
+
+Sizzle.matches = function( expr, elements ) {
+ return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+ return Sizzle( expr, null, null, [ elem ] ).length > 0;
+};
+
+// Returns a function to use in pseudos for input types
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for buttons
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for positionals
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if ( nodeType ) {
+ if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (see #11153)
+ if ( typeof elem.textContent === "string" ) {
+ return elem.textContent;
+ } else {
+ // Traverse its children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ ret += getText( elem );
+ }
+ }
+ } else if ( nodeType === 3 || nodeType === 4 ) {
+ return elem.nodeValue;
+ }
+ // Do not include comment or processing instruction nodes
+ } else {
+
+ // If no nodeType, this is expected to be an array
+ for ( ; (node = elem[i]); i++ ) {
+ // Do not traverse comment nodes
+ ret += getText( node );
+ }
+ }
+ return ret;
+};
+
+isXML = Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+// Element contains another
+contains = Sizzle.contains = docElem.contains ?
+ function( a, b ) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
+ } :
+ docElem.compareDocumentPosition ?
+ function( a, b ) {
+ return b && !!( a.compareDocumentPosition( b ) & 16 );
+ } :
+ function( a, b ) {
+ while ( (b = b.parentNode) ) {
+ if ( b === a ) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+Sizzle.attr = function( elem, name ) {
+ var val,
+ xml = isXML( elem );
+
+ if ( !xml ) {
+ name = name.toLowerCase();
+ }
+ if ( (val = Expr.attrHandle[ name ]) ) {
+ return val( elem );
+ }
+ if ( xml || assertAttributes ) {
+ return elem.getAttribute( name );
+ }
+ val = elem.getAttributeNode( name );
+ return val ?
+ typeof elem[ name ] === "boolean" ?
+ elem[ name ] ? name : null :
+ val.specified ? val.value : null :
+ null;
+};
+
+Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ // IE6/7 return a modified href
+ attrHandle: assertHrefNotNormalized ?
+ {} :
+ {
+ "href": function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ },
+ "type": function( elem ) {
+ return elem.getAttribute("type");
+ }
+ },
+
+ find: {
+ "ID": assertGetIdNotName ?
+ function( id, context, xml ) {
+ if ( typeof context.getElementById !== strundefined && !xml ) {
+ var m = context.getElementById( id );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ } :
+ function( id, context, xml ) {
+ if ( typeof context.getElementById !== strundefined && !xml ) {
+ var m = context.getElementById( id );
+
+ return m ?
+ m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
+ [m] :
+ undefined :
+ [];
+ }
+ },
+
+ "TAG": assertTagNameNoComments ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== strundefined ) {
+ return context.getElementsByTagName( tag );
+ }
+ } :
+ function( tag, context ) {
+ var results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ var elem,
+ tmp = [],
+ i = 0;
+
+ for ( ; (elem = results[i]); i++ ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ },
+
+ "NAME": assertUsableName && function( tag, context ) {
+ if ( typeof context.getElementsByName !== strundefined ) {
+ return context.getElementsByName( name );
+ }
+ },
+
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
+ if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
+ return context.getElementsByClassName( className );
+ }
+ }
+ },
+
+ relative: {
+ ">": { dir: "parentNode", first: true },
+ " ": { dir: "parentNode" },
+ "+": { dir: "previousSibling", first: true },
+ "~": { dir: "previousSibling" }
+ },
+
+ preFilter: {
+ "ATTR": function( match ) {
+ match[1] = match[1].replace( rbackslash, "" );
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
+
+ if ( match[2] === "~=" ) {
+ match[3] = " " + match[3] + " ";
+ }
+
+ return match.slice( 0, 4 );
+ },
+
+ "CHILD": function( match ) {
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 3 xn-component of xn+y argument ([+-]?\d*n|)
+ 4 sign of xn-component
+ 5 x of xn-component
+ 6 sign of y-component
+ 7 y of y-component
+ */
+ match[1] = match[1].toLowerCase();
+
+ if ( match[1] === "nth" ) {
+ // nth-child requires argument
+ if ( !match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
+ match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
+
+ // other types prohibit arguments
+ } else if ( match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function( match ) {
+ var unquoted, excess;
+ if ( matchExpr["CHILD"].test( match[0] ) ) {
+ return null;
+ }
+
+ if ( match[3] ) {
+ match[2] = match[3];
+ } else if ( (unquoted = match[4]) ) {
+ // Only check arguments that contain a pseudo
+ if ( rpseudo.test(unquoted) &&
+ // Get excess from tokenize (recursively)
+ (excess = tokenize( unquoted, true )) &&
+ // advance to the next closing parenthesis
+ (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
+
+ // excess is a negative index
+ unquoted = unquoted.slice( 0, excess );
+ match[0] = match[0].slice( 0, excess );
+ }
+ match[2] = unquoted;
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice( 0, 3 );
+ }
+ },
+
+ filter: {
+ "ID": assertGetIdNotName ?
+ function( id ) {
+ id = id.replace( rbackslash, "" );
+ return function( elem ) {
+ return elem.getAttribute("id") === id;
+ };
+ } :
+ function( id ) {
+ id = id.replace( rbackslash, "" );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+ return node && node.value === id;
+ };
+ },
+
+ "TAG": function( nodeName ) {
+ if ( nodeName === "*" ) {
+ return function() { return true; };
+ }
+ nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
+
+ return function( elem ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function( className ) {
+ var pattern = classCache[ expando ][ className ];
+ if ( !pattern ) {
+ pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
+ }
+ return function( elem ) {
+ return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
+ };
+ },
+
+ "ATTR": function( name, operator, check ) {
+ return function( elem, context ) {
+ var result = Sizzle.attr( elem, name );
+
+ if ( result == null ) {
+ return operator === "!=";
+ }
+ if ( !operator ) {
+ return true;
+ }
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.substr( result.length - check.length ) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
+ false;
+ };
+ },
+
+ "CHILD": function( type, argument, first, last ) {
+
+ if ( type === "nth" ) {
+ return function( elem ) {
+ var node, diff,
+ parent = elem.parentNode;
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ if ( parent ) {
+ diff = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ diff++;
+ if ( elem === node ) {
+ break;
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset (or cast to NaN), then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ };
+ }
+
+ return function( elem ) {
+ var node = elem;
+
+ switch ( type ) {
+ case "only":
+ case "first":
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ if ( type === "first" ) {
+ return true;
+ }
+
+ node = elem;
+
+ /* falls through */
+ case "last":
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ };
+ },
+
+ "PSEUDO": function( pseudo, argument ) {
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction(function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf.call( seed, matched[i] );
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
+ }
+ }) :
+ function( elem ) {
+ return fn( elem, 0, args );
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+ "not": markFunction(function( selector ) {
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction(function( seed, matches, context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( (elem = unmatched[i]) ) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function( elem, context, xml ) {
+ input[0] = elem;
+ matcher( input, null, xml, results );
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function( selector ) {
+ return function( elem ) {
+ return Sizzle( selector, elem ).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function( text ) {
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+ };
+ }),
+
+ "enabled": function( elem ) {
+ return elem.disabled === false;
+ },
+
+ "disabled": function( elem ) {
+ return elem.disabled === true;
+ },
+
+ "checked": function( elem ) {
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+ },
+
+ "selected": function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ "parent": function( elem ) {
+ return !Expr.pseudos["empty"]( elem );
+ },
+
+ "empty": function( elem ) {
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
+ // not comment, processing instructions, or others
+ // Thanks to Diego Perini for the nodeName shortcut
+ // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
+ var nodeType;
+ elem = elem.firstChild;
+ while ( elem ) {
+ if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
+ return false;
+ }
+ elem = elem.nextSibling;
+ }
+ return true;
+ },
+
+ "header": function( elem ) {
+ return rheader.test( elem.nodeName );
+ },
+
+ "text": function( elem ) {
+ var type, attr;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return elem.nodeName.toLowerCase() === "input" &&
+ (type = elem.type) === "text" &&
+ ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
+ },
+
+ // Input types
+ "radio": createInputPseudo("radio"),
+ "checkbox": createInputPseudo("checkbox"),
+ "file": createInputPseudo("file"),
+ "password": createInputPseudo("password"),
+ "image": createInputPseudo("image"),
+
+ "submit": createButtonPseudo("submit"),
+ "reset": createButtonPseudo("reset"),
+
+ "button": function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "input": function( elem ) {
+ return rinputs.test( elem.nodeName );
+ },
+
+ "focus": function( elem ) {
+ var doc = elem.ownerDocument;
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
+ },
+
+ "active": function( elem ) {
+ return elem === elem.ownerDocument.activeElement;
+ },
+
+ // Positional types
+ "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ 0 ];
+ }),
+
+ "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ length - 1 ];
+ }),
+
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = 0; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = 1; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
+ }
+};
+
+function siblingCheck( a, b, ret ) {
+ if ( a === b ) {
+ return ret;
+ }
+
+ var cur = a.nextSibling;
+
+ while ( cur ) {
+ if ( cur === b ) {
+ return -1;
+ }
+
+ cur = cur.nextSibling;
+ }
+
+ return 1;
+}
+
+sortOrder = docElem.compareDocumentPosition ?
+ function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
+ a.compareDocumentPosition :
+ a.compareDocumentPosition(b) & 4
+ ) ? -1 : 1;
+ } :
+ function( a, b ) {
+ // The nodes are identical, we can exit early
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // Fallback to using sourceIndex (in IE) if it's available on both nodes
+ } else if ( a.sourceIndex && b.sourceIndex ) {
+ return a.sourceIndex - b.sourceIndex;
+ }
+
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
+ cur = aup;
+
+ // If the nodes are siblings (or identical) we can do a quick check
+ if ( aup === bup ) {
+ return siblingCheck( a, b );
+
+ // If no parents were found then the nodes are disconnected
+ } else if ( !aup ) {
+ return -1;
+
+ } else if ( !bup ) {
+ return 1;
+ }
+
+ // Otherwise they're somewhere else in the tree so we need
+ // to build up a full list of the parentNodes for comparison
+ while ( cur ) {
+ ap.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ cur = bup;
+
+ while ( cur ) {
+ bp.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ al = ap.length;
+ bl = bp.length;
+
+ // Start walking down the tree looking for a discrepancy
+ for ( var i = 0; i < al && i < bl; i++ ) {
+ if ( ap[i] !== bp[i] ) {
+ return siblingCheck( ap[i], bp[i] );
+ }
+ }
+
+ // We ended someplace up the tree so do a sibling check
+ return i === al ?
+ siblingCheck( a, bp[i], -1 ) :
+ siblingCheck( ap[i], b, 1 );
+ };
+
+// Always assume the presence of duplicates if sort doesn't
+// pass them to our comparison function (as in Google Chrome).
+[0, 0].sort( sortOrder );
+baseHasDuplicate = !hasDuplicate;
+
+// Document sorting and removing duplicates
+Sizzle.uniqueSort = function( results ) {
+ var elem,
+ i = 1;
+
+ hasDuplicate = baseHasDuplicate;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( ; (elem = results[i]); i++ ) {
+ if ( elem === results[ i - 1 ] ) {
+ results.splice( i--, 1 );
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.error = function( msg ) {
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+function tokenize( selector, parseOnly ) {
+ var matched, match, tokens, type, soFar, groups, preFilters,
+ cached = tokenCache[ expando ][ selector ];
+
+ if ( cached ) {
+ return parseOnly ? 0 : cached.slice( 0 );
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while ( soFar ) {
+
+ // Comma and first run
+ if ( !matched || (match = rcomma.exec( soFar )) ) {
+ if ( match ) {
+ soFar = soFar.slice( match[0].length );
+ }
+ groups.push( tokens = [] );
+ }
+
+ matched = false;
+
+ // Combinators
+ if ( (match = rcombinators.exec( soFar )) ) {
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+
+ // Cast descendant combinators to space
+ matched.type = match[0].replace( rtrim, " " );
+ }
+
+ // Filters
+ for ( type in Expr.filter ) {
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
+ // The last two arguments here are (context, xml) for backCompat
+ (match = preFilters[ type ]( match, document, true ))) ) {
+
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+ matched.type = type;
+ matched.matches = match;
+ }
+ }
+
+ if ( !matched ) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error( selector ) :
+ // Cache the tokens
+ tokenCache( selector, groups ).slice( 0 );
+}
+
+function addCombinator( matcher, combinator, base ) {
+ var dir = combinator.dir,
+ checkNonElements = base && combinator.dir === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ return matcher( elem, context, xml );
+ }
+ }
+ } :
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if ( !xml ) {
+ var cache,
+ dirkey = dirruns + " " + doneName + " ",
+ cachedkey = dirkey + cachedruns;
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( (cache = elem[ expando ]) === cachedkey ) {
+ return elem.sizset;
+ } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
+ if ( elem.sizset ) {
+ return elem;
+ }
+ } else {
+ elem[ expando ] = cachedkey;
+ if ( matcher( elem, context, xml ) ) {
+ elem.sizset = true;
+ return elem;
+ }
+ elem.sizset = false;
+ }
+ }
+ }
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( matcher( elem, context, xml ) ) {
+ return elem;
+ }
+ }
+ }
+ }
+ };
+}
+
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[i]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[0];
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction(function( seed, results, context, xml ) {
+ // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
+ if ( seed && postFinder ) {
+ return;
+ }
+
+ var i, elem, postFilterIn,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ postFilterIn = condense( matcherOut, postMap );
+ postFilter( postFilterIn, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = postFilterIn.length;
+ while ( i-- ) {
+ if ( (elem = postFilterIn[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
+ }
+ }
+
+ // Keep seed and results synchronized
+ if ( seed ) {
+ // Ignore postFinder because it can't coexist with seed
+ i = preFilter && matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
+ }
+ }
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf.call( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+ } ];
+
+ for ( ; i < len; i++ ) {
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+ } else {
+ // The concatenated values are (context, xml) for backCompat
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && tokens.join("")
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
+
+ return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, expandContext ) {
+ var elem, j, matcher,
+ setMatched = [],
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ outermost = expandContext != null,
+ contextBackup = outermostContext,
+ // We must always have either seed elements or context
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
+ // Nested matchers should use non-integer dirruns
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
+
+ if ( outermost ) {
+ outermostContext = context !== document && context;
+ cachedruns = superMatcher.el;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
+ if ( matcher( elem, context, xml ) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ cachedruns = ++superMatcher.el;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
+ }
+
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if ( bySet && i !== matchedCount ) {
+ for ( j = 0; (matcher = setMatchers[j]); j++ ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
+
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
+
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ superMatcher.el = 0;
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ expando ][ selector ];
+
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !group ) {
+ group = tokenize( selector );
+ }
+ i = group.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( group[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+ }
+ return cached;
+};
+
+function multipleContexts( selector, contexts, results, seed ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results, seed );
+ }
+ return results;
+}
+
+function select( selector, context, results, seed, xml ) {
+ var i, tokens, token, type, find,
+ match = tokenize( selector ),
+ j = match.length;
+
+ if ( !seed ) {
+ // Try to minimize operations if there is only one group
+ if ( match.length === 1 ) {
+
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ context.nodeType === 9 && !xml &&
+ Expr.relative[ tokens[1].type ] ) {
+
+ context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
+ if ( !context ) {
+ return results;
+ }
+
+ selector = selector.slice( tokens.shift().length );
+ }
+
+ // Fetch a seed set for right-to-left matching
+ for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( rbackslash, "" ),
+ rsibling.test( tokens[0].type ) && context.parentNode || context,
+ xml
+ )) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && tokens.join("");
+ if ( !selector ) {
+ push.apply( results, slice.call( seed, 0 ) );
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function
+ // Provide `match` to avoid retokenization if we modified the selector above
+ compile( selector, match )(
+ seed,
+ context,
+ xml,
+ results,
+ rsibling.test( selector )
+ );
+ return results;
+}
+
+if ( document.querySelectorAll ) {
+ (function() {
+ var disconnectedMatch,
+ oldSelect = select,
+ rescape = /'|\\/g,
+ rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
+
+ // qSa(:focus) reports false when true (Chrome 21),
+ // A support test would require too much code (would include document ready)
+ rbuggyQSA = [":focus"],
+
+ // matchesSelector(:focus) reports false when true (Chrome 21),
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ // A support test would require too much code (would include document ready)
+ // just skip matchesSelector for :active
+ rbuggyMatches = [ ":active", ":focus" ],
+ matches = docElem.matchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.webkitMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector;
+
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function( div ) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explictly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ div.innerHTML = "<select><option selected=''></option></select>";
+
+ // IE8 - Some boolean attributes are not treated correctly
+ if ( !div.querySelectorAll("[selected]").length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here (do not put tests after this one)
+ if ( !div.querySelectorAll(":checked").length ) {
+ rbuggyQSA.push(":checked");
+ }
+ });
+
+ assert(function( div ) {
+
+ // Opera 10-12/IE9 - ^= $= *= and empty values
+ // Should not select anything
+ div.innerHTML = "<p test=''></p>";
+ if ( div.querySelectorAll("[test^='']").length ) {
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here (do not put tests after this one)
+ div.innerHTML = "<input type='hidden'/>";
+ if ( !div.querySelectorAll(":enabled").length ) {
+ rbuggyQSA.push(":enabled", ":disabled");
+ }
+ });
+
+ // rbuggyQSA always contains :focus, so no need for a length check
+ rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
+
+ select = function( selector, context, results, seed, xml ) {
+ // Only use querySelectorAll when not filtering,
+ // when this is not xml,
+ // and when no QSA bugs apply
+ if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
+ var groups, i,
+ old = true,
+ nid = expando,
+ newContext = context,
+ newSelector = context.nodeType === 9 && selector;
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
+
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
+ } else {
+ context.setAttribute( "id", nid );
+ }
+ nid = "[id='" + nid + "'] ";
+
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + groups[i].join("");
+ }
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
+ try {
+ push.apply( results, slice.call( newContext.querySelectorAll(
+ newSelector
+ ), 0 ) );
+ return results;
+ } catch(qsaError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute("id");
+ }
+ }
+ }
+ }
+
+ return oldSelect( selector, context, results, seed, xml );
+ };
+
+ if ( matches ) {
+ assert(function( div ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ disconnectedMatch = matches.call( div, "div" );
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ try {
+ matches.call( div, "[test!='']:sizzle" );
+ rbuggyMatches.push( "!=", pseudos );
+ } catch ( e ) {}
+ });
+
+ // rbuggyMatches always contains :active and :focus, so no need for a length check
+ rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
+
+ Sizzle.matchesSelector = function( elem, expr ) {
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace( rattributeQuotes, "='$1']" );
+
+ // rbuggyMatches always contains :active, so no need for an existence check
+ if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
+ try {
+ var ret = matches.call( elem, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11 ) {
+ return ret;
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle( expr, null, null, [ elem ] ).length > 0;
+ };
+ }
+ })();
+}
+
+// Deprecated
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
+
+// Back-compat
+function setFilters() {}
+Expr.filters = setFilters.prototype = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+// Override sizzle attribute retrieval
+Sizzle.attr = jQuery.attr;
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.pseudos;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+})( window );
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prev(?:Until|All))/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ rneedsContext = jQuery.expr.match.needsContext,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var i, l, length, n, r, ret,
+ self = this;
+
+ if ( typeof selector !== "string" ) {
+ return jQuery( selector ).filter(function() {
+ for ( i = 0, l = self.length; i < l; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ });
+ }
+
+ ret = this.pushStack( "", "find", selector );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( n = length; n < ret.length; n++ ) {
+ for ( r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var i,
+ targets = jQuery( target, this ),
+ len = targets.length;
+
+ return this.filter(function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && (
+ typeof selector === "string" ?
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ rneedsContext.test( selector ) ?
+ jQuery( selector, this.context ).index( this[0] ) >= 0 :
+ jQuery.filter( selector, this ).length > 0 :
+ this.filter( selector ).length > 0 );
+ },
+
+ closest: function( selectors, context ) {
+ var cur,
+ i = 0,
+ l = this.length,
+ ret = [],
+ pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
+ jQuery( selectors, context || this.context ) :
+ 0;
+
+ for ( ; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
+
+ return this.pushStack( ret, "closest", selectors );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+
+ // No argument, return index in parent
+ if ( !elem ) {
+ return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
+ }
+
+ // index in selector
+ if ( typeof elem === "string" ) {
+ return jQuery.inArray( this[0], jQuery( elem ) );
+ }
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context ) :
+ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ addBack: function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter(selector)
+ );
+ }
+});
+
+jQuery.fn.andSelf = jQuery.fn.addBack;
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+function sibling( cur, dir ) {
+ do {
+ cur = cur[ dir ];
+ } while ( cur && cur.nodeType !== 1 );
+
+ return cur;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return sibling( elem, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return sibling( elem, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.merge( [], elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
+
+ if ( this.length > 1 && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [],
+ cur = elem[ dir ];
+
+ while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+
+ // Can't pass null or undefined to indexOf in Firefox 4
+ // Set to 0 to skip string check
+ qualifier = qualifier || 0;
+
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return ( elem === qualifier ) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
+ });
+}
+function createSafeFragment( document ) {
+ var list = nodeNames.split( "|" ),
+ safeFrag = document.createDocumentFragment();
+
+ if ( safeFrag.createElement ) {
+ while ( list.length ) {
+ safeFrag.createElement(
+ list.pop()
+ );
+ }
+ }
+ return safeFrag;
+}
+
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+ "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
+ rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&#?\w+;/,
+ rnoInnerhtml = /<(?:script|style|link)/i,
+ rnocache = /<(?:script|object|embed|option|style)/i,
+ rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
+ rcheckableType = /^(?:checkbox|radio)$/,
+ // checked="checked" or checked
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+ rscriptType = /\/(java|ecma)script/i,
+ rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ },
+ safeFragment = createSafeFragment( document ),
+ fragmentDiv = safeFragment.appendChild( document.createElement("div") );
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+// unless wrapped in a div with non-breaking characters in front of it.
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "X<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( value ) {
+ return jQuery.access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
+ }, null, value, arguments.length );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append( this );
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapInner( html.call(this, i) );
+ });
+ }
+
+ return this.each(function() {
+ var self = jQuery( this ),
+ contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ var isFunction = jQuery.isFunction( html );
+
+ return this.each(function(i) {
+ jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( !isDisconnected( this[0] ) ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ }
+
+ if ( arguments.length ) {
+ var set = jQuery.clean( arguments );
+ return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
+ }
+ },
+
+ after: function() {
+ if ( !isDisconnected( this[0] ) ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ }
+
+ if ( arguments.length ) {
+ var set = jQuery.clean( arguments );
+ return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
+ }
+ },
+
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
+ if ( !keepData && elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ jQuery.cleanData( [ elem ] );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ }
+ }
+
+ return this;
+ },
+
+ empty: function() {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( elem.firstChild ) {
+ elem.removeChild( elem.firstChild );
+ }
+ }
+
+ return this;
+ },
+
+ clone: function( dataAndEvents, deepDataAndEvents ) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map( function () {
+ return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+ });
+ },
+
+ html: function( value ) {
+ return jQuery.access( this, function( value ) {
+ var elem = this[0] || {},
+ i = 0,
+ l = this.length;
+
+ if ( value === undefined ) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace( rinlinejQuery, "" ) :
+ undefined;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
+ ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+ !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
+
+ value = value.replace( rxhtmlTag, "<$1></$2>" );
+
+ try {
+ for (; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ elem = this[i] || {};
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName( "*" ) );
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {}
+ }
+
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
+ },
+
+ replaceWith: function( value ) {
+ if ( !isDisconnected( this[0] ) ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this), old = self.html();
+ self.replaceWith( value.call( this, i, old ) );
+ });
+ }
+
+ if ( typeof value !== "string" ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling,
+ parent = this.parentNode;
+
+ jQuery( this ).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ }
+
+ return this.length ?
+ this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
+ this;
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+
+ // Flatten any nested arrays
+ args = [].concat.apply( [], args );
+
+ var results, first, fragment, iNoClone,
+ i = 0,
+ value = args[0],
+ scripts = [],
+ l = this.length;
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
+ return this.each(function() {
+ jQuery(this).domManip( args, table, callback );
+ });
+ }
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call( this, i, table ? self.html() : undefined );
+ self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ results = jQuery.buildFragment( args, this, scripts );
+ fragment = results.fragment;
+ first = fragment.firstChild;
+
+ if ( fragment.childNodes.length === 1 ) {
+ fragment = first;
+ }
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ // Use the original fragment for the last item instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ // Fragments from the fragment cache must always be cloned and never used in place.
+ for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
+ callback.call(
+ table && jQuery.nodeName( this[i], "table" ) ?
+ findOrAppend( this[i], "tbody" ) :
+ this[i],
+ i === iNoClone ?
+ fragment :
+ jQuery.clone( fragment, true, true )
+ );
+ }
+ }
+
+ // Fix #11809: Avoid leaking memory
+ fragment = first = null;
+
+ if ( scripts.length ) {
+ jQuery.each( scripts, function( i, elem ) {
+ if ( elem.src ) {
+ if ( jQuery.ajax ) {
+ jQuery.ajax({
+ url: elem.src,
+ type: "GET",
+ dataType: "script",
+ async: false,
+ global: false,
+ "throws": true
+ });
+ } else {
+ jQuery.error("no ajax");
+ }
+ } else {
+ jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ });
+ }
+ }
+
+ return this;
+ }
+});
+
+function findOrAppend( elem, tag ) {
+ return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
+}
+
+function cloneCopyEvent( src, dest ) {
+
+ if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
+ return;
+ }
+
+ var type, i, l,
+ oldData = jQuery._data( src ),
+ curData = jQuery._data( dest, oldData ),
+ events = oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( type in events ) {
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+ jQuery.event.add( dest, type, events[ type ][ i ] );
+ }
+ }
+ }
+
+ // make the cloned public data object a copy from the original
+ if ( curData.data ) {
+ curData.data = jQuery.extend( {}, curData.data );
+ }
+}
+
+function cloneFixAttributes( src, dest ) {
+ var nodeName;
+
+ // We do not need to do anything for non-Elements
+ if ( dest.nodeType !== 1 ) {
+ return;
+ }
+
+ // clearAttributes removes the attributes, which we don't want,
+ // but also removes the attachEvent events, which we *do* want
+ if ( dest.clearAttributes ) {
+ dest.clearAttributes();
+ }
+
+ // mergeAttributes, in contrast, only merges back on the
+ // original attributes, not the events
+ if ( dest.mergeAttributes ) {
+ dest.mergeAttributes( src );
+ }
+
+ nodeName = dest.nodeName.toLowerCase();
+
+ if ( nodeName === "object" ) {
+ // IE6-10 improperly clones children of object elements using classid.
+ // IE10 throws NoModificationAllowedError if parent is null, #12132.
+ if ( dest.parentNode ) {
+ dest.outerHTML = src.outerHTML;
+ }
+
+ // This path appears unavoidable for IE9. When cloning an object
+ // element in IE9, the outerHTML strategy above is not sufficient.
+ // If the src has innerHTML and the destination does not,
+ // copy the src.innerHTML into the dest.innerHTML. #10324
+ if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
+ dest.innerHTML = src.innerHTML;
+ }
+
+ } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+ // IE6-8 fails to persist the checked state of a cloned checkbox
+ // or radio button. Worse, IE6-7 fail to give the cloned element
+ // a checked appearance if the defaultChecked value isn't also set
+
+ dest.defaultChecked = dest.checked = src.checked;
+
+ // IE6-7 get confused and end up setting the value of a cloned
+ // checkbox/radio button to an empty string instead of "on"
+ if ( dest.value !== src.value ) {
+ dest.value = src.value;
+ }
+
+ // IE6-8 fails to return the selected option to the default selected
+ // state when cloning options
+ } else if ( nodeName === "option" ) {
+ dest.selected = src.defaultSelected;
+
+ // IE6-8 fails to set the defaultValue to the correct value when
+ // cloning other types of input fields
+ } else if ( nodeName === "input" || nodeName === "textarea" ) {
+ dest.defaultValue = src.defaultValue;
+
+ // IE blanks contents when cloning scripts
+ } else if ( nodeName === "script" && dest.text !== src.text ) {
+ dest.text = src.text;
+ }
+
+ // Event data gets referenced instead of copied if the expando
+ // gets copied too
+ dest.removeAttribute( jQuery.expando );
+}
+
+jQuery.buildFragment = function( args, context, scripts ) {
+ var fragment, cacheable, cachehit,
+ first = args[ 0 ];
+
+ // Set context from what may come in as undefined or a jQuery collection or a node
+ // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
+ // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
+ context = context || document;
+ context = !context.nodeType && context[0] || context;
+ context = context.ownerDocument || context;
+
+ // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
+ // Cloning options loses the selected state, so don't cache them
+ // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
+ // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
+ // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
+ if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
+ first.charAt(0) === "<" && !rnocache.test( first ) &&
+ (jQuery.support.checkClone || !rchecked.test( first )) &&
+ (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
+
+ // Mark cacheable and look for a hit
+ cacheable = true;
+ fragment = jQuery.fragments[ first ];
+ cachehit = fragment !== undefined;
+ }
+
+ if ( !fragment ) {
+ fragment = context.createDocumentFragment();
+ jQuery.clean( args, context, fragment, scripts );
+
+ // Update the cache, but only store false
+ // unless this is a second parsing of the same content
+ if ( cacheable ) {
+ jQuery.fragments[ first ] = cachehit && fragment;
+ }
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+};
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var elems,
+ i = 0,
+ ret = [],
+ insert = jQuery( selector ),
+ l = insert.length,
+ parent = this.length === 1 && this[0].parentNode;
+
+ if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
+ insert[ original ]( this[0] );
+ return this;
+ } else {
+ for ( ; i < l; i++ ) {
+ elems = ( i > 0 ? this.clone(true) : this ).get();
+ jQuery( insert[i] )[ original ]( elems );
+ ret = ret.concat( elems );
+ }
+
+ return this.pushStack( ret, name, insert.selector );
+ }
+ };
+});
+
+function getAll( elem ) {
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ return elem.getElementsByTagName( "*" );
+
+ } else if ( typeof elem.querySelectorAll !== "undefined" ) {
+ return elem.querySelectorAll( "*" );
+
+ } else {
+ return [];
+ }
+}
+
+// Used in clean, fixes the defaultChecked property
+function fixDefaultChecked( elem ) {
+ if ( rcheckableType.test( elem.type ) ) {
+ elem.defaultChecked = elem.checked;
+ }
+}
+
+jQuery.extend({
+ clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+ var srcElements,
+ destElements,
+ i,
+ clone;
+
+ if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+ clone = elem.cloneNode( true );
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+ }
+
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+ // IE copies events bound via attachEvent when using cloneNode.
+ // Calling detachEvent on the clone will also remove the events
+ // from the original. In order to get around this, we use some
+ // proprietary methods to clear the events. Thanks to MooTools
+ // guys for this hotness.
+
+ cloneFixAttributes( elem, clone );
+
+ // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
+
+ // Weird iteration because IE will replace the length property
+ // with an element if you are cloning the body and one of the
+ // elements on the page has a name or id of "length"
+ for ( i = 0; srcElements[i]; ++i ) {
+ // Ensure that the destination node is not null; Fixes #9587
+ if ( destElements[i] ) {
+ cloneFixAttributes( srcElements[i], destElements[i] );
+ }
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if ( dataAndEvents ) {
+ cloneCopyEvent( elem, clone );
+
+ if ( deepDataAndEvents ) {
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
+
+ for ( i = 0; srcElements[i]; ++i ) {
+ cloneCopyEvent( srcElements[i], destElements[i] );
+ }
+ }
+ }
+
+ srcElements = destElements = null;
+
+ // Return the cloned set
+ return clone;
+ },
+
+ clean: function( elems, context, fragment, scripts ) {
+ var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
+ safe = context === document && safeFragment,
+ ret = [];
+
+ // Ensure that context is a document
+ if ( !context || typeof context.createDocumentFragment === "undefined" ) {
+ context = document;
+ }
+
+ // Use the already-created safe fragment if context permits
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ continue;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" ) {
+ if ( !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+ } else {
+ // Ensure a safe container in which to render the html
+ safe = safe || createSafeFragment( context );
+ div = context.createElement("div");
+ safe.appendChild( div );
+
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, "<$1></$2>");
+
+ // Go to html and back, then peel off extra wrappers
+ tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
+ wrap = wrapMap[ tag ] || wrapMap._default;
+ depth = wrap[0];
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ hasBody = rtbody.test(elem);
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = div.childNodes;
+
+ // Take out of fragment container (we need a fresh div each time)
+ div.parentNode.removeChild( div );
+ }
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ jQuery.merge( ret, elem );
+ }
+ }
+
+ // Fix #11356: Clear elements from safeFragment
+ if ( div ) {
+ elem = div = safe = null;
+ }
+
+ // Reset defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ if ( !jQuery.support.appendChecked ) {
+ for ( i = 0; (elem = ret[i]) != null; i++ ) {
+ if ( jQuery.nodeName( elem, "input" ) ) {
+ fixDefaultChecked( elem );
+ } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
+ }
+ }
+ }
+
+ // Append elements to a provided document fragment
+ if ( fragment ) {
+ // Special handling of each script element
+ handleScript = function( elem ) {
+ // Check if we consider it executable
+ if ( !elem.type || rscriptType.test( elem.type ) ) {
+ // Detach the script and store it in the scripts array (if provided) or the fragment
+ // Return truthy to indicate that it has been handled
+ return scripts ?
+ scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
+ fragment.appendChild( elem );
+ }
+ };
+
+ for ( i = 0; (elem = ret[i]) != null; i++ ) {
+ // Check if we're done after handling an executable script
+ if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
+ // Append to fragment and handle embedded scripts
+ fragment.appendChild( elem );
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
+ jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
+
+ // Splice the scripts into ret after their former ancestor and advance our index beyond them
+ ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
+ i += jsTags.length;
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ cleanData: function( elems, /* internal */ acceptData ) {
+ var data, id, elem, type,
+ i = 0,
+ internalKey = jQuery.expando,
+ cache = jQuery.cache,
+ deleteExpando = jQuery.support.deleteExpando,
+ special = jQuery.event.special;
+
+ for ( ; (elem = elems[i]) != null; i++ ) {
+
+ if ( acceptData || jQuery.acceptData( elem ) ) {
+
+ id = elem[ internalKey ];
+ data = id && cache[ id ];
+
+ if ( data ) {
+ if ( data.events ) {
+ for ( type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ // Remove cache only if it was not already removed by jQuery.event.remove
+ if ( cache[ id ] ) {
+
+ delete cache[ id ];
+
+ // IE does not allow us to delete expando properties from nodes,
+ // nor does it have a removeAttribute function on Document nodes;
+ // we must handle all of these cases
+ if ( deleteExpando ) {
+ delete elem[ internalKey ];
+
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( internalKey );
+
+ } else {
+ elem[ internalKey ] = null;
+ }
+
+ jQuery.deletedIds.push( id );
+ }
+ }
+ }
+ }
+ }
+});
+// Limit scope pollution from any deprecated API
+(function() {
+
+var matched, browser;
+
+// Use of jQuery.browser is frowned upon.
+// More details: http://api.jquery.com/jQuery.browser
+// jQuery.uaMatch maintained for back-compat
+jQuery.uaMatch = function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+ /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
+ /(msie) ([\w.]+)/.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
+ [];
+
+ return {
+ browser: match[ 1 ] || "",
+ version: match[ 2 ] || "0"
+ };
+};
+
+matched = jQuery.uaMatch( navigator.userAgent );
+browser = {};
+
+if ( matched.browser ) {
+ browser[ matched.browser ] = true;
+ browser.version = matched.version;
+}
+
+// Chrome is Webkit, but Webkit is also Safari.
+if ( browser.chrome ) {
+ browser.webkit = true;
+} else if ( browser.webkit ) {
+ browser.safari = true;
+}
+
+jQuery.browser = browser;
+
+jQuery.sub = function() {
+ function jQuerySub( selector, context ) {
+ return new jQuerySub.fn.init( selector, context );
+ }
+ jQuery.extend( true, jQuerySub, this );
+ jQuerySub.superclass = this;
+ jQuerySub.fn = jQuerySub.prototype = this();
+ jQuerySub.fn.constructor = jQuerySub;
+ jQuerySub.sub = this.sub;
+ jQuerySub.fn.init = function init( selector, context ) {
+ if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
+ context = jQuerySub( context );
+ }
+
+ return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
+ };
+ jQuerySub.fn.init.prototype = jQuerySub.fn;
+ var rootjQuerySub = jQuerySub(document);
+ return jQuerySub;
+};
+
+})();
+var curCSS, iframe, iframeDoc,
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity=([^)]*)/,
+ rposition = /^(top|right|bottom|left)$/,
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rmargin = /^margin/,
+ rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
+ rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
+ rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
+ elemdisplay = {},
+
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssNormalTransform = {
+ letterSpacing: 0,
+ fontWeight: 400
+ },
+
+ cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+ cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
+
+ eventsToggle = jQuery.fn.toggle;
+
+// return a css property mapped to a potentially vendor prefixed property
+function vendorPropName( style, name ) {
+
+ // shortcut for names that are not vendor prefixed
+ if ( name in style ) {
+ return name;
+ }
+
+ // check for vendor prefixed names
+ var capName = name.charAt(0).toUpperCase() + name.slice(1),
+ origName = name,
+ i = cssPrefixes.length;
+
+ while ( i-- ) {
+ name = cssPrefixes[ i ] + capName;
+ if ( name in style ) {
+ return name;
+ }
+ }
+
+ return origName;
+}
+
+function isHidden( elem, el ) {
+ elem = el || elem;
+ return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+}
+
+function showHide( elements, show ) {
+ var elem, display,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ for ( ; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ values[ index ] = jQuery._data( elem, "olddisplay" );
+ if ( show ) {
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if ( !values[ index ] && elem.style.display === "none" ) {
+ elem.style.display = "";
+ }
+
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if ( elem.style.display === "" && isHidden( elem ) ) {
+ values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
+ }
+ } else {
+ display = curCSS( elem, "display" );
+
+ if ( !values[ index ] && display !== "none" ) {
+ jQuery._data( elem, "olddisplay", display );
+ }
+ }
+ }
+
+ // Set the display of most of the elements in a second loop
+ // to avoid the constant reflow
+ for ( index = 0; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
+ elem.style.display = show ? values[ index ] || "" : "none";
+ }
+ }
+
+ return elements;
+}
+
+jQuery.fn.extend({
+ css: function( name, value ) {
+ return jQuery.access( this, function( elem, name, value ) {
+ return value !== undefined ?
+ jQuery.style( elem, name, value ) :
+ jQuery.css( elem, name );
+ }, name, value, arguments.length > 1 );
+ },
+ show: function() {
+ return showHide( this, true );
+ },
+ hide: function() {
+ return showHide( this );
+ },
+ toggle: function( state, fn2 ) {
+ var bool = typeof state === "boolean";
+
+ if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
+ return eventsToggle.apply( this, arguments );
+ }
+
+ return this.each(function() {
+ if ( bool ? state : isHidden( this ) ) {
+ jQuery( this ).show();
+ } else {
+ jQuery( this ).hide();
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ // We should always get a number back from opacity
+ var ret = curCSS( elem, "opacity" );
+ return ret === "" ? "1" : ret;
+
+ }
+ }
+ }
+ },
+
+ // Exclude the following css properties to add px
+ cssNumber: {
+ "fillOpacity": true,
+ "fontWeight": true,
+ "lineHeight": true,
+ "opacity": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {
+ // normalize float css property
+ "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
+ },
+
+ // Get and set the style property on a DOM Node
+ style: function( elem, name, value, extra ) {
+ // Don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = jQuery.camelCase( name ),
+ style = elem.style;
+
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // Check if we're setting a value
+ if ( value !== undefined ) {
+ type = typeof value;
+
+ // convert relative number strings (+= or -=) to relative numbers. #7345
+ if ( type === "string" && (ret = rrelNum.exec( value )) ) {
+ value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that NaN and null values aren't set. See: #7116
+ if ( value == null || type === "number" && isNaN( value ) ) {
+ return;
+ }
+
+ // If a number was passed in, add 'px' to the (except for certain CSS properties)
+ if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
+ value += "px";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
+ // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
+ // Fixes bug #5509
+ try {
+ style[ name ] = value;
+ } catch(e) {}
+ }
+
+ } else {
+ // If a hook was provided get the non-computed value from there
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[ name ];
+ }
+ },
+
+ css: function( elem, name, numeric, extra ) {
+ var val, num, hooks,
+ origName = jQuery.camelCase( name );
+
+ // Make sure that we're working with the right name
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // If a hook was provided get the computed value from there
+ if ( hooks && "get" in hooks ) {
+ val = hooks.get( elem, true, extra );
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if ( val === undefined ) {
+ val = curCSS( elem, name );
+ }
+
+ //convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
+ // Return, converting to number if forced or a qualifier was provided and val looks numeric
+ if ( numeric || extra !== undefined ) {
+ num = parseFloat( val );
+ return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
+ }
+ return val;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.call( elem );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+ }
+});
+
+// NOTE: To any future maintainer, we've window.getComputedStyle
+// because jsdom on node.js will break without it.
+if ( window.getComputedStyle ) {
+ curCSS = function( elem, name ) {
+ var ret, width, minWidth, maxWidth,
+ computed = window.getComputedStyle( elem, null ),
+ style = elem.style;
+
+ if ( computed ) {
+
+ ret = computed[ name ];
+ if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
+ ret = jQuery.style( elem, name );
+ }
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
+ // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
+ // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+ if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ return ret;
+ };
+} else if ( document.documentElement.currentStyle ) {
+ curCSS = function( elem, name ) {
+ var left, rsLeft,
+ ret = elem.currentStyle && elem.currentStyle[ name ],
+ style = elem.style;
+
+ // Avoid setting ret to empty string here
+ // so we don't default to auto
+ if ( ret == null && style && style[ name ] ) {
+ ret = style[ name ];
+ }
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ // but not position css attributes, as those are proportional to the parent element instead
+ // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
+ if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
+
+ // Remember the original values
+ left = style.left;
+ rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ }
+ style.left = name === "fontSize" ? "1em" : ret;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret === "" ? "auto" : ret;
+ };
+}
+
+function setPositiveNumber( elem, value, subtract ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+ Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
+ value;
+}
+
+function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
+ var i = extra === ( isBorderBox ? "border" : "content" ) ?
+ // If we already have the right measurement, avoid augmentation
+ 4 :
+ // Otherwise initialize for horizontal or vertical properties
+ name === "width" ? 1 : 0,
+
+ val = 0;
+
+ for ( ; i < 4; i += 2 ) {
+ // both box models exclude margin, so add it if we want it
+ if ( extra === "margin" ) {
+ // we use jQuery.css instead of curCSS here
+ // because of the reliableMarginRight CSS hook!
+ val += jQuery.css( elem, extra + cssExpand[ i ], true );
+ }
+
+ // From this point on we use curCSS for maximum performance (relevant in animations)
+ if ( isBorderBox ) {
+ // border-box includes padding, so remove it if we want content
+ if ( extra === "content" ) {
+ val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
+ }
+
+ // at this point, extra isn't border nor margin, so remove border
+ if ( extra !== "margin" ) {
+ val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
+ }
+ } else {
+ // at this point, extra isn't content, so add padding
+ val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
+
+ // at this point, extra isn't content nor padding, so add border
+ if ( extra !== "padding" ) {
+ val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
+ }
+ }
+ }
+
+ return val;
+}
+
+function getWidthOrHeight( elem, name, extra ) {
+
+ // Start with offset property, which is equivalent to the border-box value
+ var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+ valueIsBorderBox = true,
+ isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
+
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if ( val <= 0 || val == null ) {
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS( elem, name );
+ if ( val < 0 || val == null ) {
+ val = elem.style[ name ];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test(val) ) {
+ return val;
+ }
+
+ // we need the check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat( val ) || 0;
+ }
+
+ // use the active box-sizing model to add/subtract irrelevant styles
+ return ( val +
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox
+ )
+ ) + "px";
+}
+
+
+// Try to determine the default display value of an element
+function css_defaultDisplay( nodeName ) {
+ if ( elemdisplay[ nodeName ] ) {
+ return elemdisplay[ nodeName ];
+ }
+
+ var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
+ display = elem.css("display");
+ elem.remove();
+
+ // If the simple way fails,
+ // get element's real default display by attaching it to a temp iframe
+ if ( display === "none" || display === "" ) {
+ // Use the already-created iframe if possible
+ iframe = document.body.appendChild(
+ iframe || jQuery.extend( document.createElement("iframe"), {
+ frameBorder: 0,
+ width: 0,
+ height: 0
+ })
+ );
+
+ // Create a cacheable copy of the iframe document on first call.
+ // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
+ // document to it; WebKit & Firefox won't allow reusing the iframe document.
+ if ( !iframeDoc || !iframe.createElement ) {
+ iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
+ iframeDoc.write("<!doctype html><html><body>");
+ iframeDoc.close();
+ }
+
+ elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
+
+ display = curCSS( elem, "display" );
+ document.body.removeChild( iframe );
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+
+ return display;
+}
+
+jQuery.each([ "height", "width" ], function( i, name ) {
+ jQuery.cssHooks[ name ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+ // certain elements can have dimension info if we invisibly show them
+ // however, it must have a current display style that would benefit from this
+ if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
+ return jQuery.swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, name, extra );
+ });
+ } else {
+ return getWidthOrHeight( elem, name, extra );
+ }
+ }
+ },
+
+ set: function( elem, value, extra ) {
+ return setPositiveNumber( elem, value, extra ?
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra,
+ jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
+ ) : 0
+ );
+ }
+ };
+});
+
+if ( !jQuery.support.opacity ) {
+ jQuery.cssHooks.opacity = {
+ get: function( elem, computed ) {
+ // IE uses filters for opacity
+ return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
+ ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function( elem, value ) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
+ style.removeAttribute ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute( "filter" );
+
+ // if there there is no filter style applied in a css rule, we are done
+ if ( currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test( filter ) ?
+ filter.replace( ralpha, opacity ) :
+ filter + " " + opacity;
+ }
+ };
+}
+
+// These hooks cannot be added until DOM ready because the support test
+// for it is not run until after DOM ready
+jQuery(function() {
+ if ( !jQuery.support.reliableMarginRight ) {
+ jQuery.cssHooks.marginRight = {
+ get: function( elem, computed ) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ return jQuery.swap( elem, { "display": "inline-block" }, function() {
+ if ( computed ) {
+ return curCSS( elem, "marginRight" );
+ }
+ });
+ }
+ };
+ }
+
+ // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+ // getComputedStyle returns percent when specified for top/left/bottom/right
+ // rather than make the css module depend on the offset module, we just check for it here
+ if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
+ jQuery.each( [ "top", "left" ], function( i, prop ) {
+ jQuery.cssHooks[ prop ] = {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ var ret = curCSS( elem, prop );
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
+ }
+ }
+ };
+ });
+ }
+
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+
+// These hooks are used by animate to expand properties
+jQuery.each({
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i,
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split(" ") : [ value ],
+ expanded = {};
+
+ for ( i = 0; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
+});
+var r20 = /%20/g,
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ rselectTextarea = /^(?:select|textarea)/i;
+
+jQuery.fn.extend({
+ serialize: function() {
+ return jQuery.param( this.serializeArray() );
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ return this.elements ? jQuery.makeArray( this.elements ) : this;
+ })
+ .filter(function(){
+ return this.name && !this.disabled &&
+ ( this.checked || rselectTextarea.test( this.nodeName ) ||
+ rinput.test( this.type ) );
+ })
+ .map(function( i, elem ){
+ var val = jQuery( this ).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray( val ) ?
+ jQuery.map( val, function( val, i ){
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }) :
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }).get();
+ }
+});
+
+//Serialize an array of form elements or a set of
+//key/values into a query string
+jQuery.param = function( a, traditional ) {
+ var prefix,
+ s = [],
+ add = function( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
+ s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+ };
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for ( prefix in a ) {
+ buildParams( prefix, a[ prefix ], traditional, add );
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join( "&" ).replace( r20, "+" );
+};
+
+function buildParams( prefix, obj, traditional, add ) {
+ var name;
+
+ if ( jQuery.isArray( obj ) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional || rbracket.test( prefix ) ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
+ }
+ });
+
+ } else if ( !traditional && jQuery.type( obj ) === "object" ) {
+ // Serialize object item.
+ for ( name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+}
+var
+ // Document location
+ ajaxLocParts,
+ ajaxLocation,
+
+ rhash = /#.*$/,
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+ rquery = /\?/,
+ rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
+ rts = /([?&])_=[^&]*/,
+ rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
+
+ // Keep a copy of the old load method
+ _load = jQuery.fn.load,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = ["*/"] + ["*"];
+
+// #8138, IE may throw an exception when accessing
+// a field from window.location if document.domain has been set
+try {
+ ajaxLocation = location.href;
+} catch( e ) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement( "a" );
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function( dataTypeExpression, func ) {
+
+ if ( typeof dataTypeExpression !== "string" ) {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType, list, placeBefore,
+ dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
+ i = 0,
+ length = dataTypes.length;
+
+ if ( jQuery.isFunction( func ) ) {
+ // For each dataType in the dataTypeExpression
+ for ( ; i < length; i++ ) {
+ dataType = dataTypes[ i ];
+ // We control if we're asked to add before
+ // any existing element
+ placeBefore = /^\+/.test( dataType );
+ if ( placeBefore ) {
+ dataType = dataType.substr( 1 ) || "*";
+ }
+ list = structure[ dataType ] = structure[ dataType ] || [];
+ // then we add to the structure accordingly
+ list[ placeBefore ? "unshift" : "push" ]( func );
+ }
+ }
+ };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
+ dataType /* internal */, inspected /* internal */ ) {
+
+ dataType = dataType || options.dataTypes[ 0 ];
+ inspected = inspected || {};
+
+ inspected[ dataType ] = true;
+
+ var selection,
+ list = structure[ dataType ],
+ i = 0,
+ length = list ? list.length : 0,
+ executeOnly = ( structure === prefilters );
+
+ for ( ; i < length && ( executeOnly || !selection ); i++ ) {
+ selection = list[ i ]( options, originalOptions, jqXHR );
+ // If we got redirected to another dataType
+ // we try there if executing only and not done already
+ if ( typeof selection === "string" ) {
+ if ( !executeOnly || inspected[ selection ] ) {
+ selection = undefined;
+ } else {
+ options.dataTypes.unshift( selection );
+ selection = inspectPrefiltersOrTransports(
+ structure, options, originalOptions, jqXHR, selection, inspected );
+ }
+ }
+ }
+ // If we're only executing or nothing was selected
+ // we try the catchall dataType if not done already
+ if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
+ selection = inspectPrefiltersOrTransports(
+ structure, options, originalOptions, jqXHR, "*", inspected );
+ }
+ // unnecessary when only executing (prefilters)
+ // but it'll be ignored by the caller in that case
+ return selection;
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+ var key, deep,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+ for ( key in src ) {
+ if ( src[ key ] !== undefined ) {
+ ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
+ }
+ }
+ if ( deep ) {
+ jQuery.extend( true, target, deep );
+ }
+}
+
+jQuery.fn.load = function( url, params, callback ) {
+ if ( typeof url !== "string" && _load ) {
+ return _load.apply( this, arguments );
+ }
+
+ // Don't do a request if no elements are being requested
+ if ( !this.length ) {
+ return this;
+ }
+
+ var selector, type, response,
+ self = this,
+ off = url.indexOf(" ");
+
+ if ( off >= 0 ) {
+ selector = url.slice( off, url.length );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+
+ // if "type" variable is undefined, then "GET" method will be used
+ type: type,
+ dataType: "html",
+ data: params,
+ complete: function( jqXHR, status ) {
+ if ( callback ) {
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+ }
+ }
+ }).done(function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ // See if a selector was specified
+ self.html( selector ?
+
+ // Create a dummy div to hold the results
+ jQuery("<div>")
+
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append( responseText.replace( rscript, "" ) )
+
+ // Locate the specified elements
+ .find( selector ) :
+
+ // If not, just inject the full result
+ responseText );
+
+ });
+
+ return this;
+};
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
+ jQuery.fn[ o ] = function( f ){
+ return this.on( o, f );
+ };
+});
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+ // shift arguments if data argument was omitted
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ return jQuery.ajax({
+ type: method,
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ };
+});
+
+jQuery.extend({
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ if ( settings ) {
+ // Building a settings object
+ ajaxExtend( target, jQuery.ajaxSettings );
+ } else {
+ // Extending ajaxSettings
+ settings = target;
+ target = jQuery.ajaxSettings;
+ }
+ ajaxExtend( target, settings );
+ return target;
+ },
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ text: "text/plain",
+ json: "application/json, text/javascript",
+ "*": allTypes
+ },
+
+ contents: {
+ xml: /xml/,
+ html: /html/,
+ json: /json/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText"
+ },
+
+ // List of data converters
+ // 1) key format is "source_type destination_type" (a single space in-between)
+ // 2) the catchall symbol "*" can be used for source_type
+ converters: {
+
+ // Convert anything to text
+ "* text": window.String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ context: true,
+ url: true
+ }
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var // ifModified key
+ ifModifiedKey,
+ // Response headers
+ responseHeadersString,
+ responseHeaders,
+ // transport
+ transport,
+ // timeout handle
+ timeoutTimer,
+ // Cross-domain detection vars
+ parts,
+ // To know if global events are to be dispatched
+ fireGlobals,
+ // Loop variable
+ i,
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events
+ // It's the callbackContext if one was provided in the options
+ // and if it's a DOM node or a jQuery collection
+ globalEventContext = callbackContext !== s &&
+ ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
+ jQuery( callbackContext ) : jQuery.event,
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks( "once memory" ),
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+ // The jqXHR state
+ state = 0,
+ // Default abort message
+ strAbort = "canceled",
+ // Fake xhr
+ jqXHR = {
+
+ readyState: 0,
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ if ( !state ) {
+ var lname = name.toLowerCase();
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( state === 2 ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while( ( match = rheaders.exec( responseHeadersString ) ) ) {
+ responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() ];
+ }
+ return match === undefined ? null : match;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ statusText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( statusText );
+ }
+ done( 0, statusText );
+ return this;
+ }
+ };
+
+ // Callback for when everything is done
+ // It is defined here because jslint complains if it is declared
+ // at the end of the function (which would be more logical and readable)
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if ( state === 2 ) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // If successful, handle type chaining
+ if ( status >= 200 && status < 300 || status === 304 ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+
+ modified = jqXHR.getResponseHeader("Last-Modified");
+ if ( modified ) {
+ jQuery.lastModified[ ifModifiedKey ] = modified;
+ }
+ modified = jqXHR.getResponseHeader("Etag");
+ if ( modified ) {
+ jQuery.etag[ ifModifiedKey ] = modified;
+ }
+ }
+
+ // If not modified
+ if ( status === 304 ) {
+
+ statusText = "notmodified";
+ isSuccess = true;
+
+ // If we have data
+ } else {
+
+ isSuccess = ajaxConvert( s, response );
+ statusText = isSuccess.state;
+ success = isSuccess.data;
+ error = isSuccess.error;
+ isSuccess = !error;
+ }
+ } else {
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if ( !statusText || status ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+ }
+
+ // Attach deferreds
+ deferred.promise( jqXHR );
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+ jqXHR.complete = completeDeferred.add;
+
+ // Status-dependent callbacks
+ jqXHR.statusCode = function( map ) {
+ if ( map ) {
+ var tmp;
+ if ( state < 2 ) {
+ for ( tmp in map ) {
+ statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
+ }
+ } else {
+ tmp = map[ jqXHR.status ];
+ jqXHR.always( tmp );
+ }
+ }
+ return this;
+ };
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if ( s.crossDomain == null ) {
+ parts = rurl.exec( s.url.toLowerCase() ) || false;
+ s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
+ ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // If data is available, append data to url
+ if ( s.data ) {
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Get ifModifiedKey before adding the anti-cache parameter
+ ifModifiedKey = s.url;
+
+ // Add anti-cache in url if needed
+ if ( s.cache === false ) {
+
+ var ts = jQuery.now(),
+ // try replacing _= if it is there
+ ret = s.url.replace( rts, "$1_=" + ts );
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ ifModifiedKey = ifModifiedKey || s.url;
+ if ( jQuery.lastModified[ ifModifiedKey ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
+ }
+ if ( jQuery.etag[ ifModifiedKey ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
+ }
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+ s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+ // Abort if not done already and return
+ return jqXHR.abort();
+
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = setTimeout( function(){
+ jqXHR.abort( "timeout" );
+ }, s.timeout );
+ }
+
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch (e) {
+ // Propagate exception as error if not done
+ if ( state < 2 ) {
+ done( -1, e );
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {}
+
+});
+
+/* Handles responses to an ajax request:
+ * - sets all responseXXX fields accordingly
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+
+ var ct, type, finalDataType, firstDataType,
+ contents = s.contents,
+ dataTypes = s.dataTypes,
+ responseFields = s.responseFields;
+
+ // Fill responseXXX fields
+ for ( type in responseFields ) {
+ if ( type in responses ) {
+ jqXHR[ responseFields[type] ] = responses[ type ];
+ }
+ }
+
+ // Remove auto dataType and get content-type in the process
+ while( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+// Chain conversions given the request and the original response
+function ajaxConvert( s, response ) {
+
+ var conv, conv2, current, tmp,
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice(),
+ prev = dataTypes[ 0 ],
+ converters = {},
+ i = 0;
+
+ // Apply the dataFilter if provided
+ if ( s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ // Convert to each sequential dataType, tolerating list modification
+ for ( ; (current = dataTypes[++i]); ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current !== "*" ) {
+
+ // Convert response if prev dataType is non-auto and differs from current
+ if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split(" ");
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.splice( i--, 0, current );
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s["throws"] ) {
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
+ }
+ }
+ }
+ }
+
+ // Update prev for next iteration
+ prev = current;
+ }
+ }
+
+ return { state: "success", data: response };
+}
+var oldCallbacks = [],
+ rquestion = /\?/,
+ rjsonp = /(=)\?(?=&|$)|\?\?/,
+ nonce = jQuery.now();
+
+// Default jsonp settings
+jQuery.ajaxSetup({
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+});
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ data = s.data,
+ url = s.url,
+ hasCallback = s.jsonp !== false,
+ replaceInUrl = hasCallback && rjsonp.test( url ),
+ replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
+ !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
+ rjsonp.test( data );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+ overwritten = window[ callbackName ];
+
+ // Insert callback into url or form data
+ if ( replaceInUrl ) {
+ s.url = url.replace( rjsonp, "$1" + callbackName );
+ } else if ( replaceInData ) {
+ s.data = data.replace( rjsonp, "$1" + callbackName );
+ } else if ( hasCallback ) {
+ s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters["script json"] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always(function() {
+ // Restore preexisting value
+ window[ callbackName ] = overwritten;
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ });
+
+ // Delegate to script
+ return "script";
+ }
+});
+// Install script dataType
+jQuery.ajaxSetup({
+ accepts: {
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /javascript|ecmascript/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+});
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ s.global = false;
+ }
+});
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function(s) {
+
+ // This transport only deals with cross domain requests
+ if ( s.crossDomain ) {
+
+ var script,
+ head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
+
+ return {
+
+ send: function( _, callback ) {
+
+ script = document.createElement( "script" );
+
+ script.async = "async";
+
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ script.src = s.url;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+ if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+
+ // Remove the script
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+
+ // Dereference the script
+ script = undefined;
+
+ // Callback if not abort
+ if ( !isAbort ) {
+ callback( 200, "success" );
+ }
+ }
+ };
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+ },
+
+ abort: function() {
+ if ( script ) {
+ script.onload( 0, 1 );
+ }
+ }
+ };
+ }
+});
+var xhrCallbacks,
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
+ xhrOnUnloadAbort = window.ActiveXObject ? function() {
+ // Abort all pending requests
+ for ( var key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( 0, 1 );
+ }
+ } : false,
+ xhrId = 0;
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
+ } catch( e ) {}
+}
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject ?
+ /* Microsoft failed to properly
+ * implement the XMLHttpRequest in IE7 (can't request local files),
+ * so we use the ActiveXObject when it is available
+ * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
+ * we need a fallback.
+ */
+ function() {
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
+ } :
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+// Determine support properties
+(function( xhr ) {
+ jQuery.extend( jQuery.support, {
+ ajax: !!xhr,
+ cors: !!xhr && ( "withCredentials" in xhr )
+ });
+})( jQuery.ajaxSettings.xhr() );
+
+// Create transport if the browser can provide an xhr
+if ( jQuery.support.ajax ) {
+
+ jQuery.ajaxTransport(function( s ) {
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( !s.crossDomain || jQuery.support.cors ) {
+
+ var callback;
+
+ return {
+ send: function( headers, complete ) {
+
+ // Get a new xhr
+ var handle, i,
+ xhr = s.xhr();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open( s.type, s.url, s.async, s.username, s.password );
+ } else {
+ xhr.open( s.type, s.url, s.async );
+ }
+
+ // Apply custom fields if provided
+ if ( s.xhrFields ) {
+ for ( i in s.xhrFields ) {
+ xhr[ i ] = s.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !s.crossDomain && !headers["X-Requested-With"] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
+ } catch( _ ) {}
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send( ( s.hasContent && s.data ) || null );
+
+ // Listener
+ callback = function( _, isAbort ) {
+
+ var status,
+ statusText,
+ responseHeaders,
+ responses,
+ xml;
+
+ // Firefox throws exceptions when accessing properties
+ // of an xhr when a network error occurred
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
+ try {
+
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+
+ // Only called once
+ callback = undefined;
+
+ // Do not keep as active anymore
+ if ( handle ) {
+ xhr.onreadystatechange = jQuery.noop;
+ if ( xhrOnUnloadAbort ) {
+ delete xhrCallbacks[ handle ];
+ }
+ }
+
+ // If it's an abort
+ if ( isAbort ) {
+ // Abort it manually if needed
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ status = xhr.status;
+ responseHeaders = xhr.getAllResponseHeaders();
+ responses = {};
+ xml = xhr.responseXML;
+
+ // Construct response list
+ if ( xml && xml.documentElement /* #4958 */ ) {
+ responses.xml = xml;
+ }
+
+ // When requesting binary data, IE6-9 will throw an exception
+ // on any attempt to access responseText (#11426)
+ try {
+ responses.text = xhr.responseText;
+ } catch( _ ) {
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch( e ) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && s.isLocal && !s.crossDomain ) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
+ }
+ }
+ } catch( firefoxAccessException ) {
+ if ( !isAbort ) {
+ complete( -1, firefoxAccessException );
+ }
+ }
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, responseHeaders );
+ }
+ };
+
+ if ( !s.async ) {
+ // if we're in sync mode we fire the callback
+ callback();
+ } else if ( xhr.readyState === 4 ) {
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ setTimeout( callback, 0 );
+ } else {
+ handle = ++xhrId;
+ if ( xhrOnUnloadAbort ) {
+ // Create the active xhrs callbacks list if needed
+ // and attach the unload handler
+ if ( !xhrCallbacks ) {
+ xhrCallbacks = {};
+ jQuery( window ).unload( xhrOnUnloadAbort );
+ }
+ // Add to list of active xhrs callbacks
+ xhrCallbacks[ handle ] = callback;
+ }
+ xhr.onreadystatechange = callback;
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback(0,1);
+ }
+ }
+ };
+ }
+ });
+}
+var fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
+ rrun = /queueHooks$/,
+ animationPrefilters = [ defaultPrefilter ],
+ tweeners = {
+ "*": [function( prop, value ) {
+ var end, unit,
+ tween = this.createTween( prop, value ),
+ parts = rfxnum.exec( value ),
+ target = tween.cur(),
+ start = +target || 0,
+ scale = 1,
+ maxIterations = 20;
+
+ if ( parts ) {
+ end = +parts[2];
+ unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+
+ // We need to compute starting value
+ if ( unit !== "px" && start ) {
+ // Iteratively approximate from a nonzero starting point
+ // Prefer the current property, because this process will be trivial if it uses the same units
+ // Fallback to end or a simple constant
+ start = jQuery.css( tween.elem, prop, true ) || end || 1;
+
+ do {
+ // If previous iteration zeroed out, double until we get *something*
+ // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ start = start / scale;
+ jQuery.style( tween.elem, prop, start + unit );
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
+ }
+
+ tween.unit = unit;
+ tween.start = start;
+ // If a +=/-= token was provided, we're doing a relative animation
+ tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
+ }
+ return tween;
+ }]
+ };
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ setTimeout(function() {
+ fxNow = undefined;
+ }, 0 );
+ return ( fxNow = jQuery.now() );
+}
+
+function createTweens( animation, props ) {
+ jQuery.each( props, function( prop, value ) {
+ var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( collection[ index ].call( animation, prop, value ) ) {
+
+ // we're done with this property
+ return;
+ }
+ }
+ });
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ index = 0,
+ tweenerIndex = 0,
+ length = animationPrefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ }),
+ tick = function() {
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+ percent = 1 - ( remaining / animation.duration || 0 ),
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ]);
+
+ if ( percent < 1 && length ) {
+ return remaining;
+ } else {
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ }
+ },
+ animation = deferred.promise({
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, { specialEasing: {} }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end, easing ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if ( gotoEnd ) {
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ }),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length ; index++ ) {
+ result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ return result;
+ }
+ }
+
+ createTweens( animation, props );
+
+ if ( jQuery.isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ anim: animation,
+ queue: animation.opts.queue,
+ elem: elem
+ })
+ );
+
+ // attach callbacks from options
+ return animation.progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+}
+
+function propFilter( props, specialEasing ) {
+ var index, name, easing, value, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = jQuery.camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( jQuery.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweener: function( props, callback ) {
+ if ( jQuery.isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.split(" ");
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length ; index++ ) {
+ prop = props[ index ];
+ tweeners[ prop ] = tweeners[ prop ] || [];
+ tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ animationPrefilters.unshift( callback );
+ } else {
+ animationPrefilters.push( callback );
+ }
+ }
+});
+
+function defaultPrefilter( elem, props, opts ) {
+ var index, prop, value, length, dataShow, tween, hooks, oldfire,
+ anim = this,
+ style = elem.style,
+ orig = {},
+ handled = [],
+ hidden = elem.nodeType && isHidden( elem );
+
+ // handle queue: false promises
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always(function() {
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always(function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ });
+ });
+ }
+
+ // height/width overflow pass
+ if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ if ( jQuery.css( elem, "display" ) === "inline" &&
+ jQuery.css( elem, "float" ) === "none" ) {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
+ style.display = "inline-block";
+
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ if ( !jQuery.support.shrinkWrapBlocks ) {
+ anim.done(function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ });
+ }
+ }
+
+
+ // show/hide pass
+ for ( index in props ) {
+ value = props[ index ];
+ if ( rfxtypes.exec( value ) ) {
+ delete props[ index ];
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+ continue;
+ }
+ handled.push( index );
+ }
+ }
+
+ length = handled.length;
+ if ( length ) {
+ dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
+ if ( hidden ) {
+ jQuery( elem ).show();
+ } else {
+ anim.done(function() {
+ jQuery( elem ).hide();
+ });
+ }
+ anim.done(function() {
+ var prop;
+ jQuery.removeData( elem, "fxshow", true );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ });
+ for ( index = 0 ; index < length ; index++ ) {
+ prop = handled[ index ];
+ tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
+ orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
+
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = tween.start;
+ if ( hidden ) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+ }
+}
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ if ( tween.elem[ tween.prop ] != null &&
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing any value as a 4th parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, false, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Remove in 2.0 - this supports IE8's panic based approach
+// to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ||
+ // special check for .toggle( handler, handler, ... )
+ ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+});
+
+jQuery.fn.extend({
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+ // animate to the value specified
+ .end().animate({ opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+ // Empty animations resolve immediately
+ if ( empty ) {
+ anim.stop( true );
+ }
+ };
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue && type !== false ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each(function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ }
+});
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ attrs = { height: type },
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth? 1 : 0;
+ for( ; i < 4 ; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show"),
+ slideUp: genFx("hide"),
+ slideToggle: genFx("toggle"),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+});
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p*Math.PI ) / 2;
+ }
+};
+
+jQuery.timers = [];
+jQuery.fx = Tween.prototype.init;
+jQuery.fx.tick = function() {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+ // Checks the timer has not already been removed
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+};
+
+jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
+ timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+ }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.stop = function() {
+ clearInterval( timerId );
+ timerId = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+};
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+var rroot = /^(?:body|html)$/i;
+
+jQuery.fn.offset = function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
+ box = { top: 0, left: 0 },
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return;
+ }
+
+ if ( (body = doc.body) === elem ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if ( !jQuery.contains( docElem, elem ) ) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow( doc );
+ clientTop = docElem.clientTop || body.clientTop || 0;
+ clientLeft = docElem.clientLeft || body.clientLeft || 0;
+ scrollTop = win.pageYOffset || docElem.scrollTop;
+ scrollLeft = win.pageXOffset || docElem.scrollLeft;
+ return {
+ top: box.top + scrollTop - clientTop,
+ left: box.left + scrollLeft - clientLeft
+ };
+};
+
+jQuery.offset = {
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop,
+ left = body.offsetLeft;
+
+ if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
+ left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ var position = jQuery.css( elem, "position" );
+
+ // set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curCSSTop = jQuery.css( elem, "top" ),
+ curCSSLeft = jQuery.css( elem, "left" ),
+ calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
+ props = {}, curPosition = {}, curTop, curLeft;
+
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+
+ position: function() {
+ if ( !this[0] ) {
+ return;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
+ offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
+ parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || document.body;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
+ var top = /Y/.test( prop );
+
+ jQuery.fn[ method ] = function( val ) {
+ return jQuery.access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
+
+ if ( val === undefined ) {
+ return win ? (prop in win) ? win[ prop ] :
+ win.document.documentElement[ method ] :
+ elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length, null );
+ };
+});
+
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return jQuery.access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( jQuery.isWindow( elem ) ) {
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, value, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable, null );
+ };
+ });
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+// Expose jQuery as an AMD module, but only for AMD loaders that
+// understand the issues with loading multiple versions of jQuery
+// in a page that all might call define(). The loader will indicate
+// they have special allowances for multiple jQuery versions by
+// specifying define.amd.jQuery = true. Register as a named module,
+// since jQuery can be concatenated with other files that may use define,
+// but not use a proper concatenation script that understands anonymous
+// AMD modules. A named AMD is safest and most robust way to register.
+// Lowercase jquery is used because AMD module names are derived from
+// file names, and jQuery is normally delivered in a lowercase file name.
+// Do this after creating the global so that if an AMD module wants to call
+// noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
+ define( "jquery", [], function () { return jQuery; } );
+}
+
+})( window );
--- /dev/null
+++ b/js/godoc/pkg.html
@@ -1,0 +1,2252 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8">
+<meta name="description" content="Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta name="theme-color" content="#00ADD8">
+
+ <title>Packages - The Go Programming Language</title>
+
+<link href="https://fonts.googleapis.com/css?family=Work+Sans:600|Roboto:400,700" rel="stylesheet">
+<link href="https://fonts.googleapis.com/css?family=Product+Sans&text=Supported%20by%20Google&display=swap" rel="stylesheet">
+<link type="text/css" rel="stylesheet" href="/lib/godoc/style.css">
+
+<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
+
+<script>window.initFuncs = [];</script>
+
+<script>
+var _gaq = _gaq || [];
+_gaq.push(["_setAccount", "UA-11222381-2"]);
+window.trackPageview = function() {
+ _gaq.push(["_trackPageview", location.pathname+location.hash]);
+};
+window.trackPageview();
+window.trackEvent = function(category, action, opt_label, opt_value, opt_noninteraction) {
+ _gaq.push(["_trackEvent", category, action, opt_label, opt_value, opt_noninteraction]);
+};
+</script>
+
+<script src="/lib/godoc/jquery.js" defer></script>
+
+
+<script src="/lib/godoc/playground.js" defer></script>
+
+<script>var goVersion = "go1.15.6";</script>
+<script src="/lib/godoc/godocs.js" defer></script>
+
+<body class="Site">
+<header class="Header js-header">
+ <div class="Header-banner">
+ Black Lives Matter.
+ <a href="https://support.eji.org/give/153413/#!/donation/checkout"
+ target="_blank"
+ rel="noopener">Support the Equal Justice Initiative.</a>
+ </div>
+ <nav class="Header-nav Header-nav--wide">
+ <a href="/"><img class="Header-logo" src="/lib/godoc/images/go-logo-blue.svg" alt="Go"></a>
+ <button class="Header-menuButton js-headerMenuButton" aria-label="Main menu" aria-expanded="false">
+ <div class="Header-menuButtonInner"></div>
+ </button>
+ <ul class="Header-menu">
+ <li class="Header-menuItem"><a href="/doc/">Documents</a></li>
+ <li class="Header-menuItem"><a href="/pkg/">Packages</a></li>
+ <li class="Header-menuItem"><a href="/project/">The Project</a></li>
+ <li class="Header-menuItem"><a href="/help/">Help</a></li>
+
+ <li class="Header-menuItem"><a href="/blog/">Blog</a></li>
+
+ <li class="Header-menuItem"><a href="https://play.golang.org/">Play</a></li>
+
+
+ <li class="Header-menuItem Header-menuItem--search">
+ <form class="HeaderSearch" role="search" action="/search">
+ <input class="HeaderSearch-input"
+ type="search"
+ name="q"
+ placeholder="Search"
+ aria-label="Search"
+ autocapitalize="off"
+ autocomplete="off"
+ autocorrect="off"
+ spellcheck="false"
+ required>
+ <button class="HeaderSearch-submit">
+ <!-- magnifying glass: --><svg class="HeaderSearch-icon" width="24" height="24" viewBox="0 0 24 24"><title>Search</title><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
+ </button>
+ </form>
+ </li>
+ </ul>
+ </nav>
+</header>
+
+<main id="page" class="Site-content wide">
+<div class="container">
+
+
+ <h1>
+ Packages
+ <span class="text-muted"></span>
+ </h1>
+
+
+
+
+
+
+
+<div id="nav"></div>
+
+
+<!--
+ Copyright 2018 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file.
+-->
+<!--
+ Note: Static (i.e., not template-generated) href and id
+ attributes start with "pkg-" to make it impossible for
+ them to conflict with generated attributes (some of which
+ correspond to Go identifiers).
+-->
+
+
+
+
+
+ <div id="manual-nav">
+ <dl>
+ <dt><a href="#stdlib">Standard library</a></dt>
+
+ <dt><a href="#other">Other packages</a></dt>
+ <dd><a href="#subrepo">Sub-repositories</a></dd>
+ <dd><a href="#community">Community</a></dd>
+ </dl>
+ </div>
+
+ <div id="stdlib" class="toggleVisible">
+ <div class="collapsed">
+ <h2 class="toggleButton" title="Click to show Standard library section">Standard library ▹</h2>
+ </div>
+ <div class="expanded">
+ <h2 class="toggleButton" title="Click to hide Standard library section">Standard library ▾</h2>
+ <img alt="" class="gopher" src="/doc/gopher/pkg.png"/>
+ <div class="pkg-dir">
+ <table>
+ <tr>
+ <th class="pkg-name">Name</th>
+ <th class="pkg-synopsis">Synopsis</th>
+ </tr>
+
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="archive/">archive</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="archive/tar/">tar</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package tar implements access to tar archives.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="archive/zip/">zip</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package zip provides support for reading and writing ZIP archives.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="bufio/">bufio</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="builtin/">builtin</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package builtin provides documentation for Go's predeclared identifiers.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="bytes/">bytes</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package bytes implements functions for the manipulation of byte slices.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="compress/">compress</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="compress/bzip2/">bzip2</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package bzip2 implements bzip2 decompression.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="compress/flate/">flate</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package flate implements the DEFLATE compressed data format, described in RFC 1951.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="compress/gzip/">gzip</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package gzip implements reading and writing of gzip format compressed files, as specified in RFC 1952.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="compress/lzw/">lzw</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="compress/zlib/">zlib</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package zlib implements reading and writing of zlib format compressed data, as specified in RFC 1950.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="container/">container</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="container/heap/">heap</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package heap provides heap operations for any type that implements heap.Interface.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="container/list/">list</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package list implements a doubly linked list.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="container/ring/">ring</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ring implements operations on circular lists.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="context/">context</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="crypto/">crypto</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package crypto collects common cryptographic constants.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/aes/">aes</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package aes implements AES encryption (formerly Rijndael), as defined in U.S. Federal Information Processing Standards Publication 197.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/cipher/">cipher</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package cipher implements standard block cipher modes that can be wrapped around low-level block cipher implementations.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/des/">des</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package des implements the Data Encryption Standard (DES) and the Triple Data Encryption Algorithm (TDEA) as defined in U.S. Federal Information Processing Standards Publication 46-3.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/dsa/">dsa</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package dsa implements the Digital Signature Algorithm, as defined in FIPS 186-3.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/ecdsa/">ecdsa</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ecdsa implements the Elliptic Curve Digital Signature Algorithm, as defined in FIPS 186-3.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/ed25519/">ed25519</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ed25519 implements the Ed25519 signature algorithm.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/elliptic/">elliptic</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package elliptic implements several standard elliptic curves over prime fields.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/hmac/">hmac</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package hmac implements the Keyed-Hash Message Authentication Code (HMAC) as defined in U.S. Federal Information Processing Standards Publication 198.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/md5/">md5</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package md5 implements the MD5 hash algorithm as defined in RFC 1321.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/rand/">rand</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package rand implements a cryptographically secure random number generator.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/rc4/">rc4</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package rc4 implements RC4 encryption, as defined in Bruce Schneier's Applied Cryptography.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/rsa/">rsa</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package rsa implements RSA encryption as specified in PKCS #1 and RFC 8017.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/sha1/">sha1</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sha1 implements the SHA-1 hash algorithm as defined in RFC 3174.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/sha256/">sha256</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/sha512/">sha512</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256 hash algorithms as defined in FIPS 180-4.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/subtle/">subtle</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package subtle implements functions that are often useful in cryptographic code but require careful thought to use correctly.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/tls/">tls</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="crypto/x509/">x509</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package x509 parses X.509-encoded keys and certificates.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="crypto/x509/pkix/">pkix</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package pkix contains shared, low level structures used for ASN.1 parsing and serialization of X.509 certificates, CRL and OCSP.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="database/">database</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="database/sql/">sql</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sql provides a generic interface around SQL (or SQL-like) databases.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="database/sql/driver/">driver</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package driver defines interfaces to be implemented by database drivers as used by package sql.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="debug/">debug</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/dwarf/">dwarf</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package dwarf provides access to DWARF debugging information loaded from executable files, as defined in the DWARF 2.0 Standard at http://dwarfstd.org/doc/dwarf-2.0.0.pdf
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/elf/">elf</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package elf implements access to ELF object files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/gosym/">gosym</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package gosym implements access to the Go symbol and line number tables embedded in Go binaries generated by the gc compilers.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/macho/">macho</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package macho implements access to Mach-O object files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/pe/">pe</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package pe implements access to PE (Microsoft Windows Portable Executable) files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="debug/plan9obj/">plan9obj</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package plan9obj implements access to Plan 9 a.out object files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="encoding/">encoding</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package encoding defines interfaces shared by other packages that convert data to and from byte-level and textual representations.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/ascii85/">ascii85</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ascii85 implements the ascii85 data encoding as used in the btoa tool and Adobe's PostScript and PDF document formats.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/asn1/">asn1</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/base32/">base32</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package base32 implements base32 encoding as specified by RFC 4648.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/base64/">base64</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package base64 implements base64 encoding as specified by RFC 4648.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/binary/">binary</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package binary implements simple translation between numbers and byte sequences and encoding and decoding of varints.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/csv/">csv</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package csv reads and writes comma-separated values (CSV) files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/gob/">gob</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package gob manages streams of gobs - binary values exchanged between an Encoder (transmitter) and a Decoder (receiver).
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/hex/">hex</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package hex implements hexadecimal encoding and decoding.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/json/">json</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package json implements encoding and decoding of JSON as defined in RFC 7159.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/pem/">pem</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package pem implements the PEM data encoding, which originated in Privacy Enhanced Mail.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="encoding/xml/">xml</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package xml implements a simple XML 1.0 parser that understands XML name spaces.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="errors/">errors</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package errors implements functions to manipulate errors.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="expvar/">expvar</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package expvar provides a standardized interface to public variables, such as operation counters in servers.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="flag/">flag</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package flag implements command-line flag parsing.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="fmt/">fmt</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package fmt implements formatted I/O with functions analogous to C's printf and scanf.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="go/">go</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/ast/">ast</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ast declares the types used to represent syntax trees for Go packages.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/build/">build</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package build gathers information about Go packages.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/constant/">constant</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package constant implements Values representing untyped Go constants and their corresponding operations.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/doc/">doc</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package doc extracts source code documentation from a Go AST.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/format/">format</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package format implements standard formatting of Go source.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/importer/">importer</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package importer provides access to export data importers.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/parser/">parser</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package parser implements a parser for Go source files.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/printer/">printer</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package printer implements printing of AST nodes.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/scanner/">scanner</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package scanner implements a scanner for Go source text.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/token/">token</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="go/types/">types</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package types declares the data types and implements the algorithms for type-checking of Go packages.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="hash/">hash</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package hash provides interfaces for hash functions.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="hash/adler32/">adler32</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package adler32 implements the Adler-32 checksum.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="hash/crc32/">crc32</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, checksum.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="hash/crc64/">crc64</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package crc64 implements the 64-bit cyclic redundancy check, or CRC-64, checksum.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="hash/fnv/">fnv</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package fnv implements FNV-1 and FNV-1a, non-cryptographic hash functions created by Glenn Fowler, Landon Curt Noll, and Phong Vo.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="hash/maphash/">maphash</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package maphash provides hash functions on byte sequences.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="html/">html</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package html provides functions for escaping and unescaping HTML text.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="html/template/">template</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package template (html/template) implements data-driven templates for generating HTML output safe against code injection.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="image/">image</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package image implements a basic 2-D image library.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="image/color/">color</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package color implements a basic color library.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="image/color/palette/">palette</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package palette provides standard color palettes.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="image/draw/">draw</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package draw provides image composition functions.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="image/gif/">gif</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package gif implements a GIF image decoder and encoder.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="image/jpeg/">jpeg</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package jpeg implements a JPEG image decoder and encoder.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="image/png/">png</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package png implements a PNG image decoder and encoder.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="index/">index</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="index/suffixarray/">suffixarray</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="io/">io</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package io provides basic interfaces to I/O primitives.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="io/ioutil/">ioutil</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package ioutil implements some I/O utility functions.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="log/">log</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package log implements a simple logging package.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="log/syslog/">syslog</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package syslog provides a simple interface to the system log service.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="math/">math</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package math provides basic constants and mathematical functions.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="math/big/">big</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package big implements arbitrary-precision arithmetic (big numbers).
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="math/bits/">bits</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package bits implements bit counting and manipulation functions for the predeclared unsigned integer types.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="math/cmplx/">cmplx</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package cmplx provides basic constants and mathematical functions for complex numbers.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="math/rand/">rand</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package rand implements pseudo-random number generators.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="mime/">mime</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package mime implements parts of the MIME spec.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="mime/multipart/">multipart</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package multipart implements MIME multipart parsing, as defined in RFC 2046.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="mime/quotedprintable/">quotedprintable</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package quotedprintable implements quoted-printable encoding as specified by RFC 2045.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="net/">net</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package net provides a portable interface for network I/O, including TCP/IP, UDP, domain name resolution, and Unix domain sockets.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/http/">http</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package http provides HTTP client and server implementations.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/cgi/">cgi</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package cgi implements CGI (Common Gateway Interface) as specified in RFC 3875.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/cookiejar/">cookiejar</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/fcgi/">fcgi</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package fcgi implements the FastCGI protocol.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/httptest/">httptest</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package httptest provides utilities for HTTP testing.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/httptrace/">httptrace</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package httptrace provides mechanisms to trace the events within HTTP client requests.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/httputil/">httputil</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package httputil provides HTTP utility functions, complementing the more common ones in the net/http package.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/http/pprof/">pprof</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/mail/">mail</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package mail implements parsing of mail messages.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/rpc/">rpc</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package rpc provides access to the exported methods of an object across a network or other I/O connection.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="net/rpc/jsonrpc/">jsonrpc</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package jsonrpc implements a JSON-RPC 1.0 ClientCodec and ServerCodec for the rpc package.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/smtp/">smtp</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/textproto/">textproto</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package textproto implements generic support for text-based request/response protocols in the style of HTTP, NNTP, and SMTP.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="net/url/">url</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package url parses URLs and implements query escaping.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="os/">os</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package os provides a platform-independent interface to operating system functionality.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="os/exec/">exec</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package exec runs external commands.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="os/signal/">signal</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package signal implements access to incoming signals.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="os/user/">user</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package user allows user account lookups by name or id.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="path/">path</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package path implements utility routines for manipulating slash-separated paths.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="path/filepath/">filepath</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="plugin/">plugin</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package plugin implements loading and symbol resolution of Go plugins.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="reflect/">reflect</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="regexp/">regexp</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package regexp implements regular expression search.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="regexp/syntax/">syntax</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package syntax parses regular expressions into parse trees and compiles parse trees into programs.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="runtime/">runtime</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/cgo/">cgo</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package cgo contains runtime support for code generated by the cgo tool.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/debug/">debug</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package debug contains facilities for programs to debug themselves while they are running.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/msan/">msan</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/pprof/">pprof</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package pprof writes runtime profiling data in the format expected by the pprof visualization tool.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/race/">race</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package race implements data race detection logic.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="runtime/trace/">trace</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package trace contains facilities for programs to generate traces for the Go execution tracer.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="sort/">sort</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sort provides primitives for sorting slices and user-defined collections.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="strconv/">strconv</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package strconv implements conversions to and from string representations of basic data types.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="strings/">strings</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package strings implements simple functions to manipulate UTF-8 encoded strings.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="sync/">sync</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package sync provides basic synchronization primitives such as mutual exclusion locks.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="sync/atomic/">atomic</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="syscall/">syscall</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package syscall contains an interface to the low-level operating system primitives.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="syscall/js/">js</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package js gives access to the WebAssembly host environment when using the js/wasm architecture.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="testing/">testing</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package testing provides support for automated testing of Go packages.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="testing/iotest/">iotest</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package iotest implements Readers and Writers useful mainly for testing.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="testing/quick/">quick</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package quick implements utility functions to help with black box testing.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="text/">text</a>
+ </td>
+
+ <td class="pkg-synopsis">
+
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="text/scanner/">scanner</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package scanner provides a scanner and tokenizer for UTF-8-encoded text.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="text/tabwriter/">tabwriter</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package tabwriter implements a write filter (tabwriter.Writer) that translates tabbed columns in input into properly aligned text.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="text/template/">template</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package template implements data-driven templates for generating textual output.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 40px;">
+ <a href="text/template/parse/">parse</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package parse builds parse trees for templates as defined by text/template and html/template.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="time/">time</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package time provides functionality for measuring and displaying time.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="time/tzdata/">tzdata</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package tzdata provides an embedded copy of the timezone database.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="unicode/">unicode</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package unicode provides data and functions to test some properties of Unicode code points.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="unicode/utf16/">utf16</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package utf16 implements encoding and decoding of UTF-16 sequences.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 20px;">
+ <a href="unicode/utf8/">utf8</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package utf8 implements functions and constants to support text encoded in UTF-8.
+ </td>
+
+ </tr>
+
+ <tr>
+
+
+ <td class="pkg-name" style="padding-left: 0px;">
+ <a href="unsafe/">unsafe</a>
+ </td>
+
+ <td class="pkg-synopsis">
+ Package unsafe contains operations that step around the type safety of Go programs.
+ </td>
+
+ </tr>
+
+ </table>
+ </div> <!-- .pkg-dir -->
+ </div> <!-- .expanded -->
+ </div> <!-- #stdlib .toggleVisible -->
+
+
+
+ <h2 id="other">Other packages</h2>
+ <h3 id="subrepo">Sub-repositories</h3>
+ <p>
+ These packages are part of the Go Project but outside the main Go tree.
+ They are developed under looser <a href="/doc/go1compat">compatibility requirements</a> than the Go core.
+ Install them with "<a href="/cmd/go/#hdr-Download_and_install_packages_and_dependencies">go get</a>".
+ </p>
+ <ul>
+ <li><a href="//pkg.go.dev/golang.org/x/benchmarks">benchmarks</a> — benchmarks to measure Go as it is developed.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/blog">blog</a> — <a href="//blog.golang.org">blog.golang.org</a>'s implementation.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/build">build</a> — <a href="//build.golang.org">build.golang.org</a>'s implementation.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/crypto">crypto</a> — additional cryptography packages.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/debug">debug</a> — an experimental debugger for Go.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/image">image</a> — additional imaging packages.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/mobile">mobile</a> — experimental support for Go on mobile platforms.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/net">net</a> — additional networking packages.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/perf">perf</a> — packages and tools for performance measurement, storage, and analysis.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/pkgsite">pkgsite</a> — home of the pkg.go.dev website.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/review">review</a> — a tool for working with Gerrit code reviews.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/sync">sync</a> — additional concurrency primitives.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/sys">sys</a> — packages for making system calls.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/text">text</a> — packages for working with text.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/time">time</a> — additional time packages.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/tools">tools</a> — godoc, goimports, gorename, and other tools.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/tour">tour</a> — <a href="//tour.golang.org">tour.golang.org</a>'s implementation.</li>
+ <li><a href="//pkg.go.dev/golang.org/x/exp">exp</a> — experimental and deprecated packages (handle with care; may change without warning).</li>
+ </ul>
+
+ <h3 id="community">Community</h3>
+ <p>
+ These services can help you find Open Source packages provided by the community.
+ </p>
+ <ul>
+ <li><a href="//pkg.go.dev">Pkg.go.dev</a> - the Go package discovery site.</li>
+ <li><a href="/wiki/Projects">Projects at the Go Wiki</a> - a curated list of Go projects.</li>
+ </ul>
+
+
+
+</div><!-- .container -->
+</main><!-- #page -->
+<footer>
+ <div class="Footer Footer--wide">
+ <img class="Footer-gopher" src="/lib/godoc/images/footer-gopher.jpg" alt="The Go Gopher">
+ <ul class="Footer-links">
+ <li class="Footer-link"><a href="/doc/copyright.html">Copyright</a></li>
+ <li class="Footer-link"><a href="/doc/tos.html">Terms of Service</a></li>
+ <li class="Footer-link"><a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a></li>
+ <li class="Footer-link"><a href="http://golang.org/issues/new?title=x/website:" target="_blank" rel="noopener">Report a website issue</a></li>
+ </ul>
+ <a class="Footer-supportedBy" href="https://google.com">Supported by Google</a>
+ </div>
+</footer>
+
+<script>
+(function() {
+ var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
+ ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
+ var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+
--- /dev/null
+++ b/js/godoc/playground.js
@@ -1,0 +1,575 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+/*
+In the absence of any formal way to specify interfaces in JavaScript,
+here's a skeleton implementation of a playground transport.
+
+ function Transport() {
+ // Set up any transport state (eg, make a websocket connection).
+ return {
+ Run: function(body, output, options) {
+ // Compile and run the program 'body' with 'options'.
+ // Call the 'output' callback to display program output.
+ return {
+ Kill: function() {
+ // Kill the running program.
+ }
+ };
+ }
+ };
+ }
+
+ // The output callback is called multiple times, and each time it is
+ // passed an object of this form.
+ var write = {
+ Kind: 'string', // 'start', 'stdout', 'stderr', 'end'
+ Body: 'string' // content of write or end status message
+ }
+
+ // The first call must be of Kind 'start' with no body.
+ // Subsequent calls may be of Kind 'stdout' or 'stderr'
+ // and must have a non-null Body string.
+ // The final call should be of Kind 'end' with an optional
+ // Body string, signifying a failure ("killed", for example).
+
+ // The output callback must be of this form.
+ // See PlaygroundOutput (below) for an implementation.
+ function outputCallback(write) {
+ }
+*/
+
+// HTTPTransport is the default transport.
+// enableVet enables running vet if a program was compiled and ran successfully.
+// If vet returned any errors, display them before the output of a program.
+function HTTPTransport(enableVet) {
+ 'use strict';
+
+ function playback(output, data) {
+ // Backwards compatibility: default values do not affect the output.
+ var events = data.Events || [];
+ var errors = data.Errors || '';
+ var status = data.Status || 0;
+ var isTest = data.IsTest || false;
+ var testsFailed = data.TestsFailed || 0;
+
+ var timeout;
+ output({ Kind: 'start' });
+ function next() {
+ if (!events || events.length === 0) {
+ if (isTest) {
+ if (testsFailed > 0) {
+ output({
+ Kind: 'system',
+ Body:
+ '\n' +
+ testsFailed +
+ ' test' +
+ (testsFailed > 1 ? 's' : '') +
+ ' failed.',
+ });
+ } else {
+ output({ Kind: 'system', Body: '\nAll tests passed.' });
+ }
+ } else {
+ if (status > 0) {
+ output({ Kind: 'end', Body: 'status ' + status + '.' });
+ } else {
+ if (errors !== '') {
+ // errors are displayed only in the case of timeout.
+ output({ Kind: 'end', Body: errors + '.' });
+ } else {
+ output({ Kind: 'end' });
+ }
+ }
+ }
+ return;
+ }
+ var e = events.shift();
+ if (e.Delay === 0) {
+ output({ Kind: e.Kind, Body: e.Message });
+ next();
+ return;
+ }
+ timeout = setTimeout(function() {
+ output({ Kind: e.Kind, Body: e.Message });
+ next();
+ }, e.Delay / 1000000);
+ }
+ next();
+ return {
+ Stop: function() {
+ clearTimeout(timeout);
+ },
+ };
+ }
+
+ function error(output, msg) {
+ output({ Kind: 'start' });
+ output({ Kind: 'stderr', Body: msg });
+ output({ Kind: 'end' });
+ }
+
+ function buildFailed(output, msg) {
+ output({ Kind: 'start' });
+ output({ Kind: 'stderr', Body: msg });
+ output({ Kind: 'system', Body: '\nGo build failed.' });
+ }
+
+ var seq = 0;
+ return {
+ Run: function(body, output, options) {
+ seq++;
+ var cur = seq;
+ var playing;
+ $.ajax('/compile', {
+ type: 'POST',
+ data: { version: 2, body: body },
+ dataType: 'json',
+ success: function(data) {
+ if (seq != cur) return;
+ if (!data) return;
+ if (playing != null) playing.Stop();
+ if (data.Errors) {
+ if (data.Errors === 'process took too long') {
+ // Playback the output that was captured before the timeout.
+ playing = playback(output, data);
+ } else {
+ buildFailed(output, data.Errors);
+ }
+ return;
+ }
+
+ if (!enableVet) {
+ playing = playback(output, data);
+ return;
+ }
+
+ $.ajax('/vet', {
+ data: { body: body },
+ type: 'POST',
+ dataType: 'json',
+ success: function(dataVet) {
+ if (dataVet.Errors) {
+ if (!data.Events) {
+ data.Events = [];
+ }
+ // inject errors from the vet as the first events in the output
+ data.Events.unshift({
+ Message: 'Go vet exited.\n\n',
+ Kind: 'system',
+ Delay: 0,
+ });
+ data.Events.unshift({
+ Message: dataVet.Errors,
+ Kind: 'stderr',
+ Delay: 0,
+ });
+ }
+ playing = playback(output, data);
+ },
+ error: function() {
+ playing = playback(output, data);
+ },
+ });
+ },
+ error: function() {
+ error(output, 'Error communicating with remote server.');
+ },
+ });
+ return {
+ Kill: function() {
+ if (playing != null) playing.Stop();
+ output({ Kind: 'end', Body: 'killed' });
+ },
+ };
+ },
+ };
+}
+
+function SocketTransport() {
+ 'use strict';
+
+ var id = 0;
+ var outputs = {};
+ var started = {};
+ var websocket;
+ if (window.location.protocol == 'http:') {
+ websocket = new WebSocket('ws://' + window.location.host + '/socket');
+ } else if (window.location.protocol == 'https:') {
+ websocket = new WebSocket('wss://' + window.location.host + '/socket');
+ }
+
+ websocket.onclose = function() {
+ console.log('websocket connection closed');
+ };
+
+ websocket.onmessage = function(e) {
+ var m = JSON.parse(e.data);
+ var output = outputs[m.Id];
+ if (output === null) return;
+ if (!started[m.Id]) {
+ output({ Kind: 'start' });
+ started[m.Id] = true;
+ }
+ output({ Kind: m.Kind, Body: m.Body });
+ };
+
+ function send(m) {
+ websocket.send(JSON.stringify(m));
+ }
+
+ return {
+ Run: function(body, output, options) {
+ var thisID = id + '';
+ id++;
+ outputs[thisID] = output;
+ send({ Id: thisID, Kind: 'run', Body: body, Options: options });
+ return {
+ Kill: function() {
+ send({ Id: thisID, Kind: 'kill' });
+ },
+ };
+ },
+ };
+}
+
+function PlaygroundOutput(el) {
+ 'use strict';
+
+ return function(write) {
+ if (write.Kind == 'start') {
+ el.innerHTML = '';
+ return;
+ }
+
+ var cl = 'system';
+ if (write.Kind == 'stdout' || write.Kind == 'stderr') cl = write.Kind;
+
+ var m = write.Body;
+ if (write.Kind == 'end') {
+ m = '\nProgram exited' + (m ? ': ' + m : '.');
+ }
+
+ if (m.indexOf('IMAGE:') === 0) {
+ // TODO(adg): buffer all writes before creating image
+ var url = 'data:image/png;base64,' + m.substr(6);
+ var img = document.createElement('img');
+ img.src = url;
+ el.appendChild(img);
+ return;
+ }
+
+ // ^L clears the screen.
+ var s = m.split('\x0c');
+ if (s.length > 1) {
+ el.innerHTML = '';
+ m = s.pop();
+ }
+
+ m = m.replace(/&/g, '&');
+ m = m.replace(/</g, '<');
+ m = m.replace(/>/g, '>');
+
+ var needScroll = el.scrollTop + el.offsetHeight == el.scrollHeight;
+
+ var span = document.createElement('span');
+ span.className = cl;
+ span.innerHTML = m;
+ el.appendChild(span);
+
+ if (needScroll) el.scrollTop = el.scrollHeight - el.offsetHeight;
+ };
+}
+
+(function() {
+ function lineHighlight(error) {
+ var regex = /prog.go:([0-9]+)/g;
+ var r = regex.exec(error);
+ while (r) {
+ $('.lines div')
+ .eq(r[1] - 1)
+ .addClass('lineerror');
+ r = regex.exec(error);
+ }
+ }
+ function highlightOutput(wrappedOutput) {
+ return function(write) {
+ if (write.Body) lineHighlight(write.Body);
+ wrappedOutput(write);
+ };
+ }
+ function lineClear() {
+ $('.lineerror').removeClass('lineerror');
+ }
+
+ // opts is an object with these keys
+ // codeEl - code editor element
+ // outputEl - program output element
+ // runEl - run button element
+ // fmtEl - fmt button element (optional)
+ // fmtImportEl - fmt "imports" checkbox element (optional)
+ // shareEl - share button element (optional)
+ // shareURLEl - share URL text input element (optional)
+ // shareRedirect - base URL to redirect to on share (optional)
+ // toysEl - toys select element (optional)
+ // enableHistory - enable using HTML5 history API (optional)
+ // transport - playground transport to use (default is HTTPTransport)
+ // enableShortcuts - whether to enable shortcuts (Ctrl+S/Cmd+S to save) (default is false)
+ // enableVet - enable running vet and displaying its errors
+ function playground(opts) {
+ var code = $(opts.codeEl);
+ var transport = opts['transport'] || new HTTPTransport(opts['enableVet']);
+ var running;
+
+ // autoindent helpers.
+ function insertTabs(n) {
+ // find the selection start and end
+ var start = code[0].selectionStart;
+ var end = code[0].selectionEnd;
+ // split the textarea content into two, and insert n tabs
+ var v = code[0].value;
+ var u = v.substr(0, start);
+ for (var i = 0; i < n; i++) {
+ u += '\t';
+ }
+ u += v.substr(end);
+ // set revised content
+ code[0].value = u;
+ // reset caret position after inserted tabs
+ code[0].selectionStart = start + n;
+ code[0].selectionEnd = start + n;
+ }
+ function autoindent(el) {
+ var curpos = el.selectionStart;
+ var tabs = 0;
+ while (curpos > 0) {
+ curpos--;
+ if (el.value[curpos] == '\t') {
+ tabs++;
+ } else if (tabs > 0 || el.value[curpos] == '\n') {
+ break;
+ }
+ }
+ setTimeout(function() {
+ insertTabs(tabs);
+ }, 1);
+ }
+
+ // NOTE(cbro): e is a jQuery event, not a DOM event.
+ function handleSaveShortcut(e) {
+ if (e.isDefaultPrevented()) return false;
+ if (!e.metaKey && !e.ctrlKey) return false;
+ if (e.key != 'S' && e.key != 's') return false;
+
+ e.preventDefault();
+
+ // Share and save
+ share(function(url) {
+ window.location.href = url + '.go?download=true';
+ });
+
+ return true;
+ }
+
+ function keyHandler(e) {
+ if (opts.enableShortcuts && handleSaveShortcut(e)) return;
+
+ if (e.keyCode == 9 && !e.ctrlKey) {
+ // tab (but not ctrl-tab)
+ insertTabs(1);
+ e.preventDefault();
+ return false;
+ }
+ if (e.keyCode == 13) {
+ // enter
+ if (e.shiftKey) {
+ // +shift
+ run();
+ e.preventDefault();
+ return false;
+ }
+ if (e.ctrlKey) {
+ // +control
+ fmt();
+ e.preventDefault();
+ } else {
+ autoindent(e.target);
+ }
+ }
+ return true;
+ }
+ code.unbind('keydown').bind('keydown', keyHandler);
+ var outdiv = $(opts.outputEl).empty();
+ var output = $('<pre/>').appendTo(outdiv);
+
+ function body() {
+ return $(opts.codeEl).val();
+ }
+ function setBody(text) {
+ $(opts.codeEl).val(text);
+ }
+ function origin(href) {
+ return ('' + href)
+ .split('/')
+ .slice(0, 3)
+ .join('/');
+ }
+
+ var pushedEmpty = window.location.pathname == '/';
+ function inputChanged() {
+ if (pushedEmpty) {
+ return;
+ }
+ pushedEmpty = true;
+ $(opts.shareURLEl).hide();
+ window.history.pushState(null, '', '/');
+ }
+ function popState(e) {
+ if (e === null) {
+ return;
+ }
+ if (e && e.state && e.state.code) {
+ setBody(e.state.code);
+ }
+ }
+ var rewriteHistory = false;
+ if (
+ window.history &&
+ window.history.pushState &&
+ window.addEventListener &&
+ opts.enableHistory
+ ) {
+ rewriteHistory = true;
+ code[0].addEventListener('input', inputChanged);
+ window.addEventListener('popstate', popState);
+ }
+
+ function setError(error) {
+ if (running) running.Kill();
+ lineClear();
+ lineHighlight(error);
+ output
+ .empty()
+ .addClass('error')
+ .text(error);
+ }
+ function loading() {
+ lineClear();
+ if (running) running.Kill();
+ output.removeClass('error').text('Waiting for remote server...');
+ }
+ function run() {
+ loading();
+ running = transport.Run(
+ body(),
+ highlightOutput(PlaygroundOutput(output[0]))
+ );
+ }
+
+ function fmt() {
+ loading();
+ var data = { body: body() };
+ if ($(opts.fmtImportEl).is(':checked')) {
+ data['imports'] = 'true';
+ }
+ $.ajax('/fmt', {
+ data: data,
+ type: 'POST',
+ dataType: 'json',
+ success: function(data) {
+ if (data.Error) {
+ setError(data.Error);
+ } else {
+ setBody(data.Body);
+ setError('');
+ }
+ },
+ });
+ }
+
+ var shareURL; // jQuery element to show the shared URL.
+ var sharing = false; // true if there is a pending request.
+ var shareCallbacks = [];
+ function share(opt_callback) {
+ if (opt_callback) shareCallbacks.push(opt_callback);
+
+ if (sharing) return;
+ sharing = true;
+
+ var sharingData = body();
+ $.ajax('/share', {
+ processData: false,
+ data: sharingData,
+ type: 'POST',
+ contentType: 'text/plain; charset=utf-8',
+ complete: function(xhr) {
+ sharing = false;
+ if (xhr.status != 200) {
+ alert('Server error; try again.');
+ return;
+ }
+ if (opts.shareRedirect) {
+ window.location = opts.shareRedirect + xhr.responseText;
+ }
+ var path = '/p/' + xhr.responseText;
+ var url = origin(window.location) + path;
+
+ for (var i = 0; i < shareCallbacks.length; i++) {
+ shareCallbacks[i](url);
+ }
+ shareCallbacks = [];
+
+ if (shareURL) {
+ shareURL
+ .show()
+ .val(url)
+ .focus()
+ .select();
+
+ if (rewriteHistory) {
+ var historyData = { code: sharingData };
+ window.history.pushState(historyData, '', path);
+ pushedEmpty = false;
+ }
+ }
+ },
+ });
+ }
+
+ $(opts.runEl).click(run);
+ $(opts.fmtEl).click(fmt);
+
+ if (
+ opts.shareEl !== null &&
+ (opts.shareURLEl !== null || opts.shareRedirect !== null)
+ ) {
+ if (opts.shareURLEl) {
+ shareURL = $(opts.shareURLEl).hide();
+ }
+ $(opts.shareEl).click(function() {
+ share();
+ });
+ }
+
+ if (opts.toysEl !== null) {
+ $(opts.toysEl).bind('change', function() {
+ var toy = $(this).val();
+ $.ajax('/doc/play/' + toy, {
+ processData: false,
+ type: 'GET',
+ complete: function(xhr) {
+ if (xhr.status != 200) {
+ alert('Server error; try again.');
+ return;
+ }
+ setBody(xhr.responseText);
+ },
+ });
+ });
+ }
+ }
+
+ window.playground = playground;
+})();
--- /dev/null
+++ b/js/jquery-3.5.1.js
@@ -1,0 +1,10872 @@
+/*!
+ * jQuery JavaScript Library v3.5.1
+ * https://jquery.com/
+ *
+ * Includes Sizzle.js
+ * https://sizzlejs.com/
+ *
+ * Copyright JS Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: 2020-05-04T22:49Z
+ */
+( function( global, factory ) {
+
+ "use strict";
+
+ if ( typeof module === "object" && typeof module.exports === "object" ) {
+
+ // For CommonJS and CommonJS-like environments where a proper `window`
+ // is present, execute the factory and get jQuery.
+ // For environments that do not have a `window` with a `document`
+ // (such as Node.js), expose a factory as module.exports.
+ // This accentuates the need for the creation of a real `window`.
+ // e.g. var jQuery = require("jquery")(window);
+ // See ticket #14549 for more info.
+ module.exports = global.document ?
+ factory( global, true ) :
+ function( w ) {
+ if ( !w.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+ }
+ return factory( w );
+ };
+ } else {
+ factory( global );
+ }
+
+// Pass this if window is not defined yet
+} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
+
+// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
+// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
+// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
+// enough that all such attempts are guarded in a try block.
+"use strict";
+
+var arr = [];
+
+var getProto = Object.getPrototypeOf;
+
+var slice = arr.slice;
+
+var flat = arr.flat ? function( array ) {
+ return arr.flat.call( array );
+} : function( array ) {
+ return arr.concat.apply( [], array );
+};
+
+
+var push = arr.push;
+
+var indexOf = arr.indexOf;
+
+var class2type = {};
+
+var toString = class2type.toString;
+
+var hasOwn = class2type.hasOwnProperty;
+
+var fnToString = hasOwn.toString;
+
+var ObjectFunctionString = fnToString.call( Object );
+
+var support = {};
+
+var isFunction = function isFunction( obj ) {
+
+ // Support: Chrome <=57, Firefox <=52
+ // In some browsers, typeof returns "function" for HTML <object> elements
+ // (i.e., `typeof document.createElement( "object" ) === "function"`).
+ // We don't want to classify *any* DOM node as a function.
+ return typeof obj === "function" && typeof obj.nodeType !== "number";
+ };
+
+
+var isWindow = function isWindow( obj ) {
+ return obj != null && obj === obj.window;
+ };
+
+
+var document = window.document;
+
+
+
+ var preservedScriptAttributes = {
+ type: true,
+ src: true,
+ nonce: true,
+ noModule: true
+ };
+
+ function DOMEval( code, node, doc ) {
+ doc = doc || document;
+
+ var i, val,
+ script = doc.createElement( "script" );
+
+ script.text = code;
+ if ( node ) {
+ for ( i in preservedScriptAttributes ) {
+
+ // Support: Firefox 64+, Edge 18+
+ // Some browsers don't support the "nonce" property on scripts.
+ // On the other hand, just using `getAttribute` is not enough as
+ // the `nonce` attribute is reset to an empty string whenever it
+ // becomes browsing-context connected.
+ // See https://github.com/whatwg/html/issues/2369
+ // See https://html.spec.whatwg.org/#nonce-attributes
+ // The `node.getAttribute` check was added for the sake of
+ // `jQuery.globalEval` so that it can fake a nonce-containing node
+ // via an object.
+ val = node[ i ] || node.getAttribute && node.getAttribute( i );
+ if ( val ) {
+ script.setAttribute( i, val );
+ }
+ }
+ }
+ doc.head.appendChild( script ).parentNode.removeChild( script );
+ }
+
+
+function toType( obj ) {
+ if ( obj == null ) {
+ return obj + "";
+ }
+
+ // Support: Android <=2.3 only (functionish RegExp)
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[ toString.call( obj ) ] || "object" :
+ typeof obj;
+}
+/* global Symbol */
+// Defining this global in .eslintrc.json would create a danger of using the global
+// unguarded in another place, it seems safer to define global only for this module
+
+
+
+var
+ version = "3.5.1",
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+
+ // The jQuery object is actually just the init constructor 'enhanced'
+ // Need init if jQuery is called (just allow error to be thrown if not included)
+ return new jQuery.fn.init( selector, context );
+ };
+
+jQuery.fn = jQuery.prototype = {
+
+ // The current version of jQuery being used
+ jquery: version,
+
+ constructor: jQuery,
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ toArray: function() {
+ return slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+
+ // Return all the elements in a clean array
+ if ( num == null ) {
+ return slice.call( this );
+ }
+
+ // Return just the one element from the set
+ return num < 0 ? this[ num + this.length ] : this[ num ];
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ each: function( callback ) {
+ return jQuery.each( this, callback );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map( this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ } ) );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ) );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ even: function() {
+ return this.pushStack( jQuery.grep( this, function( _elem, i ) {
+ return ( i + 1 ) % 2;
+ } ) );
+ },
+
+ odd: function() {
+ return this.pushStack( jQuery.grep( this, function( _elem, i ) {
+ return i % 2;
+ } ) );
+ },
+
+ eq: function( i ) {
+ var len = this.length,
+ j = +i + ( i < 0 ? len : 0 );
+ return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor();
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: arr.sort,
+ splice: arr.splice
+};
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[ 0 ] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+
+ // Skip the boolean and the target
+ target = arguments[ i ] || {};
+ i++;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !isFunction( target ) ) {
+ target = {};
+ }
+
+ // Extend jQuery itself if only one argument is passed
+ if ( i === length ) {
+ target = this;
+ i--;
+ }
+
+ for ( ; i < length; i++ ) {
+
+ // Only deal with non-null/undefined values
+ if ( ( options = arguments[ i ] ) != null ) {
+
+ // Extend the base object
+ for ( name in options ) {
+ copy = options[ name ];
+
+ // Prevent Object.prototype pollution
+ // Prevent never-ending loop
+ if ( name === "__proto__" || target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
+ ( copyIsArray = Array.isArray( copy ) ) ) ) {
+ src = target[ name ];
+
+ // Ensure proper type for the source value
+ if ( copyIsArray && !Array.isArray( src ) ) {
+ clone = [];
+ } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
+ clone = {};
+ } else {
+ clone = src;
+ }
+ copyIsArray = false;
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend( {
+
+ // Unique for each copy of jQuery on the page
+ expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
+
+ // Assume jQuery is ready without the ready module
+ isReady: true,
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ noop: function() {},
+
+ isPlainObject: function( obj ) {
+ var proto, Ctor;
+
+ // Detect obvious negatives
+ // Use toString instead of jQuery.type to catch host objects
+ if ( !obj || toString.call( obj ) !== "[object Object]" ) {
+ return false;
+ }
+
+ proto = getProto( obj );
+
+ // Objects with no prototype (e.g., `Object.create( null )`) are plain
+ if ( !proto ) {
+ return true;
+ }
+
+ // Objects with prototype are plain iff they were constructed by a global Object function
+ Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
+ return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ // Evaluates a script in a provided context; falls back to the global one
+ // if not specified.
+ globalEval: function( code, options, doc ) {
+ DOMEval( code, { nonce: options && options.nonce }, doc );
+ },
+
+ each: function( obj, callback ) {
+ var length, i = 0;
+
+ if ( isArrayLike( obj ) ) {
+ length = obj.length;
+ for ( ; i < length; i++ ) {
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+ break;
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var ret = results || [];
+
+ if ( arr != null ) {
+ if ( isArrayLike( Object( arr ) ) ) {
+ jQuery.merge( ret,
+ typeof arr === "string" ?
+ [ arr ] : arr
+ );
+ } else {
+ push.call( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ return arr == null ? -1 : indexOf.call( arr, elem, i );
+ },
+
+ // Support: Android <=4.0 only, PhantomJS 1 only
+ // push.apply(_, arraylike) throws on ancient WebKit
+ merge: function( first, second ) {
+ var len = +second.length,
+ j = 0,
+ i = first.length;
+
+ for ( ; j < len; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, invert ) {
+ var callbackInverse,
+ matches = [],
+ i = 0,
+ length = elems.length,
+ callbackExpect = !invert;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ callbackInverse = !callback( elems[ i ], i );
+ if ( callbackInverse !== callbackExpect ) {
+ matches.push( elems[ i ] );
+ }
+ }
+
+ return matches;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var length, value,
+ i = 0,
+ ret = [];
+
+ // Go through the array, translating each of the items to their new values
+ if ( isArrayLike( elems ) ) {
+ length = elems.length;
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret.push( value );
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( i in elems ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret.push( value );
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return flat( ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // jQuery.support is not used in Core but other projects attach their
+ // properties to it so it needs to exist.
+ support: support
+} );
+
+if ( typeof Symbol === "function" ) {
+ jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
+}
+
+// Populate the class2type map
+jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
+function( _i, name ) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+} );
+
+function isArrayLike( obj ) {
+
+ // Support: real iOS 8.2 only (not reproducible in simulator)
+ // `in` check used to prevent JIT error (gh-2145)
+ // hasOwn isn't used here due to false negatives
+ // regarding Nodelist length in IE
+ var length = !!obj && "length" in obj && obj.length,
+ type = toType( obj );
+
+ if ( isFunction( obj ) || isWindow( obj ) ) {
+ return false;
+ }
+
+ return type === "array" || length === 0 ||
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj;
+}
+var Sizzle =
+/*!
+ * Sizzle CSS Selector Engine v2.3.5
+ * https://sizzlejs.com/
+ *
+ * Copyright JS Foundation and other contributors
+ * Released under the MIT license
+ * https://js.foundation/
+ *
+ * Date: 2020-03-14
+ */
+( function( window ) {
+var i,
+ support,
+ Expr,
+ getText,
+ isXML,
+ tokenize,
+ compile,
+ select,
+ outermostContext,
+ sortInput,
+ hasDuplicate,
+
+ // Local document vars
+ setDocument,
+ document,
+ docElem,
+ documentIsHTML,
+ rbuggyQSA,
+ rbuggyMatches,
+ matches,
+ contains,
+
+ // Instance-specific data
+ expando = "sizzle" + 1 * new Date(),
+ preferredDoc = window.document,
+ dirruns = 0,
+ done = 0,
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+ nonnativeSelectorCache = createCache(),
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ }
+ return 0;
+ },
+
+ // Instance methods
+ hasOwn = ( {} ).hasOwnProperty,
+ arr = [],
+ pop = arr.pop,
+ pushNative = arr.push,
+ push = arr.push,
+ slice = arr.slice,
+
+ // Use a stripped-down indexOf as it's faster than native
+ // https://jsperf.com/thor-indexof-vs-for/5
+ indexOf = function( list, elem ) {
+ var i = 0,
+ len = list.length;
+ for ( ; i < len; i++ ) {
+ if ( list[ i ] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
+ "ismap|loop|multiple|open|readonly|required|scoped",
+
+ // Regular expressions
+
+ // http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+
+ // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
+ identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
+ "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
+
+ // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
+ attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
+
+ // Operator (capture 2)
+ "*([*^$|!~]?=)" + whitespace +
+
+ // "Attribute values must be CSS identifiers [capture 5]
+ // or strings [capture 3 or capture 4]"
+ "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
+ whitespace + "*\\]",
+
+ pseudos = ":(" + identifier + ")(?:\\((" +
+
+ // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
+ // 1. quoted (capture 3; capture 4 or capture 5)
+ "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
+
+ // 2. simple (capture 6)
+ "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
+
+ // 3. anything else (capture 2)
+ ".*" +
+ ")\\)|)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rwhitespace = new RegExp( whitespace + "+", "g" ),
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
+ whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
+ "*" ),
+ rdescend = new RegExp( whitespace + "|>" ),
+
+ rpseudo = new RegExp( pseudos ),
+ ridentifier = new RegExp( "^" + identifier + "$" ),
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + identifier + ")" ),
+ "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
+ "TAG": new RegExp( "^(" + identifier + "|[*])" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
+ whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
+ whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
+
+ // For use in libraries implementing .is()
+ // We use this for POS matching in `select`
+ "needsContext": new RegExp( "^" + whitespace +
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+ },
+
+ rhtml = /HTML$/i,
+ rinputs = /^(?:input|select|textarea|button)$/i,
+ rheader = /^h\d$/i,
+
+ rnative = /^[^{]+\{\s*\[native \w/,
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+ rsibling = /[+~]/,
+
+ // CSS escapes
+ // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+ runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
+ funescape = function( escape, nonHex ) {
+ var high = "0x" + escape.slice( 1 ) - 0x10000;
+
+ return nonHex ?
+
+ // Strip the backslash prefix from a non-hex escape sequence
+ nonHex :
+
+ // Replace a hexadecimal escape sequence with the encoded Unicode code point
+ // Support: IE <=11+
+ // For values outside the Basic Multilingual Plane (BMP), manually construct a
+ // surrogate pair
+ high < 0 ?
+ String.fromCharCode( high + 0x10000 ) :
+ String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+ },
+
+ // CSS string/identifier serialization
+ // https://drafts.csswg.org/cssom/#common-serializing-idioms
+ rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
+ fcssescape = function( ch, asCodePoint ) {
+ if ( asCodePoint ) {
+
+ // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
+ if ( ch === "\0" ) {
+ return "\uFFFD";
+ }
+
+ // Control characters and (dependent upon position) numbers get escaped as code points
+ return ch.slice( 0, -1 ) + "\\" +
+ ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
+ }
+
+ // Other potentially-special ASCII characters get backslash-escaped
+ return "\\" + ch;
+ },
+
+ // Used for iframes
+ // See setDocument()
+ // Removing the function wrapper causes a "Permission Denied"
+ // error in IE
+ unloadHandler = function() {
+ setDocument();
+ },
+
+ inDisabledFieldset = addCombinator(
+ function( elem ) {
+ return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
+ },
+ { dir: "parentNode", next: "legend" }
+ );
+
+// Optimize for push.apply( _, NodeList )
+try {
+ push.apply(
+ ( arr = slice.call( preferredDoc.childNodes ) ),
+ preferredDoc.childNodes
+ );
+
+ // Support: Android<4.0
+ // Detect silently failing push.apply
+ // eslint-disable-next-line no-unused-expressions
+ arr[ preferredDoc.childNodes.length ].nodeType;
+} catch ( e ) {
+ push = { apply: arr.length ?
+
+ // Leverage slice if possible
+ function( target, els ) {
+ pushNative.apply( target, slice.call( els ) );
+ } :
+
+ // Support: IE<9
+ // Otherwise append directly
+ function( target, els ) {
+ var j = target.length,
+ i = 0;
+
+ // Can't trust NodeList.length
+ while ( ( target[ j++ ] = els[ i++ ] ) ) {}
+ target.length = j - 1;
+ }
+ };
+}
+
+function Sizzle( selector, context, results, seed ) {
+ var m, i, elem, nid, match, groups, newSelector,
+ newContext = context && context.ownerDocument,
+
+ // nodeType defaults to 9, since context defaults to document
+ nodeType = context ? context.nodeType : 9;
+
+ results = results || [];
+
+ // Return early from calls with invalid selector or context
+ if ( typeof selector !== "string" || !selector ||
+ nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
+
+ return results;
+ }
+
+ // Try to shortcut find operations (as opposed to filters) in HTML documents
+ if ( !seed ) {
+ setDocument( context );
+ context = context || document;
+
+ if ( documentIsHTML ) {
+
+ // If the selector is sufficiently simple, try using a "get*By*" DOM method
+ // (excepting DocumentFragment context, where the methods don't exist)
+ if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
+
+ // ID selector
+ if ( ( m = match[ 1 ] ) ) {
+
+ // Document context
+ if ( nodeType === 9 ) {
+ if ( ( elem = context.getElementById( m ) ) ) {
+
+ // Support: IE, Opera, Webkit
+ // TODO: identify versions
+ // getElementById can match elements by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+
+ // Element context
+ } else {
+
+ // Support: IE, Opera, Webkit
+ // TODO: identify versions
+ // getElementById can match elements by name instead of ID
+ if ( newContext && ( elem = newContext.getElementById( m ) ) &&
+ contains( context, elem ) &&
+ elem.id === m ) {
+
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Type selector
+ } else if ( match[ 2 ] ) {
+ push.apply( results, context.getElementsByTagName( selector ) );
+ return results;
+
+ // Class selector
+ } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
+ context.getElementsByClassName ) {
+
+ push.apply( results, context.getElementsByClassName( m ) );
+ return results;
+ }
+ }
+
+ // Take advantage of querySelectorAll
+ if ( support.qsa &&
+ !nonnativeSelectorCache[ selector + " " ] &&
+ ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
+
+ // Support: IE 8 only
+ // Exclude object elements
+ ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
+
+ newSelector = selector;
+ newContext = context;
+
+ // qSA considers elements outside a scoping root when evaluating child or
+ // descendant combinators, which is not what we want.
+ // In such cases, we work around the behavior by prefixing every selector in the
+ // list with an ID selector referencing the scope context.
+ // The technique has to be used as well when a leading combinator is used
+ // as such selectors are not recognized by querySelectorAll.
+ // Thanks to Andrew Dupont for this technique.
+ if ( nodeType === 1 &&
+ ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
+
+ // Expand context for sibling selectors
+ newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
+ context;
+
+ // We can use :scope instead of the ID hack if the browser
+ // supports it & if we're not changing the context.
+ if ( newContext !== context || !support.scope ) {
+
+ // Capture the context ID, setting it first if necessary
+ if ( ( nid = context.getAttribute( "id" ) ) ) {
+ nid = nid.replace( rcssescape, fcssescape );
+ } else {
+ context.setAttribute( "id", ( nid = expando ) );
+ }
+ }
+
+ // Prefix every selector in the list
+ groups = tokenize( selector );
+ i = groups.length;
+ while ( i-- ) {
+ groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
+ toSelector( groups[ i ] );
+ }
+ newSelector = groups.join( "," );
+ }
+
+ try {
+ push.apply( results,
+ newContext.querySelectorAll( newSelector )
+ );
+ return results;
+ } catch ( qsaError ) {
+ nonnativeSelectorCache( selector, true );
+ } finally {
+ if ( nid === expando ) {
+ context.removeAttribute( "id" );
+ }
+ }
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {function(string, object)} Returns the Object data after storing it on itself with
+ * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ * deleting the oldest entry
+ */
+function createCache() {
+ var keys = [];
+
+ function cache( key, value ) {
+
+ // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+ if ( keys.push( key + " " ) > Expr.cacheLength ) {
+
+ // Only keep the most recent entries
+ delete cache[ keys.shift() ];
+ }
+ return ( cache[ key + " " ] = value );
+ }
+ return cache;
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+ fn[ expando ] = true;
+ return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created element and returns a boolean result
+ */
+function assert( fn ) {
+ var el = document.createElement( "fieldset" );
+
+ try {
+ return !!fn( el );
+ } catch ( e ) {
+ return false;
+ } finally {
+
+ // Remove from its parent by default
+ if ( el.parentNode ) {
+ el.parentNode.removeChild( el );
+ }
+
+ // release memory in IE
+ el = null;
+ }
+}
+
+/**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+function addHandle( attrs, handler ) {
+ var arr = attrs.split( "|" ),
+ i = arr.length;
+
+ while ( i-- ) {
+ Expr.attrHandle[ arr[ i ] ] = handler;
+ }
+}
+
+/**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+function siblingCheck( a, b ) {
+ var cur = b && a,
+ diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+ a.sourceIndex - b.sourceIndex;
+
+ // Use IE sourceIndex if available on both nodes
+ if ( diff ) {
+ return diff;
+ }
+
+ // Check if b follows a
+ if ( cur ) {
+ while ( ( cur = cur.nextSibling ) ) {
+ if ( cur === b ) {
+ return -1;
+ }
+ }
+ }
+
+ return a ? 1 : -1;
+}
+
+/**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return ( name === "input" || name === "button" ) && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for :enabled/:disabled
+ * @param {Boolean} disabled true for :disabled; false for :enabled
+ */
+function createDisabledPseudo( disabled ) {
+
+ // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
+ return function( elem ) {
+
+ // Only certain elements can match :enabled or :disabled
+ // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
+ // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
+ if ( "form" in elem ) {
+
+ // Check for inherited disabledness on relevant non-disabled elements:
+ // * listed form-associated elements in a disabled fieldset
+ // https://html.spec.whatwg.org/multipage/forms.html#category-listed
+ // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
+ // * option elements in a disabled optgroup
+ // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
+ // All such elements have a "form" property.
+ if ( elem.parentNode && elem.disabled === false ) {
+
+ // Option elements defer to a parent optgroup if present
+ if ( "label" in elem ) {
+ if ( "label" in elem.parentNode ) {
+ return elem.parentNode.disabled === disabled;
+ } else {
+ return elem.disabled === disabled;
+ }
+ }
+
+ // Support: IE 6 - 11
+ // Use the isDisabled shortcut property to check for disabled fieldset ancestors
+ return elem.isDisabled === disabled ||
+
+ // Where there is no isDisabled, check manually
+ /* jshint -W018 */
+ elem.isDisabled !== !disabled &&
+ inDisabledFieldset( elem ) === disabled;
+ }
+
+ return elem.disabled === disabled;
+
+ // Try to winnow out elements that can't be disabled before trusting the disabled property.
+ // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
+ // even exist on them, let alone have a boolean value.
+ } else if ( "label" in elem ) {
+ return elem.disabled === disabled;
+ }
+
+ // Remaining elements are neither :enabled nor :disabled
+ return false;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+function createPositionalPseudo( fn ) {
+ return markFunction( function( argument ) {
+ argument = +argument;
+ return markFunction( function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
+ seed[ j ] = !( matches[ j ] = seed[ j ] );
+ }
+ }
+ } );
+ } );
+}
+
+/**
+ * Checks a node for validity as a Sizzle context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+function testContext( context ) {
+ return context && typeof context.getElementsByTagName !== "undefined" && context;
+}
+
+// Expose support vars for convenience
+support = Sizzle.support = {};
+
+/**
+ * Detects XML nodes
+ * @param {Element|Object} elem An element or a document
+ * @returns {Boolean} True iff elem is a non-HTML XML node
+ */
+isXML = Sizzle.isXML = function( elem ) {
+ var namespace = elem.namespaceURI,
+ docElem = ( elem.ownerDocument || elem ).documentElement;
+
+ // Support: IE <=8
+ // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
+ // https://bugs.jquery.com/ticket/4833
+ return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
+};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+ var hasCompare, subWindow,
+ doc = node ? node.ownerDocument || node : preferredDoc;
+
+ // Return early if doc is invalid or already selected
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
+ return document;
+ }
+
+ // Update global variables
+ document = doc;
+ docElem = document.documentElement;
+ documentIsHTML = !isXML( document );
+
+ // Support: IE 9 - 11+, Edge 12 - 18+
+ // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( preferredDoc != document &&
+ ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
+
+ // Support: IE 11, Edge
+ if ( subWindow.addEventListener ) {
+ subWindow.addEventListener( "unload", unloadHandler, false );
+
+ // Support: IE 9 - 10 only
+ } else if ( subWindow.attachEvent ) {
+ subWindow.attachEvent( "onunload", unloadHandler );
+ }
+ }
+
+ // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
+ // Safari 4 - 5 only, Opera <=11.6 - 12.x only
+ // IE/Edge & older browsers don't support the :scope pseudo-class.
+ // Support: Safari 6.0 only
+ // Safari 6.0 supports :scope but it's an alias of :root there.
+ support.scope = assert( function( el ) {
+ docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
+ return typeof el.querySelectorAll !== "undefined" &&
+ !el.querySelectorAll( ":scope fieldset div" ).length;
+ } );
+
+ /* Attributes
+ ---------------------------------------------------------------------- */
+
+ // Support: IE<8
+ // Verify that getAttribute really returns attributes and not properties
+ // (excepting IE8 booleans)
+ support.attributes = assert( function( el ) {
+ el.className = "i";
+ return !el.getAttribute( "className" );
+ } );
+
+ /* getElement(s)By*
+ ---------------------------------------------------------------------- */
+
+ // Check if getElementsByTagName("*") returns only elements
+ support.getElementsByTagName = assert( function( el ) {
+ el.appendChild( document.createComment( "" ) );
+ return !el.getElementsByTagName( "*" ).length;
+ } );
+
+ // Support: IE<9
+ support.getElementsByClassName = rnative.test( document.getElementsByClassName );
+
+ // Support: IE<10
+ // Check if getElementById returns elements by name
+ // The broken getElementById methods don't pick up programmatically-set names,
+ // so use a roundabout getElementsByName test
+ support.getById = assert( function( el ) {
+ docElem.appendChild( el ).id = expando;
+ return !document.getElementsByName || !document.getElementsByName( expando ).length;
+ } );
+
+ // ID filter and find
+ if ( support.getById ) {
+ Expr.filter[ "ID" ] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ return elem.getAttribute( "id" ) === attrId;
+ };
+ };
+ Expr.find[ "ID" ] = function( id, context ) {
+ if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
+ var elem = context.getElementById( id );
+ return elem ? [ elem ] : [];
+ }
+ };
+ } else {
+ Expr.filter[ "ID" ] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== "undefined" &&
+ elem.getAttributeNode( "id" );
+ return node && node.value === attrId;
+ };
+ };
+
+ // Support: IE 6 - 7 only
+ // getElementById is not reliable as a find shortcut
+ Expr.find[ "ID" ] = function( id, context ) {
+ if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
+ var node, i, elems,
+ elem = context.getElementById( id );
+
+ if ( elem ) {
+
+ // Verify the id attribute
+ node = elem.getAttributeNode( "id" );
+ if ( node && node.value === id ) {
+ return [ elem ];
+ }
+
+ // Fall back on getElementsByName
+ elems = context.getElementsByName( id );
+ i = 0;
+ while ( ( elem = elems[ i++ ] ) ) {
+ node = elem.getAttributeNode( "id" );
+ if ( node && node.value === id ) {
+ return [ elem ];
+ }
+ }
+ }
+
+ return [];
+ }
+ };
+ }
+
+ // Tag
+ Expr.find[ "TAG" ] = support.getElementsByTagName ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== "undefined" ) {
+ return context.getElementsByTagName( tag );
+
+ // DocumentFragment nodes don't have gEBTN
+ } else if ( support.qsa ) {
+ return context.querySelectorAll( tag );
+ }
+ } :
+
+ function( tag, context ) {
+ var elem,
+ tmp = [],
+ i = 0,
+
+ // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
+ results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ while ( ( elem = results[ i++ ] ) ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ };
+
+ // Class
+ Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
+ if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
+ return context.getElementsByClassName( className );
+ }
+ };
+
+ /* QSA/matchesSelector
+ ---------------------------------------------------------------------- */
+
+ // QSA and matchesSelector support
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ rbuggyMatches = [];
+
+ // qSa(:focus) reports false when true (Chrome 21)
+ // We allow this because of a bug in IE8/9 that throws an error
+ // whenever `document.activeElement` is accessed on an iframe
+ // So, we allow :focus to pass through QSA all the time to avoid the IE error
+ // See https://bugs.jquery.com/ticket/13378
+ rbuggyQSA = [];
+
+ if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
+
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert( function( el ) {
+
+ var input;
+
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explicitly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // https://bugs.jquery.com/ticket/12359
+ docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
+ "<select id='" + expando + "-\r\\' msallowcapture=''>" +
+ "<option selected=''></option></select>";
+
+ // Support: IE8, Opera 11-12.16
+ // Nothing should be selected when empty strings follow ^= or $= or *=
+ // The test attribute must be unknown in Opera but "safe" for WinRT
+ // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
+ if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
+ }
+
+ // Support: IE8
+ // Boolean attributes and "value" are not treated correctly
+ if ( !el.querySelectorAll( "[selected]" ).length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
+ }
+
+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
+ if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
+ rbuggyQSA.push( "~=" );
+ }
+
+ // Support: IE 11+, Edge 15 - 18+
+ // IE 11/Edge don't find elements on a `[name='']` query in some cases.
+ // Adding a temporary attribute to the document before the selection works
+ // around the issue.
+ // Interestingly, IE 10 & older don't seem to have the issue.
+ input = document.createElement( "input" );
+ input.setAttribute( "name", "" );
+ el.appendChild( input );
+ if ( !el.querySelectorAll( "[name='']" ).length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
+ whitespace + "*(?:''|\"\")" );
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here and will not see later tests
+ if ( !el.querySelectorAll( ":checked" ).length ) {
+ rbuggyQSA.push( ":checked" );
+ }
+
+ // Support: Safari 8+, iOS 8+
+ // https://bugs.webkit.org/show_bug.cgi?id=136851
+ // In-page `selector#id sibling-combinator selector` fails
+ if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
+ rbuggyQSA.push( ".#.+[+~]" );
+ }
+
+ // Support: Firefox <=3.6 - 5 only
+ // Old Firefox doesn't throw on a badly-escaped identifier.
+ el.querySelectorAll( "\\\f" );
+ rbuggyQSA.push( "[\\r\\n\\f]" );
+ } );
+
+ assert( function( el ) {
+ el.innerHTML = "<a href='' disabled='disabled'></a>" +
+ "<select disabled='disabled'><option/></select>";
+
+ // Support: Windows 8 Native Apps
+ // The type and name attributes are restricted during .innerHTML assignment
+ var input = document.createElement( "input" );
+ input.setAttribute( "type", "hidden" );
+ el.appendChild( input ).setAttribute( "name", "D" );
+
+ // Support: IE8
+ // Enforce case-sensitivity of name attribute
+ if ( el.querySelectorAll( "[name=d]" ).length ) {
+ rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here and will not see later tests
+ if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
+ rbuggyQSA.push( ":enabled", ":disabled" );
+ }
+
+ // Support: IE9-11+
+ // IE's :disabled selector does not pick up the children of disabled fieldsets
+ docElem.appendChild( el ).disabled = true;
+ if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
+ rbuggyQSA.push( ":enabled", ":disabled" );
+ }
+
+ // Support: Opera 10 - 11 only
+ // Opera 10-11 does not throw on post-comma invalid pseudos
+ el.querySelectorAll( "*,:x" );
+ rbuggyQSA.push( ",.*:" );
+ } );
+ }
+
+ if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
+ docElem.webkitMatchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector ) ) ) ) {
+
+ assert( function( el ) {
+
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ support.disconnectedMatch = matches.call( el, "*" );
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( el, "[s!='']:x" );
+ rbuggyMatches.push( "!=", pseudos );
+ } );
+ }
+
+ rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
+ rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
+
+ /* Contains
+ ---------------------------------------------------------------------- */
+ hasCompare = rnative.test( docElem.compareDocumentPosition );
+
+ // Element contains another
+ // Purposefully self-exclusive
+ // As in, an element does not contain itself
+ contains = hasCompare || rnative.test( docElem.contains ) ?
+ function( a, b ) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && (
+ adown.contains ?
+ adown.contains( bup ) :
+ a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+ ) );
+ } :
+ function( a, b ) {
+ if ( b ) {
+ while ( ( b = b.parentNode ) ) {
+ if ( b === a ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ /* Sorting
+ ---------------------------------------------------------------------- */
+
+ // Document order sorting
+ sortOrder = hasCompare ?
+ function( a, b ) {
+
+ // Flag for duplicate removal
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ // Sort on method existence if only one input has compareDocumentPosition
+ var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ if ( compare ) {
+ return compare;
+ }
+
+ // Calculate position if both inputs belong to the same document
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
+ a.compareDocumentPosition( b ) :
+
+ // Otherwise we know they are disconnected
+ 1;
+
+ // Disconnected nodes
+ if ( compare & 1 ||
+ ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
+
+ // Choose the first element that is related to our preferred document
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( a == document || a.ownerDocument == preferredDoc &&
+ contains( preferredDoc, a ) ) {
+ return -1;
+ }
+
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( b == document || b.ownerDocument == preferredDoc &&
+ contains( preferredDoc, b ) ) {
+ return 1;
+ }
+
+ // Maintain original order
+ return sortInput ?
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+ 0;
+ }
+
+ return compare & 4 ? -1 : 1;
+ } :
+ function( a, b ) {
+
+ // Exit early if the nodes are identical
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ var cur,
+ i = 0,
+ aup = a.parentNode,
+ bup = b.parentNode,
+ ap = [ a ],
+ bp = [ b ];
+
+ // Parentless nodes are either documents or disconnected
+ if ( !aup || !bup ) {
+
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ /* eslint-disable eqeqeq */
+ return a == document ? -1 :
+ b == document ? 1 :
+ /* eslint-enable eqeqeq */
+ aup ? -1 :
+ bup ? 1 :
+ sortInput ?
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+ 0;
+
+ // If the nodes are siblings, we can do a quick check
+ } else if ( aup === bup ) {
+ return siblingCheck( a, b );
+ }
+
+ // Otherwise we need full lists of their ancestors for comparison
+ cur = a;
+ while ( ( cur = cur.parentNode ) ) {
+ ap.unshift( cur );
+ }
+ cur = b;
+ while ( ( cur = cur.parentNode ) ) {
+ bp.unshift( cur );
+ }
+
+ // Walk down the tree looking for a discrepancy
+ while ( ap[ i ] === bp[ i ] ) {
+ i++;
+ }
+
+ return i ?
+
+ // Do a sibling check if the nodes have a common ancestor
+ siblingCheck( ap[ i ], bp[ i ] ) :
+
+ // Otherwise nodes in our document sort first
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ /* eslint-disable eqeqeq */
+ ap[ i ] == preferredDoc ? -1 :
+ bp[ i ] == preferredDoc ? 1 :
+ /* eslint-enable eqeqeq */
+ 0;
+ };
+
+ return document;
+};
+
+Sizzle.matches = function( expr, elements ) {
+ return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+ setDocument( elem );
+
+ if ( support.matchesSelector && documentIsHTML &&
+ !nonnativeSelectorCache[ expr + " " ] &&
+ ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
+ ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
+
+ try {
+ var ret = matches.call( elem, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || support.disconnectedMatch ||
+
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11 ) {
+ return ret;
+ }
+ } catch ( e ) {
+ nonnativeSelectorCache( expr, true );
+ }
+ }
+
+ return Sizzle( expr, document, null, [ elem ] ).length > 0;
+};
+
+Sizzle.contains = function( context, elem ) {
+
+ // Set document vars if needed
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( ( context.ownerDocument || context ) != document ) {
+ setDocument( context );
+ }
+ return contains( context, elem );
+};
+
+Sizzle.attr = function( elem, name ) {
+
+ // Set document vars if needed
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( ( elem.ownerDocument || elem ) != document ) {
+ setDocument( elem );
+ }
+
+ var fn = Expr.attrHandle[ name.toLowerCase() ],
+
+ // Don't get fooled by Object.prototype properties (jQuery #13807)
+ val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
+ fn( elem, name, !documentIsHTML ) :
+ undefined;
+
+ return val !== undefined ?
+ val :
+ support.attributes || !documentIsHTML ?
+ elem.getAttribute( name ) :
+ ( val = elem.getAttributeNode( name ) ) && val.specified ?
+ val.value :
+ null;
+};
+
+Sizzle.escape = function( sel ) {
+ return ( sel + "" ).replace( rcssescape, fcssescape );
+};
+
+Sizzle.error = function( msg ) {
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+/**
+ * Document sorting and removing duplicates
+ * @param {ArrayLike} results
+ */
+Sizzle.uniqueSort = function( results ) {
+ var elem,
+ duplicates = [],
+ j = 0,
+ i = 0;
+
+ // Unless we *know* we can detect duplicates, assume their presence
+ hasDuplicate = !support.detectDuplicates;
+ sortInput = !support.sortStable && results.slice( 0 );
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ while ( ( elem = results[ i++ ] ) ) {
+ if ( elem === results[ i ] ) {
+ j = duplicates.push( i );
+ }
+ }
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
+ }
+
+ // Clear input after sorting to release objects
+ // See https://github.com/jquery/sizzle/pull/225
+ sortInput = null;
+
+ return results;
+};
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if ( !nodeType ) {
+
+ // If no nodeType, this is expected to be an array
+ while ( ( node = elem[ i++ ] ) ) {
+
+ // Do not traverse comment nodes
+ ret += getText( node );
+ }
+ } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (jQuery #11153)
+ if ( typeof elem.textContent === "string" ) {
+ return elem.textContent;
+ } else {
+
+ // Traverse its children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ ret += getText( elem );
+ }
+ }
+ } else if ( nodeType === 3 || nodeType === 4 ) {
+ return elem.nodeValue;
+ }
+
+ // Do not include comment or processing instruction nodes
+
+ return ret;
+};
+
+Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ attrHandle: {},
+
+ find: {},
+
+ relative: {
+ ">": { dir: "parentNode", first: true },
+ " ": { dir: "parentNode" },
+ "+": { dir: "previousSibling", first: true },
+ "~": { dir: "previousSibling" }
+ },
+
+ preFilter: {
+ "ATTR": function( match ) {
+ match[ 1 ] = match[ 1 ].replace( runescape, funescape );
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
+ match[ 5 ] || "" ).replace( runescape, funescape );
+
+ if ( match[ 2 ] === "~=" ) {
+ match[ 3 ] = " " + match[ 3 ] + " ";
+ }
+
+ return match.slice( 0, 4 );
+ },
+
+ "CHILD": function( match ) {
+
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 what (child|of-type)
+ 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 4 xn-component of xn+y argument ([+-]?\d*n|)
+ 5 sign of xn-component
+ 6 x of xn-component
+ 7 sign of y-component
+ 8 y of y-component
+ */
+ match[ 1 ] = match[ 1 ].toLowerCase();
+
+ if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
+
+ // nth-* requires argument
+ if ( !match[ 3 ] ) {
+ Sizzle.error( match[ 0 ] );
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[ 4 ] = +( match[ 4 ] ?
+ match[ 5 ] + ( match[ 6 ] || 1 ) :
+ 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
+ match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
+
+ // other types prohibit arguments
+ } else if ( match[ 3 ] ) {
+ Sizzle.error( match[ 0 ] );
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function( match ) {
+ var excess,
+ unquoted = !match[ 6 ] && match[ 2 ];
+
+ if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
+ return null;
+ }
+
+ // Accept quoted arguments as-is
+ if ( match[ 3 ] ) {
+ match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
+
+ // Strip excess characters from unquoted arguments
+ } else if ( unquoted && rpseudo.test( unquoted ) &&
+
+ // Get excess from tokenize (recursively)
+ ( excess = tokenize( unquoted, true ) ) &&
+
+ // advance to the next closing parenthesis
+ ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
+
+ // excess is a negative index
+ match[ 0 ] = match[ 0 ].slice( 0, excess );
+ match[ 2 ] = unquoted.slice( 0, excess );
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice( 0, 3 );
+ }
+ },
+
+ filter: {
+
+ "TAG": function( nodeNameSelector ) {
+ var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
+ return nodeNameSelector === "*" ?
+ function() {
+ return true;
+ } :
+ function( elem ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function( className ) {
+ var pattern = classCache[ className + " " ];
+
+ return pattern ||
+ ( pattern = new RegExp( "(^|" + whitespace +
+ ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
+ className, function( elem ) {
+ return pattern.test(
+ typeof elem.className === "string" && elem.className ||
+ typeof elem.getAttribute !== "undefined" &&
+ elem.getAttribute( "class" ) ||
+ ""
+ );
+ } );
+ },
+
+ "ATTR": function( name, operator, check ) {
+ return function( elem ) {
+ var result = Sizzle.attr( elem, name );
+
+ if ( result == null ) {
+ return operator === "!=";
+ }
+ if ( !operator ) {
+ return true;
+ }
+
+ result += "";
+
+ /* eslint-disable max-len */
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.slice( -check.length ) === check :
+ operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
+ false;
+ /* eslint-enable max-len */
+
+ };
+ },
+
+ "CHILD": function( type, what, _argument, first, last ) {
+ var simple = type.slice( 0, 3 ) !== "nth",
+ forward = type.slice( -4 ) !== "last",
+ ofType = what === "of-type";
+
+ return first === 1 && last === 0 ?
+
+ // Shortcut for :nth-*(n)
+ function( elem ) {
+ return !!elem.parentNode;
+ } :
+
+ function( elem, _context, xml ) {
+ var cache, uniqueCache, outerCache, node, nodeIndex, start,
+ dir = simple !== forward ? "nextSibling" : "previousSibling",
+ parent = elem.parentNode,
+ name = ofType && elem.nodeName.toLowerCase(),
+ useCache = !xml && !ofType,
+ diff = false;
+
+ if ( parent ) {
+
+ // :(first|last|only)-(child|of-type)
+ if ( simple ) {
+ while ( dir ) {
+ node = elem;
+ while ( ( node = node[ dir ] ) ) {
+ if ( ofType ?
+ node.nodeName.toLowerCase() === name :
+ node.nodeType === 1 ) {
+
+ return false;
+ }
+ }
+
+ // Reverse direction for :only-* (if we haven't yet done so)
+ start = dir = type === "only" && !start && "nextSibling";
+ }
+ return true;
+ }
+
+ start = [ forward ? parent.firstChild : parent.lastChild ];
+
+ // non-xml :nth-child(...) stores cache data on `parent`
+ if ( forward && useCache ) {
+
+ // Seek `elem` from a previously-cached index
+
+ // ...in a gzip-friendly way
+ node = parent;
+ outerCache = node[ expando ] || ( node[ expando ] = {} );
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ ( outerCache[ node.uniqueID ] = {} );
+
+ cache = uniqueCache[ type ] || [];
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+ diff = nodeIndex && cache[ 2 ];
+ node = nodeIndex && parent.childNodes[ nodeIndex ];
+
+ while ( ( node = ++nodeIndex && node && node[ dir ] ||
+
+ // Fallback to seeking `elem` from the start
+ ( diff = nodeIndex = 0 ) || start.pop() ) ) {
+
+ // When found, cache indexes on `parent` and break
+ if ( node.nodeType === 1 && ++diff && node === elem ) {
+ uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
+ break;
+ }
+ }
+
+ } else {
+
+ // Use previously-cached element index if available
+ if ( useCache ) {
+
+ // ...in a gzip-friendly way
+ node = elem;
+ outerCache = node[ expando ] || ( node[ expando ] = {} );
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ ( outerCache[ node.uniqueID ] = {} );
+
+ cache = uniqueCache[ type ] || [];
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+ diff = nodeIndex;
+ }
+
+ // xml :nth-child(...)
+ // or :nth-last-child(...) or :nth(-last)?-of-type(...)
+ if ( diff === false ) {
+
+ // Use the same loop as above to seek `elem` from the start
+ while ( ( node = ++nodeIndex && node && node[ dir ] ||
+ ( diff = nodeIndex = 0 ) || start.pop() ) ) {
+
+ if ( ( ofType ?
+ node.nodeName.toLowerCase() === name :
+ node.nodeType === 1 ) &&
+ ++diff ) {
+
+ // Cache the index of each encountered element
+ if ( useCache ) {
+ outerCache = node[ expando ] ||
+ ( node[ expando ] = {} );
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ ( outerCache[ node.uniqueID ] = {} );
+
+ uniqueCache[ type ] = [ dirruns, diff ];
+ }
+
+ if ( node === elem ) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset, then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ }
+ };
+ },
+
+ "PSEUDO": function( pseudo, argument ) {
+
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction( function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf( seed, matched[ i ] );
+ seed[ idx ] = !( matches[ idx ] = matched[ i ] );
+ }
+ } ) :
+ function( elem ) {
+ return fn( elem, 0, args );
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+
+ // Potentially complex pseudos
+ "not": markFunction( function( selector ) {
+
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction( function( seed, matches, _context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( ( elem = unmatched[ i ] ) ) {
+ seed[ i ] = !( matches[ i ] = elem );
+ }
+ }
+ } ) :
+ function( elem, _context, xml ) {
+ input[ 0 ] = elem;
+ matcher( input, null, xml, results );
+
+ // Don't keep the element (issue #299)
+ input[ 0 ] = null;
+ return !results.pop();
+ };
+ } ),
+
+ "has": markFunction( function( selector ) {
+ return function( elem ) {
+ return Sizzle( selector, elem ).length > 0;
+ };
+ } ),
+
+ "contains": markFunction( function( text ) {
+ text = text.replace( runescape, funescape );
+ return function( elem ) {
+ return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
+ };
+ } ),
+
+ // "Whether an element is represented by a :lang() selector
+ // is based solely on the element's language value
+ // being equal to the identifier C,
+ // or beginning with the identifier C immediately followed by "-".
+ // The matching of C against the element's language value is performed case-insensitively.
+ // The identifier C does not have to be a valid language name."
+ // http://www.w3.org/TR/selectors/#lang-pseudo
+ "lang": markFunction( function( lang ) {
+
+ // lang value must be a valid identifier
+ if ( !ridentifier.test( lang || "" ) ) {
+ Sizzle.error( "unsupported lang: " + lang );
+ }
+ lang = lang.replace( runescape, funescape ).toLowerCase();
+ return function( elem ) {
+ var elemLang;
+ do {
+ if ( ( elemLang = documentIsHTML ?
+ elem.lang :
+ elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
+
+ elemLang = elemLang.toLowerCase();
+ return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
+ }
+ } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
+ return false;
+ };
+ } ),
+
+ // Miscellaneous
+ "target": function( elem ) {
+ var hash = window.location && window.location.hash;
+ return hash && hash.slice( 1 ) === elem.id;
+ },
+
+ "root": function( elem ) {
+ return elem === docElem;
+ },
+
+ "focus": function( elem ) {
+ return elem === document.activeElement &&
+ ( !document.hasFocus || document.hasFocus() ) &&
+ !!( elem.type || elem.href || ~elem.tabIndex );
+ },
+
+ // Boolean properties
+ "enabled": createDisabledPseudo( false ),
+ "disabled": createDisabledPseudo( true ),
+
+ "checked": function( elem ) {
+
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return ( nodeName === "input" && !!elem.checked ) ||
+ ( nodeName === "option" && !!elem.selected );
+ },
+
+ "selected": function( elem ) {
+
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if ( elem.parentNode ) {
+ // eslint-disable-next-line no-unused-expressions
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ // Contents
+ "empty": function( elem ) {
+
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
+ // but not by others (comment: 8; processing instruction: 7; etc.)
+ // nodeType < 6 works because attributes (2) do not appear as children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ if ( elem.nodeType < 6 ) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ "parent": function( elem ) {
+ return !Expr.pseudos[ "empty" ]( elem );
+ },
+
+ // Element/input types
+ "header": function( elem ) {
+ return rheader.test( elem.nodeName );
+ },
+
+ "input": function( elem ) {
+ return rinputs.test( elem.nodeName );
+ },
+
+ "button": function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "text": function( elem ) {
+ var attr;
+ return elem.nodeName.toLowerCase() === "input" &&
+ elem.type === "text" &&
+
+ // Support: IE<8
+ // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
+ ( ( attr = elem.getAttribute( "type" ) ) == null ||
+ attr.toLowerCase() === "text" );
+ },
+
+ // Position-in-collection
+ "first": createPositionalPseudo( function() {
+ return [ 0 ];
+ } ),
+
+ "last": createPositionalPseudo( function( _matchIndexes, length ) {
+ return [ length - 1 ];
+ } ),
+
+ "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ } ),
+
+ "even": createPositionalPseudo( function( matchIndexes, length ) {
+ var i = 0;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ } ),
+
+ "odd": createPositionalPseudo( function( matchIndexes, length ) {
+ var i = 1;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ } ),
+
+ "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
+ var i = argument < 0 ?
+ argument + length :
+ argument > length ?
+ length :
+ argument;
+ for ( ; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ } ),
+
+ "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
+ var i = argument < 0 ? argument + length : argument;
+ for ( ; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ } )
+ }
+};
+
+Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
+
+// Add button/input type pseudos
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
+ Expr.pseudos[ i ] = createInputPseudo( i );
+}
+for ( i in { submit: true, reset: true } ) {
+ Expr.pseudos[ i ] = createButtonPseudo( i );
+}
+
+// Easy API for creating new setFilters
+function setFilters() {}
+setFilters.prototype = Expr.filters = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
+ var matched, match, tokens, type,
+ soFar, groups, preFilters,
+ cached = tokenCache[ selector + " " ];
+
+ if ( cached ) {
+ return parseOnly ? 0 : cached.slice( 0 );
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while ( soFar ) {
+
+ // Comma and first run
+ if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
+ if ( match ) {
+
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice( match[ 0 ].length ) || soFar;
+ }
+ groups.push( ( tokens = [] ) );
+ }
+
+ matched = false;
+
+ // Combinators
+ if ( ( match = rcombinators.exec( soFar ) ) ) {
+ matched = match.shift();
+ tokens.push( {
+ value: matched,
+
+ // Cast descendant combinators to space
+ type: match[ 0 ].replace( rtrim, " " )
+ } );
+ soFar = soFar.slice( matched.length );
+ }
+
+ // Filters
+ for ( type in Expr.filter ) {
+ if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
+ ( match = preFilters[ type ]( match ) ) ) ) {
+ matched = match.shift();
+ tokens.push( {
+ value: matched,
+ type: type,
+ matches: match
+ } );
+ soFar = soFar.slice( matched.length );
+ }
+ }
+
+ if ( !matched ) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error( selector ) :
+
+ // Cache the tokens
+ tokenCache( selector, groups ).slice( 0 );
+};
+
+function toSelector( tokens ) {
+ var i = 0,
+ len = tokens.length,
+ selector = "";
+ for ( ; i < len; i++ ) {
+ selector += tokens[ i ].value;
+ }
+ return selector;
+}
+
+function addCombinator( matcher, combinator, base ) {
+ var dir = combinator.dir,
+ skip = combinator.next,
+ key = skip || dir,
+ checkNonElements = base && key === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
+ while ( ( elem = elem[ dir ] ) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ return matcher( elem, context, xml );
+ }
+ }
+ return false;
+ } :
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ var oldCache, uniqueCache, outerCache,
+ newCache = [ dirruns, doneName ];
+
+ // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
+ if ( xml ) {
+ while ( ( elem = elem[ dir ] ) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ if ( matcher( elem, context, xml ) ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ while ( ( elem = elem[ dir ] ) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ outerCache = elem[ expando ] || ( elem[ expando ] = {} );
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ elem.uniqueID ] ||
+ ( outerCache[ elem.uniqueID ] = {} );
+
+ if ( skip && skip === elem.nodeName.toLowerCase() ) {
+ elem = elem[ dir ] || elem;
+ } else if ( ( oldCache = uniqueCache[ key ] ) &&
+ oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
+
+ // Assign to newCache so results back-propagate to previous elements
+ return ( newCache[ 2 ] = oldCache[ 2 ] );
+ } else {
+
+ // Reuse newcache so results back-propagate to previous elements
+ uniqueCache[ key ] = newCache;
+
+ // A match means we're done; a fail means we have to keep checking
+ if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ };
+}
+
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[ i ]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[ 0 ];
+}
+
+function multipleContexts( selector, contexts, results ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[ i ], results );
+ }
+ return results;
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for ( ; i < len; i++ ) {
+ if ( ( elem = unmatched[ i ] ) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction( function( seed, results, context, xml ) {
+ var temp, i, elem,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts(
+ selector || "*",
+ context.nodeType ? [ context ] : context,
+ []
+ ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ temp = condense( matcherOut, postMap );
+ postFilter( temp, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while ( i-- ) {
+ if ( ( elem = temp[ i ] ) ) {
+ matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
+ }
+ }
+ }
+
+ if ( seed ) {
+ if ( postFinder || preFilter ) {
+ if ( postFinder ) {
+
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( ( elem = matcherOut[ i ] ) ) {
+
+ // Restore matcherIn since elem is not yet a final match
+ temp.push( ( matcherIn[ i ] = elem ) );
+ }
+ }
+ postFinder( null, ( matcherOut = [] ), temp, xml );
+ }
+
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( ( elem = matcherOut[ i ] ) &&
+ ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
+
+ seed[ temp ] = !( results[ temp ] = elem );
+ }
+ }
+ }
+
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ } );
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[ 0 ].type ],
+ implicitRelative = leadingRelative || Expr.relative[ " " ],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ ( checkContext = context ).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+
+ // Avoid hanging onto element (issue #299)
+ checkContext = null;
+ return ret;
+ } ];
+
+ for ( ; i < len; i++ ) {
+ if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+ } else {
+ matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[ j ].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && toSelector(
+
+ // If the preceding token was a descendant combinator, insert an implicit any-element `*`
+ tokens
+ .slice( 0, i - 1 )
+ .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
+ ).replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
+ j < len && toSelector( tokens )
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
+
+ return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, outermost ) {
+ var elem, j, matcher,
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ setMatched = [],
+ contextBackup = outermostContext,
+
+ // We must always have either seed elements or outermost context
+ elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
+
+ // Use integer dirruns iff this is the outermost matcher
+ dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
+ len = elems.length;
+
+ if ( outermost ) {
+
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ outermostContext = context == document || context || outermost;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ // Support: IE<9, Safari
+ // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
+ for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
+ if ( byElement && elem ) {
+ j = 0;
+
+ // Support: IE 11+, Edge 17 - 18+
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( !context && elem.ownerDocument != document ) {
+ setDocument( elem );
+ xml = !documentIsHTML;
+ }
+ while ( ( matcher = elementMatchers[ j++ ] ) ) {
+ if ( matcher( elem, context || document, xml ) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+
+ // They will have gone through all possible matchers
+ if ( ( elem = !matcher && elem ) ) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
+ }
+
+ // `i` is now the count of elements visited above, and adding it to `matchedCount`
+ // makes the latter nonnegative.
+ matchedCount += i;
+
+ // Apply set filters to unmatched elements
+ // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
+ // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
+ // no element matchers and no seed.
+ // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
+ // case, which will result in a "00" `matchedCount` that differs from `i` but is also
+ // numerically zero.
+ if ( bySet && i !== matchedCount ) {
+ j = 0;
+ while ( ( matcher = setMatchers[ j++ ] ) ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
+
+ if ( seed ) {
+
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
+ setMatched[ i ] = pop.call( results );
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
+
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ selector + " " ];
+
+ if ( !cached ) {
+
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !match ) {
+ match = tokenize( selector );
+ }
+ i = match.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( match[ i ] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache(
+ selector,
+ matcherFromGroupMatchers( elementMatchers, setMatchers )
+ );
+
+ // Save selector and tokenization
+ cached.selector = selector;
+ }
+ return cached;
+};
+
+/**
+ * A low-level selection function that works with Sizzle's compiled
+ * selector functions
+ * @param {String|Function} selector A selector or a pre-compiled
+ * selector function built with Sizzle.compile
+ * @param {Element} context
+ * @param {Array} [results]
+ * @param {Array} [seed] A set of elements to match against
+ */
+select = Sizzle.select = function( selector, context, results, seed ) {
+ var i, tokens, token, type, find,
+ compiled = typeof selector === "function" && selector,
+ match = !seed && tokenize( ( selector = compiled.selector || selector ) );
+
+ results = results || [];
+
+ // Try to minimize operations if there is only one selector in the list and no seed
+ // (the latter of which guarantees us context)
+ if ( match.length === 1 ) {
+
+ // Reduce context if the leading compound selector is an ID
+ tokens = match[ 0 ] = match[ 0 ].slice( 0 );
+ if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
+ context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
+
+ context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
+ .replace( runescape, funescape ), context ) || [] )[ 0 ];
+ if ( !context ) {
+ return results;
+
+ // Precompiled matchers will still verify ancestry, so step up a level
+ } else if ( compiled ) {
+ context = context.parentNode;
+ }
+
+ selector = selector.slice( tokens.shift().value.length );
+ }
+
+ // Fetch a seed set for right-to-left matching
+ i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
+ while ( i-- ) {
+ token = tokens[ i ];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ ( type = token.type ) ] ) {
+ break;
+ }
+ if ( ( find = Expr.find[ type ] ) ) {
+
+ // Search, expanding context for leading sibling combinators
+ if ( ( seed = find(
+ token.matches[ 0 ].replace( runescape, funescape ),
+ rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
+ context
+ ) ) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && toSelector( tokens );
+ if ( !selector ) {
+ push.apply( results, seed );
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function if one is not provided
+ // Provide `match` to avoid retokenization if we modified the selector above
+ ( compiled || compile( selector, match ) )(
+ seed,
+ context,
+ !documentIsHTML,
+ results,
+ !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
+ );
+ return results;
+};
+
+// One-time assignments
+
+// Sort stability
+support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
+
+// Support: Chrome 14-35+
+// Always assume duplicates if they aren't passed to the comparison function
+support.detectDuplicates = !!hasDuplicate;
+
+// Initialize against the default document
+setDocument();
+
+// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
+// Detached nodes confoundingly follow *each other*
+support.sortDetached = assert( function( el ) {
+
+ // Should return 1, but returns 4 (following)
+ return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
+} );
+
+// Support: IE<8
+// Prevent attribute/property "interpolation"
+// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !assert( function( el ) {
+ el.innerHTML = "<a href='#'></a>";
+ return el.firstChild.getAttribute( "href" ) === "#";
+} ) ) {
+ addHandle( "type|href|height|width", function( elem, name, isXML ) {
+ if ( !isXML ) {
+ return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
+ }
+ } );
+}
+
+// Support: IE<9
+// Use defaultValue in place of getAttribute("value")
+if ( !support.attributes || !assert( function( el ) {
+ el.innerHTML = "<input/>";
+ el.firstChild.setAttribute( "value", "" );
+ return el.firstChild.getAttribute( "value" ) === "";
+} ) ) {
+ addHandle( "value", function( elem, _name, isXML ) {
+ if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
+ return elem.defaultValue;
+ }
+ } );
+}
+
+// Support: IE<9
+// Use getAttributeNode to fetch booleans when getAttribute lies
+if ( !assert( function( el ) {
+ return el.getAttribute( "disabled" ) == null;
+} ) ) {
+ addHandle( booleans, function( elem, name, isXML ) {
+ var val;
+ if ( !isXML ) {
+ return elem[ name ] === true ? name.toLowerCase() :
+ ( val = elem.getAttributeNode( name ) ) && val.specified ?
+ val.value :
+ null;
+ }
+ } );
+}
+
+return Sizzle;
+
+} )( window );
+
+
+
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+
+// Deprecated
+jQuery.expr[ ":" ] = jQuery.expr.pseudos;
+jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+jQuery.escapeSelector = Sizzle.escape;
+
+
+
+
+var dir = function( elem, dir, until ) {
+ var matched = [],
+ truncate = until !== undefined;
+
+ while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
+ if ( elem.nodeType === 1 ) {
+ if ( truncate && jQuery( elem ).is( until ) ) {
+ break;
+ }
+ matched.push( elem );
+ }
+ }
+ return matched;
+};
+
+
+var siblings = function( n, elem ) {
+ var matched = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ matched.push( n );
+ }
+ }
+
+ return matched;
+};
+
+
+var rneedsContext = jQuery.expr.match.needsContext;
+
+
+
+function nodeName( elem, name ) {
+
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+
+};
+var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
+
+
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, not ) {
+ if ( isFunction( qualifier ) ) {
+ return jQuery.grep( elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) !== not;
+ } );
+ }
+
+ // Single element
+ if ( qualifier.nodeType ) {
+ return jQuery.grep( elements, function( elem ) {
+ return ( elem === qualifier ) !== not;
+ } );
+ }
+
+ // Arraylike of elements (jQuery, arguments, Array)
+ if ( typeof qualifier !== "string" ) {
+ return jQuery.grep( elements, function( elem ) {
+ return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
+ } );
+ }
+
+ // Filtered directly for both simple and complex selectors
+ return jQuery.filter( qualifier, elements, not );
+}
+
+jQuery.filter = function( expr, elems, not ) {
+ var elem = elems[ 0 ];
+
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ if ( elems.length === 1 && elem.nodeType === 1 ) {
+ return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
+ }
+
+ return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
+ return elem.nodeType === 1;
+ } ) );
+};
+
+jQuery.fn.extend( {
+ find: function( selector ) {
+ var i, ret,
+ len = this.length,
+ self = this;
+
+ if ( typeof selector !== "string" ) {
+ return this.pushStack( jQuery( selector ).filter( function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ } ) );
+ }
+
+ ret = this.pushStack( [] );
+
+ for ( i = 0; i < len; i++ ) {
+ jQuery.find( selector, self[ i ], ret );
+ }
+
+ return len > 1 ? jQuery.uniqueSort( ret ) : ret;
+ },
+ filter: function( selector ) {
+ return this.pushStack( winnow( this, selector || [], false ) );
+ },
+ not: function( selector ) {
+ return this.pushStack( winnow( this, selector || [], true ) );
+ },
+ is: function( selector ) {
+ return !!winnow(
+ this,
+
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ typeof selector === "string" && rneedsContext.test( selector ) ?
+ jQuery( selector ) :
+ selector || [],
+ false
+ ).length;
+ }
+} );
+
+
+// Initialize a jQuery object
+
+
+// A central reference to the root jQuery(document)
+var rootjQuery,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+ // Strict HTML recognition (#11290: must start with <)
+ // Shortcut simple #id case for speed
+ rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
+
+ init = jQuery.fn.init = function( selector, context, root ) {
+ var match, elem;
+
+ // HANDLE: $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Method init() accepts an alternate rootjQuery
+ // so migrate can support jQuery.sub (gh-2101)
+ root = root || rootjQuery;
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector[ 0 ] === "<" &&
+ selector[ selector.length - 1 ] === ">" &&
+ selector.length >= 3 ) {
+
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && ( match[ 1 ] || !context ) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[ 1 ] ) {
+ context = context instanceof jQuery ? context[ 0 ] : context;
+
+ // Option to run scripts is true for back-compat
+ // Intentionally let the error be thrown if parseHTML is not present
+ jQuery.merge( this, jQuery.parseHTML(
+ match[ 1 ],
+ context && context.nodeType ? context.ownerDocument || context : document,
+ true
+ ) );
+
+ // HANDLE: $(html, props)
+ if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
+ for ( match in context ) {
+
+ // Properties of context are called as methods if possible
+ if ( isFunction( this[ match ] ) ) {
+ this[ match ]( context[ match ] );
+
+ // ...and otherwise set as attributes
+ } else {
+ this.attr( match, context[ match ] );
+ }
+ }
+ }
+
+ return this;
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[ 2 ] );
+
+ if ( elem ) {
+
+ // Inject the element directly into the jQuery object
+ this[ 0 ] = elem;
+ this.length = 1;
+ }
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || root ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(DOMElement)
+ } else if ( selector.nodeType ) {
+ this[ 0 ] = selector;
+ this.length = 1;
+ return this;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( isFunction( selector ) ) {
+ return root.ready !== undefined ?
+ root.ready( selector ) :
+
+ // Execute immediately if ready is not present
+ selector( jQuery );
+ }
+
+ return jQuery.makeArray( selector, this );
+ };
+
+// Give the init function the jQuery prototype for later instantiation
+init.prototype = jQuery.fn;
+
+// Initialize central reference
+rootjQuery = jQuery( document );
+
+
+var rparentsprev = /^(?:parents|prev(?:Until|All))/,
+
+ // Methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+jQuery.fn.extend( {
+ has: function( target ) {
+ var targets = jQuery( target, this ),
+ l = targets.length;
+
+ return this.filter( function() {
+ var i = 0;
+ for ( ; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[ i ] ) ) {
+ return true;
+ }
+ }
+ } );
+ },
+
+ closest: function( selectors, context ) {
+ var cur,
+ i = 0,
+ l = this.length,
+ matched = [],
+ targets = typeof selectors !== "string" && jQuery( selectors );
+
+ // Positional selectors never match, since there's no _selection_ context
+ if ( !rneedsContext.test( selectors ) ) {
+ for ( ; i < l; i++ ) {
+ for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
+
+ // Always skip document fragments
+ if ( cur.nodeType < 11 && ( targets ?
+ targets.index( cur ) > -1 :
+
+ // Don't pass non-elements to Sizzle
+ cur.nodeType === 1 &&
+ jQuery.find.matchesSelector( cur, selectors ) ) ) {
+
+ matched.push( cur );
+ break;
+ }
+ }
+ }
+ }
+
+ return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
+ },
+
+ // Determine the position of an element within the set
+ index: function( elem ) {
+
+ // No argument, return index in parent
+ if ( !elem ) {
+ return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
+ }
+
+ // Index in selector
+ if ( typeof elem === "string" ) {
+ return indexOf.call( jQuery( elem ), this[ 0 ] );
+ }
+
+ // Locate the position of the desired element
+ return indexOf.call( this,
+
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[ 0 ] : elem
+ );
+ },
+
+ add: function( selector, context ) {
+ return this.pushStack(
+ jQuery.uniqueSort(
+ jQuery.merge( this.get(), jQuery( selector, context ) )
+ )
+ );
+ },
+
+ addBack: function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter( selector )
+ );
+ }
+} );
+
+function sibling( cur, dir ) {
+ while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
+ return cur;
+}
+
+jQuery.each( {
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, _i, until ) {
+ return dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return sibling( elem, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return sibling( elem, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, _i, until ) {
+ return dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, _i, until ) {
+ return dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return siblings( ( elem.parentNode || {} ).firstChild, elem );
+ },
+ children: function( elem ) {
+ return siblings( elem.firstChild );
+ },
+ contents: function( elem ) {
+ if ( elem.contentDocument != null &&
+
+ // Support: IE 11+
+ // <object> elements with no `data` attribute has an object
+ // `contentDocument` with a `null` prototype.
+ getProto( elem.contentDocument ) ) {
+
+ return elem.contentDocument;
+ }
+
+ // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
+ // Treat the template element as a regular one in browsers that
+ // don't support it.
+ if ( nodeName( elem, "template" ) ) {
+ elem = elem.content || elem;
+ }
+
+ return jQuery.merge( [], elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var matched = jQuery.map( this, fn, until );
+
+ if ( name.slice( -5 ) !== "Until" ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ matched = jQuery.filter( selector, matched );
+ }
+
+ if ( this.length > 1 ) {
+
+ // Remove duplicates
+ if ( !guaranteedUnique[ name ] ) {
+ jQuery.uniqueSort( matched );
+ }
+
+ // Reverse order for parents* and prev-derivatives
+ if ( rparentsprev.test( name ) ) {
+ matched.reverse();
+ }
+ }
+
+ return this.pushStack( matched );
+ };
+} );
+var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
+
+
+
+// Convert String-formatted options into Object-formatted ones
+function createOptions( options ) {
+ var object = {};
+ jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
+ object[ flag ] = true;
+ } );
+ return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ createOptions( options ) :
+ jQuery.extend( {}, options );
+
+ var // Flag to know if list is currently firing
+ firing,
+
+ // Last fire value for non-forgettable lists
+ memory,
+
+ // Flag to know if list was already fired
+ fired,
+
+ // Flag to prevent firing
+ locked,
+
+ // Actual callback list
+ list = [],
+
+ // Queue of execution data for repeatable lists
+ queue = [],
+
+ // Index of currently firing callback (modified by add/remove as needed)
+ firingIndex = -1,
+
+ // Fire callbacks
+ fire = function() {
+
+ // Enforce single-firing
+ locked = locked || options.once;
+
+ // Execute callbacks for all pending executions,
+ // respecting firingIndex overrides and runtime changes
+ fired = firing = true;
+ for ( ; queue.length; firingIndex = -1 ) {
+ memory = queue.shift();
+ while ( ++firingIndex < list.length ) {
+
+ // Run callback and check for early termination
+ if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
+ options.stopOnFalse ) {
+
+ // Jump to end and forget the data so .add doesn't re-fire
+ firingIndex = list.length;
+ memory = false;
+ }
+ }
+ }
+
+ // Forget the data if we're done with it
+ if ( !options.memory ) {
+ memory = false;
+ }
+
+ firing = false;
+
+ // Clean up if we're done firing for good
+ if ( locked ) {
+
+ // Keep an empty list if we have data for future add calls
+ if ( memory ) {
+ list = [];
+
+ // Otherwise, this object is spent
+ } else {
+ list = "";
+ }
+ }
+ },
+
+ // Actual Callbacks object
+ self = {
+
+ // Add a callback or a collection of callbacks to the list
+ add: function() {
+ if ( list ) {
+
+ // If we have memory from a past run, we should fire after adding
+ if ( memory && !firing ) {
+ firingIndex = list.length - 1;
+ queue.push( memory );
+ }
+
+ ( function add( args ) {
+ jQuery.each( args, function( _, arg ) {
+ if ( isFunction( arg ) ) {
+ if ( !options.unique || !self.has( arg ) ) {
+ list.push( arg );
+ }
+ } else if ( arg && arg.length && toType( arg ) !== "string" ) {
+
+ // Inspect recursively
+ add( arg );
+ }
+ } );
+ } )( arguments );
+
+ if ( memory && !firing ) {
+ fire();
+ }
+ }
+ return this;
+ },
+
+ // Remove a callback from the list
+ remove: function() {
+ jQuery.each( arguments, function( _, arg ) {
+ var index;
+ while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+ list.splice( index, 1 );
+
+ // Handle firing indexes
+ if ( index <= firingIndex ) {
+ firingIndex--;
+ }
+ }
+ } );
+ return this;
+ },
+
+ // Check if a given callback is in the list.
+ // If no argument is given, return whether or not list has callbacks attached.
+ has: function( fn ) {
+ return fn ?
+ jQuery.inArray( fn, list ) > -1 :
+ list.length > 0;
+ },
+
+ // Remove all callbacks from the list
+ empty: function() {
+ if ( list ) {
+ list = [];
+ }
+ return this;
+ },
+
+ // Disable .fire and .add
+ // Abort any current/pending executions
+ // Clear all callbacks and values
+ disable: function() {
+ locked = queue = [];
+ list = memory = "";
+ return this;
+ },
+ disabled: function() {
+ return !list;
+ },
+
+ // Disable .fire
+ // Also disable .add unless we have memory (since it would have no effect)
+ // Abort any pending executions
+ lock: function() {
+ locked = queue = [];
+ if ( !memory && !firing ) {
+ list = memory = "";
+ }
+ return this;
+ },
+ locked: function() {
+ return !!locked;
+ },
+
+ // Call all callbacks with the given context and arguments
+ fireWith: function( context, args ) {
+ if ( !locked ) {
+ args = args || [];
+ args = [ context, args.slice ? args.slice() : args ];
+ queue.push( args );
+ if ( !firing ) {
+ fire();
+ }
+ }
+ return this;
+ },
+
+ // Call all the callbacks with the given arguments
+ fire: function() {
+ self.fireWith( this, arguments );
+ return this;
+ },
+
+ // To know if the callbacks have already been called at least once
+ fired: function() {
+ return !!fired;
+ }
+ };
+
+ return self;
+};
+
+
+function Identity( v ) {
+ return v;
+}
+function Thrower( ex ) {
+ throw ex;
+}
+
+function adoptValue( value, resolve, reject, noValue ) {
+ var method;
+
+ try {
+
+ // Check for promise aspect first to privilege synchronous behavior
+ if ( value && isFunction( ( method = value.promise ) ) ) {
+ method.call( value ).done( resolve ).fail( reject );
+
+ // Other thenables
+ } else if ( value && isFunction( ( method = value.then ) ) ) {
+ method.call( value, resolve, reject );
+
+ // Other non-thenables
+ } else {
+
+ // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
+ // * false: [ value ].slice( 0 ) => resolve( value )
+ // * true: [ value ].slice( 1 ) => resolve()
+ resolve.apply( undefined, [ value ].slice( noValue ) );
+ }
+
+ // For Promises/A+, convert exceptions into rejections
+ // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
+ // Deferred#then to conditionally suppress rejection.
+ } catch ( value ) {
+
+ // Support: Android 4.0 only
+ // Strict mode functions invoked without .call/.apply get global-object context
+ reject.apply( undefined, [ value ] );
+ }
+}
+
+jQuery.extend( {
+
+ Deferred: function( func ) {
+ var tuples = [
+
+ // action, add listener, callbacks,
+ // ... .then handlers, argument index, [final state]
+ [ "notify", "progress", jQuery.Callbacks( "memory" ),
+ jQuery.Callbacks( "memory" ), 2 ],
+ [ "resolve", "done", jQuery.Callbacks( "once memory" ),
+ jQuery.Callbacks( "once memory" ), 0, "resolved" ],
+ [ "reject", "fail", jQuery.Callbacks( "once memory" ),
+ jQuery.Callbacks( "once memory" ), 1, "rejected" ]
+ ],
+ state = "pending",
+ promise = {
+ state: function() {
+ return state;
+ },
+ always: function() {
+ deferred.done( arguments ).fail( arguments );
+ return this;
+ },
+ "catch": function( fn ) {
+ return promise.then( null, fn );
+ },
+
+ // Keep pipe for back-compat
+ pipe: function( /* fnDone, fnFail, fnProgress */ ) {
+ var fns = arguments;
+
+ return jQuery.Deferred( function( newDefer ) {
+ jQuery.each( tuples, function( _i, tuple ) {
+
+ // Map tuples (progress, done, fail) to arguments (done, fail, progress)
+ var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
+
+ // deferred.progress(function() { bind to newDefer or newDefer.notify })
+ // deferred.done(function() { bind to newDefer or newDefer.resolve })
+ // deferred.fail(function() { bind to newDefer or newDefer.reject })
+ deferred[ tuple[ 1 ] ]( function() {
+ var returned = fn && fn.apply( this, arguments );
+ if ( returned && isFunction( returned.promise ) ) {
+ returned.promise()
+ .progress( newDefer.notify )
+ .done( newDefer.resolve )
+ .fail( newDefer.reject );
+ } else {
+ newDefer[ tuple[ 0 ] + "With" ](
+ this,
+ fn ? [ returned ] : arguments
+ );
+ }
+ } );
+ } );
+ fns = null;
+ } ).promise();
+ },
+ then: function( onFulfilled, onRejected, onProgress ) {
+ var maxDepth = 0;
+ function resolve( depth, deferred, handler, special ) {
+ return function() {
+ var that = this,
+ args = arguments,
+ mightThrow = function() {
+ var returned, then;
+
+ // Support: Promises/A+ section 2.3.3.3.3
+ // https://promisesaplus.com/#point-59
+ // Ignore double-resolution attempts
+ if ( depth < maxDepth ) {
+ return;
+ }
+
+ returned = handler.apply( that, args );
+
+ // Support: Promises/A+ section 2.3.1
+ // https://promisesaplus.com/#point-48
+ if ( returned === deferred.promise() ) {
+ throw new TypeError( "Thenable self-resolution" );
+ }
+
+ // Support: Promises/A+ sections 2.3.3.1, 3.5
+ // https://promisesaplus.com/#point-54
+ // https://promisesaplus.com/#point-75
+ // Retrieve `then` only once
+ then = returned &&
+
+ // Support: Promises/A+ section 2.3.4
+ // https://promisesaplus.com/#point-64
+ // Only check objects and functions for thenability
+ ( typeof returned === "object" ||
+ typeof returned === "function" ) &&
+ returned.then;
+
+ // Handle a returned thenable
+ if ( isFunction( then ) ) {
+
+ // Special processors (notify) just wait for resolution
+ if ( special ) {
+ then.call(
+ returned,
+ resolve( maxDepth, deferred, Identity, special ),
+ resolve( maxDepth, deferred, Thrower, special )
+ );
+
+ // Normal processors (resolve) also hook into progress
+ } else {
+
+ // ...and disregard older resolution values
+ maxDepth++;
+
+ then.call(
+ returned,
+ resolve( maxDepth, deferred, Identity, special ),
+ resolve( maxDepth, deferred, Thrower, special ),
+ resolve( maxDepth, deferred, Identity,
+ deferred.notifyWith )
+ );
+ }
+
+ // Handle all other returned values
+ } else {
+
+ // Only substitute handlers pass on context
+ // and multiple values (non-spec behavior)
+ if ( handler !== Identity ) {
+ that = undefined;
+ args = [ returned ];
+ }
+
+ // Process the value(s)
+ // Default process is resolve
+ ( special || deferred.resolveWith )( that, args );
+ }
+ },
+
+ // Only normal processors (resolve) catch and reject exceptions
+ process = special ?
+ mightThrow :
+ function() {
+ try {
+ mightThrow();
+ } catch ( e ) {
+
+ if ( jQuery.Deferred.exceptionHook ) {
+ jQuery.Deferred.exceptionHook( e,
+ process.stackTrace );
+ }
+
+ // Support: Promises/A+ section 2.3.3.3.4.1
+ // https://promisesaplus.com/#point-61
+ // Ignore post-resolution exceptions
+ if ( depth + 1 >= maxDepth ) {
+
+ // Only substitute handlers pass on context
+ // and multiple values (non-spec behavior)
+ if ( handler !== Thrower ) {
+ that = undefined;
+ args = [ e ];
+ }
+
+ deferred.rejectWith( that, args );
+ }
+ }
+ };
+
+ // Support: Promises/A+ section 2.3.3.3.1
+ // https://promisesaplus.com/#point-57
+ // Re-resolve promises immediately to dodge false rejection from
+ // subsequent errors
+ if ( depth ) {
+ process();
+ } else {
+
+ // Call an optional hook to record the stack, in case of exception
+ // since it's otherwise lost when execution goes async
+ if ( jQuery.Deferred.getStackHook ) {
+ process.stackTrace = jQuery.Deferred.getStackHook();
+ }
+ window.setTimeout( process );
+ }
+ };
+ }
+
+ return jQuery.Deferred( function( newDefer ) {
+
+ // progress_handlers.add( ... )
+ tuples[ 0 ][ 3 ].add(
+ resolve(
+ 0,
+ newDefer,
+ isFunction( onProgress ) ?
+ onProgress :
+ Identity,
+ newDefer.notifyWith
+ )
+ );
+
+ // fulfilled_handlers.add( ... )
+ tuples[ 1 ][ 3 ].add(
+ resolve(
+ 0,
+ newDefer,
+ isFunction( onFulfilled ) ?
+ onFulfilled :
+ Identity
+ )
+ );
+
+ // rejected_handlers.add( ... )
+ tuples[ 2 ][ 3 ].add(
+ resolve(
+ 0,
+ newDefer,
+ isFunction( onRejected ) ?
+ onRejected :
+ Thrower
+ )
+ );
+ } ).promise();
+ },
+
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
+ }
+ },
+ deferred = {};
+
+ // Add list-specific methods
+ jQuery.each( tuples, function( i, tuple ) {
+ var list = tuple[ 2 ],
+ stateString = tuple[ 5 ];
+
+ // promise.progress = list.add
+ // promise.done = list.add
+ // promise.fail = list.add
+ promise[ tuple[ 1 ] ] = list.add;
+
+ // Handle state
+ if ( stateString ) {
+ list.add(
+ function() {
+
+ // state = "resolved" (i.e., fulfilled)
+ // state = "rejected"
+ state = stateString;
+ },
+
+ // rejected_callbacks.disable
+ // fulfilled_callbacks.disable
+ tuples[ 3 - i ][ 2 ].disable,
+
+ // rejected_handlers.disable
+ // fulfilled_handlers.disable
+ tuples[ 3 - i ][ 3 ].disable,
+
+ // progress_callbacks.lock
+ tuples[ 0 ][ 2 ].lock,
+
+ // progress_handlers.lock
+ tuples[ 0 ][ 3 ].lock
+ );
+ }
+
+ // progress_handlers.fire
+ // fulfilled_handlers.fire
+ // rejected_handlers.fire
+ list.add( tuple[ 3 ].fire );
+
+ // deferred.notify = function() { deferred.notifyWith(...) }
+ // deferred.resolve = function() { deferred.resolveWith(...) }
+ // deferred.reject = function() { deferred.rejectWith(...) }
+ deferred[ tuple[ 0 ] ] = function() {
+ deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
+ return this;
+ };
+
+ // deferred.notifyWith = list.fireWith
+ // deferred.resolveWith = list.fireWith
+ // deferred.rejectWith = list.fireWith
+ deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
+ } );
+
+ // Make the deferred a promise
+ promise.promise( deferred );
+
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( singleValue ) {
+ var
+
+ // count of uncompleted subordinates
+ remaining = arguments.length,
+
+ // count of unprocessed arguments
+ i = remaining,
+
+ // subordinate fulfillment data
+ resolveContexts = Array( i ),
+ resolveValues = slice.call( arguments ),
+
+ // the master Deferred
+ master = jQuery.Deferred(),
+
+ // subordinate callback factory
+ updateFunc = function( i ) {
+ return function( value ) {
+ resolveContexts[ i ] = this;
+ resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
+ if ( !( --remaining ) ) {
+ master.resolveWith( resolveContexts, resolveValues );
+ }
+ };
+ };
+
+ // Single- and empty arguments are adopted like Promise.resolve
+ if ( remaining <= 1 ) {
+ adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
+ !remaining );
+
+ // Use .then() to unwrap secondary thenables (cf. gh-3000)
+ if ( master.state() === "pending" ||
+ isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
+
+ return master.then();
+ }
+ }
+
+ // Multiple arguments are aggregated like Promise.all array elements
+ while ( i-- ) {
+ adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
+ }
+
+ return master.promise();
+ }
+} );
+
+
+// These usually indicate a programmer mistake during development,
+// warn about them ASAP rather than swallowing them by default.
+var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
+
+jQuery.Deferred.exceptionHook = function( error, stack ) {
+
+ // Support: IE 8 - 9 only
+ // Console exists when dev tools are open, which can happen at any time
+ if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
+ window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
+ }
+};
+
+
+
+
+jQuery.readyException = function( error ) {
+ window.setTimeout( function() {
+ throw error;
+ } );
+};
+
+
+
+
+// The deferred used on DOM ready
+var readyList = jQuery.Deferred();
+
+jQuery.fn.ready = function( fn ) {
+
+ readyList
+ .then( fn )
+
+ // Wrap jQuery.readyException in a function so that the lookup
+ // happens at the time of error handling instead of callback
+ // registration.
+ .catch( function( error ) {
+ jQuery.readyException( error );
+ } );
+
+ return this;
+};
+
+jQuery.extend( {
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+ }
+} );
+
+jQuery.ready.then = readyList.then;
+
+// The ready event handler and self cleanup method
+function completed() {
+ document.removeEventListener( "DOMContentLoaded", completed );
+ window.removeEventListener( "load", completed );
+ jQuery.ready();
+}
+
+// Catch cases where $(document).ready() is called
+// after the browser event has already occurred.
+// Support: IE <=9 - 10 only
+// Older IE sometimes signals "interactive" too soon
+if ( document.readyState === "complete" ||
+ ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
+
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ window.setTimeout( jQuery.ready );
+
+} else {
+
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", completed );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", completed );
+}
+
+
+
+
+// Multifunctional method to get and set values of a collection
+// The value/s can optionally be executed if it's a function
+var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
+ var i = 0,
+ len = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if ( toType( key ) === "object" ) {
+ chainable = true;
+ for ( i in key ) {
+ access( elems, fn, i, key[ i ], true, emptyGet, raw );
+ }
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ chainable = true;
+
+ if ( !isFunction( value ) ) {
+ raw = true;
+ }
+
+ if ( bulk ) {
+
+ // Bulk operations run against the entire set
+ if ( raw ) {
+ fn.call( elems, value );
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function( elem, _key, value ) {
+ return bulk.call( jQuery( elem ), value );
+ };
+ }
+ }
+
+ if ( fn ) {
+ for ( ; i < len; i++ ) {
+ fn(
+ elems[ i ], key, raw ?
+ value :
+ value.call( elems[ i ], i, fn( elems[ i ], key ) )
+ );
+ }
+ }
+ }
+
+ if ( chainable ) {
+ return elems;
+ }
+
+ // Gets
+ if ( bulk ) {
+ return fn.call( elems );
+ }
+
+ return len ? fn( elems[ 0 ], key ) : emptyGet;
+};
+
+
+// Matches dashed string for camelizing
+var rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([a-z])/g;
+
+// Used by camelCase as callback to replace()
+function fcamelCase( _all, letter ) {
+ return letter.toUpperCase();
+}
+
+// Convert dashed to camelCase; used by the css and data modules
+// Support: IE <=9 - 11, Edge 12 - 15
+// Microsoft forgot to hump their vendor prefix (#9572)
+function camelCase( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+}
+var acceptData = function( owner ) {
+
+ // Accepts only:
+ // - Node
+ // - Node.ELEMENT_NODE
+ // - Node.DOCUMENT_NODE
+ // - Object
+ // - Any
+ return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
+};
+
+
+
+
+function Data() {
+ this.expando = jQuery.expando + Data.uid++;
+}
+
+Data.uid = 1;
+
+Data.prototype = {
+
+ cache: function( owner ) {
+
+ // Check if the owner object already has a cache
+ var value = owner[ this.expando ];
+
+ // If not, create one
+ if ( !value ) {
+ value = {};
+
+ // We can accept data for non-element nodes in modern browsers,
+ // but we should not, see #8335.
+ // Always return an empty object.
+ if ( acceptData( owner ) ) {
+
+ // If it is a node unlikely to be stringify-ed or looped over
+ // use plain assignment
+ if ( owner.nodeType ) {
+ owner[ this.expando ] = value;
+
+ // Otherwise secure it in a non-enumerable property
+ // configurable must be true to allow the property to be
+ // deleted when data is removed
+ } else {
+ Object.defineProperty( owner, this.expando, {
+ value: value,
+ configurable: true
+ } );
+ }
+ }
+ }
+
+ return value;
+ },
+ set: function( owner, data, value ) {
+ var prop,
+ cache = this.cache( owner );
+
+ // Handle: [ owner, key, value ] args
+ // Always use camelCase key (gh-2257)
+ if ( typeof data === "string" ) {
+ cache[ camelCase( data ) ] = value;
+
+ // Handle: [ owner, { properties } ] args
+ } else {
+
+ // Copy the properties one-by-one to the cache object
+ for ( prop in data ) {
+ cache[ camelCase( prop ) ] = data[ prop ];
+ }
+ }
+ return cache;
+ },
+ get: function( owner, key ) {
+ return key === undefined ?
+ this.cache( owner ) :
+
+ // Always use camelCase key (gh-2257)
+ owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
+ },
+ access: function( owner, key, value ) {
+
+ // In cases where either:
+ //
+ // 1. No key was specified
+ // 2. A string key was specified, but no value provided
+ //
+ // Take the "read" path and allow the get method to determine
+ // which value to return, respectively either:
+ //
+ // 1. The entire cache object
+ // 2. The data stored at the key
+ //
+ if ( key === undefined ||
+ ( ( key && typeof key === "string" ) && value === undefined ) ) {
+
+ return this.get( owner, key );
+ }
+
+ // When the key is not a string, or both a key and value
+ // are specified, set or extend (existing objects) with either:
+ //
+ // 1. An object of properties
+ // 2. A key and value
+ //
+ this.set( owner, key, value );
+
+ // Since the "set" path can have two possible entry points
+ // return the expected data based on which path was taken[*]
+ return value !== undefined ? value : key;
+ },
+ remove: function( owner, key ) {
+ var i,
+ cache = owner[ this.expando ];
+
+ if ( cache === undefined ) {
+ return;
+ }
+
+ if ( key !== undefined ) {
+
+ // Support array or space separated string of keys
+ if ( Array.isArray( key ) ) {
+
+ // If key is an array of keys...
+ // We always set camelCase keys, so remove that.
+ key = key.map( camelCase );
+ } else {
+ key = camelCase( key );
+
+ // If a key with the spaces exists, use it.
+ // Otherwise, create an array by matching non-whitespace
+ key = key in cache ?
+ [ key ] :
+ ( key.match( rnothtmlwhite ) || [] );
+ }
+
+ i = key.length;
+
+ while ( i-- ) {
+ delete cache[ key[ i ] ];
+ }
+ }
+
+ // Remove the expando if there's no more data
+ if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
+
+ // Support: Chrome <=35 - 45
+ // Webkit & Blink performance suffers when deleting properties
+ // from DOM nodes, so set to undefined instead
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
+ if ( owner.nodeType ) {
+ owner[ this.expando ] = undefined;
+ } else {
+ delete owner[ this.expando ];
+ }
+ }
+ },
+ hasData: function( owner ) {
+ var cache = owner[ this.expando ];
+ return cache !== undefined && !jQuery.isEmptyObject( cache );
+ }
+};
+var dataPriv = new Data();
+
+var dataUser = new Data();
+
+
+
+// Implementation Summary
+//
+// 1. Enforce API surface and semantic compatibility with 1.9.x branch
+// 2. Improve the module's maintainability by reducing the storage
+// paths to a single mechanism.
+// 3. Use the same single mechanism to support "private" and "user" data.
+// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
+// 5. Avoid exposing implementation details on user objects (eg. expando properties)
+// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
+
+var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
+ rmultiDash = /[A-Z]/g;
+
+function getData( data ) {
+ if ( data === "true" ) {
+ return true;
+ }
+
+ if ( data === "false" ) {
+ return false;
+ }
+
+ if ( data === "null" ) {
+ return null;
+ }
+
+ // Only convert to a number if it doesn't change the string
+ if ( data === +data + "" ) {
+ return +data;
+ }
+
+ if ( rbrace.test( data ) ) {
+ return JSON.parse( data );
+ }
+
+ return data;
+}
+
+function dataAttr( elem, key, data ) {
+ var name;
+
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+ name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
+ data = elem.getAttribute( name );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = getData( data );
+ } catch ( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ dataUser.set( elem, key, data );
+ } else {
+ data = undefined;
+ }
+ }
+ return data;
+}
+
+jQuery.extend( {
+ hasData: function( elem ) {
+ return dataUser.hasData( elem ) || dataPriv.hasData( elem );
+ },
+
+ data: function( elem, name, data ) {
+ return dataUser.access( elem, name, data );
+ },
+
+ removeData: function( elem, name ) {
+ dataUser.remove( elem, name );
+ },
+
+ // TODO: Now that all calls to _data and _removeData have been replaced
+ // with direct calls to dataPriv methods, these can be deprecated.
+ _data: function( elem, name, data ) {
+ return dataPriv.access( elem, name, data );
+ },
+
+ _removeData: function( elem, name ) {
+ dataPriv.remove( elem, name );
+ }
+} );
+
+jQuery.fn.extend( {
+ data: function( key, value ) {
+ var i, name, data,
+ elem = this[ 0 ],
+ attrs = elem && elem.attributes;
+
+ // Gets all values
+ if ( key === undefined ) {
+ if ( this.length ) {
+ data = dataUser.get( elem );
+
+ if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
+ i = attrs.length;
+ while ( i-- ) {
+
+ // Support: IE 11 only
+ // The attrs elements can be null (#14894)
+ if ( attrs[ i ] ) {
+ name = attrs[ i ].name;
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = camelCase( name.slice( 5 ) );
+ dataAttr( elem, name, data[ name ] );
+ }
+ }
+ }
+ dataPriv.set( elem, "hasDataAttrs", true );
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if ( typeof key === "object" ) {
+ return this.each( function() {
+ dataUser.set( this, key );
+ } );
+ }
+
+ return access( this, function( value ) {
+ var data;
+
+ // The calling jQuery object (element matches) is not empty
+ // (and therefore has an element appears at this[ 0 ]) and the
+ // `value` parameter was not undefined. An empty jQuery object
+ // will result in `undefined` for elem = this[ 0 ] which will
+ // throw an exception if an attempt to read a data cache is made.
+ if ( elem && value === undefined ) {
+
+ // Attempt to get data from the cache
+ // The key will always be camelCased in Data
+ data = dataUser.get( elem, key );
+ if ( data !== undefined ) {
+ return data;
+ }
+
+ // Attempt to "discover" the data in
+ // HTML5 custom data-* attrs
+ data = dataAttr( elem, key );
+ if ( data !== undefined ) {
+ return data;
+ }
+
+ // We tried really hard, but the data doesn't exist.
+ return;
+ }
+
+ // Set the data...
+ this.each( function() {
+
+ // We always store the camelCased key
+ dataUser.set( this, key, value );
+ } );
+ }, null, value, arguments.length > 1, null, true );
+ },
+
+ removeData: function( key ) {
+ return this.each( function() {
+ dataUser.remove( this, key );
+ } );
+ }
+} );
+
+
+jQuery.extend( {
+ queue: function( elem, type, data ) {
+ var queue;
+
+ if ( elem ) {
+ type = ( type || "fx" ) + "queue";
+ queue = dataPriv.get( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !queue || Array.isArray( data ) ) {
+ queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
+ } else {
+ queue.push( data );
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks( elem, type ),
+ next = function() {
+ jQuery.dequeue( elem, type );
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ if ( fn ) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift( "inprogress" );
+ }
+
+ // Clear up the last queue stop function
+ delete hooks.stop;
+ fn.call( elem, next, hooks );
+ }
+
+ if ( !startLength && hooks ) {
+ hooks.empty.fire();
+ }
+ },
+
+ // Not public - generate a queueHooks object, or return the current one
+ _queueHooks: function( elem, type ) {
+ var key = type + "queueHooks";
+ return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
+ empty: jQuery.Callbacks( "once memory" ).add( function() {
+ dataPriv.remove( elem, [ type + "queue", key ] );
+ } )
+ } );
+ }
+} );
+
+jQuery.fn.extend( {
+ queue: function( type, data ) {
+ var setter = 2;
+
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if ( arguments.length < setter ) {
+ return jQuery.queue( this[ 0 ], type );
+ }
+
+ return data === undefined ?
+ this :
+ this.each( function() {
+ var queue = jQuery.queue( this, type, data );
+
+ // Ensure a hooks for this queue
+ jQuery._queueHooks( this, type );
+
+ if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ } );
+ },
+ dequeue: function( type ) {
+ return this.each( function() {
+ jQuery.dequeue( this, type );
+ } );
+ },
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ },
+
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function( type, obj ) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ };
+
+ if ( typeof type !== "string" ) {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while ( i-- ) {
+ tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
+ count++;
+ tmp.empty.add( resolve );
+ }
+ }
+ resolve();
+ return defer.promise( obj );
+ }
+} );
+var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
+
+var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
+
+
+var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
+var documentElement = document.documentElement;
+
+
+
+ var isAttached = function( elem ) {
+ return jQuery.contains( elem.ownerDocument, elem );
+ },
+ composed = { composed: true };
+
+ // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
+ // Check attachment across shadow DOM boundaries when possible (gh-3504)
+ // Support: iOS 10.0-10.2 only
+ // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
+ // leading to errors. We need to check for `getRootNode`.
+ if ( documentElement.getRootNode ) {
+ isAttached = function( elem ) {
+ return jQuery.contains( elem.ownerDocument, elem ) ||
+ elem.getRootNode( composed ) === elem.ownerDocument;
+ };
+ }
+var isHiddenWithinTree = function( elem, el ) {
+
+ // isHiddenWithinTree might be called from jQuery#filter function;
+ // in that case, element will be second argument
+ elem = el || elem;
+
+ // Inline style trumps all
+ return elem.style.display === "none" ||
+ elem.style.display === "" &&
+
+ // Otherwise, check computed style
+ // Support: Firefox <=43 - 45
+ // Disconnected elements can have computed display: none, so first confirm that elem is
+ // in the document.
+ isAttached( elem ) &&
+
+ jQuery.css( elem, "display" ) === "none";
+ };
+
+
+
+function adjustCSS( elem, prop, valueParts, tween ) {
+ var adjusted, scale,
+ maxIterations = 20,
+ currentValue = tween ?
+ function() {
+ return tween.cur();
+ } :
+ function() {
+ return jQuery.css( elem, prop, "" );
+ },
+ initial = currentValue(),
+ unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
+
+ // Starting value computation is required for potential unit mismatches
+ initialInUnit = elem.nodeType &&
+ ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
+ rcssNum.exec( jQuery.css( elem, prop ) );
+
+ if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
+
+ // Support: Firefox <=54
+ // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
+ initial = initial / 2;
+
+ // Trust units reported by jQuery.css
+ unit = unit || initialInUnit[ 3 ];
+
+ // Iteratively approximate from a nonzero starting point
+ initialInUnit = +initial || 1;
+
+ while ( maxIterations-- ) {
+
+ // Evaluate and update our best guess (doubling guesses that zero out).
+ // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
+ jQuery.style( elem, prop, initialInUnit + unit );
+ if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
+ maxIterations = 0;
+ }
+ initialInUnit = initialInUnit / scale;
+
+ }
+
+ initialInUnit = initialInUnit * 2;
+ jQuery.style( elem, prop, initialInUnit + unit );
+
+ // Make sure we update the tween properties later on
+ valueParts = valueParts || [];
+ }
+
+ if ( valueParts ) {
+ initialInUnit = +initialInUnit || +initial || 0;
+
+ // Apply relative offset (+=/-=) if specified
+ adjusted = valueParts[ 1 ] ?
+ initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+ +valueParts[ 2 ];
+ if ( tween ) {
+ tween.unit = unit;
+ tween.start = initialInUnit;
+ tween.end = adjusted;
+ }
+ }
+ return adjusted;
+}
+
+
+var defaultDisplayMap = {};
+
+function getDefaultDisplay( elem ) {
+ var temp,
+ doc = elem.ownerDocument,
+ nodeName = elem.nodeName,
+ display = defaultDisplayMap[ nodeName ];
+
+ if ( display ) {
+ return display;
+ }
+
+ temp = doc.body.appendChild( doc.createElement( nodeName ) );
+ display = jQuery.css( temp, "display" );
+
+ temp.parentNode.removeChild( temp );
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+ defaultDisplayMap[ nodeName ] = display;
+
+ return display;
+}
+
+function showHide( elements, show ) {
+ var display, elem,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ // Determine new display value for elements that need to change
+ for ( ; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+
+ display = elem.style.display;
+ if ( show ) {
+
+ // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
+ // check is required in this first loop unless we have a nonempty display value (either
+ // inline or about-to-be-restored)
+ if ( display === "none" ) {
+ values[ index ] = dataPriv.get( elem, "display" ) || null;
+ if ( !values[ index ] ) {
+ elem.style.display = "";
+ }
+ }
+ if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
+ values[ index ] = getDefaultDisplay( elem );
+ }
+ } else {
+ if ( display !== "none" ) {
+ values[ index ] = "none";
+
+ // Remember what we're overwriting
+ dataPriv.set( elem, "display", display );
+ }
+ }
+ }
+
+ // Set the display of the elements in a second loop to avoid constant reflow
+ for ( index = 0; index < length; index++ ) {
+ if ( values[ index ] != null ) {
+ elements[ index ].style.display = values[ index ];
+ }
+ }
+
+ return elements;
+}
+
+jQuery.fn.extend( {
+ show: function() {
+ return showHide( this, true );
+ },
+ hide: function() {
+ return showHide( this );
+ },
+ toggle: function( state ) {
+ if ( typeof state === "boolean" ) {
+ return state ? this.show() : this.hide();
+ }
+
+ return this.each( function() {
+ if ( isHiddenWithinTree( this ) ) {
+ jQuery( this ).show();
+ } else {
+ jQuery( this ).hide();
+ }
+ } );
+ }
+} );
+var rcheckableType = ( /^(?:checkbox|radio)$/i );
+
+var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
+
+var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
+
+
+
+( function() {
+ var fragment = document.createDocumentFragment(),
+ div = fragment.appendChild( document.createElement( "div" ) ),
+ input = document.createElement( "input" );
+
+ // Support: Android 4.0 - 4.3 only
+ // Check state lost if the name is set (#11217)
+ // Support: Windows Web Apps (WWA)
+ // `name` and `type` must use .setAttribute for WWA (#14901)
+ input.setAttribute( "type", "radio" );
+ input.setAttribute( "checked", "checked" );
+ input.setAttribute( "name", "t" );
+
+ div.appendChild( input );
+
+ // Support: Android <=4.1 only
+ // Older WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ // Support: IE <=11 only
+ // Make sure textarea (and checkbox) defaultValue is properly cloned
+ div.innerHTML = "<textarea>x</textarea>";
+ support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+ // Support: IE <=9 only
+ // IE <=9 replaces <option> tags with their contents when inserted outside of
+ // the select element.
+ div.innerHTML = "<option></option>";
+ support.option = !!div.lastChild;
+} )();
+
+
+// We have to close these tags to support XHTML (#13200)
+var wrapMap = {
+
+ // XHTML parsers do not magically insert elements in the
+ // same way that tag soup parsers do. So we cannot shorten
+ // this by omitting <tbody> or other required elements.
+ thead: [ 1, "<table>", "</table>" ],
+ col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+
+ _default: [ 0, "", "" ]
+};
+
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// Support: IE <=9 only
+if ( !support.option ) {
+ wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
+}
+
+
+function getAll( context, tag ) {
+
+ // Support: IE <=9 - 11 only
+ // Use typeof to avoid zero-argument method invocation on host objects (#15151)
+ var ret;
+
+ if ( typeof context.getElementsByTagName !== "undefined" ) {
+ ret = context.getElementsByTagName( tag || "*" );
+
+ } else if ( typeof context.querySelectorAll !== "undefined" ) {
+ ret = context.querySelectorAll( tag || "*" );
+
+ } else {
+ ret = [];
+ }
+
+ if ( tag === undefined || tag && nodeName( context, tag ) ) {
+ return jQuery.merge( [ context ], ret );
+ }
+
+ return ret;
+}
+
+
+// Mark scripts as having already been evaluated
+function setGlobalEval( elems, refElements ) {
+ var i = 0,
+ l = elems.length;
+
+ for ( ; i < l; i++ ) {
+ dataPriv.set(
+ elems[ i ],
+ "globalEval",
+ !refElements || dataPriv.get( refElements[ i ], "globalEval" )
+ );
+ }
+}
+
+
+var rhtml = /<|&#?\w+;/;
+
+function buildFragment( elems, context, scripts, selection, ignored ) {
+ var elem, tmp, tag, wrap, attached, j,
+ fragment = context.createDocumentFragment(),
+ nodes = [],
+ i = 0,
+ l = elems.length;
+
+ for ( ; i < l; i++ ) {
+ elem = elems[ i ];
+
+ if ( elem || elem === 0 ) {
+
+ // Add nodes directly
+ if ( toType( elem ) === "object" ) {
+
+ // Support: Android <=4.0 only, PhantomJS 1 only
+ // push.apply(_, arraylike) throws on ancient WebKit
+ jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
+
+ // Convert non-html into a text node
+ } else if ( !rhtml.test( elem ) ) {
+ nodes.push( context.createTextNode( elem ) );
+
+ // Convert html into DOM nodes
+ } else {
+ tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
+
+ // Deserialize a standard representation
+ tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
+ wrap = wrapMap[ tag ] || wrapMap._default;
+ tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
+
+ // Descend through wrappers to the right content
+ j = wrap[ 0 ];
+ while ( j-- ) {
+ tmp = tmp.lastChild;
+ }
+
+ // Support: Android <=4.0 only, PhantomJS 1 only
+ // push.apply(_, arraylike) throws on ancient WebKit
+ jQuery.merge( nodes, tmp.childNodes );
+
+ // Remember the top-level container
+ tmp = fragment.firstChild;
+
+ // Ensure the created nodes are orphaned (#12392)
+ tmp.textContent = "";
+ }
+ }
+ }
+
+ // Remove wrapper from fragment
+ fragment.textContent = "";
+
+ i = 0;
+ while ( ( elem = nodes[ i++ ] ) ) {
+
+ // Skip elements already in the context collection (trac-4087)
+ if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
+ if ( ignored ) {
+ ignored.push( elem );
+ }
+ continue;
+ }
+
+ attached = isAttached( elem );
+
+ // Append to fragment
+ tmp = getAll( fragment.appendChild( elem ), "script" );
+
+ // Preserve script evaluation history
+ if ( attached ) {
+ setGlobalEval( tmp );
+ }
+
+ // Capture executables
+ if ( scripts ) {
+ j = 0;
+ while ( ( elem = tmp[ j++ ] ) ) {
+ if ( rscriptType.test( elem.type || "" ) ) {
+ scripts.push( elem );
+ }
+ }
+ }
+ }
+
+ return fragment;
+}
+
+
+var
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
+ rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
+
+function returnTrue() {
+ return true;
+}
+
+function returnFalse() {
+ return false;
+}
+
+// Support: IE <=9 - 11+
+// focus() and blur() are asynchronous, except when they are no-op.
+// So expect focus to be synchronous when the element is already active,
+// and blur to be synchronous when the element is not already active.
+// (focus and blur are always synchronous in other supported browsers,
+// this just defines when we can count on it).
+function expectSync( elem, type ) {
+ return ( elem === safeActiveElement() ) === ( type === "focus" );
+}
+
+// Support: IE <=9 only
+// Accessing document.activeElement can throw unexpectedly
+// https://bugs.jquery.com/ticket/13393
+function safeActiveElement() {
+ try {
+ return document.activeElement;
+ } catch ( err ) { }
+}
+
+function on( elem, types, selector, data, fn, one ) {
+ var origFn, type;
+
+ // Types can be a map of types/handlers
+ if ( typeof types === "object" ) {
+
+ // ( types-Object, selector, data )
+ if ( typeof selector !== "string" ) {
+
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for ( type in types ) {
+ on( elem, type, selector, data, types[ type ], one );
+ }
+ return elem;
+ }
+
+ if ( data == null && fn == null ) {
+
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if ( fn == null ) {
+ if ( typeof selector === "string" ) {
+
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ } else if ( !fn ) {
+ return elem;
+ }
+
+ if ( one === 1 ) {
+ origFn = fn;
+ fn = function( event ) {
+
+ // Can use an empty set, since event contains the info
+ jQuery().off( event );
+ return origFn.apply( this, arguments );
+ };
+
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return elem.each( function() {
+ jQuery.event.add( this, types, fn, data, selector );
+ } );
+}
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+ global: {},
+
+ add: function( elem, types, handler, data, selector ) {
+
+ var handleObjIn, eventHandle, tmp,
+ events, t, handleObj,
+ special, handlers, type, namespaces, origType,
+ elemData = dataPriv.get( elem );
+
+ // Only attach events to objects that accept data
+ if ( !acceptData( elem ) ) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Ensure that invalid selectors throw exceptions at attach time
+ // Evaluate against documentElement in case elem is a non-element node (e.g., document)
+ if ( selector ) {
+ jQuery.find.matchesSelector( documentElement, selector );
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ if ( !( events = elemData.events ) ) {
+ events = elemData.events = Object.create( null );
+ }
+ if ( !( eventHandle = elemData.handle ) ) {
+ eventHandle = elemData.handle = function( e ) {
+
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
+ jQuery.event.dispatch.apply( elem, arguments ) : undefined;
+ };
+ }
+
+ // Handle multiple events separated by a space
+ types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[ t ] ) || [];
+ type = origType = tmp[ 1 ];
+ namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+ // There *must* be a type, no attaching namespace-only handlers
+ if ( !type ) {
+ continue;
+ }
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[ type ] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[ type ] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend( {
+ type: type,
+ origType: origType,
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+ namespace: namespaces.join( "." )
+ }, handleObjIn );
+
+ // Init the event handler queue if we're the first
+ if ( !( handlers = events[ type ] ) ) {
+ handlers = events[ type ] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener if the special events handler returns false
+ if ( !special.setup ||
+ special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if ( selector ) {
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
+ } else {
+ handlers.push( handleObj );
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ },
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, selector, mappedTypes ) {
+
+ var j, origCount, tmp,
+ events, t, handleObj,
+ special, handlers, type, namespaces, origType,
+ elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
+
+ if ( !elemData || !( events = elemData.events ) ) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[ t ] ) || [];
+ type = origType = tmp[ 1 ];
+ namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if ( !type ) {
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+ handlers = events[ type ] || [];
+ tmp = tmp[ 2 ] &&
+ new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
+
+ // Remove matching events
+ origCount = j = handlers.length;
+ while ( j-- ) {
+ handleObj = handlers[ j ];
+
+ if ( ( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !tmp || tmp.test( handleObj.namespace ) ) &&
+ ( !selector || selector === handleObj.selector ||
+ selector === "**" && handleObj.selector ) ) {
+ handlers.splice( j, 1 );
+
+ if ( handleObj.selector ) {
+ handlers.delegateCount--;
+ }
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if ( origCount && !handlers.length ) {
+ if ( !special.teardown ||
+ special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ delete events[ type ];
+ }
+ }
+
+ // Remove data and the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ dataPriv.remove( elem, "handle events" );
+ }
+ },
+
+ dispatch: function( nativeEvent ) {
+
+ var i, j, ret, matched, handleObj, handlerQueue,
+ args = new Array( arguments.length ),
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix( nativeEvent ),
+
+ handlers = (
+ dataPriv.get( this, "events" ) || Object.create( null )
+ )[ event.type ] || [],
+ special = jQuery.event.special[ event.type ] || {};
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[ 0 ] = event;
+
+ for ( i = 1; i < arguments.length; i++ ) {
+ args[ i ] = arguments[ i ];
+ }
+
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
+ // Determine handlers
+ handlerQueue = jQuery.event.handlers.call( this, event, handlers );
+
+ // Run delegates first; they may want to stop propagation beneath us
+ i = 0;
+ while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
+ event.currentTarget = matched.elem;
+
+ j = 0;
+ while ( ( handleObj = matched.handlers[ j++ ] ) &&
+ !event.isImmediatePropagationStopped() ) {
+
+ // If the event is namespaced, then each handler is only invoked if it is
+ // specially universal or its namespaces are a superset of the event's.
+ if ( !event.rnamespace || handleObj.namespace === false ||
+ event.rnamespace.test( handleObj.namespace ) ) {
+
+ event.handleObj = handleObj;
+ event.data = handleObj.data;
+
+ ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
+ handleObj.handler ).apply( matched.elem, args );
+
+ if ( ret !== undefined ) {
+ if ( ( event.result = ret ) === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
+ return event.result;
+ },
+
+ handlers: function( event, handlers ) {
+ var i, handleObj, sel, matchedHandlers, matchedSelectors,
+ handlerQueue = [],
+ delegateCount = handlers.delegateCount,
+ cur = event.target;
+
+ // Find delegate handlers
+ if ( delegateCount &&
+
+ // Support: IE <=9
+ // Black-hole SVG <use> instance trees (trac-13180)
+ cur.nodeType &&
+
+ // Support: Firefox <=42
+ // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
+ // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
+ // Support: IE 11 only
+ // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
+ !( event.type === "click" && event.button >= 1 ) ) {
+
+ for ( ; cur !== this; cur = cur.parentNode || this ) {
+
+ // Don't check non-elements (#13208)
+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
+ matchedHandlers = [];
+ matchedSelectors = {};
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
+
+ if ( matchedSelectors[ sel ] === undefined ) {
+ matchedSelectors[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) > -1 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( matchedSelectors[ sel ] ) {
+ matchedHandlers.push( handleObj );
+ }
+ }
+ if ( matchedHandlers.length ) {
+ handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ cur = this;
+ if ( delegateCount < handlers.length ) {
+ handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
+ }
+
+ return handlerQueue;
+ },
+
+ addProp: function( name, hook ) {
+ Object.defineProperty( jQuery.Event.prototype, name, {
+ enumerable: true,
+ configurable: true,
+
+ get: isFunction( hook ) ?
+ function() {
+ if ( this.originalEvent ) {
+ return hook( this.originalEvent );
+ }
+ } :
+ function() {
+ if ( this.originalEvent ) {
+ return this.originalEvent[ name ];
+ }
+ },
+
+ set: function( value ) {
+ Object.defineProperty( this, name, {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: value
+ } );
+ }
+ } );
+ },
+
+ fix: function( originalEvent ) {
+ return originalEvent[ jQuery.expando ] ?
+ originalEvent :
+ new jQuery.Event( originalEvent );
+ },
+
+ special: {
+ load: {
+
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+ click: {
+
+ // Utilize native event to ensure correct state for checkable inputs
+ setup: function( data ) {
+
+ // For mutual compressibility with _default, replace `this` access with a local var.
+ // `|| data` is dead code meant only to preserve the variable through minification.
+ var el = this || data;
+
+ // Claim the first handler
+ if ( rcheckableType.test( el.type ) &&
+ el.click && nodeName( el, "input" ) ) {
+
+ // dataPriv.set( el, "click", ... )
+ leverageNative( el, "click", returnTrue );
+ }
+
+ // Return false to allow normal processing in the caller
+ return false;
+ },
+ trigger: function( data ) {
+
+ // For mutual compressibility with _default, replace `this` access with a local var.
+ // `|| data` is dead code meant only to preserve the variable through minification.
+ var el = this || data;
+
+ // Force setup before triggering a click
+ if ( rcheckableType.test( el.type ) &&
+ el.click && nodeName( el, "input" ) ) {
+
+ leverageNative( el, "click" );
+ }
+
+ // Return non-false to allow normal event-path propagation
+ return true;
+ },
+
+ // For cross-browser consistency, suppress native .click() on links
+ // Also prevent it if we're currently inside a leveraged native-event stack
+ _default: function( event ) {
+ var target = event.target;
+ return rcheckableType.test( target.type ) &&
+ target.click && nodeName( target, "input" ) &&
+ dataPriv.get( target, "click" ) ||
+ nodeName( target, "a" );
+ }
+ },
+
+ beforeunload: {
+ postDispatch: function( event ) {
+
+ // Support: Firefox 20+
+ // Firefox doesn't alert if the returnValue field is not set.
+ if ( event.result !== undefined && event.originalEvent ) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ }
+};
+
+// Ensure the presence of an event listener that handles manually-triggered
+// synthetic events by interrupting progress until reinvoked in response to
+// *native* events that it fires directly, ensuring that state changes have
+// already occurred before other listeners are invoked.
+function leverageNative( el, type, expectSync ) {
+
+ // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
+ if ( !expectSync ) {
+ if ( dataPriv.get( el, type ) === undefined ) {
+ jQuery.event.add( el, type, returnTrue );
+ }
+ return;
+ }
+
+ // Register the controller as a special universal handler for all event namespaces
+ dataPriv.set( el, type, false );
+ jQuery.event.add( el, type, {
+ namespace: false,
+ handler: function( event ) {
+ var notAsync, result,
+ saved = dataPriv.get( this, type );
+
+ if ( ( event.isTrigger & 1 ) && this[ type ] ) {
+
+ // Interrupt processing of the outer synthetic .trigger()ed event
+ // Saved data should be false in such cases, but might be a leftover capture object
+ // from an async native handler (gh-4350)
+ if ( !saved.length ) {
+
+ // Store arguments for use when handling the inner native event
+ // There will always be at least one argument (an event object), so this array
+ // will not be confused with a leftover capture object.
+ saved = slice.call( arguments );
+ dataPriv.set( this, type, saved );
+
+ // Trigger the native event and capture its result
+ // Support: IE <=9 - 11+
+ // focus() and blur() are asynchronous
+ notAsync = expectSync( this, type );
+ this[ type ]();
+ result = dataPriv.get( this, type );
+ if ( saved !== result || notAsync ) {
+ dataPriv.set( this, type, false );
+ } else {
+ result = {};
+ }
+ if ( saved !== result ) {
+
+ // Cancel the outer synthetic event
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ return result.value;
+ }
+
+ // If this is an inner synthetic event for an event with a bubbling surrogate
+ // (focus or blur), assume that the surrogate already propagated from triggering the
+ // native event and prevent that from happening again here.
+ // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
+ // bubbling surrogate propagates *after* the non-bubbling base), but that seems
+ // less bad than duplication.
+ } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
+ event.stopPropagation();
+ }
+
+ // If this is a native event triggered above, everything is now in order
+ // Fire an inner synthetic event with the original arguments
+ } else if ( saved.length ) {
+
+ // ...and capture the result
+ dataPriv.set( this, type, {
+ value: jQuery.event.trigger(
+
+ // Support: IE <=9 - 11+
+ // Extend with the prototype to reset the above stopImmediatePropagation()
+ jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
+ saved.slice( 1 ),
+ this
+ )
+ } );
+
+ // Abort handling of the native event
+ event.stopImmediatePropagation();
+ }
+ }
+ } );
+}
+
+jQuery.removeEvent = function( elem, type, handle ) {
+
+ // This "if" is needed for plain objects
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle );
+ }
+};
+
+jQuery.Event = function( src, props ) {
+
+ // Allow instantiation without the 'new' keyword
+ if ( !( this instanceof jQuery.Event ) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = src.defaultPrevented ||
+ src.defaultPrevented === undefined &&
+
+ // Support: Android <=2.3 only
+ src.returnValue === false ?
+ returnTrue :
+ returnFalse;
+
+ // Create target properties
+ // Support: Safari <=6 - 7 only
+ // Target should not be a text node (#504, #13143)
+ this.target = ( src.target && src.target.nodeType === 3 ) ?
+ src.target.parentNode :
+ src.target;
+
+ this.currentTarget = src.currentTarget;
+ this.relatedTarget = src.relatedTarget;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || Date.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ constructor: jQuery.Event,
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+ isSimulated: false,
+
+ preventDefault: function() {
+ var e = this.originalEvent;
+
+ this.isDefaultPrevented = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.preventDefault();
+ }
+ },
+ stopPropagation: function() {
+ var e = this.originalEvent;
+
+ this.isPropagationStopped = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.stopPropagation();
+ }
+ },
+ stopImmediatePropagation: function() {
+ var e = this.originalEvent;
+
+ this.isImmediatePropagationStopped = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.stopImmediatePropagation();
+ }
+
+ this.stopPropagation();
+ }
+};
+
+// Includes all common event props including KeyEvent and MouseEvent specific props
+jQuery.each( {
+ altKey: true,
+ bubbles: true,
+ cancelable: true,
+ changedTouches: true,
+ ctrlKey: true,
+ detail: true,
+ eventPhase: true,
+ metaKey: true,
+ pageX: true,
+ pageY: true,
+ shiftKey: true,
+ view: true,
+ "char": true,
+ code: true,
+ charCode: true,
+ key: true,
+ keyCode: true,
+ button: true,
+ buttons: true,
+ clientX: true,
+ clientY: true,
+ offsetX: true,
+ offsetY: true,
+ pointerId: true,
+ pointerType: true,
+ screenX: true,
+ screenY: true,
+ targetTouches: true,
+ toElement: true,
+ touches: true,
+
+ which: function( event ) {
+ var button = event.button;
+
+ // Add which for key events
+ if ( event.which == null && rkeyEvent.test( event.type ) ) {
+ return event.charCode != null ? event.charCode : event.keyCode;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
+ if ( button & 1 ) {
+ return 1;
+ }
+
+ if ( button & 2 ) {
+ return 3;
+ }
+
+ if ( button & 4 ) {
+ return 2;
+ }
+
+ return 0;
+ }
+
+ return event.which;
+ }
+}, jQuery.event.addProp );
+
+jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
+ jQuery.event.special[ type ] = {
+
+ // Utilize native event if possible so blur/focus sequence is correct
+ setup: function() {
+
+ // Claim the first handler
+ // dataPriv.set( this, "focus", ... )
+ // dataPriv.set( this, "blur", ... )
+ leverageNative( this, type, expectSync );
+
+ // Return false to allow normal processing in the caller
+ return false;
+ },
+ trigger: function() {
+
+ // Force setup before trigger
+ leverageNative( this, type );
+
+ // Return non-false to allow normal event-path propagation
+ return true;
+ },
+
+ delegateType: delegateType
+ };
+} );
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+// so that event delegation works in jQuery.
+// Do the same for pointerenter/pointerleave and pointerover/pointerout
+//
+// Support: Safari 7 only
+// Safari sends mouseenter too often; see:
+// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
+// for the description of the bug (it existed in older Chrome versions as well).
+jQuery.each( {
+ mouseenter: "mouseover",
+ mouseleave: "mouseout",
+ pointerenter: "pointerover",
+ pointerleave: "pointerout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj;
+
+ // For mouseenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+} );
+
+jQuery.fn.extend( {
+
+ on: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn );
+ },
+ one: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ?
+ handleObj.origType + "." + handleObj.namespace :
+ handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each( function() {
+ jQuery.event.remove( this, types, fn, selector );
+ } );
+ }
+} );
+
+
+var
+
+ // Support: IE <=10 - 11, Edge 12 - 13 only
+ // In IE/Edge using regex groups here causes severe slowdowns.
+ // See https://connect.microsoft.com/IE/feedback/details/1736512/
+ rnoInnerhtml = /<script|<style|<link/i,
+
+ // checked="checked" or checked
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+ rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
+
+// Prefer a tbody over its parent table for containing new rows
+function manipulationTarget( elem, content ) {
+ if ( nodeName( elem, "table" ) &&
+ nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
+
+ return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
+ }
+
+ return elem;
+}
+
+// Replace/restore the type attribute of script elements for safe DOM manipulation
+function disableScript( elem ) {
+ elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
+ return elem;
+}
+function restoreScript( elem ) {
+ if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
+ elem.type = elem.type.slice( 5 );
+ } else {
+ elem.removeAttribute( "type" );
+ }
+
+ return elem;
+}
+
+function cloneCopyEvent( src, dest ) {
+ var i, l, type, pdataOld, udataOld, udataCur, events;
+
+ if ( dest.nodeType !== 1 ) {
+ return;
+ }
+
+ // 1. Copy private data: events, handlers, etc.
+ if ( dataPriv.hasData( src ) ) {
+ pdataOld = dataPriv.get( src );
+ events = pdataOld.events;
+
+ if ( events ) {
+ dataPriv.remove( dest, "handle events" );
+
+ for ( type in events ) {
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+ jQuery.event.add( dest, type, events[ type ][ i ] );
+ }
+ }
+ }
+ }
+
+ // 2. Copy user data
+ if ( dataUser.hasData( src ) ) {
+ udataOld = dataUser.access( src );
+ udataCur = jQuery.extend( {}, udataOld );
+
+ dataUser.set( dest, udataCur );
+ }
+}
+
+// Fix IE bugs, see support tests
+function fixInput( src, dest ) {
+ var nodeName = dest.nodeName.toLowerCase();
+
+ // Fails to persist the checked state of a cloned checkbox or radio button.
+ if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+ dest.checked = src.checked;
+
+ // Fails to return the selected option to the default selected state when cloning options
+ } else if ( nodeName === "input" || nodeName === "textarea" ) {
+ dest.defaultValue = src.defaultValue;
+ }
+}
+
+function domManip( collection, args, callback, ignored ) {
+
+ // Flatten any nested arrays
+ args = flat( args );
+
+ var fragment, first, scripts, hasScripts, node, doc,
+ i = 0,
+ l = collection.length,
+ iNoClone = l - 1,
+ value = args[ 0 ],
+ valueIsFunction = isFunction( value );
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( valueIsFunction ||
+ ( l > 1 && typeof value === "string" &&
+ !support.checkClone && rchecked.test( value ) ) ) {
+ return collection.each( function( index ) {
+ var self = collection.eq( index );
+ if ( valueIsFunction ) {
+ args[ 0 ] = value.call( this, index, self.html() );
+ }
+ domManip( self, args, callback, ignored );
+ } );
+ }
+
+ if ( l ) {
+ fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
+ first = fragment.firstChild;
+
+ if ( fragment.childNodes.length === 1 ) {
+ fragment = first;
+ }
+
+ // Require either new content or an interest in ignored elements to invoke the callback
+ if ( first || ignored ) {
+ scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
+ hasScripts = scripts.length;
+
+ // Use the original fragment for the last item
+ // instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ for ( ; i < l; i++ ) {
+ node = fragment;
+
+ if ( i !== iNoClone ) {
+ node = jQuery.clone( node, true, true );
+
+ // Keep references to cloned scripts for later restoration
+ if ( hasScripts ) {
+
+ // Support: Android <=4.0 only, PhantomJS 1 only
+ // push.apply(_, arraylike) throws on ancient WebKit
+ jQuery.merge( scripts, getAll( node, "script" ) );
+ }
+ }
+
+ callback.call( collection[ i ], node, i );
+ }
+
+ if ( hasScripts ) {
+ doc = scripts[ scripts.length - 1 ].ownerDocument;
+
+ // Reenable scripts
+ jQuery.map( scripts, restoreScript );
+
+ // Evaluate executable scripts on first document insertion
+ for ( i = 0; i < hasScripts; i++ ) {
+ node = scripts[ i ];
+ if ( rscriptType.test( node.type || "" ) &&
+ !dataPriv.access( node, "globalEval" ) &&
+ jQuery.contains( doc, node ) ) {
+
+ if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
+
+ // Optional AJAX dependency, but won't run scripts if not present
+ if ( jQuery._evalUrl && !node.noModule ) {
+ jQuery._evalUrl( node.src, {
+ nonce: node.nonce || node.getAttribute( "nonce" )
+ }, doc );
+ }
+ } else {
+ DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return collection;
+}
+
+function remove( elem, selector, keepData ) {
+ var node,
+ nodes = selector ? jQuery.filter( selector, elem ) : elem,
+ i = 0;
+
+ for ( ; ( node = nodes[ i ] ) != null; i++ ) {
+ if ( !keepData && node.nodeType === 1 ) {
+ jQuery.cleanData( getAll( node ) );
+ }
+
+ if ( node.parentNode ) {
+ if ( keepData && isAttached( node ) ) {
+ setGlobalEval( getAll( node, "script" ) );
+ }
+ node.parentNode.removeChild( node );
+ }
+ }
+
+ return elem;
+}
+
+jQuery.extend( {
+ htmlPrefilter: function( html ) {
+ return html;
+ },
+
+ clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+ var i, l, srcElements, destElements,
+ clone = elem.cloneNode( true ),
+ inPage = isAttached( elem );
+
+ // Fix IE cloning issues
+ if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
+ !jQuery.isXMLDoc( elem ) ) {
+
+ // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
+ destElements = getAll( clone );
+ srcElements = getAll( elem );
+
+ for ( i = 0, l = srcElements.length; i < l; i++ ) {
+ fixInput( srcElements[ i ], destElements[ i ] );
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if ( dataAndEvents ) {
+ if ( deepDataAndEvents ) {
+ srcElements = srcElements || getAll( elem );
+ destElements = destElements || getAll( clone );
+
+ for ( i = 0, l = srcElements.length; i < l; i++ ) {
+ cloneCopyEvent( srcElements[ i ], destElements[ i ] );
+ }
+ } else {
+ cloneCopyEvent( elem, clone );
+ }
+ }
+
+ // Preserve script evaluation history
+ destElements = getAll( clone, "script" );
+ if ( destElements.length > 0 ) {
+ setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
+ }
+
+ // Return the cloned set
+ return clone;
+ },
+
+ cleanData: function( elems ) {
+ var data, elem, type,
+ special = jQuery.event.special,
+ i = 0;
+
+ for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
+ if ( acceptData( elem ) ) {
+ if ( ( data = elem[ dataPriv.expando ] ) ) {
+ if ( data.events ) {
+ for ( type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ // Support: Chrome <=35 - 45+
+ // Assign undefined instead of using delete, see Data#remove
+ elem[ dataPriv.expando ] = undefined;
+ }
+ if ( elem[ dataUser.expando ] ) {
+
+ // Support: Chrome <=35 - 45+
+ // Assign undefined instead of using delete, see Data#remove
+ elem[ dataUser.expando ] = undefined;
+ }
+ }
+ }
+ }
+} );
+
+jQuery.fn.extend( {
+ detach: function( selector ) {
+ return remove( this, selector, true );
+ },
+
+ remove: function( selector ) {
+ return remove( this, selector );
+ },
+
+ text: function( value ) {
+ return access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().each( function() {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ this.textContent = value;
+ }
+ } );
+ }, null, value, arguments.length );
+ },
+
+ append: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ var target = manipulationTarget( this, elem );
+ target.appendChild( elem );
+ }
+ } );
+ },
+
+ prepend: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ var target = manipulationTarget( this, elem );
+ target.insertBefore( elem, target.firstChild );
+ }
+ } );
+ },
+
+ before: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this );
+ }
+ } );
+ },
+
+ after: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ }
+ } );
+ },
+
+ empty: function() {
+ var elem,
+ i = 0;
+
+ for ( ; ( elem = this[ i ] ) != null; i++ ) {
+ if ( elem.nodeType === 1 ) {
+
+ // Prevent memory leaks
+ jQuery.cleanData( getAll( elem, false ) );
+
+ // Remove any remaining nodes
+ elem.textContent = "";
+ }
+ }
+
+ return this;
+ },
+
+ clone: function( dataAndEvents, deepDataAndEvents ) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map( function() {
+ return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+ } );
+ },
+
+ html: function( value ) {
+ return access( this, function( value ) {
+ var elem = this[ 0 ] || {},
+ i = 0,
+ l = this.length;
+
+ if ( value === undefined && elem.nodeType === 1 ) {
+ return elem.innerHTML;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
+
+ value = jQuery.htmlPrefilter( value );
+
+ try {
+ for ( ; i < l; i++ ) {
+ elem = this[ i ] || {};
+
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem, false ) );
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch ( e ) {}
+ }
+
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
+ },
+
+ replaceWith: function() {
+ var ignored = [];
+
+ // Make the changes, replacing each non-ignored context element with the new content
+ return domManip( this, arguments, function( elem ) {
+ var parent = this.parentNode;
+
+ if ( jQuery.inArray( this, ignored ) < 0 ) {
+ jQuery.cleanData( getAll( this ) );
+ if ( parent ) {
+ parent.replaceChild( elem, this );
+ }
+ }
+
+ // Force callback invocation
+ }, ignored );
+ }
+} );
+
+jQuery.each( {
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var elems,
+ ret = [],
+ insert = jQuery( selector ),
+ last = insert.length - 1,
+ i = 0;
+
+ for ( ; i <= last; i++ ) {
+ elems = i === last ? this : this.clone( true );
+ jQuery( insert[ i ] )[ original ]( elems );
+
+ // Support: Android <=4.0 only, PhantomJS 1 only
+ // .get() because push.apply(_, arraylike) throws on ancient WebKit
+ push.apply( ret, elems.get() );
+ }
+
+ return this.pushStack( ret );
+ };
+} );
+var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
+
+var getStyles = function( elem ) {
+
+ // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
+ // IE throws on elements created in popups
+ // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
+ var view = elem.ownerDocument.defaultView;
+
+ if ( !view || !view.opener ) {
+ view = window;
+ }
+
+ return view.getComputedStyle( elem );
+ };
+
+var swap = function( elem, options, callback ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.call( elem );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+};
+
+
+var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
+
+
+
+( function() {
+
+ // Executing both pixelPosition & boxSizingReliable tests require only one layout
+ // so they're executed at the same time to save the second computation.
+ function computeStyleTests() {
+
+ // This is a singleton, we need to execute it only once
+ if ( !div ) {
+ return;
+ }
+
+ container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
+ "margin-top:1px;padding:0;border:0";
+ div.style.cssText =
+ "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
+ "margin:auto;border:1px;padding:1px;" +
+ "width:60%;top:1%";
+ documentElement.appendChild( container ).appendChild( div );
+
+ var divStyle = window.getComputedStyle( div );
+ pixelPositionVal = divStyle.top !== "1%";
+
+ // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
+ reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
+
+ // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
+ // Some styles come back with percentage values, even though they shouldn't
+ div.style.right = "60%";
+ pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
+
+ // Support: IE 9 - 11 only
+ // Detect misreporting of content dimensions for box-sizing:border-box elements
+ boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
+
+ // Support: IE 9 only
+ // Detect overflow:scroll screwiness (gh-3699)
+ // Support: Chrome <=64
+ // Don't get tricked when zoom affects offsetWidth (gh-4029)
+ div.style.position = "absolute";
+ scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
+
+ documentElement.removeChild( container );
+
+ // Nullify the div so it wouldn't be stored in the memory and
+ // it will also be a sign that checks already performed
+ div = null;
+ }
+
+ function roundPixelMeasures( measure ) {
+ return Math.round( parseFloat( measure ) );
+ }
+
+ var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
+ reliableTrDimensionsVal, reliableMarginLeftVal,
+ container = document.createElement( "div" ),
+ div = document.createElement( "div" );
+
+ // Finish early in limited (non-browser) environments
+ if ( !div.style ) {
+ return;
+ }
+
+ // Support: IE <=9 - 11 only
+ // Style of cloned element affects source element cloned (#8908)
+ div.style.backgroundClip = "content-box";
+ div.cloneNode( true ).style.backgroundClip = "";
+ support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+ jQuery.extend( support, {
+ boxSizingReliable: function() {
+ computeStyleTests();
+ return boxSizingReliableVal;
+ },
+ pixelBoxStyles: function() {
+ computeStyleTests();
+ return pixelBoxStylesVal;
+ },
+ pixelPosition: function() {
+ computeStyleTests();
+ return pixelPositionVal;
+ },
+ reliableMarginLeft: function() {
+ computeStyleTests();
+ return reliableMarginLeftVal;
+ },
+ scrollboxSize: function() {
+ computeStyleTests();
+ return scrollboxSizeVal;
+ },
+
+ // Support: IE 9 - 11+, Edge 15 - 18+
+ // IE/Edge misreport `getComputedStyle` of table rows with width/height
+ // set in CSS while `offset*` properties report correct values.
+ // Behavior in IE 9 is more subtle than in newer versions & it passes
+ // some versions of this test; make sure not to make it pass there!
+ reliableTrDimensions: function() {
+ var table, tr, trChild, trStyle;
+ if ( reliableTrDimensionsVal == null ) {
+ table = document.createElement( "table" );
+ tr = document.createElement( "tr" );
+ trChild = document.createElement( "div" );
+
+ table.style.cssText = "position:absolute;left:-11111px";
+ tr.style.height = "1px";
+ trChild.style.height = "9px";
+
+ documentElement
+ .appendChild( table )
+ .appendChild( tr )
+ .appendChild( trChild );
+
+ trStyle = window.getComputedStyle( tr );
+ reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
+
+ documentElement.removeChild( table );
+ }
+ return reliableTrDimensionsVal;
+ }
+ } );
+} )();
+
+
+function curCSS( elem, name, computed ) {
+ var width, minWidth, maxWidth, ret,
+
+ // Support: Firefox 51+
+ // Retrieving style before computed somehow
+ // fixes an issue with getting wrong values
+ // on detached elements
+ style = elem.style;
+
+ computed = computed || getStyles( elem );
+
+ // getPropertyValue is needed for:
+ // .css('filter') (IE 9 only, #12537)
+ // .css('--customProperty) (#3144)
+ if ( computed ) {
+ ret = computed.getPropertyValue( name ) || computed[ name ];
+
+ if ( ret === "" && !isAttached( elem ) ) {
+ ret = jQuery.style( elem, name );
+ }
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Android Browser returns percentage for some values,
+ // but width seems to be reliably pixels.
+ // This is against the CSSOM draft spec:
+ // https://drafts.csswg.org/cssom/#resolved-values
+ if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
+
+ // Remember the original values
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ // Put in the new values to get a computed value out
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ // Revert the changed values
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ return ret !== undefined ?
+
+ // Support: IE <=9 - 11 only
+ // IE returns zIndex value as an integer.
+ ret + "" :
+ ret;
+}
+
+
+function addGetHookIf( conditionFn, hookFn ) {
+
+ // Define the hook, we'll check on the first run if it's really needed.
+ return {
+ get: function() {
+ if ( conditionFn() ) {
+
+ // Hook not needed (or it's not possible to use it due
+ // to missing dependency), remove it.
+ delete this.get;
+ return;
+ }
+
+ // Hook needed; redefine it so that the support test is not executed again.
+ return ( this.get = hookFn ).apply( this, arguments );
+ }
+ };
+}
+
+
+var cssPrefixes = [ "Webkit", "Moz", "ms" ],
+ emptyStyle = document.createElement( "div" ).style,
+ vendorProps = {};
+
+// Return a vendor-prefixed property or undefined
+function vendorPropName( name ) {
+
+ // Check for vendor prefixed names
+ var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
+ i = cssPrefixes.length;
+
+ while ( i-- ) {
+ name = cssPrefixes[ i ] + capName;
+ if ( name in emptyStyle ) {
+ return name;
+ }
+ }
+}
+
+// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
+function finalPropName( name ) {
+ var final = jQuery.cssProps[ name ] || vendorProps[ name ];
+
+ if ( final ) {
+ return final;
+ }
+ if ( name in emptyStyle ) {
+ return name;
+ }
+ return vendorProps[ name ] = vendorPropName( name ) || name;
+}
+
+
+var
+
+ // Swappable if display is none or starts with table
+ // except "table", "table-cell", or "table-caption"
+ // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rcustomProp = /^--/,
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssNormalTransform = {
+ letterSpacing: "0",
+ fontWeight: "400"
+ };
+
+function setPositiveNumber( _elem, value, subtract ) {
+
+ // Any relative (+/-) values have already been
+ // normalized at this point
+ var matches = rcssNum.exec( value );
+ return matches ?
+
+ // Guard against undefined "subtract", e.g., when used as in cssHooks
+ Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
+ value;
+}
+
+function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
+ var i = dimension === "width" ? 1 : 0,
+ extra = 0,
+ delta = 0;
+
+ // Adjustment may not be necessary
+ if ( box === ( isBorderBox ? "border" : "content" ) ) {
+ return 0;
+ }
+
+ for ( ; i < 4; i += 2 ) {
+
+ // Both box models exclude margin
+ if ( box === "margin" ) {
+ delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
+ }
+
+ // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
+ if ( !isBorderBox ) {
+
+ // Add padding
+ delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+ // For "border" or "margin", add border
+ if ( box !== "padding" ) {
+ delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+
+ // But still keep track of it otherwise
+ } else {
+ extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+
+ // If we get here with a border-box (content + padding + border), we're seeking "content" or
+ // "padding" or "margin"
+ } else {
+
+ // For "content", subtract padding
+ if ( box === "content" ) {
+ delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+ }
+
+ // For "content" or "padding", subtract border
+ if ( box !== "margin" ) {
+ delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ }
+ }
+
+ // Account for positive content-box scroll gutter when requested by providing computedVal
+ if ( !isBorderBox && computedVal >= 0 ) {
+
+ // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
+ // Assuming integer scroll gutter, subtract the rest and round down
+ delta += Math.max( 0, Math.ceil(
+ elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
+ computedVal -
+ delta -
+ extra -
+ 0.5
+
+ // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
+ // Use an explicit zero to avoid NaN (gh-3964)
+ ) ) || 0;
+ }
+
+ return delta;
+}
+
+function getWidthOrHeight( elem, dimension, extra ) {
+
+ // Start with computed style
+ var styles = getStyles( elem ),
+
+ // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
+ // Fake content-box until we know it's needed to know the true value.
+ boxSizingNeeded = !support.boxSizingReliable() || extra,
+ isBorderBox = boxSizingNeeded &&
+ jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+ valueIsBorderBox = isBorderBox,
+
+ val = curCSS( elem, dimension, styles ),
+ offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
+
+ // Support: Firefox <=54
+ // Return a confounding non-pixel value or feign ignorance, as appropriate.
+ if ( rnumnonpx.test( val ) ) {
+ if ( !extra ) {
+ return val;
+ }
+ val = "auto";
+ }
+
+
+ // Support: IE 9 - 11 only
+ // Use offsetWidth/offsetHeight for when box sizing is unreliable.
+ // In those cases, the computed value can be trusted to be border-box.
+ if ( ( !support.boxSizingReliable() && isBorderBox ||
+
+ // Support: IE 10 - 11+, Edge 15 - 18+
+ // IE/Edge misreport `getComputedStyle` of table rows with width/height
+ // set in CSS while `offset*` properties report correct values.
+ // Interestingly, in some cases IE 9 doesn't suffer from this issue.
+ !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
+
+ // Fall back to offsetWidth/offsetHeight when value is "auto"
+ // This happens for inline elements with no explicit setting (gh-3571)
+ val === "auto" ||
+
+ // Support: Android <=4.1 - 4.3 only
+ // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
+ !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
+
+ // Make sure the element is visible & connected
+ elem.getClientRects().length ) {
+
+ isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
+
+ // Where available, offsetWidth/offsetHeight approximate border box dimensions.
+ // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
+ // retrieved value as a content box dimension.
+ valueIsBorderBox = offsetProp in elem;
+ if ( valueIsBorderBox ) {
+ val = elem[ offsetProp ];
+ }
+ }
+
+ // Normalize "" and auto
+ val = parseFloat( val ) || 0;
+
+ // Adjust for the element's box model
+ return ( val +
+ boxModelAdjustment(
+ elem,
+ dimension,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox,
+ styles,
+
+ // Provide the current computed size to request scroll gutter calculation (gh-3589)
+ val
+ )
+ ) + "px";
+}
+
+jQuery.extend( {
+
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function( elem, computed ) {
+ if ( computed ) {
+
+ // We should always get a number back from opacity
+ var ret = curCSS( elem, "opacity" );
+ return ret === "" ? "1" : ret;
+ }
+ }
+ }
+ },
+
+ // Don't automatically add "px" to these possibly-unitless properties
+ cssNumber: {
+ "animationIterationCount": true,
+ "columnCount": true,
+ "fillOpacity": true,
+ "flexGrow": true,
+ "flexShrink": true,
+ "fontWeight": true,
+ "gridArea": true,
+ "gridColumn": true,
+ "gridColumnEnd": true,
+ "gridColumnStart": true,
+ "gridRow": true,
+ "gridRowEnd": true,
+ "gridRowStart": true,
+ "lineHeight": true,
+ "opacity": true,
+ "order": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {},
+
+ // Get and set the style property on a DOM Node
+ style: function( elem, name, value, extra ) {
+
+ // Don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = camelCase( name ),
+ isCustomProp = rcustomProp.test( name ),
+ style = elem.style;
+
+ // Make sure that we're working with the right name. We don't
+ // want to query the value if it is a CSS custom property
+ // since they are user-defined.
+ if ( !isCustomProp ) {
+ name = finalPropName( origName );
+ }
+
+ // Gets hook for the prefixed version, then unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // Check if we're setting a value
+ if ( value !== undefined ) {
+ type = typeof value;
+
+ // Convert "+=" or "-=" to relative numbers (#7345)
+ if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
+ value = adjustCSS( elem, name, ret );
+
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that null and NaN values aren't set (#7116)
+ if ( value == null || value !== value ) {
+ return;
+ }
+
+ // If a number was passed in, add the unit (except for certain CSS properties)
+ // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
+ // "px" to a few hardcoded values.
+ if ( type === "number" && !isCustomProp ) {
+ value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
+ }
+
+ // background-* props affect original clone's values
+ if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
+ style[ name ] = "inherit";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if ( !hooks || !( "set" in hooks ) ||
+ ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
+
+ if ( isCustomProp ) {
+ style.setProperty( name, value );
+ } else {
+ style[ name ] = value;
+ }
+ }
+
+ } else {
+
+ // If a hook was provided get the non-computed value from there
+ if ( hooks && "get" in hooks &&
+ ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
+
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[ name ];
+ }
+ },
+
+ css: function( elem, name, extra, styles ) {
+ var val, num, hooks,
+ origName = camelCase( name ),
+ isCustomProp = rcustomProp.test( name );
+
+ // Make sure that we're working with the right name. We don't
+ // want to modify the value if it is a CSS custom property
+ // since they are user-defined.
+ if ( !isCustomProp ) {
+ name = finalPropName( origName );
+ }
+
+ // Try prefixed name followed by the unprefixed name
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // If a hook was provided get the computed value from there
+ if ( hooks && "get" in hooks ) {
+ val = hooks.get( elem, true, extra );
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if ( val === undefined ) {
+ val = curCSS( elem, name, styles );
+ }
+
+ // Convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
+ // Make numeric if forced or a qualifier was provided and val looks numeric
+ if ( extra === "" || extra ) {
+ num = parseFloat( val );
+ return extra === true || isFinite( num ) ? num || 0 : val;
+ }
+
+ return val;
+ }
+} );
+
+jQuery.each( [ "height", "width" ], function( _i, dimension ) {
+ jQuery.cssHooks[ dimension ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+
+ // Certain elements can have dimension info if we invisibly show them
+ // but it must have a current display style that would benefit
+ return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
+
+ // Support: Safari 8+
+ // Table columns in Safari have non-zero offsetWidth & zero
+ // getBoundingClientRect().width unless display is changed.
+ // Support: IE <=11 only
+ // Running getBoundingClientRect on a disconnected node
+ // in IE throws an error.
+ ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
+ swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, dimension, extra );
+ } ) :
+ getWidthOrHeight( elem, dimension, extra );
+ }
+ },
+
+ set: function( elem, value, extra ) {
+ var matches,
+ styles = getStyles( elem ),
+
+ // Only read styles.position if the test has a chance to fail
+ // to avoid forcing a reflow.
+ scrollboxSizeBuggy = !support.scrollboxSize() &&
+ styles.position === "absolute",
+
+ // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
+ boxSizingNeeded = scrollboxSizeBuggy || extra,
+ isBorderBox = boxSizingNeeded &&
+ jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+ subtract = extra ?
+ boxModelAdjustment(
+ elem,
+ dimension,
+ extra,
+ isBorderBox,
+ styles
+ ) :
+ 0;
+
+ // Account for unreliable border-box dimensions by comparing offset* to computed and
+ // faking a content-box to get border and padding (gh-3699)
+ if ( isBorderBox && scrollboxSizeBuggy ) {
+ subtract -= Math.ceil(
+ elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
+ parseFloat( styles[ dimension ] ) -
+ boxModelAdjustment( elem, dimension, "border", false, styles ) -
+ 0.5
+ );
+ }
+
+ // Convert to pixels if value adjustment is needed
+ if ( subtract && ( matches = rcssNum.exec( value ) ) &&
+ ( matches[ 3 ] || "px" ) !== "px" ) {
+
+ elem.style[ dimension ] = value;
+ value = jQuery.css( elem, dimension );
+ }
+
+ return setPositiveNumber( elem, value, subtract );
+ }
+ };
+} );
+
+jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
+ function( elem, computed ) {
+ if ( computed ) {
+ return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
+ elem.getBoundingClientRect().left -
+ swap( elem, { marginLeft: 0 }, function() {
+ return elem.getBoundingClientRect().left;
+ } )
+ ) + "px";
+ }
+ }
+);
+
+// These hooks are used by animate to expand properties
+jQuery.each( {
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i = 0,
+ expanded = {},
+
+ // Assumes a single number if not a string
+ parts = typeof value === "string" ? value.split( " " ) : [ value ];
+
+ for ( ; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+
+ if ( prefix !== "margin" ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
+} );
+
+jQuery.fn.extend( {
+ css: function( name, value ) {
+ return access( this, function( elem, name, value ) {
+ var styles, len,
+ map = {},
+ i = 0;
+
+ if ( Array.isArray( name ) ) {
+ styles = getStyles( elem );
+ len = name.length;
+
+ for ( ; i < len; i++ ) {
+ map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
+ }
+
+ return map;
+ }
+
+ return value !== undefined ?
+ jQuery.style( elem, name, value ) :
+ jQuery.css( elem, name );
+ }, name, value, arguments.length > 1 );
+ }
+} );
+
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || jQuery.easing._default;
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ // Use a property on the element directly when it is not a DOM element,
+ // or when there is no matching style property that exists.
+ if ( tween.elem.nodeType !== 1 ||
+ tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // Passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails.
+ // Simple values such as "10px" are parsed to Float;
+ // complex values such as "rotate(1rad)" are returned as-is.
+ result = jQuery.css( tween.elem, tween.prop, "" );
+
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+
+ // Use step hook for back compat.
+ // Use cssHook if its there.
+ // Use .style if available and use plain properties where available.
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.nodeType === 1 && (
+ jQuery.cssHooks[ tween.prop ] ||
+ tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Support: IE <=9 only
+// Panic based approach to setting things on disconnected nodes
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p * Math.PI ) / 2;
+ },
+ _default: "swing"
+};
+
+jQuery.fx = Tween.prototype.init;
+
+// Back compat <1.8 extension point
+jQuery.fx.step = {};
+
+
+
+
+var
+ fxNow, inProgress,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rrun = /queueHooks$/;
+
+function schedule() {
+ if ( inProgress ) {
+ if ( document.hidden === false && window.requestAnimationFrame ) {
+ window.requestAnimationFrame( schedule );
+ } else {
+ window.setTimeout( schedule, jQuery.fx.interval );
+ }
+
+ jQuery.fx.tick();
+ }
+}
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ window.setTimeout( function() {
+ fxNow = undefined;
+ } );
+ return ( fxNow = Date.now() );
+}
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ i = 0,
+ attrs = { height: type };
+
+ // If we include width, step value is 1 to do all cssExpand values,
+ // otherwise step value is 2 to skip over Left and Right
+ includeWidth = includeWidth ? 1 : 0;
+ for ( ; i < 4; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+function createTween( value, prop, animation ) {
+ var tween,
+ collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
+
+ // We're done with this property
+ return tween;
+ }
+ }
+}
+
+function defaultPrefilter( elem, props, opts ) {
+ var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
+ isBox = "width" in props || "height" in props,
+ anim = this,
+ orig = {},
+ style = elem.style,
+ hidden = elem.nodeType && isHiddenWithinTree( elem ),
+ dataShow = dataPriv.get( elem, "fxshow" );
+
+ // Queue-skipping animations hijack the fx hooks
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always( function() {
+
+ // Ensure the complete handler is called before this completes
+ anim.always( function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ } );
+ } );
+ }
+
+ // Detect show/hide animations
+ for ( prop in props ) {
+ value = props[ prop ];
+ if ( rfxtypes.test( value ) ) {
+ delete props[ prop ];
+ toggle = toggle || value === "toggle";
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+
+ // Pretend to be hidden if this is a "show" and
+ // there is still data from a stopped show/hide
+ if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
+ hidden = true;
+
+ // Ignore all other no-op show/hide data
+ } else {
+ continue;
+ }
+ }
+ orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
+ }
+ }
+
+ // Bail out if this is a no-op like .hide().hide()
+ propTween = !jQuery.isEmptyObject( props );
+ if ( !propTween && jQuery.isEmptyObject( orig ) ) {
+ return;
+ }
+
+ // Restrict "overflow" and "display" styles during box animations
+ if ( isBox && elem.nodeType === 1 ) {
+
+ // Support: IE <=9 - 11, Edge 12 - 15
+ // Record all 3 overflow attributes because IE does not infer the shorthand
+ // from identically-valued overflowX and overflowY and Edge just mirrors
+ // the overflowX value there.
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Identify a display type, preferring old show/hide data over the CSS cascade
+ restoreDisplay = dataShow && dataShow.display;
+ if ( restoreDisplay == null ) {
+ restoreDisplay = dataPriv.get( elem, "display" );
+ }
+ display = jQuery.css( elem, "display" );
+ if ( display === "none" ) {
+ if ( restoreDisplay ) {
+ display = restoreDisplay;
+ } else {
+
+ // Get nonempty value(s) by temporarily forcing visibility
+ showHide( [ elem ], true );
+ restoreDisplay = elem.style.display || restoreDisplay;
+ display = jQuery.css( elem, "display" );
+ showHide( [ elem ] );
+ }
+ }
+
+ // Animate inline elements as inline-block
+ if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
+ if ( jQuery.css( elem, "float" ) === "none" ) {
+
+ // Restore the original display value at the end of pure show/hide animations
+ if ( !propTween ) {
+ anim.done( function() {
+ style.display = restoreDisplay;
+ } );
+ if ( restoreDisplay == null ) {
+ display = style.display;
+ restoreDisplay = display === "none" ? "" : display;
+ }
+ }
+ style.display = "inline-block";
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ anim.always( function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ } );
+ }
+
+ // Implement show/hide animations
+ propTween = false;
+ for ( prop in orig ) {
+
+ // General show/hide setup for this element animation
+ if ( !propTween ) {
+ if ( dataShow ) {
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+ } else {
+ dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
+ }
+
+ // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
+
+ // Show elements before animating them
+ if ( hidden ) {
+ showHide( [ elem ], true );
+ }
+
+ /* eslint-disable no-loop-func */
+
+ anim.done( function() {
+
+ /* eslint-enable no-loop-func */
+
+ // The final step of a "hide" animation is actually hiding the element
+ if ( !hidden ) {
+ showHide( [ elem ] );
+ }
+ dataPriv.remove( elem, "fxshow" );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ } );
+ }
+
+ // Per-property setup
+ propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = propTween.start;
+ if ( hidden ) {
+ propTween.end = propTween.start;
+ propTween.start = 0;
+ }
+ }
+ }
+}
+
+function propFilter( props, specialEasing ) {
+ var index, name, easing, value, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( Array.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // Not quite $.extend, this won't overwrite existing keys.
+ // Reusing 'index' because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ stopped,
+ index = 0,
+ length = Animation.prefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+
+ // Don't match elem in the :animated selector
+ delete tick.elem;
+ } ),
+ tick = function() {
+ if ( stopped ) {
+ return false;
+ }
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+
+ // Support: Android 2.3 only
+ // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ] );
+
+ // If there's more to do, yield
+ if ( percent < 1 && length ) {
+ return remaining;
+ }
+
+ // If this was an empty animation, synthesize a final progress notification
+ if ( !length ) {
+ deferred.notifyWith( elem, [ animation, 1, 0 ] );
+ }
+
+ // Resolve the animation and report its conclusion
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ },
+ animation = deferred.promise( {
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, {
+ specialEasing: {},
+ easing: jQuery.easing._default
+ }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+
+ // If we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+ if ( stopped ) {
+ return this;
+ }
+ stopped = true;
+ for ( ; index < length; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // Resolve when we played the last frame; otherwise, reject
+ if ( gotoEnd ) {
+ deferred.notifyWith( elem, [ animation, 1, 0 ] );
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ } ),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length; index++ ) {
+ result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ if ( isFunction( result.stop ) ) {
+ jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
+ result.stop.bind( result );
+ }
+ return result;
+ }
+ }
+
+ jQuery.map( props, createTween, animation );
+
+ if ( isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ // Attach callbacks from options
+ animation
+ .progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ elem: elem,
+ anim: animation,
+ queue: animation.opts.queue
+ } )
+ );
+
+ return animation;
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweeners: {
+ "*": [ function( prop, value ) {
+ var tween = this.createTween( prop, value );
+ adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
+ return tween;
+ } ]
+ },
+
+ tweener: function( props, callback ) {
+ if ( isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.match( rnothtmlwhite );
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length; index++ ) {
+ prop = props[ index ];
+ Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
+ Animation.tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilters: [ defaultPrefilter ],
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ Animation.prefilters.unshift( callback );
+ } else {
+ Animation.prefilters.push( callback );
+ }
+ }
+} );
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+ complete: fn || !fn && easing ||
+ isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !isFunction( easing ) && easing
+ };
+
+ // Go to the end state if fx are off
+ if ( jQuery.fx.off ) {
+ opt.duration = 0;
+
+ } else {
+ if ( typeof opt.duration !== "number" ) {
+ if ( opt.duration in jQuery.fx.speeds ) {
+ opt.duration = jQuery.fx.speeds[ opt.duration ];
+
+ } else {
+ opt.duration = jQuery.fx.speeds._default;
+ }
+ }
+ }
+
+ // Normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.fn.extend( {
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // Show any hidden elements after setting opacity to 0
+ return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
+
+ // Animate to the value specified
+ .end().animate( { opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+ // Empty animations, or finishing resolves immediately
+ if ( empty || dataPriv.get( this, "finish" ) ) {
+ anim.stop( true );
+ }
+ };
+ doAnimation.finish = doAnimation;
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each( function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = dataPriv.get( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this &&
+ ( type == null || timers[ index ].queue === type ) ) {
+
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // Start the next in the queue if the last step wasn't forced.
+ // Timers currently will call their complete callbacks, which
+ // will dequeue but only if they were gotoEnd.
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ } );
+ },
+ finish: function( type ) {
+ if ( type !== false ) {
+ type = type || "fx";
+ }
+ return this.each( function() {
+ var index,
+ data = dataPriv.get( this ),
+ queue = data[ type + "queue" ],
+ hooks = data[ type + "queueHooks" ],
+ timers = jQuery.timers,
+ length = queue ? queue.length : 0;
+
+ // Enable finishing flag on private data
+ data.finish = true;
+
+ // Empty the queue first
+ jQuery.queue( this, type, [] );
+
+ if ( hooks && hooks.stop ) {
+ hooks.stop.call( this, true );
+ }
+
+ // Look for any active animations, and finish them
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+ timers[ index ].anim.stop( true );
+ timers.splice( index, 1 );
+ }
+ }
+
+ // Look for any animations in the old queue and finish them
+ for ( index = 0; index < length; index++ ) {
+ if ( queue[ index ] && queue[ index ].finish ) {
+ queue[ index ].finish.call( this );
+ }
+ }
+
+ // Turn off finishing flag
+ delete data.finish;
+ } );
+ }
+} );
+
+jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+} );
+
+// Generate shortcuts for custom animations
+jQuery.each( {
+ slideDown: genFx( "show" ),
+ slideUp: genFx( "hide" ),
+ slideToggle: genFx( "toggle" ),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+} );
+
+jQuery.timers = [];
+jQuery.fx.tick = function() {
+ var timer,
+ i = 0,
+ timers = jQuery.timers;
+
+ fxNow = Date.now();
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+
+ // Run the timer and safely remove it when done (allowing for external removal)
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+ jQuery.timers.push( timer );
+ jQuery.fx.start();
+};
+
+jQuery.fx.interval = 13;
+jQuery.fx.start = function() {
+ if ( inProgress ) {
+ return;
+ }
+
+ inProgress = true;
+ schedule();
+};
+
+jQuery.fx.stop = function() {
+ inProgress = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+
+ // Default speed
+ _default: 400
+};
+
+
+// Based off of the plugin by Clint Helfers, with permission.
+// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
+jQuery.fn.delay = function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = window.setTimeout( next, time );
+ hooks.stop = function() {
+ window.clearTimeout( timeout );
+ };
+ } );
+};
+
+
+( function() {
+ var input = document.createElement( "input" ),
+ select = document.createElement( "select" ),
+ opt = select.appendChild( document.createElement( "option" ) );
+
+ input.type = "checkbox";
+
+ // Support: Android <=4.3 only
+ // Default value for a checkbox should be "on"
+ support.checkOn = input.value !== "";
+
+ // Support: IE <=11 only
+ // Must access selectedIndex to make default options select
+ support.optSelected = opt.selected;
+
+ // Support: IE <=11 only
+ // An input loses its value after becoming a radio
+ input = document.createElement( "input" );
+ input.value = "t";
+ input.type = "radio";
+ support.radioValue = input.value === "t";
+} )();
+
+
+var boolHook,
+ attrHandle = jQuery.expr.attrHandle;
+
+jQuery.fn.extend( {
+ attr: function( name, value ) {
+ return access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each( function() {
+ jQuery.removeAttr( this, name );
+ } );
+ }
+} );
+
+jQuery.extend( {
+ attr: function( elem, name, value ) {
+ var ret, hooks,
+ nType = elem.nodeType;
+
+ // Don't get/set attributes on text, comment and attribute nodes
+ if ( nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === "undefined" ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ // Attribute hooks are determined by the lowercase version
+ // Grab necessary hook if one is defined
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+ hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
+ ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
+ }
+
+ if ( value !== undefined ) {
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+ return;
+ }
+
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+ return ret;
+ }
+
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+ return ret;
+ }
+
+ ret = jQuery.find.attr( elem, name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ? undefined : ret;
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ if ( !support.radioValue && value === "radio" &&
+ nodeName( elem, "input" ) ) {
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var name,
+ i = 0,
+
+ // Attribute names can contain non-HTML whitespace characters
+ // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
+ attrNames = value && value.match( rnothtmlwhite );
+
+ if ( attrNames && elem.nodeType === 1 ) {
+ while ( ( name = attrNames[ i++ ] ) ) {
+ elem.removeAttribute( name );
+ }
+ }
+ }
+} );
+
+// Hooks for boolean attributes
+boolHook = {
+ set: function( elem, value, name ) {
+ if ( value === false ) {
+
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else {
+ elem.setAttribute( name, name );
+ }
+ return name;
+ }
+};
+
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
+ var getter = attrHandle[ name ] || jQuery.find.attr;
+
+ attrHandle[ name ] = function( elem, name, isXML ) {
+ var ret, handle,
+ lowercaseName = name.toLowerCase();
+
+ if ( !isXML ) {
+
+ // Avoid an infinite loop by temporarily removing this function from the getter
+ handle = attrHandle[ lowercaseName ];
+ attrHandle[ lowercaseName ] = ret;
+ ret = getter( elem, name, isXML ) != null ?
+ lowercaseName :
+ null;
+ attrHandle[ lowercaseName ] = handle;
+ }
+ return ret;
+ };
+} );
+
+
+
+
+var rfocusable = /^(?:input|select|textarea|button)$/i,
+ rclickable = /^(?:a|area)$/i;
+
+jQuery.fn.extend( {
+ prop: function( name, value ) {
+ return access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ return this.each( function() {
+ delete this[ jQuery.propFix[ name ] || name ];
+ } );
+ }
+} );
+
+jQuery.extend( {
+ prop: function( elem, name, value ) {
+ var ret, hooks,
+ nType = elem.nodeType;
+
+ // Don't get/set properties on text, comment and attribute nodes
+ if ( nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+ return ret;
+ }
+
+ return ( elem[ name ] = value );
+ }
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+ return ret;
+ }
+
+ return elem[ name ];
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+
+ // Support: IE <=9 - 11 only
+ // elem.tabIndex doesn't always return the
+ // correct value when it hasn't been explicitly set
+ // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ // Use proper attribute retrieval(#12072)
+ var tabindex = jQuery.find.attr( elem, "tabindex" );
+
+ if ( tabindex ) {
+ return parseInt( tabindex, 10 );
+ }
+
+ if (
+ rfocusable.test( elem.nodeName ) ||
+ rclickable.test( elem.nodeName ) &&
+ elem.href
+ ) {
+ return 0;
+ }
+
+ return -1;
+ }
+ }
+ },
+
+ propFix: {
+ "for": "htmlFor",
+ "class": "className"
+ }
+} );
+
+// Support: IE <=11 only
+// Accessing the selectedIndex property
+// forces the browser to respect setting selected
+// on the option
+// The getter ensures a default option is selected
+// when in an optgroup
+// eslint rule "no-unused-expressions" is disabled for this code
+// since it considers such accessions noop
+if ( !support.optSelected ) {
+ jQuery.propHooks.selected = {
+ get: function( elem ) {
+
+ /* eslint no-unused-expressions: "off" */
+
+ var parent = elem.parentNode;
+ if ( parent && parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ return null;
+ },
+ set: function( elem ) {
+
+ /* eslint no-unused-expressions: "off" */
+
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+ };
+}
+
+jQuery.each( [
+ "tabIndex",
+ "readOnly",
+ "maxLength",
+ "cellSpacing",
+ "cellPadding",
+ "rowSpan",
+ "colSpan",
+ "useMap",
+ "frameBorder",
+ "contentEditable"
+], function() {
+ jQuery.propFix[ this.toLowerCase() ] = this;
+} );
+
+
+
+
+ // Strip and collapse whitespace according to HTML spec
+ // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
+ function stripAndCollapse( value ) {
+ var tokens = value.match( rnothtmlwhite ) || [];
+ return tokens.join( " " );
+ }
+
+
+function getClass( elem ) {
+ return elem.getAttribute && elem.getAttribute( "class" ) || "";
+}
+
+function classesToArray( value ) {
+ if ( Array.isArray( value ) ) {
+ return value;
+ }
+ if ( typeof value === "string" ) {
+ return value.match( rnothtmlwhite ) || [];
+ }
+ return [];
+}
+
+jQuery.fn.extend( {
+ addClass: function( value ) {
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
+
+ if ( isFunction( value ) ) {
+ return this.each( function( j ) {
+ jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
+ } );
+ }
+
+ classes = classesToArray( value );
+
+ if ( classes.length ) {
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+ cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
+
+ if ( cur ) {
+ j = 0;
+ while ( ( clazz = classes[ j++ ] ) ) {
+ if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+ cur += clazz + " ";
+ }
+ }
+
+ // Only assign if different to avoid unneeded rendering.
+ finalValue = stripAndCollapse( cur );
+ if ( curValue !== finalValue ) {
+ elem.setAttribute( "class", finalValue );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
+
+ if ( isFunction( value ) ) {
+ return this.each( function( j ) {
+ jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
+ } );
+ }
+
+ if ( !arguments.length ) {
+ return this.attr( "class", "" );
+ }
+
+ classes = classesToArray( value );
+
+ if ( classes.length ) {
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+
+ // This expression is here for better compressibility (see addClass)
+ cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
+
+ if ( cur ) {
+ j = 0;
+ while ( ( clazz = classes[ j++ ] ) ) {
+
+ // Remove *all* instances
+ while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
+ cur = cur.replace( " " + clazz + " ", " " );
+ }
+ }
+
+ // Only assign if different to avoid unneeded rendering.
+ finalValue = stripAndCollapse( cur );
+ if ( curValue !== finalValue ) {
+ elem.setAttribute( "class", finalValue );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isValidValue = type === "string" || Array.isArray( value );
+
+ if ( typeof stateVal === "boolean" && isValidValue ) {
+ return stateVal ? this.addClass( value ) : this.removeClass( value );
+ }
+
+ if ( isFunction( value ) ) {
+ return this.each( function( i ) {
+ jQuery( this ).toggleClass(
+ value.call( this, i, getClass( this ), stateVal ),
+ stateVal
+ );
+ } );
+ }
+
+ return this.each( function() {
+ var className, i, self, classNames;
+
+ if ( isValidValue ) {
+
+ // Toggle individual class names
+ i = 0;
+ self = jQuery( this );
+ classNames = classesToArray( value );
+
+ while ( ( className = classNames[ i++ ] ) ) {
+
+ // Check each className given, space separated list
+ if ( self.hasClass( className ) ) {
+ self.removeClass( className );
+ } else {
+ self.addClass( className );
+ }
+ }
+
+ // Toggle whole class name
+ } else if ( value === undefined || type === "boolean" ) {
+ className = getClass( this );
+ if ( className ) {
+
+ // Store className if set
+ dataPriv.set( this, "__className__", className );
+ }
+
+ // If the element has a class name or if we're passed `false`,
+ // then remove the whole classname (if there was one, the above saved it).
+ // Otherwise bring back whatever was previously saved (if anything),
+ // falling back to the empty string if nothing was stored.
+ if ( this.setAttribute ) {
+ this.setAttribute( "class",
+ className || value === false ?
+ "" :
+ dataPriv.get( this, "__className__" ) || ""
+ );
+ }
+ }
+ } );
+ },
+
+ hasClass: function( selector ) {
+ var className, elem,
+ i = 0;
+
+ className = " " + selector + " ";
+ while ( ( elem = this[ i++ ] ) ) {
+ if ( elem.nodeType === 1 &&
+ ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+} );
+
+
+
+
+var rreturn = /\r/g;
+
+jQuery.fn.extend( {
+ val: function( value ) {
+ var hooks, ret, valueIsFunction,
+ elem = this[ 0 ];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] ||
+ jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if ( hooks &&
+ "get" in hooks &&
+ ( ret = hooks.get( elem, "value" ) ) !== undefined
+ ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ // Handle most common string cases
+ if ( typeof ret === "string" ) {
+ return ret.replace( rreturn, "" );
+ }
+
+ // Handle cases where value is null/undef or number
+ return ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ valueIsFunction = isFunction( value );
+
+ return this.each( function( i ) {
+ var val;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( valueIsFunction ) {
+ val = value.call( this, i, jQuery( this ).val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+
+ } else if ( typeof val === "number" ) {
+ val += "";
+
+ } else if ( Array.isArray( val ) ) {
+ val = jQuery.map( val, function( value ) {
+ return value == null ? "" : value + "";
+ } );
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ } );
+ }
+} );
+
+jQuery.extend( {
+ valHooks: {
+ option: {
+ get: function( elem ) {
+
+ var val = jQuery.find.attr( elem, "value" );
+ return val != null ?
+ val :
+
+ // Support: IE <=10 - 11 only
+ // option.text throws exceptions (#14686, #14858)
+ // Strip and collapse whitespace
+ // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
+ stripAndCollapse( jQuery.text( elem ) );
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, option, i,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one",
+ values = one ? null : [],
+ max = one ? index + 1 : options.length;
+
+ if ( index < 0 ) {
+ i = max;
+
+ } else {
+ i = one ? index : 0;
+ }
+
+ // Loop through all the selected options
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // Support: IE <=9 only
+ // IE8-9 doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+
+ // Don't return options that are disabled or in a disabled optgroup
+ !option.disabled &&
+ ( !option.parentNode.disabled ||
+ !nodeName( option.parentNode, "optgroup" ) ) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var optionSet, option,
+ options = elem.options,
+ values = jQuery.makeArray( value ),
+ i = options.length;
+
+ while ( i-- ) {
+ option = options[ i ];
+
+ /* eslint-disable no-cond-assign */
+
+ if ( option.selected =
+ jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
+ ) {
+ optionSet = true;
+ }
+
+ /* eslint-enable no-cond-assign */
+ }
+
+ // Force browsers to behave consistently when non-matching value is set
+ if ( !optionSet ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ }
+} );
+
+// Radios and checkboxes getter/setter
+jQuery.each( [ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ set: function( elem, value ) {
+ if ( Array.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
+ }
+ }
+ };
+ if ( !support.checkOn ) {
+ jQuery.valHooks[ this ].get = function( elem ) {
+ return elem.getAttribute( "value" ) === null ? "on" : elem.value;
+ };
+ }
+} );
+
+
+
+
+// Return jQuery for attributes-only inclusion
+
+
+support.focusin = "onfocusin" in window;
+
+
+var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ stopPropagationCallback = function( e ) {
+ e.stopPropagation();
+ };
+
+jQuery.extend( jQuery.event, {
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+
+ var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
+ eventPath = [ elem || document ],
+ type = hasOwn.call( event, "type" ) ? event.type : event,
+ namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
+
+ cur = lastElement = tmp = elem = elem || document;
+
+ // Don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+ return;
+ }
+
+ if ( type.indexOf( "." ) > -1 ) {
+
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split( "." );
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+ ontype = type.indexOf( ":" ) < 0 && "on" + type;
+
+ // Caller can pass in a jQuery.Event object, Object, or just an event type string
+ event = event[ jQuery.expando ] ?
+ event :
+ new jQuery.Event( type, typeof event === "object" && event );
+
+ // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
+ event.isTrigger = onlyHandlers ? 2 : 3;
+ event.namespace = namespaces.join( "." );
+ event.rnamespace = event.namespace ?
+ new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
+ null;
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if ( !event.target ) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data == null ?
+ [ event ] :
+ jQuery.makeArray( data, [ event ] );
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[ type ] || {};
+ if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
+
+ bubbleType = special.delegateType || type;
+ if ( !rfocusMorph.test( bubbleType + type ) ) {
+ cur = cur.parentNode;
+ }
+ for ( ; cur; cur = cur.parentNode ) {
+ eventPath.push( cur );
+ tmp = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if ( tmp === ( elem.ownerDocument || document ) ) {
+ eventPath.push( tmp.defaultView || tmp.parentWindow || window );
+ }
+ }
+
+ // Fire handlers on the event path
+ i = 0;
+ while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
+ lastElement = cur;
+ event.type = i > 1 ?
+ bubbleType :
+ special.bindType || type;
+
+ // jQuery handler
+ handle = (
+ dataPriv.get( cur, "events" ) || Object.create( null )
+ )[ event.type ] &&
+ dataPriv.get( cur, "handle" );
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+
+ // Native handler
+ handle = ontype && cur[ ontype ];
+ if ( handle && handle.apply && acceptData( cur ) ) {
+ event.result = handle.apply( cur, data );
+ if ( event.result === false ) {
+ event.preventDefault();
+ }
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+ if ( ( !special._default ||
+ special._default.apply( eventPath.pop(), data ) === false ) &&
+ acceptData( elem ) ) {
+
+ // Call a native DOM method on the target with the same name as the event.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ tmp = elem[ ontype ];
+
+ if ( tmp ) {
+ elem[ ontype ] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+
+ if ( event.isPropagationStopped() ) {
+ lastElement.addEventListener( type, stopPropagationCallback );
+ }
+
+ elem[ type ]();
+
+ if ( event.isPropagationStopped() ) {
+ lastElement.removeEventListener( type, stopPropagationCallback );
+ }
+
+ jQuery.event.triggered = undefined;
+
+ if ( tmp ) {
+ elem[ ontype ] = tmp;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ // Piggyback on a donor event to simulate a different one
+ // Used only for `focus(in | out)` events
+ simulate: function( type, elem, event ) {
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ {
+ type: type,
+ isSimulated: true
+ }
+ );
+
+ jQuery.event.trigger( e, null, elem );
+ }
+
+} );
+
+jQuery.fn.extend( {
+
+ trigger: function( type, data ) {
+ return this.each( function() {
+ jQuery.event.trigger( type, data, this );
+ } );
+ },
+ triggerHandler: function( type, data ) {
+ var elem = this[ 0 ];
+ if ( elem ) {
+ return jQuery.event.trigger( type, data, elem, true );
+ }
+ }
+} );
+
+
+// Support: Firefox <=44
+// Firefox doesn't have focus(in | out) events
+// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
+//
+// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
+// focus(in | out) events fire after focus & blur events,
+// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
+// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
+if ( !support.focusin ) {
+ jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler on the document while someone wants focusin/focusout
+ var handler = function( event ) {
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
+ };
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+
+ // Handle: regular nodes (via `this.ownerDocument`), window
+ // (via `this.document`) & document (via `this`).
+ var doc = this.ownerDocument || this.document || this,
+ attaches = dataPriv.access( doc, fix );
+
+ if ( !attaches ) {
+ doc.addEventListener( orig, handler, true );
+ }
+ dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
+ },
+ teardown: function() {
+ var doc = this.ownerDocument || this.document || this,
+ attaches = dataPriv.access( doc, fix ) - 1;
+
+ if ( !attaches ) {
+ doc.removeEventListener( orig, handler, true );
+ dataPriv.remove( doc, fix );
+
+ } else {
+ dataPriv.access( doc, fix, attaches );
+ }
+ }
+ };
+ } );
+}
+var location = window.location;
+
+var nonce = { guid: Date.now() };
+
+var rquery = ( /\?/ );
+
+
+
+// Cross-browser xml parsing
+jQuery.parseXML = function( data ) {
+ var xml;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+
+ // Support: IE 9 - 11 only
+ // IE throws on parseFromString with invalid input.
+ try {
+ xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
+ } catch ( e ) {
+ xml = undefined;
+ }
+
+ if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+};
+
+
+var
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+ rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+function buildParams( prefix, obj, traditional, add ) {
+ var name;
+
+ if ( Array.isArray( obj ) ) {
+
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional || rbracket.test( prefix ) ) {
+
+ // Treat each array item as a scalar.
+ add( prefix, v );
+
+ } else {
+
+ // Item is non-scalar (array or object), encode its numeric index.
+ buildParams(
+ prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
+ v,
+ traditional,
+ add
+ );
+ }
+ } );
+
+ } else if ( !traditional && toType( obj ) === "object" ) {
+
+ // Serialize object item.
+ for ( name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
+
+ } else {
+
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+}
+
+// Serialize an array of form elements or a set of
+// key/values into a query string
+jQuery.param = function( a, traditional ) {
+ var prefix,
+ s = [],
+ add = function( key, valueOrFunction ) {
+
+ // If value is a function, invoke it and use its return value
+ var value = isFunction( valueOrFunction ) ?
+ valueOrFunction() :
+ valueOrFunction;
+
+ s[ s.length ] = encodeURIComponent( key ) + "=" +
+ encodeURIComponent( value == null ? "" : value );
+ };
+
+ if ( a == null ) {
+ return "";
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ } );
+
+ } else {
+
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for ( prefix in a ) {
+ buildParams( prefix, a[ prefix ], traditional, add );
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join( "&" );
+};
+
+jQuery.fn.extend( {
+ serialize: function() {
+ return jQuery.param( this.serializeArray() );
+ },
+ serializeArray: function() {
+ return this.map( function() {
+
+ // Can add propHook for "elements" to filter or add form elements
+ var elements = jQuery.prop( this, "elements" );
+ return elements ? jQuery.makeArray( elements ) : this;
+ } )
+ .filter( function() {
+ var type = this.type;
+
+ // Use .is( ":disabled" ) so that fieldset[disabled] works
+ return this.name && !jQuery( this ).is( ":disabled" ) &&
+ rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
+ ( this.checked || !rcheckableType.test( type ) );
+ } )
+ .map( function( _i, elem ) {
+ var val = jQuery( this ).val();
+
+ if ( val == null ) {
+ return null;
+ }
+
+ if ( Array.isArray( val ) ) {
+ return jQuery.map( val, function( val ) {
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ } );
+ }
+
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ } ).get();
+ }
+} );
+
+
+var
+ r20 = /%20/g,
+ rhash = /#.*$/,
+ rantiCache = /([?&])_=[^&]*/,
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
+
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = "*/".concat( "*" ),
+
+ // Anchor tag for parsing the document origin
+ originAnchor = document.createElement( "a" );
+ originAnchor.href = location.href;
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function( dataTypeExpression, func ) {
+
+ if ( typeof dataTypeExpression !== "string" ) {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType,
+ i = 0,
+ dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
+
+ if ( isFunction( func ) ) {
+
+ // For each dataType in the dataTypeExpression
+ while ( ( dataType = dataTypes[ i++ ] ) ) {
+
+ // Prepend if requested
+ if ( dataType[ 0 ] === "+" ) {
+ dataType = dataType.slice( 1 ) || "*";
+ ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
+
+ // Otherwise append
+ } else {
+ ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
+ }
+ }
+ }
+ };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
+
+ var inspected = {},
+ seekingTransport = ( structure === transports );
+
+ function inspect( dataType ) {
+ var selected;
+ inspected[ dataType ] = true;
+ jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
+ var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
+ if ( typeof dataTypeOrTransport === "string" &&
+ !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
+
+ options.dataTypes.unshift( dataTypeOrTransport );
+ inspect( dataTypeOrTransport );
+ return false;
+ } else if ( seekingTransport ) {
+ return !( selected = dataTypeOrTransport );
+ }
+ } );
+ return selected;
+ }
+
+ return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+ var key, deep,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+ for ( key in src ) {
+ if ( src[ key ] !== undefined ) {
+ ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
+ }
+ }
+ if ( deep ) {
+ jQuery.extend( true, target, deep );
+ }
+
+ return target;
+}
+
+/* Handles responses to an ajax request:
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+
+ var ct, type, finalDataType, firstDataType,
+ contents = s.contents,
+ dataTypes = s.dataTypes;
+
+ // Remove auto dataType and get content-type in the process
+ while ( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+/* Chain conversions given the request and the original response
+ * Also sets the responseXXX fields on the jqXHR instance
+ */
+function ajaxConvert( s, response, jqXHR, isSuccess ) {
+ var conv2, current, conv, tmp, prev,
+ converters = {},
+
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice();
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ current = dataTypes.shift();
+
+ // Convert to each sequential dataType
+ while ( current ) {
+
+ if ( s.responseFields[ current ] ) {
+ jqXHR[ s.responseFields[ current ] ] = response;
+ }
+
+ // Apply the dataFilter if provided
+ if ( !prev && isSuccess && s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ prev = current;
+ current = dataTypes.shift();
+
+ if ( current ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current === "*" ) {
+
+ current = prev;
+
+ // Convert response if prev dataType is non-auto and differs from current
+ } else if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split( " " );
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.unshift( tmp[ 1 ] );
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s.throws ) {
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return {
+ state: "parsererror",
+ error: conv ? e : "No conversion from " + prev + " to " + current
+ };
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return { state: "success", data: response };
+}
+
+jQuery.extend( {
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajaxSettings: {
+ url: location.href,
+ type: "GET",
+ isLocal: rlocalProtocol.test( location.protocol ),
+ global: true,
+ processData: true,
+ async: true,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ "*": allTypes,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+
+ contents: {
+ xml: /\bxml\b/,
+ html: /\bhtml/,
+ json: /\bjson\b/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText",
+ json: "responseJSON"
+ },
+
+ // Data converters
+ // Keys separate source (or catchall "*") and destination types with a single space
+ converters: {
+
+ // Convert anything to text
+ "* text": String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": JSON.parse,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ url: true,
+ context: true
+ }
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ return settings ?
+
+ // Building a settings object
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+ // Extending ajaxSettings
+ ajaxExtend( jQuery.ajaxSettings, target );
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var transport,
+
+ // URL without anti-cache param
+ cacheURL,
+
+ // Response headers
+ responseHeadersString,
+ responseHeaders,
+
+ // timeout handle
+ timeoutTimer,
+
+ // Url cleanup var
+ urlAnchor,
+
+ // Request state (becomes false upon send and true upon completion)
+ completed,
+
+ // To know if global events are to be dispatched
+ fireGlobals,
+
+ // Loop variable
+ i,
+
+ // uncached part of the url
+ uncached,
+
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+
+ // Callbacks context
+ callbackContext = s.context || s,
+
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
+ globalEventContext = s.context &&
+ ( callbackContext.nodeType || callbackContext.jquery ) ?
+ jQuery( callbackContext ) :
+ jQuery.event,
+
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks( "once memory" ),
+
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+
+ // Default abort message
+ strAbort = "canceled",
+
+ // Fake xhr
+ jqXHR = {
+ readyState: 0,
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( completed ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
+ responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
+ ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
+ .concat( match[ 2 ] );
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() + " " ];
+ }
+ return match == null ? null : match.join( ", " );
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return completed ? responseHeadersString : null;
+ },
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ if ( completed == null ) {
+ name = requestHeadersNames[ name.toLowerCase() ] =
+ requestHeadersNames[ name.toLowerCase() ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( completed == null ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Status-dependent callbacks
+ statusCode: function( map ) {
+ var code;
+ if ( map ) {
+ if ( completed ) {
+
+ // Execute the appropriate callbacks
+ jqXHR.always( map[ jqXHR.status ] );
+ } else {
+
+ // Lazy-add the new callbacks in a way that preserves old ones
+ for ( code in map ) {
+ statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+ }
+ }
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ var finalText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( finalText );
+ }
+ done( 0, finalText );
+ return this;
+ }
+ };
+
+ // Attach deferreds
+ deferred.promise( jqXHR );
+
+ // Add protocol if not provided (prefilters might expect it)
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url || location.href ) + "" )
+ .replace( rprotocol, location.protocol + "//" );
+
+ // Alias method option to type as per ticket #12004
+ s.type = options.method || options.type || s.method || s.type;
+
+ // Extract dataTypes list
+ s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
+
+ // A cross-domain request is in order when the origin doesn't match the current origin.
+ if ( s.crossDomain == null ) {
+ urlAnchor = document.createElement( "a" );
+
+ // Support: IE <=8 - 11, Edge 12 - 15
+ // IE throws exception on accessing the href property if url is malformed,
+ // e.g. http://example.com:80x/
+ try {
+ urlAnchor.href = s.url;
+
+ // Support: IE <=8 - 11 only
+ // Anchor's host property isn't correctly set when s.url is relative
+ urlAnchor.href = urlAnchor.href;
+ s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
+ urlAnchor.protocol + "//" + urlAnchor.host;
+ } catch ( e ) {
+
+ // If there is an error parsing the URL, assume it is crossDomain,
+ // it can be rejected by the transport if it is invalid
+ s.crossDomain = true;
+ }
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( completed ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
+ fireGlobals = jQuery.event && s.global;
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Save the URL in case we're toying with the If-Modified-Since
+ // and/or If-None-Match header later on
+ // Remove hash to simplify url manipulation
+ cacheURL = s.url.replace( rhash, "" );
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // Remember the hash so we can put it back
+ uncached = s.url.slice( cacheURL.length );
+
+ // If data is available and should be processed, append data to url
+ if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
+ cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
+
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Add or update anti-cache param if needed
+ if ( s.cache === false ) {
+ cacheURL = cacheURL.replace( rantiCache, "$1" );
+ uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
+ uncached;
+ }
+
+ // Put hash and anti-cache on the URL that will be requested (gh-1732)
+ s.url = cacheURL + uncached;
+
+ // Change '%20' to '+' if this is encoded form body content (gh-2658)
+ } else if ( s.data && s.processData &&
+ ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
+ s.data = s.data.replace( r20, "+" );
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+ }
+ if ( jQuery.etag[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
+ s.accepts[ s.dataTypes[ 0 ] ] +
+ ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend &&
+ ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
+
+ // Abort if not done already and return
+ return jqXHR.abort();
+ }
+
+ // Aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ completeDeferred.add( s.complete );
+ jqXHR.done( s.success );
+ jqXHR.fail( s.error );
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+
+ // If request was aborted inside ajaxSend, stop there
+ if ( completed ) {
+ return jqXHR;
+ }
+
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = window.setTimeout( function() {
+ jqXHR.abort( "timeout" );
+ }, s.timeout );
+ }
+
+ try {
+ completed = false;
+ transport.send( requestHeaders, done );
+ } catch ( e ) {
+
+ // Rethrow post-completion exceptions
+ if ( completed ) {
+ throw e;
+ }
+
+ // Propagate others as results
+ done( -1, e );
+ }
+ }
+
+ // Callback for when everything is done
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Ignore repeat invocations
+ if ( completed ) {
+ return;
+ }
+
+ completed = true;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ window.clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Determine if successful
+ isSuccess = status >= 200 && status < 300 || status === 304;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // Use a noop converter for missing script
+ if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
+ s.converters[ "text script" ] = function() {};
+ }
+
+ // Convert no matter what (that way responseXXX fields are always set)
+ response = ajaxConvert( s, response, jqXHR, isSuccess );
+
+ // If successful, handle type chaining
+ if ( isSuccess ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ modified = jqXHR.getResponseHeader( "Last-Modified" );
+ if ( modified ) {
+ jQuery.lastModified[ cacheURL ] = modified;
+ }
+ modified = jqXHR.getResponseHeader( "etag" );
+ if ( modified ) {
+ jQuery.etag[ cacheURL ] = modified;
+ }
+ }
+
+ // if no content
+ if ( status === 204 || s.type === "HEAD" ) {
+ statusText = "nocontent";
+
+ // if not modified
+ } else if ( status === 304 ) {
+ statusText = "notmodified";
+
+ // If we have data, let's convert it
+ } else {
+ statusText = response.state;
+ success = response.data;
+ error = response.error;
+ isSuccess = !error;
+ }
+ } else {
+
+ // Extract error from statusText and normalize for non-aborts
+ error = statusText;
+ if ( status || !statusText ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ }
+} );
+
+jQuery.each( [ "get", "post" ], function( _i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+
+ // Shift arguments if data argument was omitted
+ if ( isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ // The url can be an options object (which then must have .url)
+ return jQuery.ajax( jQuery.extend( {
+ url: url,
+ type: method,
+ dataType: type,
+ data: data,
+ success: callback
+ }, jQuery.isPlainObject( url ) && url ) );
+ };
+} );
+
+jQuery.ajaxPrefilter( function( s ) {
+ var i;
+ for ( i in s.headers ) {
+ if ( i.toLowerCase() === "content-type" ) {
+ s.contentType = s.headers[ i ] || "";
+ }
+ }
+} );
+
+
+jQuery._evalUrl = function( url, options, doc ) {
+ return jQuery.ajax( {
+ url: url,
+
+ // Make this explicit, since user can override this through ajaxSetup (#11264)
+ type: "GET",
+ dataType: "script",
+ cache: true,
+ async: false,
+ global: false,
+
+ // Only evaluate the response if it is successful (gh-4126)
+ // dataFilter is not invoked for failure responses, so using it instead
+ // of the default converter is kludgy but it works.
+ converters: {
+ "text script": function() {}
+ },
+ dataFilter: function( response ) {
+ jQuery.globalEval( response, options, doc );
+ }
+ } );
+};
+
+
+jQuery.fn.extend( {
+ wrapAll: function( html ) {
+ var wrap;
+
+ if ( this[ 0 ] ) {
+ if ( isFunction( html ) ) {
+ html = html.call( this[ 0 ] );
+ }
+
+ // The elements to wrap the target around
+ wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
+
+ if ( this[ 0 ].parentNode ) {
+ wrap.insertBefore( this[ 0 ] );
+ }
+
+ wrap.map( function() {
+ var elem = this;
+
+ while ( elem.firstElementChild ) {
+ elem = elem.firstElementChild;
+ }
+
+ return elem;
+ } ).append( this );
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ if ( isFunction( html ) ) {
+ return this.each( function( i ) {
+ jQuery( this ).wrapInner( html.call( this, i ) );
+ } );
+ }
+
+ return this.each( function() {
+ var self = jQuery( this ),
+ contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ } );
+ },
+
+ wrap: function( html ) {
+ var htmlIsFunction = isFunction( html );
+
+ return this.each( function( i ) {
+ jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
+ } );
+ },
+
+ unwrap: function( selector ) {
+ this.parent( selector ).not( "body" ).each( function() {
+ jQuery( this ).replaceWith( this.childNodes );
+ } );
+ return this;
+ }
+} );
+
+
+jQuery.expr.pseudos.hidden = function( elem ) {
+ return !jQuery.expr.pseudos.visible( elem );
+};
+jQuery.expr.pseudos.visible = function( elem ) {
+ return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
+};
+
+
+
+
+jQuery.ajaxSettings.xhr = function() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch ( e ) {}
+};
+
+var xhrSuccessStatus = {
+
+ // File protocol always yields status code 0, assume 200
+ 0: 200,
+
+ // Support: IE <=9 only
+ // #1450: sometimes IE returns 1223 when it should be 204
+ 1223: 204
+ },
+ xhrSupported = jQuery.ajaxSettings.xhr();
+
+support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+support.ajax = xhrSupported = !!xhrSupported;
+
+jQuery.ajaxTransport( function( options ) {
+ var callback, errorCallback;
+
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( support.cors || xhrSupported && !options.crossDomain ) {
+ return {
+ send: function( headers, complete ) {
+ var i,
+ xhr = options.xhr();
+
+ xhr.open(
+ options.type,
+ options.url,
+ options.async,
+ options.username,
+ options.password
+ );
+
+ // Apply custom fields if provided
+ if ( options.xhrFields ) {
+ for ( i in options.xhrFields ) {
+ xhr[ i ] = options.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( options.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( options.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
+ }
+
+ // Set headers
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
+
+ // Callback
+ callback = function( type ) {
+ return function() {
+ if ( callback ) {
+ callback = errorCallback = xhr.onload =
+ xhr.onerror = xhr.onabort = xhr.ontimeout =
+ xhr.onreadystatechange = null;
+
+ if ( type === "abort" ) {
+ xhr.abort();
+ } else if ( type === "error" ) {
+
+ // Support: IE <=9 only
+ // On a manual native abort, IE9 throws
+ // errors on any property access that is not readyState
+ if ( typeof xhr.status !== "number" ) {
+ complete( 0, "error" );
+ } else {
+ complete(
+
+ // File: protocol always yields status 0; see #8605, #14207
+ xhr.status,
+ xhr.statusText
+ );
+ }
+ } else {
+ complete(
+ xhrSuccessStatus[ xhr.status ] || xhr.status,
+ xhr.statusText,
+
+ // Support: IE <=9 only
+ // IE9 has no XHR2 but throws on binary (trac-11426)
+ // For XHR2 non-text, let the caller handle it (gh-2498)
+ ( xhr.responseType || "text" ) !== "text" ||
+ typeof xhr.responseText !== "string" ?
+ { binary: xhr.response } :
+ { text: xhr.responseText },
+ xhr.getAllResponseHeaders()
+ );
+ }
+ }
+ };
+ };
+
+ // Listen to events
+ xhr.onload = callback();
+ errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
+
+ // Support: IE 9 only
+ // Use onreadystatechange to replace onabort
+ // to handle uncaught aborts
+ if ( xhr.onabort !== undefined ) {
+ xhr.onabort = errorCallback;
+ } else {
+ xhr.onreadystatechange = function() {
+
+ // Check readyState before timeout as it changes
+ if ( xhr.readyState === 4 ) {
+
+ // Allow onerror to be called first,
+ // but that will not handle a native abort
+ // Also, save errorCallback to a variable
+ // as xhr.onerror cannot be accessed
+ window.setTimeout( function() {
+ if ( callback ) {
+ errorCallback();
+ }
+ } );
+ }
+ };
+ }
+
+ // Create the abort callback
+ callback = callback( "abort" );
+
+ try {
+
+ // Do send the request (this may raise an exception)
+ xhr.send( options.hasContent && options.data || null );
+ } catch ( e ) {
+
+ // #14683: Only rethrow if this hasn't been notified as an error yet
+ if ( callback ) {
+ throw e;
+ }
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback();
+ }
+ }
+ };
+ }
+} );
+
+
+
+
+// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
+jQuery.ajaxPrefilter( function( s ) {
+ if ( s.crossDomain ) {
+ s.contents.script = false;
+ }
+} );
+
+// Install script dataType
+jQuery.ajaxSetup( {
+ accepts: {
+ script: "text/javascript, application/javascript, " +
+ "application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /\b(?:java|ecma)script\b/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+} );
+
+// Handle cache's special case and crossDomain
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ }
+} );
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function( s ) {
+
+ // This transport only deals with cross domain or forced-by-attrs requests
+ if ( s.crossDomain || s.scriptAttrs ) {
+ var script, callback;
+ return {
+ send: function( _, complete ) {
+ script = jQuery( "<script>" )
+ .attr( s.scriptAttrs || {} )
+ .prop( { charset: s.scriptCharset, src: s.url } )
+ .on( "load error", callback = function( evt ) {
+ script.remove();
+ callback = null;
+ if ( evt ) {
+ complete( evt.type === "error" ? 404 : 200, evt.type );
+ }
+ } );
+
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
+ document.head.appendChild( script[ 0 ] );
+ },
+ abort: function() {
+ if ( callback ) {
+ callback();
+ }
+ }
+ };
+ }
+} );
+
+
+
+
+var oldCallbacks = [],
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup( {
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+} );
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+ "url" :
+ typeof s.data === "string" &&
+ ( s.contentType || "" )
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
+ rjsonp.test( s.data ) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if ( jsonProp ) {
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+ } else if ( s.jsonp !== false ) {
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters[ "script json" ] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // Force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ overwritten = window[ callbackName ];
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always( function() {
+
+ // If previous value didn't exist - remove it
+ if ( overwritten === undefined ) {
+ jQuery( window ).removeProp( callbackName );
+
+ // Otherwise restore preexisting value
+ } else {
+ window[ callbackName ] = overwritten;
+ }
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+
+ // Make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // Save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ } );
+
+ // Delegate to script
+ return "script";
+ }
+} );
+
+
+
+
+// Support: Safari 8 only
+// In Safari 8 documents created via document.implementation.createHTMLDocument
+// collapse sibling forms: the second one becomes a child of the first one.
+// Because of that, this security measure has to be disabled in Safari 8.
+// https://bugs.webkit.org/show_bug.cgi?id=137337
+support.createHTMLDocument = ( function() {
+ var body = document.implementation.createHTMLDocument( "" ).body;
+ body.innerHTML = "<form></form><form></form>";
+ return body.childNodes.length === 2;
+} )();
+
+
+// Argument "data" should be string of html
+// context (optional): If specified, the fragment will be created in this context,
+// defaults to document
+// keepScripts (optional): If true, will include scripts passed in the html string
+jQuery.parseHTML = function( data, context, keepScripts ) {
+ if ( typeof data !== "string" ) {
+ return [];
+ }
+ if ( typeof context === "boolean" ) {
+ keepScripts = context;
+ context = false;
+ }
+
+ var base, parsed, scripts;
+
+ if ( !context ) {
+
+ // Stop scripts or inline event handlers from being executed immediately
+ // by using document.implementation
+ if ( support.createHTMLDocument ) {
+ context = document.implementation.createHTMLDocument( "" );
+
+ // Set the base href for the created document
+ // so any parsed elements with URLs
+ // are based on the document's URL (gh-2965)
+ base = context.createElement( "base" );
+ base.href = document.location.href;
+ context.head.appendChild( base );
+ } else {
+ context = document;
+ }
+ }
+
+ parsed = rsingleTag.exec( data );
+ scripts = !keepScripts && [];
+
+ // Single tag
+ if ( parsed ) {
+ return [ context.createElement( parsed[ 1 ] ) ];
+ }
+
+ parsed = buildFragment( [ data ], context, scripts );
+
+ if ( scripts && scripts.length ) {
+ jQuery( scripts ).remove();
+ }
+
+ return jQuery.merge( [], parsed.childNodes );
+};
+
+
+/**
+ * Load a url into a page
+ */
+jQuery.fn.load = function( url, params, callback ) {
+ var selector, type, response,
+ self = this,
+ off = url.indexOf( " " );
+
+ if ( off > -1 ) {
+ selector = stripAndCollapse( url.slice( off ) );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // If we have elements to modify, make the request
+ if ( self.length > 0 ) {
+ jQuery.ajax( {
+ url: url,
+
+ // If "type" variable is undefined, then "GET" method will be used.
+ // Make value of this field explicit since
+ // user can override it through ajaxSetup method
+ type: type || "GET",
+ dataType: "html",
+ data: params
+ } ).done( function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ self.html( selector ?
+
+ // If a selector was specified, locate the right elements in a dummy div
+ // Exclude scripts to avoid IE 'Permission Denied' errors
+ jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+ // Otherwise use the full result
+ responseText );
+
+ // If the request succeeds, this function gets "data", "status", "jqXHR"
+ // but they are ignored because response was set above.
+ // If it fails, this function gets "jqXHR", "status", "error"
+ } ).always( callback && function( jqXHR, status ) {
+ self.each( function() {
+ callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
+ } );
+ } );
+ }
+
+ return this;
+};
+
+
+
+
+jQuery.expr.pseudos.animated = function( elem ) {
+ return jQuery.grep( jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ } ).length;
+};
+
+
+
+
+jQuery.offset = {
+ setOffset: function( elem, options, i ) {
+ var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
+ position = jQuery.css( elem, "position" ),
+ curElem = jQuery( elem ),
+ props = {};
+
+ // Set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ curOffset = curElem.offset();
+ curCSSTop = jQuery.css( elem, "top" );
+ curCSSLeft = jQuery.css( elem, "left" );
+ calculatePosition = ( position === "absolute" || position === "fixed" ) &&
+ ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
+
+ // Need to be able to calculate position if either
+ // top or left is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( isFunction( options ) ) {
+
+ // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
+ options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+
+ } else {
+ if ( typeof props.top === "number" ) {
+ props.top += "px";
+ }
+ if ( typeof props.left === "number" ) {
+ props.left += "px";
+ }
+ curElem.css( props );
+ }
+ }
+};
+
+jQuery.fn.extend( {
+
+ // offset() relates an element's border box to the document origin
+ offset: function( options ) {
+
+ // Preserve chaining for setter
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each( function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ } );
+ }
+
+ var rect, win,
+ elem = this[ 0 ];
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
+ // Support: IE <=11 only
+ // Running getBoundingClientRect on a
+ // disconnected node in IE throws an error
+ if ( !elem.getClientRects().length ) {
+ return { top: 0, left: 0 };
+ }
+
+ // Get document-relative position by adding viewport scroll to viewport-relative gBCR
+ rect = elem.getBoundingClientRect();
+ win = elem.ownerDocument.defaultView;
+ return {
+ top: rect.top + win.pageYOffset,
+ left: rect.left + win.pageXOffset
+ };
+ },
+
+ // position() relates an element's margin box to its offset parent's padding box
+ // This corresponds to the behavior of CSS absolute positioning
+ position: function() {
+ if ( !this[ 0 ] ) {
+ return;
+ }
+
+ var offsetParent, offset, doc,
+ elem = this[ 0 ],
+ parentOffset = { top: 0, left: 0 };
+
+ // position:fixed elements are offset from the viewport, which itself always has zero offset
+ if ( jQuery.css( elem, "position" ) === "fixed" ) {
+
+ // Assume position:fixed implies availability of getBoundingClientRect
+ offset = elem.getBoundingClientRect();
+
+ } else {
+ offset = this.offset();
+
+ // Account for the *real* offset parent, which can be the document or its root element
+ // when a statically positioned element is identified
+ doc = elem.ownerDocument;
+ offsetParent = elem.offsetParent || doc.documentElement;
+ while ( offsetParent &&
+ ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
+ jQuery.css( offsetParent, "position" ) === "static" ) {
+
+ offsetParent = offsetParent.parentNode;
+ }
+ if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
+
+ // Incorporate borders into its offset, since they are outside its content origin
+ parentOffset = jQuery( offsetParent ).offset();
+ parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
+ parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
+ }
+ }
+
+ // Subtract parent offsets and element margins
+ return {
+ top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+ left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
+ };
+ },
+
+ // This method will return documentElement in the following cases:
+ // 1) For the element inside the iframe without offsetParent, this method will return
+ // documentElement of the parent window
+ // 2) For the hidden or detached element
+ // 3) For body or html element, i.e. in case of the html node - it will return itself
+ //
+ // but those exceptions were never presented as a real life use-cases
+ // and might be considered as more preferable results.
+ //
+ // This logic, however, is not guaranteed and can change at any point in the future
+ offsetParent: function() {
+ return this.map( function() {
+ var offsetParent = this.offsetParent;
+
+ while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+
+ return offsetParent || documentElement;
+ } );
+ }
+} );
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
+ var top = "pageYOffset" === prop;
+
+ jQuery.fn[ method ] = function( val ) {
+ return access( this, function( elem, method, val ) {
+
+ // Coalesce documents and windows
+ var win;
+ if ( isWindow( elem ) ) {
+ win = elem;
+ } else if ( elem.nodeType === 9 ) {
+ win = elem.defaultView;
+ }
+
+ if ( val === undefined ) {
+ return win ? win[ prop ] : elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : win.pageXOffset,
+ top ? val : win.pageYOffset
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length );
+ };
+} );
+
+// Support: Safari <=7 - 9.1, Chrome <=37 - 49
+// Add the top/left cssHooks using jQuery.fn.position
+// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
+// getComputedStyle returns percent when specified for top/left/bottom/right;
+// rather than make the css module depend on the offset module, just check for it here
+jQuery.each( [ "top", "left" ], function( _i, prop ) {
+ jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
+ function( elem, computed ) {
+ if ( computed ) {
+ computed = curCSS( elem, prop );
+
+ // If curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( computed ) ?
+ jQuery( elem ).position()[ prop ] + "px" :
+ computed;
+ }
+ }
+ );
+} );
+
+
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
+ function( defaultExtra, funcName ) {
+
+ // Margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( isWindow( elem ) ) {
+
+ // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
+ return funcName.indexOf( "outer" ) === 0 ?
+ elem[ "inner" + name ] :
+ elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
+ // whichever is greatest
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable );
+ };
+ } );
+} );
+
+
+jQuery.each( [
+ "ajaxStart",
+ "ajaxStop",
+ "ajaxComplete",
+ "ajaxError",
+ "ajaxSuccess",
+ "ajaxSend"
+], function( _i, type ) {
+ jQuery.fn[ type ] = function( fn ) {
+ return this.on( type, fn );
+ };
+} );
+
+
+
+
+jQuery.fn.extend( {
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ?
+ this.off( selector, "**" ) :
+ this.off( types, selector || "**", fn );
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+} );
+
+jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup contextmenu" ).split( " " ),
+ function( _i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+ } );
+
+
+
+
+// Support: Android <=4.0 only
+// Make sure we trim BOM and NBSP
+var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
+
+// Bind a function to a context, optionally partially applying any
+// arguments.
+// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
+// However, it is not slated for removal any time soon
+jQuery.proxy = function( fn, context ) {
+ var tmp, args, proxy;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+};
+
+jQuery.holdReady = function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+};
+jQuery.isArray = Array.isArray;
+jQuery.parseJSON = JSON.parse;
+jQuery.nodeName = nodeName;
+jQuery.isFunction = isFunction;
+jQuery.isWindow = isWindow;
+jQuery.camelCase = camelCase;
+jQuery.type = toType;
+
+jQuery.now = Date.now;
+
+jQuery.isNumeric = function( obj ) {
+
+ // As of jQuery 3.0, isNumeric is limited to
+ // strings and numbers (primitives or objects)
+ // that can be coerced to finite numbers (gh-2662)
+ var type = jQuery.type( obj );
+ return ( type === "number" || type === "string" ) &&
+
+ // parseFloat NaNs numeric-cast false positives ("")
+ // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+ // subtraction forces infinities to NaN
+ !isNaN( obj - parseFloat( obj ) );
+};
+
+jQuery.trim = function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+};
+
+
+
+// Register as a named AMD module, since jQuery can be concatenated with other
+// files that may use define, but not via a proper concatenation script that
+// understands anonymous AMD modules. A named AMD is safest and most robust
+// way to register. Lowercase jquery is used because AMD module names are
+// derived from file names, and jQuery is normally delivered in a lowercase
+// file name. Do this after creating the global so that if an AMD module wants
+// to call noConflict to hide this version of jQuery, it will work.
+
+// Note that for maximum portability, libraries that are not jQuery should
+// declare themselves as anonymous modules, and avoid setting a global if an
+// AMD loader is present. jQuery is a special case. For more information, see
+// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
+
+if ( typeof define === "function" && define.amd ) {
+ define( "jquery", [], function() {
+ return jQuery;
+ } );
+}
+
+
+
+
+var
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$;
+
+jQuery.noConflict = function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+};
+
+// Expose jQuery and $ identifiers, even in AMD
+// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
+// and CommonJS for browser emulators (#13566)
+if ( typeof noGlobal === "undefined" ) {
+ window.jQuery = window.$ = jQuery;
+}
+
+
+
+
+return jQuery;
+} );
--- /dev/null
+++ b/js/jqueryui/jquery-1.12.4.js
@@ -1,0 +1,11008 @@
+/*!
+ * jQuery JavaScript Library v1.12.4
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2016-05-20T17:17Z
+ */
+
+(function( global, factory ) {
+
+ if ( typeof module === "object" && typeof module.exports === "object" ) {
+ // For CommonJS and CommonJS-like environments where a proper `window`
+ // is present, execute the factory and get jQuery.
+ // For environments that do not have a `window` with a `document`
+ // (such as Node.js), expose a factory as module.exports.
+ // This accentuates the need for the creation of a real `window`.
+ // e.g. var jQuery = require("jquery")(window);
+ // See ticket #14549 for more info.
+ module.exports = global.document ?
+ factory( global, true ) :
+ function( w ) {
+ if ( !w.document ) {
+ throw new Error( "jQuery requires a window with a document" );
+ }
+ return factory( w );
+ };
+ } else {
+ factory( global );
+ }
+
+// Pass this if window is not defined yet
+}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
+
+// Support: Firefox 18+
+// Can't be in strict mode, several libs including ASP.NET trace
+// the stack via arguments.caller.callee and Firefox dies if
+// you try to trace through "use strict" call chains. (#13335)
+//"use strict";
+var deletedIds = [];
+
+var document = window.document;
+
+var slice = deletedIds.slice;
+
+var concat = deletedIds.concat;
+
+var push = deletedIds.push;
+
+var indexOf = deletedIds.indexOf;
+
+var class2type = {};
+
+var toString = class2type.toString;
+
+var hasOwn = class2type.hasOwnProperty;
+
+var support = {};
+
+
+
+var
+ version = "1.12.4",
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+
+ // The jQuery object is actually just the init constructor 'enhanced'
+ // Need init if jQuery is called (just allow error to be thrown if not included)
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Support: Android<4.1, IE<9
+ // Make sure we trim BOM and NBSP
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+ // Matches dashed string for camelizing
+ rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([\da-z])/gi,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn = jQuery.prototype = {
+
+ // The current version of jQuery being used
+ jquery: version,
+
+ constructor: jQuery,
+
+ // Start with an empty selector
+ selector: "",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ toArray: function() {
+ return slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num != null ?
+
+ // Return just the one element from the set
+ ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
+
+ // Return all the elements in a clean array
+ slice.call( this );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+ ret.context = this.context;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ each: function( callback ) {
+ return jQuery.each( this, callback );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map( this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ } ) );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ) );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ eq: function( i ) {
+ var len = this.length,
+ j = +i + ( i < 0 ? len : 0 );
+ return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor();
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: deletedIds.sort,
+ splice: deletedIds.splice
+};
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var src, copyIsArray, copy, name, options, clone,
+ target = arguments[ 0 ] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+
+ // skip the boolean and the target
+ target = arguments[ i ] || {};
+ i++;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( i === length ) {
+ target = this;
+ i--;
+ }
+
+ for ( ; i < length; i++ ) {
+
+ // Only deal with non-null/undefined values
+ if ( ( options = arguments[ i ] ) != null ) {
+
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
+ ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
+
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray( src ) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject( src ) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend( {
+
+ // Unique for each copy of jQuery on the page
+ expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
+
+ // Assume jQuery is ready without the ready module
+ isReady: true,
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ noop: function() {},
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type( obj ) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type( obj ) === "array";
+ },
+
+ isWindow: function( obj ) {
+ /* jshint eqeqeq: false */
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function( obj ) {
+
+ // parseFloat NaNs numeric-cast false positives (null|true|false|"")
+ // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+ // subtraction forces infinities to NaN
+ // adding 1 corrects loss of precision from parseFloat (#15100)
+ var realStringObj = obj && obj.toString();
+ return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ isPlainObject: function( obj ) {
+ var key;
+
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ try {
+
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !hasOwn.call( obj, "constructor" ) &&
+ !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
+ return false;
+ }
+ } catch ( e ) {
+
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Support: IE<9
+ // Handle iteration over inherited properties before own properties.
+ if ( !support.ownFirst ) {
+ for ( key in obj ) {
+ return hasOwn.call( obj, key );
+ }
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwn.call( obj, key );
+ },
+
+ type: function( obj ) {
+ if ( obj == null ) {
+ return obj + "";
+ }
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[ toString.call( obj ) ] || "object" :
+ typeof obj;
+ },
+
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function( data ) {
+ if ( data && jQuery.trim( data ) ) {
+
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function( data ) {
+ window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
+ } )( data );
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ each: function( obj, callback ) {
+ var length, i = 0;
+
+ if ( isArrayLike( obj ) ) {
+ length = obj.length;
+ for ( ; i < length; i++ ) {
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+ break;
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Support: Android<4.1, IE<9
+ trim: function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var ret = results || [];
+
+ if ( arr != null ) {
+ if ( isArrayLike( Object( arr ) ) ) {
+ jQuery.merge( ret,
+ typeof arr === "string" ?
+ [ arr ] : arr
+ );
+ } else {
+ push.call( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ var len;
+
+ if ( arr ) {
+ if ( indexOf ) {
+ return indexOf.call( arr, elem, i );
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+ for ( ; i < len; i++ ) {
+
+ // Skip accessing in sparse arrays
+ if ( i in arr && arr[ i ] === elem ) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var len = +second.length,
+ j = 0,
+ i = first.length;
+
+ while ( j < len ) {
+ first[ i++ ] = second[ j++ ];
+ }
+
+ // Support: IE<9
+ // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
+ if ( len !== len ) {
+ while ( second[ j ] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, invert ) {
+ var callbackInverse,
+ matches = [],
+ i = 0,
+ length = elems.length,
+ callbackExpect = !invert;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ callbackInverse = !callback( elems[ i ], i );
+ if ( callbackInverse !== callbackExpect ) {
+ matches.push( elems[ i ] );
+ }
+ }
+
+ return matches;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var length, value,
+ i = 0,
+ ret = [];
+
+ // Go through the array, translating each of the items to their new values
+ if ( isArrayLike( elems ) ) {
+ length = elems.length;
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret.push( value );
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( i in elems ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret.push( value );
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function( fn, context ) {
+ var args, proxy, tmp;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !jQuery.isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ now: function() {
+ return +( new Date() );
+ },
+
+ // jQuery.support is not used in Core but other projects attach their
+ // properties to it so it needs to exist.
+ support: support
+} );
+
+// JSHint would error on this code due to the Symbol not being defined in ES5.
+// Defining this global in .jshintrc would create a danger of using the global
+// unguarded in another place, it seems safer to just disable JSHint for these
+// three lines.
+/* jshint ignore: start */
+if ( typeof Symbol === "function" ) {
+ jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
+}
+/* jshint ignore: end */
+
+// Populate the class2type map
+jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
+function( i, name ) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+} );
+
+function isArrayLike( obj ) {
+
+ // Support: iOS 8.2 (not reproducible in simulator)
+ // `in` check used to prevent JIT error (gh-2145)
+ // hasOwn isn't used here due to false negatives
+ // regarding Nodelist length in IE
+ var length = !!obj && "length" in obj && obj.length,
+ type = jQuery.type( obj );
+
+ if ( type === "function" || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ return type === "array" || length === 0 ||
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj;
+}
+var Sizzle =
+/*!
+ * Sizzle CSS Selector Engine v2.2.1
+ * http://sizzlejs.com/
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2015-10-17
+ */
+(function( window ) {
+
+var i,
+ support,
+ Expr,
+ getText,
+ isXML,
+ tokenize,
+ compile,
+ select,
+ outermostContext,
+ sortInput,
+ hasDuplicate,
+
+ // Local document vars
+ setDocument,
+ document,
+ docElem,
+ documentIsHTML,
+ rbuggyQSA,
+ rbuggyMatches,
+ matches,
+ contains,
+
+ // Instance-specific data
+ expando = "sizzle" + 1 * new Date(),
+ preferredDoc = window.document,
+ dirruns = 0,
+ done = 0,
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ }
+ return 0;
+ },
+
+ // General-purpose constants
+ MAX_NEGATIVE = 1 << 31,
+
+ // Instance methods
+ hasOwn = ({}).hasOwnProperty,
+ arr = [],
+ pop = arr.pop,
+ push_native = arr.push,
+ push = arr.push,
+ slice = arr.slice,
+ // Use a stripped-down indexOf as it's faster than native
+ // http://jsperf.com/thor-indexof-vs-for/5
+ indexOf = function( list, elem ) {
+ var i = 0,
+ len = list.length;
+ for ( ; i < len; i++ ) {
+ if ( list[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
+
+ // Regular expressions
+
+ // http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+
+ // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
+
+ // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
+ attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
+ // Operator (capture 2)
+ "*([*^$|!~]?=)" + whitespace +
+ // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
+ "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
+ "*\\]",
+
+ pseudos = ":(" + identifier + ")(?:\\((" +
+ // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
+ // 1. quoted (capture 3; capture 4 or capture 5)
+ "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
+ // 2. simple (capture 6)
+ "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
+ // 3. anything else (capture 2)
+ ".*" +
+ ")\\)|)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rwhitespace = new RegExp( whitespace + "+", "g" ),
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
+
+ rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
+
+ rpseudo = new RegExp( pseudos ),
+ ridentifier = new RegExp( "^" + identifier + "$" ),
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + identifier + ")" ),
+ "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
+ "TAG": new RegExp( "^(" + identifier + "|[*])" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
+ // For use in libraries implementing .is()
+ // We use this for POS matching in `select`
+ "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
+ whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+ },
+
+ rinputs = /^(?:input|select|textarea|button)$/i,
+ rheader = /^h\d$/i,
+
+ rnative = /^[^{]+\{\s*\[native \w/,
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+ rsibling = /[+~]/,
+ rescape = /'|\\/g,
+
+ // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+ runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
+ funescape = function( _, escaped, escapedWhitespace ) {
+ var high = "0x" + escaped - 0x10000;
+ // NaN means non-codepoint
+ // Support: Firefox<24
+ // Workaround erroneous numeric interpretation of +"0x"
+ return high !== high || escapedWhitespace ?
+ escaped :
+ high < 0 ?
+ // BMP codepoint
+ String.fromCharCode( high + 0x10000 ) :
+ // Supplemental Plane codepoint (surrogate pair)
+ String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+ },
+
+ // Used for iframes
+ // See setDocument()
+ // Removing the function wrapper causes a "Permission Denied"
+ // error in IE
+ unloadHandler = function() {
+ setDocument();
+ };
+
+// Optimize for push.apply( _, NodeList )
+try {
+ push.apply(
+ (arr = slice.call( preferredDoc.childNodes )),
+ preferredDoc.childNodes
+ );
+ // Support: Android<4.0
+ // Detect silently failing push.apply
+ arr[ preferredDoc.childNodes.length ].nodeType;
+} catch ( e ) {
+ push = { apply: arr.length ?
+
+ // Leverage slice if possible
+ function( target, els ) {
+ push_native.apply( target, slice.call(els) );
+ } :
+
+ // Support: IE<9
+ // Otherwise append directly
+ function( target, els ) {
+ var j = target.length,
+ i = 0;
+ // Can't trust NodeList.length
+ while ( (target[j++] = els[i++]) ) {}
+ target.length = j - 1;
+ }
+ };
+}
+
+function Sizzle( selector, context, results, seed ) {
+ var m, i, elem, nid, nidselect, match, groups, newSelector,
+ newContext = context && context.ownerDocument,
+
+ // nodeType defaults to 9, since context defaults to document
+ nodeType = context ? context.nodeType : 9;
+
+ results = results || [];
+
+ // Return early from calls with invalid selector or context
+ if ( typeof selector !== "string" || !selector ||
+ nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
+
+ return results;
+ }
+
+ // Try to shortcut find operations (as opposed to filters) in HTML documents
+ if ( !seed ) {
+
+ if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
+ setDocument( context );
+ }
+ context = context || document;
+
+ if ( documentIsHTML ) {
+
+ // If the selector is sufficiently simple, try using a "get*By*" DOM method
+ // (excepting DocumentFragment context, where the methods don't exist)
+ if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
+
+ // ID selector
+ if ( (m = match[1]) ) {
+
+ // Document context
+ if ( nodeType === 9 ) {
+ if ( (elem = context.getElementById( m )) ) {
+
+ // Support: IE, Opera, Webkit
+ // TODO: identify versions
+ // getElementById can match elements by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+
+ // Element context
+ } else {
+
+ // Support: IE, Opera, Webkit
+ // TODO: identify versions
+ // getElementById can match elements by name instead of ID
+ if ( newContext && (elem = newContext.getElementById( m )) &&
+ contains( context, elem ) &&
+ elem.id === m ) {
+
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Type selector
+ } else if ( match[2] ) {
+ push.apply( results, context.getElementsByTagName( selector ) );
+ return results;
+
+ // Class selector
+ } else if ( (m = match[3]) && support.getElementsByClassName &&
+ context.getElementsByClassName ) {
+
+ push.apply( results, context.getElementsByClassName( m ) );
+ return results;
+ }
+ }
+
+ // Take advantage of querySelectorAll
+ if ( support.qsa &&
+ !compilerCache[ selector + " " ] &&
+ (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
+
+ if ( nodeType !== 1 ) {
+ newContext = context;
+ newSelector = selector;
+
+ // qSA looks outside Element context, which is not what we want
+ // Thanks to Andrew Dupont for this workaround technique
+ // Support: IE <=8
+ // Exclude object elements
+ } else if ( context.nodeName.toLowerCase() !== "object" ) {
+
+ // Capture the context ID, setting it first if necessary
+ if ( (nid = context.getAttribute( "id" )) ) {
+ nid = nid.replace( rescape, "\\$&" );
+ } else {
+ context.setAttribute( "id", (nid = expando) );
+ }
+
+ // Prefix every selector in the list
+ groups = tokenize( selector );
+ i = groups.length;
+ nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
+ while ( i-- ) {
+ groups[i] = nidselect + " " + toSelector( groups[i] );
+ }
+ newSelector = groups.join( "," );
+
+ // Expand context for sibling selectors
+ newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
+ context;
+ }
+
+ if ( newSelector ) {
+ try {
+ push.apply( results,
+ newContext.querySelectorAll( newSelector )
+ );
+ return results;
+ } catch ( qsaError ) {
+ } finally {
+ if ( nid === expando ) {
+ context.removeAttribute( "id" );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {function(string, object)} Returns the Object data after storing it on itself with
+ * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ * deleting the oldest entry
+ */
+function createCache() {
+ var keys = [];
+
+ function cache( key, value ) {
+ // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+ if ( keys.push( key + " " ) > Expr.cacheLength ) {
+ // Only keep the most recent entries
+ delete cache[ keys.shift() ];
+ }
+ return (cache[ key + " " ] = value);
+ }
+ return cache;
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+ fn[ expando ] = true;
+ return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created div and expects a boolean result
+ */
+function assert( fn ) {
+ var div = document.createElement("div");
+
+ try {
+ return !!fn( div );
+ } catch (e) {
+ return false;
+ } finally {
+ // Remove from its parent by default
+ if ( div.parentNode ) {
+ div.parentNode.removeChild( div );
+ }
+ // release memory in IE
+ div = null;
+ }
+}
+
+/**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+function addHandle( attrs, handler ) {
+ var arr = attrs.split("|"),
+ i = arr.length;
+
+ while ( i-- ) {
+ Expr.attrHandle[ arr[i] ] = handler;
+ }
+}
+
+/**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+function siblingCheck( a, b ) {
+ var cur = b && a,
+ diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+ ( ~b.sourceIndex || MAX_NEGATIVE ) -
+ ( ~a.sourceIndex || MAX_NEGATIVE );
+
+ // Use IE sourceIndex if available on both nodes
+ if ( diff ) {
+ return diff;
+ }
+
+ // Check if b follows a
+ if ( cur ) {
+ while ( (cur = cur.nextSibling) ) {
+ if ( cur === b ) {
+ return -1;
+ }
+ }
+ }
+
+ return a ? 1 : -1;
+}
+
+/**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
+/**
+ * Checks a node for validity as a Sizzle context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+function testContext( context ) {
+ return context && typeof context.getElementsByTagName !== "undefined" && context;
+}
+
+// Expose support vars for convenience
+support = Sizzle.support = {};
+
+/**
+ * Detects XML nodes
+ * @param {Element|Object} elem An element or a document
+ * @returns {Boolean} True iff elem is a non-HTML XML node
+ */
+isXML = Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+ var hasCompare, parent,
+ doc = node ? node.ownerDocument || node : preferredDoc;
+
+ // Return early if doc is invalid or already selected
+ if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
+ return document;
+ }
+
+ // Update global variables
+ document = doc;
+ docElem = document.documentElement;
+ documentIsHTML = !isXML( document );
+
+ // Support: IE 9-11, Edge
+ // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
+ if ( (parent = document.defaultView) && parent.top !== parent ) {
+ // Support: IE 11
+ if ( parent.addEventListener ) {
+ parent.addEventListener( "unload", unloadHandler, false );
+
+ // Support: IE 9 - 10 only
+ } else if ( parent.attachEvent ) {
+ parent.attachEvent( "onunload", unloadHandler );
+ }
+ }
+
+ /* Attributes
+ ---------------------------------------------------------------------- */
+
+ // Support: IE<8
+ // Verify that getAttribute really returns attributes and not properties
+ // (excepting IE8 booleans)
+ support.attributes = assert(function( div ) {
+ div.className = "i";
+ return !div.getAttribute("className");
+ });
+
+ /* getElement(s)By*
+ ---------------------------------------------------------------------- */
+
+ // Check if getElementsByTagName("*") returns only elements
+ support.getElementsByTagName = assert(function( div ) {
+ div.appendChild( document.createComment("") );
+ return !div.getElementsByTagName("*").length;
+ });
+
+ // Support: IE<9
+ support.getElementsByClassName = rnative.test( document.getElementsByClassName );
+
+ // Support: IE<10
+ // Check if getElementById returns elements by name
+ // The broken getElementById methods don't pick up programatically-set names,
+ // so use a roundabout getElementsByName test
+ support.getById = assert(function( div ) {
+ docElem.appendChild( div ).id = expando;
+ return !document.getElementsByName || !document.getElementsByName( expando ).length;
+ });
+
+ // ID find and filter
+ if ( support.getById ) {
+ Expr.find["ID"] = function( id, context ) {
+ if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
+ var m = context.getElementById( id );
+ return m ? [ m ] : [];
+ }
+ };
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ return elem.getAttribute("id") === attrId;
+ };
+ };
+ } else {
+ // Support: IE6/7
+ // getElementById is not reliable as a find shortcut
+ delete Expr.find["ID"];
+
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== "undefined" &&
+ elem.getAttributeNode("id");
+ return node && node.value === attrId;
+ };
+ };
+ }
+
+ // Tag
+ Expr.find["TAG"] = support.getElementsByTagName ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== "undefined" ) {
+ return context.getElementsByTagName( tag );
+
+ // DocumentFragment nodes don't have gEBTN
+ } else if ( support.qsa ) {
+ return context.querySelectorAll( tag );
+ }
+ } :
+
+ function( tag, context ) {
+ var elem,
+ tmp = [],
+ i = 0,
+ // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
+ results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ while ( (elem = results[i++]) ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ };
+
+ // Class
+ Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
+ if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
+ return context.getElementsByClassName( className );
+ }
+ };
+
+ /* QSA/matchesSelector
+ ---------------------------------------------------------------------- */
+
+ // QSA and matchesSelector support
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ rbuggyMatches = [];
+
+ // qSa(:focus) reports false when true (Chrome 21)
+ // We allow this because of a bug in IE8/9 that throws an error
+ // whenever `document.activeElement` is accessed on an iframe
+ // So, we allow :focus to pass through QSA all the time to avoid the IE error
+ // See http://bugs.jquery.com/ticket/13378
+ rbuggyQSA = [];
+
+ if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function( div ) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explicitly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
+ "<select id='" + expando + "-\r\\' msallowcapture=''>" +
+ "<option selected=''></option></select>";
+
+ // Support: IE8, Opera 11-12.16
+ // Nothing should be selected when empty strings follow ^= or $= or *=
+ // The test attribute must be unknown in Opera but "safe" for WinRT
+ // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
+ if ( div.querySelectorAll("[msallowcapture^='']").length ) {
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
+ }
+
+ // Support: IE8
+ // Boolean attributes and "value" are not treated correctly
+ if ( !div.querySelectorAll("[selected]").length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
+ }
+
+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
+ if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
+ rbuggyQSA.push("~=");
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here and will not see later tests
+ if ( !div.querySelectorAll(":checked").length ) {
+ rbuggyQSA.push(":checked");
+ }
+
+ // Support: Safari 8+, iOS 8+
+ // https://bugs.webkit.org/show_bug.cgi?id=136851
+ // In-page `selector#id sibing-combinator selector` fails
+ if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
+ rbuggyQSA.push(".#.+[+~]");
+ }
+ });
+
+ assert(function( div ) {
+ // Support: Windows 8 Native Apps
+ // The type and name attributes are restricted during .innerHTML assignment
+ var input = document.createElement("input");
+ input.setAttribute( "type", "hidden" );
+ div.appendChild( input ).setAttribute( "name", "D" );
+
+ // Support: IE8
+ // Enforce case-sensitivity of name attribute
+ if ( div.querySelectorAll("[name=d]").length ) {
+ rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here and will not see later tests
+ if ( !div.querySelectorAll(":enabled").length ) {
+ rbuggyQSA.push( ":enabled", ":disabled" );
+ }
+
+ // Opera 10-11 does not throw on post-comma invalid pseudos
+ div.querySelectorAll("*,:x");
+ rbuggyQSA.push(",.*:");
+ });
+ }
+
+ if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
+ docElem.webkitMatchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector) )) ) {
+
+ assert(function( div ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ support.disconnectedMatch = matches.call( div, "div" );
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( div, "[s!='']:x" );
+ rbuggyMatches.push( "!=", pseudos );
+ });
+ }
+
+ rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
+ rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
+
+ /* Contains
+ ---------------------------------------------------------------------- */
+ hasCompare = rnative.test( docElem.compareDocumentPosition );
+
+ // Element contains another
+ // Purposefully self-exclusive
+ // As in, an element does not contain itself
+ contains = hasCompare || rnative.test( docElem.contains ) ?
+ function( a, b ) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && (
+ adown.contains ?
+ adown.contains( bup ) :
+ a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+ ));
+ } :
+ function( a, b ) {
+ if ( b ) {
+ while ( (b = b.parentNode) ) {
+ if ( b === a ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ /* Sorting
+ ---------------------------------------------------------------------- */
+
+ // Document order sorting
+ sortOrder = hasCompare ?
+ function( a, b ) {
+
+ // Flag for duplicate removal
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ // Sort on method existence if only one input has compareDocumentPosition
+ var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ if ( compare ) {
+ return compare;
+ }
+
+ // Calculate position if both inputs belong to the same document
+ compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
+ a.compareDocumentPosition( b ) :
+
+ // Otherwise we know they are disconnected
+ 1;
+
+ // Disconnected nodes
+ if ( compare & 1 ||
+ (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
+
+ // Choose the first element that is related to our preferred document
+ if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
+ return -1;
+ }
+ if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
+ return 1;
+ }
+
+ // Maintain original order
+ return sortInput ?
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+ 0;
+ }
+
+ return compare & 4 ? -1 : 1;
+ } :
+ function( a, b ) {
+ // Exit early if the nodes are identical
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ var cur,
+ i = 0,
+ aup = a.parentNode,
+ bup = b.parentNode,
+ ap = [ a ],
+ bp = [ b ];
+
+ // Parentless nodes are either documents or disconnected
+ if ( !aup || !bup ) {
+ return a === document ? -1 :
+ b === document ? 1 :
+ aup ? -1 :
+ bup ? 1 :
+ sortInput ?
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+ 0;
+
+ // If the nodes are siblings, we can do a quick check
+ } else if ( aup === bup ) {
+ return siblingCheck( a, b );
+ }
+
+ // Otherwise we need full lists of their ancestors for comparison
+ cur = a;
+ while ( (cur = cur.parentNode) ) {
+ ap.unshift( cur );
+ }
+ cur = b;
+ while ( (cur = cur.parentNode) ) {
+ bp.unshift( cur );
+ }
+
+ // Walk down the tree looking for a discrepancy
+ while ( ap[i] === bp[i] ) {
+ i++;
+ }
+
+ return i ?
+ // Do a sibling check if the nodes have a common ancestor
+ siblingCheck( ap[i], bp[i] ) :
+
+ // Otherwise nodes in our document sort first
+ ap[i] === preferredDoc ? -1 :
+ bp[i] === preferredDoc ? 1 :
+ 0;
+ };
+
+ return document;
+};
+
+Sizzle.matches = function( expr, elements ) {
+ return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+ // Set document vars if needed
+ if ( ( elem.ownerDocument || elem ) !== document ) {
+ setDocument( elem );
+ }
+
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace( rattributeQuotes, "='$1']" );
+
+ if ( support.matchesSelector && documentIsHTML &&
+ !compilerCache[ expr + " " ] &&
+ ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
+ ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
+
+ try {
+ var ret = matches.call( elem, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || support.disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11 ) {
+ return ret;
+ }
+ } catch (e) {}
+ }
+
+ return Sizzle( expr, document, null, [ elem ] ).length > 0;
+};
+
+Sizzle.contains = function( context, elem ) {
+ // Set document vars if needed
+ if ( ( context.ownerDocument || context ) !== document ) {
+ setDocument( context );
+ }
+ return contains( context, elem );
+};
+
+Sizzle.attr = function( elem, name ) {
+ // Set document vars if needed
+ if ( ( elem.ownerDocument || elem ) !== document ) {
+ setDocument( elem );
+ }
+
+ var fn = Expr.attrHandle[ name.toLowerCase() ],
+ // Don't get fooled by Object.prototype properties (jQuery #13807)
+ val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
+ fn( elem, name, !documentIsHTML ) :
+ undefined;
+
+ return val !== undefined ?
+ val :
+ support.attributes || !documentIsHTML ?
+ elem.getAttribute( name ) :
+ (val = elem.getAttributeNode(name)) && val.specified ?
+ val.value :
+ null;
+};
+
+Sizzle.error = function( msg ) {
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+/**
+ * Document sorting and removing duplicates
+ * @param {ArrayLike} results
+ */
+Sizzle.uniqueSort = function( results ) {
+ var elem,
+ duplicates = [],
+ j = 0,
+ i = 0;
+
+ // Unless we *know* we can detect duplicates, assume their presence
+ hasDuplicate = !support.detectDuplicates;
+ sortInput = !support.sortStable && results.slice( 0 );
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ while ( (elem = results[i++]) ) {
+ if ( elem === results[ i ] ) {
+ j = duplicates.push( i );
+ }
+ }
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
+ }
+
+ // Clear input after sorting to release objects
+ // See https://github.com/jquery/sizzle/pull/225
+ sortInput = null;
+
+ return results;
+};
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if ( !nodeType ) {
+ // If no nodeType, this is expected to be an array
+ while ( (node = elem[i++]) ) {
+ // Do not traverse comment nodes
+ ret += getText( node );
+ }
+ } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (jQuery #11153)
+ if ( typeof elem.textContent === "string" ) {
+ return elem.textContent;
+ } else {
+ // Traverse its children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ ret += getText( elem );
+ }
+ }
+ } else if ( nodeType === 3 || nodeType === 4 ) {
+ return elem.nodeValue;
+ }
+ // Do not include comment or processing instruction nodes
+
+ return ret;
+};
+
+Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ attrHandle: {},
+
+ find: {},
+
+ relative: {
+ ">": { dir: "parentNode", first: true },
+ " ": { dir: "parentNode" },
+ "+": { dir: "previousSibling", first: true },
+ "~": { dir: "previousSibling" }
+ },
+
+ preFilter: {
+ "ATTR": function( match ) {
+ match[1] = match[1].replace( runescape, funescape );
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
+
+ if ( match[2] === "~=" ) {
+ match[3] = " " + match[3] + " ";
+ }
+
+ return match.slice( 0, 4 );
+ },
+
+ "CHILD": function( match ) {
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 what (child|of-type)
+ 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 4 xn-component of xn+y argument ([+-]?\d*n|)
+ 5 sign of xn-component
+ 6 x of xn-component
+ 7 sign of y-component
+ 8 y of y-component
+ */
+ match[1] = match[1].toLowerCase();
+
+ if ( match[1].slice( 0, 3 ) === "nth" ) {
+ // nth-* requires argument
+ if ( !match[3] ) {
+ Sizzle.error( match[0] );
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
+ match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
+
+ // other types prohibit arguments
+ } else if ( match[3] ) {
+ Sizzle.error( match[0] );
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function( match ) {
+ var excess,
+ unquoted = !match[6] && match[2];
+
+ if ( matchExpr["CHILD"].test( match[0] ) ) {
+ return null;
+ }
+
+ // Accept quoted arguments as-is
+ if ( match[3] ) {
+ match[2] = match[4] || match[5] || "";
+
+ // Strip excess characters from unquoted arguments
+ } else if ( unquoted && rpseudo.test( unquoted ) &&
+ // Get excess from tokenize (recursively)
+ (excess = tokenize( unquoted, true )) &&
+ // advance to the next closing parenthesis
+ (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
+
+ // excess is a negative index
+ match[0] = match[0].slice( 0, excess );
+ match[2] = unquoted.slice( 0, excess );
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice( 0, 3 );
+ }
+ },
+
+ filter: {
+
+ "TAG": function( nodeNameSelector ) {
+ var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
+ return nodeNameSelector === "*" ?
+ function() { return true; } :
+ function( elem ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function( className ) {
+ var pattern = classCache[ className + " " ];
+
+ return pattern ||
+ (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
+ classCache( className, function( elem ) {
+ return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
+ });
+ },
+
+ "ATTR": function( name, operator, check ) {
+ return function( elem ) {
+ var result = Sizzle.attr( elem, name );
+
+ if ( result == null ) {
+ return operator === "!=";
+ }
+ if ( !operator ) {
+ return true;
+ }
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.slice( -check.length ) === check :
+ operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
+ false;
+ };
+ },
+
+ "CHILD": function( type, what, argument, first, last ) {
+ var simple = type.slice( 0, 3 ) !== "nth",
+ forward = type.slice( -4 ) !== "last",
+ ofType = what === "of-type";
+
+ return first === 1 && last === 0 ?
+
+ // Shortcut for :nth-*(n)
+ function( elem ) {
+ return !!elem.parentNode;
+ } :
+
+ function( elem, context, xml ) {
+ var cache, uniqueCache, outerCache, node, nodeIndex, start,
+ dir = simple !== forward ? "nextSibling" : "previousSibling",
+ parent = elem.parentNode,
+ name = ofType && elem.nodeName.toLowerCase(),
+ useCache = !xml && !ofType,
+ diff = false;
+
+ if ( parent ) {
+
+ // :(first|last|only)-(child|of-type)
+ if ( simple ) {
+ while ( dir ) {
+ node = elem;
+ while ( (node = node[ dir ]) ) {
+ if ( ofType ?
+ node.nodeName.toLowerCase() === name :
+ node.nodeType === 1 ) {
+
+ return false;
+ }
+ }
+ // Reverse direction for :only-* (if we haven't yet done so)
+ start = dir = type === "only" && !start && "nextSibling";
+ }
+ return true;
+ }
+
+ start = [ forward ? parent.firstChild : parent.lastChild ];
+
+ // non-xml :nth-child(...) stores cache data on `parent`
+ if ( forward && useCache ) {
+
+ // Seek `elem` from a previously-cached index
+
+ // ...in a gzip-friendly way
+ node = parent;
+ outerCache = node[ expando ] || (node[ expando ] = {});
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ (outerCache[ node.uniqueID ] = {});
+
+ cache = uniqueCache[ type ] || [];
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+ diff = nodeIndex && cache[ 2 ];
+ node = nodeIndex && parent.childNodes[ nodeIndex ];
+
+ while ( (node = ++nodeIndex && node && node[ dir ] ||
+
+ // Fallback to seeking `elem` from the start
+ (diff = nodeIndex = 0) || start.pop()) ) {
+
+ // When found, cache indexes on `parent` and break
+ if ( node.nodeType === 1 && ++diff && node === elem ) {
+ uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
+ break;
+ }
+ }
+
+ } else {
+ // Use previously-cached element index if available
+ if ( useCache ) {
+ // ...in a gzip-friendly way
+ node = elem;
+ outerCache = node[ expando ] || (node[ expando ] = {});
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ (outerCache[ node.uniqueID ] = {});
+
+ cache = uniqueCache[ type ] || [];
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+ diff = nodeIndex;
+ }
+
+ // xml :nth-child(...)
+ // or :nth-last-child(...) or :nth(-last)?-of-type(...)
+ if ( diff === false ) {
+ // Use the same loop as above to seek `elem` from the start
+ while ( (node = ++nodeIndex && node && node[ dir ] ||
+ (diff = nodeIndex = 0) || start.pop()) ) {
+
+ if ( ( ofType ?
+ node.nodeName.toLowerCase() === name :
+ node.nodeType === 1 ) &&
+ ++diff ) {
+
+ // Cache the index of each encountered element
+ if ( useCache ) {
+ outerCache = node[ expando ] || (node[ expando ] = {});
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ node.uniqueID ] ||
+ (outerCache[ node.uniqueID ] = {});
+
+ uniqueCache[ type ] = [ dirruns, diff ];
+ }
+
+ if ( node === elem ) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset, then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ }
+ };
+ },
+
+ "PSEUDO": function( pseudo, argument ) {
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction(function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf( seed, matched[i] );
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
+ }
+ }) :
+ function( elem ) {
+ return fn( elem, 0, args );
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+ // Potentially complex pseudos
+ "not": markFunction(function( selector ) {
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction(function( seed, matches, context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( (elem = unmatched[i]) ) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function( elem, context, xml ) {
+ input[0] = elem;
+ matcher( input, null, xml, results );
+ // Don't keep the element (issue #299)
+ input[0] = null;
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function( selector ) {
+ return function( elem ) {
+ return Sizzle( selector, elem ).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function( text ) {
+ text = text.replace( runescape, funescape );
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+ };
+ }),
+
+ // "Whether an element is represented by a :lang() selector
+ // is based solely on the element's language value
+ // being equal to the identifier C,
+ // or beginning with the identifier C immediately followed by "-".
+ // The matching of C against the element's language value is performed case-insensitively.
+ // The identifier C does not have to be a valid language name."
+ // http://www.w3.org/TR/selectors/#lang-pseudo
+ "lang": markFunction( function( lang ) {
+ // lang value must be a valid identifier
+ if ( !ridentifier.test(lang || "") ) {
+ Sizzle.error( "unsupported lang: " + lang );
+ }
+ lang = lang.replace( runescape, funescape ).toLowerCase();
+ return function( elem ) {
+ var elemLang;
+ do {
+ if ( (elemLang = documentIsHTML ?
+ elem.lang :
+ elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
+
+ elemLang = elemLang.toLowerCase();
+ return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
+ }
+ } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
+ return false;
+ };
+ }),
+
+ // Miscellaneous
+ "target": function( elem ) {
+ var hash = window.location && window.location.hash;
+ return hash && hash.slice( 1 ) === elem.id;
+ },
+
+ "root": function( elem ) {
+ return elem === docElem;
+ },
+
+ "focus": function( elem ) {
+ return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+ },
+
+ // Boolean properties
+ "enabled": function( elem ) {
+ return elem.disabled === false;
+ },
+
+ "disabled": function( elem ) {
+ return elem.disabled === true;
+ },
+
+ "checked": function( elem ) {
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+ },
+
+ "selected": function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ // Contents
+ "empty": function( elem ) {
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
+ // but not by others (comment: 8; processing instruction: 7; etc.)
+ // nodeType < 6 works because attributes (2) do not appear as children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ if ( elem.nodeType < 6 ) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ "parent": function( elem ) {
+ return !Expr.pseudos["empty"]( elem );
+ },
+
+ // Element/input types
+ "header": function( elem ) {
+ return rheader.test( elem.nodeName );
+ },
+
+ "input": function( elem ) {
+ return rinputs.test( elem.nodeName );
+ },
+
+ "button": function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "text": function( elem ) {
+ var attr;
+ return elem.nodeName.toLowerCase() === "input" &&
+ elem.type === "text" &&
+
+ // Support: IE<8
+ // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
+ ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
+ },
+
+ // Position-in-collection
+ "first": createPositionalPseudo(function() {
+ return [ 0 ];
+ }),
+
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
+ return [ length - 1 ];
+ }),
+
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
+ var i = 0;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
+ var i = 1;
+ for ( ; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ var i = argument < 0 ? argument + length : argument;
+ for ( ; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ var i = argument < 0 ? argument + length : argument;
+ for ( ; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
+ }
+};
+
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
+
+// Add button/input type pseudos
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
+ Expr.pseudos[ i ] = createInputPseudo( i );
+}
+for ( i in { submit: true, reset: true } ) {
+ Expr.pseudos[ i ] = createButtonPseudo( i );
+}
+
+// Easy API for creating new setFilters
+function setFilters() {}
+setFilters.prototype = Expr.filters = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
+ var matched, match, tokens, type,
+ soFar, groups, preFilters,
+ cached = tokenCache[ selector + " " ];
+
+ if ( cached ) {
+ return parseOnly ? 0 : cached.slice( 0 );
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while ( soFar ) {
+
+ // Comma and first run
+ if ( !matched || (match = rcomma.exec( soFar )) ) {
+ if ( match ) {
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice( match[0].length ) || soFar;
+ }
+ groups.push( (tokens = []) );
+ }
+
+ matched = false;
+
+ // Combinators
+ if ( (match = rcombinators.exec( soFar )) ) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ // Cast descendant combinators to space
+ type: match[0].replace( rtrim, " " )
+ });
+ soFar = soFar.slice( matched.length );
+ }
+
+ // Filters
+ for ( type in Expr.filter ) {
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
+ (match = preFilters[ type ]( match ))) ) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ type: type,
+ matches: match
+ });
+ soFar = soFar.slice( matched.length );
+ }
+ }
+
+ if ( !matched ) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error( selector ) :
+ // Cache the tokens
+ tokenCache( selector, groups ).slice( 0 );
+};
+
+function toSelector( tokens ) {
+ var i = 0,
+ len = tokens.length,
+ selector = "";
+ for ( ; i < len; i++ ) {
+ selector += tokens[i].value;
+ }
+ return selector;
+}
+
+function addCombinator( matcher, combinator, base ) {
+ var dir = combinator.dir,
+ checkNonElements = base && dir === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ return matcher( elem, context, xml );
+ }
+ }
+ } :
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ var oldCache, uniqueCache, outerCache,
+ newCache = [ dirruns, doneName ];
+
+ // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
+ if ( xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ if ( matcher( elem, context, xml ) ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( elem.nodeType === 1 || checkNonElements ) {
+ outerCache = elem[ expando ] || (elem[ expando ] = {});
+
+ // Support: IE <9 only
+ // Defend against cloned attroperties (jQuery gh-1709)
+ uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
+
+ if ( (oldCache = uniqueCache[ dir ]) &&
+ oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
+
+ // Assign to newCache so results back-propagate to previous elements
+ return (newCache[ 2 ] = oldCache[ 2 ]);
+ } else {
+ // Reuse newcache so results back-propagate to previous elements
+ uniqueCache[ dir ] = newCache;
+
+ // A match means we're done; a fail means we have to keep checking
+ if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ };
+}
+
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[i]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[0];
+}
+
+function multipleContexts( selector, contexts, results ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results );
+ }
+ return results;
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction(function( seed, results, context, xml ) {
+ var temp, i, elem,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ temp = condense( matcherOut, postMap );
+ postFilter( temp, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while ( i-- ) {
+ if ( (elem = temp[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
+ }
+ }
+
+ if ( seed ) {
+ if ( postFinder || preFilter ) {
+ if ( postFinder ) {
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ // Restore matcherIn since elem is not yet a final match
+ temp.push( (matcherIn[i] = elem) );
+ }
+ }
+ postFinder( null, (matcherOut = []), temp, xml );
+ }
+
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) &&
+ (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
+
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
+
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+ // Avoid hanging onto element (issue #299)
+ checkContext = null;
+ return ret;
+ } ];
+
+ for ( ; i < len; i++ ) {
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
+ } else {
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && toSelector(
+ // If the preceding token was a descendant combinator, insert an implicit any-element `*`
+ tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
+ ).replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && toSelector( tokens )
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
+
+ return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, outermost ) {
+ var elem, j, matcher,
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ setMatched = [],
+ contextBackup = outermostContext,
+ // We must always have either seed elements or outermost context
+ elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
+ // Use integer dirruns iff this is the outermost matcher
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
+ len = elems.length;
+
+ if ( outermost ) {
+ outermostContext = context === document || context || outermost;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ // Support: IE<9, Safari
+ // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
+ for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ j = 0;
+ if ( !context && elem.ownerDocument !== document ) {
+ setDocument( elem );
+ xml = !documentIsHTML;
+ }
+ while ( (matcher = elementMatchers[j++]) ) {
+ if ( matcher( elem, context || document, xml) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
+ }
+
+ // `i` is now the count of elements visited above, and adding it to `matchedCount`
+ // makes the latter nonnegative.
+ matchedCount += i;
+
+ // Apply set filters to unmatched elements
+ // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
+ // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
+ // no element matchers and no seed.
+ // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
+ // case, which will result in a "00" `matchedCount` that differs from `i` but is also
+ // numerically zero.
+ if ( bySet && i !== matchedCount ) {
+ j = 0;
+ while ( (matcher = setMatchers[j++]) ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
+
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
+
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ selector + " " ];
+
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !match ) {
+ match = tokenize( selector );
+ }
+ i = match.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( match[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+
+ // Save selector and tokenization
+ cached.selector = selector;
+ }
+ return cached;
+};
+
+/**
+ * A low-level selection function that works with Sizzle's compiled
+ * selector functions
+ * @param {String|Function} selector A selector or a pre-compiled
+ * selector function built with Sizzle.compile
+ * @param {Element} context
+ * @param {Array} [results]
+ * @param {Array} [seed] A set of elements to match against
+ */
+select = Sizzle.select = function( selector, context, results, seed ) {
+ var i, tokens, token, type, find,
+ compiled = typeof selector === "function" && selector,
+ match = !seed && tokenize( (selector = compiled.selector || selector) );
+
+ results = results || [];
+
+ // Try to minimize operations if there is only one selector in the list and no seed
+ // (the latter of which guarantees us context)
+ if ( match.length === 1 ) {
+
+ // Reduce context if the leading compound selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ support.getById && context.nodeType === 9 && documentIsHTML &&
+ Expr.relative[ tokens[1].type ] ) {
+
+ context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
+ if ( !context ) {
+ return results;
+
+ // Precompiled matchers will still verify ancestry, so step up a level
+ } else if ( compiled ) {
+ context = context.parentNode;
+ }
+
+ selector = selector.slice( tokens.shift().value.length );
+ }
+
+ // Fetch a seed set for right-to-left matching
+ i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
+ while ( i-- ) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( runescape, funescape ),
+ rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
+ )) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && toSelector( tokens );
+ if ( !selector ) {
+ push.apply( results, seed );
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function if one is not provided
+ // Provide `match` to avoid retokenization if we modified the selector above
+ ( compiled || compile( selector, match ) )(
+ seed,
+ context,
+ !documentIsHTML,
+ results,
+ !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
+ );
+ return results;
+};
+
+// One-time assignments
+
+// Sort stability
+support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
+
+// Support: Chrome 14-35+
+// Always assume duplicates if they aren't passed to the comparison function
+support.detectDuplicates = !!hasDuplicate;
+
+// Initialize against the default document
+setDocument();
+
+// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
+// Detached nodes confoundingly follow *each other*
+support.sortDetached = assert(function( div1 ) {
+ // Should return 1, but returns 4 (following)
+ return div1.compareDocumentPosition( document.createElement("div") ) & 1;
+});
+
+// Support: IE<8
+// Prevent attribute/property "interpolation"
+// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !assert(function( div ) {
+ div.innerHTML = "<a href='#'></a>";
+ return div.firstChild.getAttribute("href") === "#" ;
+}) ) {
+ addHandle( "type|href|height|width", function( elem, name, isXML ) {
+ if ( !isXML ) {
+ return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
+ }
+ });
+}
+
+// Support: IE<9
+// Use defaultValue in place of getAttribute("value")
+if ( !support.attributes || !assert(function( div ) {
+ div.innerHTML = "<input/>";
+ div.firstChild.setAttribute( "value", "" );
+ return div.firstChild.getAttribute( "value" ) === "";
+}) ) {
+ addHandle( "value", function( elem, name, isXML ) {
+ if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
+ return elem.defaultValue;
+ }
+ });
+}
+
+// Support: IE<9
+// Use getAttributeNode to fetch booleans when getAttribute lies
+if ( !assert(function( div ) {
+ return div.getAttribute("disabled") == null;
+}) ) {
+ addHandle( booleans, function( elem, name, isXML ) {
+ var val;
+ if ( !isXML ) {
+ return elem[ name ] === true ? name.toLowerCase() :
+ (val = elem.getAttributeNode( name )) && val.specified ?
+ val.value :
+ null;
+ }
+ });
+}
+
+return Sizzle;
+
+})( window );
+
+
+
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[ ":" ] = jQuery.expr.pseudos;
+jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+
+var dir = function( elem, dir, until ) {
+ var matched = [],
+ truncate = until !== undefined;
+
+ while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
+ if ( elem.nodeType === 1 ) {
+ if ( truncate && jQuery( elem ).is( until ) ) {
+ break;
+ }
+ matched.push( elem );
+ }
+ }
+ return matched;
+};
+
+
+var siblings = function( n, elem ) {
+ var matched = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ matched.push( n );
+ }
+ }
+
+ return matched;
+};
+
+
+var rneedsContext = jQuery.expr.match.needsContext;
+
+var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
+
+
+
+var risSimple = /^.[^:#\[\.,]*$/;
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, not ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep( elements, function( elem, i ) {
+ /* jshint -W018 */
+ return !!qualifier.call( elem, i, elem ) !== not;
+ } );
+
+ }
+
+ if ( qualifier.nodeType ) {
+ return jQuery.grep( elements, function( elem ) {
+ return ( elem === qualifier ) !== not;
+ } );
+
+ }
+
+ if ( typeof qualifier === "string" ) {
+ if ( risSimple.test( qualifier ) ) {
+ return jQuery.filter( qualifier, elements, not );
+ }
+
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+
+ return jQuery.grep( elements, function( elem ) {
+ return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
+ } );
+}
+
+jQuery.filter = function( expr, elems, not ) {
+ var elem = elems[ 0 ];
+
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 && elem.nodeType === 1 ?
+ jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
+ jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
+ return elem.nodeType === 1;
+ } ) );
+};
+
+jQuery.fn.extend( {
+ find: function( selector ) {
+ var i,
+ ret = [],
+ self = this,
+ len = self.length;
+
+ if ( typeof selector !== "string" ) {
+ return this.pushStack( jQuery( selector ).filter( function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ } ) );
+ }
+
+ for ( i = 0; i < len; i++ ) {
+ jQuery.find( selector, self[ i ], ret );
+ }
+
+ // Needed because $( selector, context ) becomes $( context ).find( selector )
+ ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
+ ret.selector = this.selector ? this.selector + " " + selector : selector;
+ return ret;
+ },
+ filter: function( selector ) {
+ return this.pushStack( winnow( this, selector || [], false ) );
+ },
+ not: function( selector ) {
+ return this.pushStack( winnow( this, selector || [], true ) );
+ },
+ is: function( selector ) {
+ return !!winnow(
+ this,
+
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ typeof selector === "string" && rneedsContext.test( selector ) ?
+ jQuery( selector ) :
+ selector || [],
+ false
+ ).length;
+ }
+} );
+
+
+// Initialize a jQuery object
+
+
+// A central reference to the root jQuery(document)
+var rootjQuery,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+ // Strict HTML recognition (#11290: must start with <)
+ rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+
+ init = jQuery.fn.init = function( selector, context, root ) {
+ var match, elem;
+
+ // HANDLE: $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // init accepts an alternate rootjQuery
+ // so migrate can support jQuery.sub (gh-2101)
+ root = root || rootjQuery;
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector.charAt( 0 ) === "<" &&
+ selector.charAt( selector.length - 1 ) === ">" &&
+ selector.length >= 3 ) {
+
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && ( match[ 1 ] || !context ) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[ 1 ] ) {
+ context = context instanceof jQuery ? context[ 0 ] : context;
+
+ // scripts is true for back-compat
+ // Intentionally let the error be thrown if parseHTML is not present
+ jQuery.merge( this, jQuery.parseHTML(
+ match[ 1 ],
+ context && context.nodeType ? context.ownerDocument || context : document,
+ true
+ ) );
+
+ // HANDLE: $(html, props)
+ if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
+ for ( match in context ) {
+
+ // Properties of context are called as methods if possible
+ if ( jQuery.isFunction( this[ match ] ) ) {
+ this[ match ]( context[ match ] );
+
+ // ...and otherwise set as attributes
+ } else {
+ this.attr( match, context[ match ] );
+ }
+ }
+ }
+
+ return this;
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[ 2 ] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[ 2 ] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[ 0 ] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || root ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(DOMElement)
+ } else if ( selector.nodeType ) {
+ this.context = this[ 0 ] = selector;
+ this.length = 1;
+ return this;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return typeof root.ready !== "undefined" ?
+ root.ready( selector ) :
+
+ // Execute immediately if ready is not present
+ selector( jQuery );
+ }
+
+ if ( selector.selector !== undefined ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ };
+
+// Give the init function the jQuery prototype for later instantiation
+init.prototype = jQuery.fn;
+
+// Initialize central reference
+rootjQuery = jQuery( document );
+
+
+var rparentsprev = /^(?:parents|prev(?:Until|All))/,
+
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+jQuery.fn.extend( {
+ has: function( target ) {
+ var i,
+ targets = jQuery( target, this ),
+ len = targets.length;
+
+ return this.filter( function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( this, targets[ i ] ) ) {
+ return true;
+ }
+ }
+ } );
+ },
+
+ closest: function( selectors, context ) {
+ var cur,
+ i = 0,
+ l = this.length,
+ matched = [],
+ pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
+ jQuery( selectors, context || this.context ) :
+ 0;
+
+ for ( ; i < l; i++ ) {
+ for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
+
+ // Always skip document fragments
+ if ( cur.nodeType < 11 && ( pos ?
+ pos.index( cur ) > -1 :
+
+ // Don't pass non-elements to Sizzle
+ cur.nodeType === 1 &&
+ jQuery.find.matchesSelector( cur, selectors ) ) ) {
+
+ matched.push( cur );
+ break;
+ }
+ }
+ }
+
+ return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+
+ // No argument, return index in parent
+ if ( !elem ) {
+ return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
+ }
+
+ // index in selector
+ if ( typeof elem === "string" ) {
+ return jQuery.inArray( this[ 0 ], jQuery( elem ) );
+ }
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[ 0 ] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ return this.pushStack(
+ jQuery.uniqueSort(
+ jQuery.merge( this.get(), jQuery( selector, context ) )
+ )
+ );
+ },
+
+ addBack: function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter( selector )
+ );
+ }
+} );
+
+function sibling( cur, dir ) {
+ do {
+ cur = cur[ dir ];
+ } while ( cur && cur.nodeType !== 1 );
+
+ return cur;
+}
+
+jQuery.each( {
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return sibling( elem, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return sibling( elem, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return siblings( ( elem.parentNode || {} ).firstChild, elem );
+ },
+ children: function( elem ) {
+ return siblings( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.merge( [], elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( name.slice( -5 ) !== "Until" ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ if ( this.length > 1 ) {
+
+ // Remove duplicates
+ if ( !guaranteedUnique[ name ] ) {
+ ret = jQuery.uniqueSort( ret );
+ }
+
+ // Reverse order for parents* and prev-derivatives
+ if ( rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+ }
+
+ return this.pushStack( ret );
+ };
+} );
+var rnotwhite = ( /\S+/g );
+
+
+
+// Convert String-formatted options into Object-formatted ones
+function createOptions( options ) {
+ var object = {};
+ jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
+ object[ flag ] = true;
+ } );
+ return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ createOptions( options ) :
+ jQuery.extend( {}, options );
+
+ var // Flag to know if list is currently firing
+ firing,
+
+ // Last fire value for non-forgettable lists
+ memory,
+
+ // Flag to know if list was already fired
+ fired,
+
+ // Flag to prevent firing
+ locked,
+
+ // Actual callback list
+ list = [],
+
+ // Queue of execution data for repeatable lists
+ queue = [],
+
+ // Index of currently firing callback (modified by add/remove as needed)
+ firingIndex = -1,
+
+ // Fire callbacks
+ fire = function() {
+
+ // Enforce single-firing
+ locked = options.once;
+
+ // Execute callbacks for all pending executions,
+ // respecting firingIndex overrides and runtime changes
+ fired = firing = true;
+ for ( ; queue.length; firingIndex = -1 ) {
+ memory = queue.shift();
+ while ( ++firingIndex < list.length ) {
+
+ // Run callback and check for early termination
+ if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
+ options.stopOnFalse ) {
+
+ // Jump to end and forget the data so .add doesn't re-fire
+ firingIndex = list.length;
+ memory = false;
+ }
+ }
+ }
+
+ // Forget the data if we're done with it
+ if ( !options.memory ) {
+ memory = false;
+ }
+
+ firing = false;
+
+ // Clean up if we're done firing for good
+ if ( locked ) {
+
+ // Keep an empty list if we have data for future add calls
+ if ( memory ) {
+ list = [];
+
+ // Otherwise, this object is spent
+ } else {
+ list = "";
+ }
+ }
+ },
+
+ // Actual Callbacks object
+ self = {
+
+ // Add a callback or a collection of callbacks to the list
+ add: function() {
+ if ( list ) {
+
+ // If we have memory from a past run, we should fire after adding
+ if ( memory && !firing ) {
+ firingIndex = list.length - 1;
+ queue.push( memory );
+ }
+
+ ( function add( args ) {
+ jQuery.each( args, function( _, arg ) {
+ if ( jQuery.isFunction( arg ) ) {
+ if ( !options.unique || !self.has( arg ) ) {
+ list.push( arg );
+ }
+ } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
+
+ // Inspect recursively
+ add( arg );
+ }
+ } );
+ } )( arguments );
+
+ if ( memory && !firing ) {
+ fire();
+ }
+ }
+ return this;
+ },
+
+ // Remove a callback from the list
+ remove: function() {
+ jQuery.each( arguments, function( _, arg ) {
+ var index;
+ while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+ list.splice( index, 1 );
+
+ // Handle firing indexes
+ if ( index <= firingIndex ) {
+ firingIndex--;
+ }
+ }
+ } );
+ return this;
+ },
+
+ // Check if a given callback is in the list.
+ // If no argument is given, return whether or not list has callbacks attached.
+ has: function( fn ) {
+ return fn ?
+ jQuery.inArray( fn, list ) > -1 :
+ list.length > 0;
+ },
+
+ // Remove all callbacks from the list
+ empty: function() {
+ if ( list ) {
+ list = [];
+ }
+ return this;
+ },
+
+ // Disable .fire and .add
+ // Abort any current/pending executions
+ // Clear all callbacks and values
+ disable: function() {
+ locked = queue = [];
+ list = memory = "";
+ return this;
+ },
+ disabled: function() {
+ return !list;
+ },
+
+ // Disable .fire
+ // Also disable .add unless we have memory (since it would have no effect)
+ // Abort any pending executions
+ lock: function() {
+ locked = true;
+ if ( !memory ) {
+ self.disable();
+ }
+ return this;
+ },
+ locked: function() {
+ return !!locked;
+ },
+
+ // Call all callbacks with the given context and arguments
+ fireWith: function( context, args ) {
+ if ( !locked ) {
+ args = args || [];
+ args = [ context, args.slice ? args.slice() : args ];
+ queue.push( args );
+ if ( !firing ) {
+ fire();
+ }
+ }
+ return this;
+ },
+
+ // Call all the callbacks with the given arguments
+ fire: function() {
+ self.fireWith( this, arguments );
+ return this;
+ },
+
+ // To know if the callbacks have already been called at least once
+ fired: function() {
+ return !!fired;
+ }
+ };
+
+ return self;
+};
+
+
+jQuery.extend( {
+
+ Deferred: function( func ) {
+ var tuples = [
+
+ // action, add listener, listener list, final state
+ [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
+ [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
+ [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
+ ],
+ state = "pending",
+ promise = {
+ state: function() {
+ return state;
+ },
+ always: function() {
+ deferred.done( arguments ).fail( arguments );
+ return this;
+ },
+ then: function( /* fnDone, fnFail, fnProgress */ ) {
+ var fns = arguments;
+ return jQuery.Deferred( function( newDefer ) {
+ jQuery.each( tuples, function( i, tuple ) {
+ var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
+
+ // deferred[ done | fail | progress ] for forwarding actions to newDefer
+ deferred[ tuple[ 1 ] ]( function() {
+ var returned = fn && fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise()
+ .progress( newDefer.notify )
+ .done( newDefer.resolve )
+ .fail( newDefer.reject );
+ } else {
+ newDefer[ tuple[ 0 ] + "With" ](
+ this === promise ? newDefer.promise() : this,
+ fn ? [ returned ] : arguments
+ );
+ }
+ } );
+ } );
+ fns = null;
+ } ).promise();
+ },
+
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
+ }
+ },
+ deferred = {};
+
+ // Keep pipe for back-compat
+ promise.pipe = promise.then;
+
+ // Add list-specific methods
+ jQuery.each( tuples, function( i, tuple ) {
+ var list = tuple[ 2 ],
+ stateString = tuple[ 3 ];
+
+ // promise[ done | fail | progress ] = list.add
+ promise[ tuple[ 1 ] ] = list.add;
+
+ // Handle state
+ if ( stateString ) {
+ list.add( function() {
+
+ // state = [ resolved | rejected ]
+ state = stateString;
+
+ // [ reject_list | resolve_list ].disable; progress_list.lock
+ }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
+ }
+
+ // deferred[ resolve | reject | notify ]
+ deferred[ tuple[ 0 ] ] = function() {
+ deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
+ return this;
+ };
+ deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
+ } );
+
+ // Make the deferred a promise
+ promise.promise( deferred );
+
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( subordinate /* , ..., subordinateN */ ) {
+ var i = 0,
+ resolveValues = slice.call( arguments ),
+ length = resolveValues.length,
+
+ // the count of uncompleted subordinates
+ remaining = length !== 1 ||
+ ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
+
+ // the master Deferred.
+ // If resolveValues consist of only a single Deferred, just use that.
+ deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+ // Update function for both resolve and progress values
+ updateFunc = function( i, contexts, values ) {
+ return function( value ) {
+ contexts[ i ] = this;
+ values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
+ if ( values === progressValues ) {
+ deferred.notifyWith( contexts, values );
+
+ } else if ( !( --remaining ) ) {
+ deferred.resolveWith( contexts, values );
+ }
+ };
+ },
+
+ progressValues, progressContexts, resolveContexts;
+
+ // add listeners to Deferred subordinates; treat others as resolved
+ if ( length > 1 ) {
+ progressValues = new Array( length );
+ progressContexts = new Array( length );
+ resolveContexts = new Array( length );
+ for ( ; i < length; i++ ) {
+ if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
+ resolveValues[ i ].promise()
+ .progress( updateFunc( i, progressContexts, progressValues ) )
+ .done( updateFunc( i, resolveContexts, resolveValues ) )
+ .fail( deferred.reject );
+ } else {
+ --remaining;
+ }
+ }
+ }
+
+ // if we're not waiting on anything, resolve the master
+ if ( !remaining ) {
+ deferred.resolveWith( resolveContexts, resolveValues );
+ }
+
+ return deferred.promise();
+ }
+} );
+
+
+// The deferred used on DOM ready
+var readyList;
+
+jQuery.fn.ready = function( fn ) {
+
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+};
+
+jQuery.extend( {
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ jQuery( document ).off( "ready" );
+ }
+ }
+} );
+
+/**
+ * Clean-up method for dom ready events
+ */
+function detach() {
+ if ( document.addEventListener ) {
+ document.removeEventListener( "DOMContentLoaded", completed );
+ window.removeEventListener( "load", completed );
+
+ } else {
+ document.detachEvent( "onreadystatechange", completed );
+ window.detachEvent( "onload", completed );
+ }
+}
+
+/**
+ * The ready event handler and self cleanup method
+ */
+function completed() {
+
+ // readyState === "complete" is good enough for us to call the dom ready in oldIE
+ if ( document.addEventListener ||
+ window.event.type === "load" ||
+ document.readyState === "complete" ) {
+
+ detach();
+ jQuery.ready();
+ }
+}
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called
+ // after the browser event has already occurred.
+ // Support: IE6-10
+ // Older IE sometimes signals "interactive" too soon
+ if ( document.readyState === "complete" ||
+ ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
+
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ window.setTimeout( jQuery.ready );
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if ( document.addEventListener ) {
+
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", completed );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", completed );
+
+ // If IE event model is used
+ } else {
+
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", completed );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", completed );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch ( e ) {}
+
+ if ( top && top.doScroll ) {
+ ( function doScrollCheck() {
+ if ( !jQuery.isReady ) {
+
+ try {
+
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll( "left" );
+ } catch ( e ) {
+ return window.setTimeout( doScrollCheck, 50 );
+ }
+
+ // detach all dom ready events
+ detach();
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ } )();
+ }
+ }
+ }
+ return readyList.promise( obj );
+};
+
+// Kick off the DOM ready check even if the user does not
+jQuery.ready.promise();
+
+
+
+
+// Support: IE<9
+// Iteration over object's inherited properties before its own
+var i;
+for ( i in jQuery( support ) ) {
+ break;
+}
+support.ownFirst = i === "0";
+
+// Note: most support tests are defined in their respective modules.
+// false until the test is run
+support.inlineBlockNeedsLayout = false;
+
+// Execute ASAP in case we need to set body.style.zoom
+jQuery( function() {
+
+ // Minified: var a,b,c,d
+ var val, div, body, container;
+
+ body = document.getElementsByTagName( "body" )[ 0 ];
+ if ( !body || !body.style ) {
+
+ // Return for frameset docs that don't have a body
+ return;
+ }
+
+ // Setup
+ div = document.createElement( "div" );
+ container = document.createElement( "div" );
+ container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
+ body.appendChild( container ).appendChild( div );
+
+ if ( typeof div.style.zoom !== "undefined" ) {
+
+ // Support: IE<8
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
+
+ support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
+ if ( val ) {
+
+ // Prevent IE 6 from affecting layout for positioned elements #11048
+ // Prevent IE from shrinking the body in IE 7 mode #12869
+ // Support: IE<8
+ body.style.zoom = 1;
+ }
+ }
+
+ body.removeChild( container );
+} );
+
+
+( function() {
+ var div = document.createElement( "div" );
+
+ // Support: IE<9
+ support.deleteExpando = true;
+ try {
+ delete div.test;
+ } catch ( e ) {
+ support.deleteExpando = false;
+ }
+
+ // Null elements to avoid leaks in IE.
+ div = null;
+} )();
+var acceptData = function( elem ) {
+ var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
+ nodeType = +elem.nodeType || 1;
+
+ // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
+ return nodeType !== 1 && nodeType !== 9 ?
+ false :
+
+ // Nodes accept data unless otherwise specified; rejection can be conditional
+ !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
+};
+
+
+
+
+var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+function dataAttr( elem, key, data ) {
+
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+
+ var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
+
+ data = elem.getAttribute( name );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+
+ // Only convert to a number if it doesn't change the string
+ +data + "" === data ? +data :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch ( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+ var name;
+ for ( name in obj ) {
+
+ // if the public data object is empty, the private is still empty
+ if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
+ continue;
+ }
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
+ if ( !acceptData( elem ) ) {
+ return;
+ }
+
+ var ret, thisCache,
+ internalKey = jQuery.expando,
+
+ // We have to handle DOM nodes and JS objects differently because IE6-7
+ // can't GC object references properly across the DOM-JS boundary
+ isNode = elem.nodeType,
+
+ // Only DOM nodes need the global jQuery cache; JS object data is
+ // attached directly to the object so GC can occur automatically
+ cache = isNode ? jQuery.cache : elem,
+
+ // Only defining an ID for JS objects if its cache already exists allows
+ // the code to shortcut on the same path as a DOM node with no cache
+ id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
+
+ // Avoid doing any more work than we need to when trying to get data on an
+ // object that has no data at all
+ if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
+ data === undefined && typeof name === "string" ) {
+ return;
+ }
+
+ if ( !id ) {
+
+ // Only DOM nodes need a new unique ID for each element since their data
+ // ends up in the global cache
+ if ( isNode ) {
+ id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
+ } else {
+ id = internalKey;
+ }
+ }
+
+ if ( !cache[ id ] ) {
+
+ // Avoid exposing jQuery metadata on plain JS objects when the object
+ // is serialized using JSON.stringify
+ cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
+ }
+
+ // An object can be passed to jQuery.data instead of a key/value pair; this gets
+ // shallow copied over onto the existing cache
+ if ( typeof name === "object" || typeof name === "function" ) {
+ if ( pvt ) {
+ cache[ id ] = jQuery.extend( cache[ id ], name );
+ } else {
+ cache[ id ].data = jQuery.extend( cache[ id ].data, name );
+ }
+ }
+
+ thisCache = cache[ id ];
+
+ // jQuery data() is stored in a separate object inside the object's internal data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data.
+ if ( !pvt ) {
+ if ( !thisCache.data ) {
+ thisCache.data = {};
+ }
+
+ thisCache = thisCache.data;
+ }
+
+ if ( data !== undefined ) {
+ thisCache[ jQuery.camelCase( name ) ] = data;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( typeof name === "string" ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == null ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+}
+
+function internalRemoveData( elem, name, pvt ) {
+ if ( !acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, i,
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+ id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
+
+ // If there is already no cache entry for this object, there is no
+ // purpose in continuing
+ if ( !cache[ id ] ) {
+ return;
+ }
+
+ if ( name ) {
+
+ thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+ if ( thisCache ) {
+
+ // Support array or space separated string names for data keys
+ if ( !jQuery.isArray( name ) ) {
+
+ // try the string as a key before any manipulation
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+
+ // split the camel cased version by spaces unless a key with the spaces exists
+ name = jQuery.camelCase( name );
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+ name = name.split( " " );
+ }
+ }
+ } else {
+
+ // If "name" is an array of keys...
+ // When data is initially created, via ("key", "val") signature,
+ // keys will be converted to camelCase.
+ // Since there is no way to tell _how_ a key was added, remove
+ // both plain key and camelCase key. #12786
+ // This will only penalize the array argument path.
+ name = name.concat( jQuery.map( name, jQuery.camelCase ) );
+ }
+
+ i = name.length;
+ while ( i-- ) {
+ delete thisCache[ name[ i ] ];
+ }
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if ( !pvt ) {
+ delete cache[ id ].data;
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if ( !isEmptyDataObject( cache[ id ] ) ) {
+ return;
+ }
+ }
+
+ // Destroy the cache
+ if ( isNode ) {
+ jQuery.cleanData( [ elem ], true );
+
+ // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+ /* jshint eqeqeq: false */
+ } else if ( support.deleteExpando || cache != cache.window ) {
+ /* jshint eqeqeq: true */
+ delete cache[ id ];
+
+ // When all else fails, undefined
+ } else {
+ cache[ id ] = undefined;
+ }
+}
+
+jQuery.extend( {
+ cache: {},
+
+ // The following elements (space-suffixed to avoid Object.prototype collisions)
+ // throw uncatchable exceptions if you attempt to set expando properties
+ noData: {
+ "applet ": true,
+ "embed ": true,
+
+ // ...but Flash objects (which have this classid) *can* handle expandos
+ "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+ },
+
+ hasData: function( elem ) {
+ elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
+ return !!elem && !isEmptyDataObject( elem );
+ },
+
+ data: function( elem, name, data ) {
+ return internalData( elem, name, data );
+ },
+
+ removeData: function( elem, name ) {
+ return internalRemoveData( elem, name );
+ },
+
+ // For internal use only.
+ _data: function( elem, name, data ) {
+ return internalData( elem, name, data, true );
+ },
+
+ _removeData: function( elem, name ) {
+ return internalRemoveData( elem, name, true );
+ }
+} );
+
+jQuery.fn.extend( {
+ data: function( key, value ) {
+ var i, name, data,
+ elem = this[ 0 ],
+ attrs = elem && elem.attributes;
+
+ // Special expections of .data basically thwart jQuery.access,
+ // so implement the relevant behavior ourselves
+
+ // Gets all values
+ if ( key === undefined ) {
+ if ( this.length ) {
+ data = jQuery.data( elem );
+
+ if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+ i = attrs.length;
+ while ( i-- ) {
+
+ // Support: IE11+
+ // The attrs elements can be null (#14894)
+ if ( attrs[ i ] ) {
+ name = attrs[ i ].name;
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = jQuery.camelCase( name.slice( 5 ) );
+ dataAttr( elem, name, data[ name ] );
+ }
+ }
+ }
+ jQuery._data( elem, "parsedAttrs", true );
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if ( typeof key === "object" ) {
+ return this.each( function() {
+ jQuery.data( this, key );
+ } );
+ }
+
+ return arguments.length > 1 ?
+
+ // Sets one value
+ this.each( function() {
+ jQuery.data( this, key, value );
+ } ) :
+
+ // Gets one value
+ // Try to fetch any internally stored data first
+ elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
+ },
+
+ removeData: function( key ) {
+ return this.each( function() {
+ jQuery.removeData( this, key );
+ } );
+ }
+} );
+
+
+jQuery.extend( {
+ queue: function( elem, type, data ) {
+ var queue;
+
+ if ( elem ) {
+ type = ( type || "fx" ) + "queue";
+ queue = jQuery._data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !queue || jQuery.isArray( data ) ) {
+ queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
+ } else {
+ queue.push( data );
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks( elem, type ),
+ next = function() {
+ jQuery.dequeue( elem, type );
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ if ( fn ) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift( "inprogress" );
+ }
+
+ // clear up the last queue stop function
+ delete hooks.stop;
+ fn.call( elem, next, hooks );
+ }
+
+ if ( !startLength && hooks ) {
+ hooks.empty.fire();
+ }
+ },
+
+ // not intended for public consumption - generates a queueHooks object,
+ // or returns the current one
+ _queueHooks: function( elem, type ) {
+ var key = type + "queueHooks";
+ return jQuery._data( elem, key ) || jQuery._data( elem, key, {
+ empty: jQuery.Callbacks( "once memory" ).add( function() {
+ jQuery._removeData( elem, type + "queue" );
+ jQuery._removeData( elem, key );
+ } )
+ } );
+ }
+} );
+
+jQuery.fn.extend( {
+ queue: function( type, data ) {
+ var setter = 2;
+
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if ( arguments.length < setter ) {
+ return jQuery.queue( this[ 0 ], type );
+ }
+
+ return data === undefined ?
+ this :
+ this.each( function() {
+ var queue = jQuery.queue( this, type, data );
+
+ // ensure a hooks for this queue
+ jQuery._queueHooks( this, type );
+
+ if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ } );
+ },
+ dequeue: function( type ) {
+ return this.each( function() {
+ jQuery.dequeue( this, type );
+ } );
+ },
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ },
+
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function( type, obj ) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ };
+
+ if ( typeof type !== "string" ) {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while ( i-- ) {
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
+ count++;
+ tmp.empty.add( resolve );
+ }
+ }
+ resolve();
+ return defer.promise( obj );
+ }
+} );
+
+
+( function() {
+ var shrinkWrapBlocksVal;
+
+ support.shrinkWrapBlocks = function() {
+ if ( shrinkWrapBlocksVal != null ) {
+ return shrinkWrapBlocksVal;
+ }
+
+ // Will be changed later if needed.
+ shrinkWrapBlocksVal = false;
+
+ // Minified: var b,c,d
+ var div, body, container;
+
+ body = document.getElementsByTagName( "body" )[ 0 ];
+ if ( !body || !body.style ) {
+
+ // Test fired too early or in an unsupported environment, exit.
+ return;
+ }
+
+ // Setup
+ div = document.createElement( "div" );
+ container = document.createElement( "div" );
+ container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
+ body.appendChild( container ).appendChild( div );
+
+ // Support: IE6
+ // Check if elements with layout shrink-wrap their children
+ if ( typeof div.style.zoom !== "undefined" ) {
+
+ // Reset CSS: box-sizing; display; margin; border
+ div.style.cssText =
+
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
+ "box-sizing:content-box;display:block;margin:0;border:0;" +
+ "padding:1px;width:1px;zoom:1";
+ div.appendChild( document.createElement( "div" ) ).style.width = "5px";
+ shrinkWrapBlocksVal = div.offsetWidth !== 3;
+ }
+
+ body.removeChild( container );
+
+ return shrinkWrapBlocksVal;
+ };
+
+} )();
+var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
+
+var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
+
+
+var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
+var isHidden = function( elem, el ) {
+
+ // isHidden might be called from jQuery#filter function;
+ // in that case, element will be second argument
+ elem = el || elem;
+ return jQuery.css( elem, "display" ) === "none" ||
+ !jQuery.contains( elem.ownerDocument, elem );
+ };
+
+
+
+function adjustCSS( elem, prop, valueParts, tween ) {
+ var adjusted,
+ scale = 1,
+ maxIterations = 20,
+ currentValue = tween ?
+ function() { return tween.cur(); } :
+ function() { return jQuery.css( elem, prop, "" ); },
+ initial = currentValue(),
+ unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
+
+ // Starting value computation is required for potential unit mismatches
+ initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
+ rcssNum.exec( jQuery.css( elem, prop ) );
+
+ if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
+
+ // Trust units reported by jQuery.css
+ unit = unit || initialInUnit[ 3 ];
+
+ // Make sure we update the tween properties later on
+ valueParts = valueParts || [];
+
+ // Iteratively approximate from a nonzero starting point
+ initialInUnit = +initial || 1;
+
+ do {
+
+ // If previous iteration zeroed out, double until we get *something*.
+ // Use string for doubling so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ initialInUnit = initialInUnit / scale;
+ jQuery.style( elem, prop, initialInUnit + unit );
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // Break the loop if scale is unchanged or perfect, or if we've just had enough.
+ } while (
+ scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
+ );
+ }
+
+ if ( valueParts ) {
+ initialInUnit = +initialInUnit || +initial || 0;
+
+ // Apply relative offset (+=/-=) if specified
+ adjusted = valueParts[ 1 ] ?
+ initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+ +valueParts[ 2 ];
+ if ( tween ) {
+ tween.unit = unit;
+ tween.start = initialInUnit;
+ tween.end = adjusted;
+ }
+ }
+ return adjusted;
+}
+
+
+// Multifunctional method to get and set values of a collection
+// The value/s can optionally be executed if it's a function
+var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
+ var i = 0,
+ length = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if ( jQuery.type( key ) === "object" ) {
+ chainable = true;
+ for ( i in key ) {
+ access( elems, fn, i, key[ i ], true, emptyGet, raw );
+ }
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ chainable = true;
+
+ if ( !jQuery.isFunction( value ) ) {
+ raw = true;
+ }
+
+ if ( bulk ) {
+
+ // Bulk operations run against the entire set
+ if ( raw ) {
+ fn.call( elems, value );
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function( elem, key, value ) {
+ return bulk.call( jQuery( elem ), value );
+ };
+ }
+ }
+
+ if ( fn ) {
+ for ( ; i < length; i++ ) {
+ fn(
+ elems[ i ],
+ key,
+ raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
+ );
+ }
+ }
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[ 0 ], key ) : emptyGet;
+};
+var rcheckableType = ( /^(?:checkbox|radio)$/i );
+
+var rtagName = ( /<([\w:-]+)/ );
+
+var rscriptType = ( /^$|\/(?:java|ecma)script/i );
+
+var rleadingWhitespace = ( /^\s+/ );
+
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
+ "details|dialog|figcaption|figure|footer|header|hgroup|main|" +
+ "mark|meter|nav|output|picture|progress|section|summary|template|time|video";
+
+
+
+function createSafeFragment( document ) {
+ var list = nodeNames.split( "|" ),
+ safeFrag = document.createDocumentFragment();
+
+ if ( safeFrag.createElement ) {
+ while ( list.length ) {
+ safeFrag.createElement(
+ list.pop()
+ );
+ }
+ }
+ return safeFrag;
+}
+
+
+( function() {
+ var div = document.createElement( "div" ),
+ fragment = document.createDocumentFragment(),
+ input = document.createElement( "input" );
+
+ // Setup
+ div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+
+ // IE strips leading whitespace when .innerHTML is used
+ support.leadingWhitespace = div.firstChild.nodeType === 3;
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ support.tbody = !div.getElementsByTagName( "tbody" ).length;
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
+
+ // Makes sure cloning an html5 element does not cause problems
+ // Where outerHTML is undefined, this still works
+ support.html5Clone =
+ document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ input.type = "checkbox";
+ input.checked = true;
+ fragment.appendChild( input );
+ support.appendChecked = input.checked;
+
+ // Make sure textarea (and checkbox) defaultValue is properly cloned
+ // Support: IE6-IE11+
+ div.innerHTML = "<textarea>x</textarea>";
+ support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ fragment.appendChild( div );
+
+ // Support: Windows Web Apps (WWA)
+ // `name` and `type` must use .setAttribute for WWA (#14901)
+ input = document.createElement( "input" );
+ input.setAttribute( "type", "radio" );
+ input.setAttribute( "checked", "checked" );
+ input.setAttribute( "name", "t" );
+
+ div.appendChild( input );
+
+ // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
+ // old WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ // Support: IE<9
+ // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
+ support.noCloneEvent = !!div.addEventListener;
+
+ // Support: IE<9
+ // Since attributes and properties are the same in IE,
+ // cleanData must set properties to undefined rather than use removeAttribute
+ div[ jQuery.expando ] = 1;
+ support.attributes = !div.getAttribute( jQuery.expando );
+} )();
+
+
+// We have to close these tags to support XHTML (#13200)
+var wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ area: [ 1, "<map>", "</map>" ],
+
+ // Support: IE8
+ param: [ 1, "<object>", "</object>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+
+ // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+ // unless wrapped in a div with non-breaking characters in front of it.
+ _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
+};
+
+// Support: IE8-IE9
+wrapMap.optgroup = wrapMap.option;
+
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+
+function getAll( context, tag ) {
+ var elems, elem,
+ i = 0,
+ found = typeof context.getElementsByTagName !== "undefined" ?
+ context.getElementsByTagName( tag || "*" ) :
+ typeof context.querySelectorAll !== "undefined" ?
+ context.querySelectorAll( tag || "*" ) :
+ undefined;
+
+ if ( !found ) {
+ for ( found = [], elems = context.childNodes || context;
+ ( elem = elems[ i ] ) != null;
+ i++
+ ) {
+ if ( !tag || jQuery.nodeName( elem, tag ) ) {
+ found.push( elem );
+ } else {
+ jQuery.merge( found, getAll( elem, tag ) );
+ }
+ }
+ }
+
+ return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
+ jQuery.merge( [ context ], found ) :
+ found;
+}
+
+
+// Mark scripts as having already been evaluated
+function setGlobalEval( elems, refElements ) {
+ var elem,
+ i = 0;
+ for ( ; ( elem = elems[ i ] ) != null; i++ ) {
+ jQuery._data(
+ elem,
+ "globalEval",
+ !refElements || jQuery._data( refElements[ i ], "globalEval" )
+ );
+ }
+}
+
+
+var rhtml = /<|&#?\w+;/,
+ rtbody = /<tbody/i;
+
+function fixDefaultChecked( elem ) {
+ if ( rcheckableType.test( elem.type ) ) {
+ elem.defaultChecked = elem.checked;
+ }
+}
+
+function buildFragment( elems, context, scripts, selection, ignored ) {
+ var j, elem, contains,
+ tmp, tag, tbody, wrap,
+ l = elems.length,
+
+ // Ensure a safe fragment
+ safe = createSafeFragment( context ),
+
+ nodes = [],
+ i = 0;
+
+ for ( ; i < l; i++ ) {
+ elem = elems[ i ];
+
+ if ( elem || elem === 0 ) {
+
+ // Add nodes directly
+ if ( jQuery.type( elem ) === "object" ) {
+ jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
+
+ // Convert non-html into a text node
+ } else if ( !rhtml.test( elem ) ) {
+ nodes.push( context.createTextNode( elem ) );
+
+ // Convert html into DOM nodes
+ } else {
+ tmp = tmp || safe.appendChild( context.createElement( "div" ) );
+
+ // Deserialize a standard representation
+ tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
+ wrap = wrapMap[ tag ] || wrapMap._default;
+
+ tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
+
+ // Descend through wrappers to the right content
+ j = wrap[ 0 ];
+ while ( j-- ) {
+ tmp = tmp.lastChild;
+ }
+
+ // Manually add leading whitespace removed by IE
+ if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ elem = tag === "table" && !rtbody.test( elem ) ?
+ tmp.firstChild :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
+ tmp :
+ 0;
+
+ j = elem && elem.childNodes.length;
+ while ( j-- ) {
+ if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
+ !tbody.childNodes.length ) {
+
+ elem.removeChild( tbody );
+ }
+ }
+ }
+
+ jQuery.merge( nodes, tmp.childNodes );
+
+ // Fix #12392 for WebKit and IE > 9
+ tmp.textContent = "";
+
+ // Fix #12392 for oldIE
+ while ( tmp.firstChild ) {
+ tmp.removeChild( tmp.firstChild );
+ }
+
+ // Remember the top-level container for proper cleanup
+ tmp = safe.lastChild;
+ }
+ }
+ }
+
+ // Fix #11356: Clear elements from fragment
+ if ( tmp ) {
+ safe.removeChild( tmp );
+ }
+
+ // Reset defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ if ( !support.appendChecked ) {
+ jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
+ }
+
+ i = 0;
+ while ( ( elem = nodes[ i++ ] ) ) {
+
+ // Skip elements already in the context collection (trac-4087)
+ if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
+ if ( ignored ) {
+ ignored.push( elem );
+ }
+
+ continue;
+ }
+
+ contains = jQuery.contains( elem.ownerDocument, elem );
+
+ // Append to fragment
+ tmp = getAll( safe.appendChild( elem ), "script" );
+
+ // Preserve script evaluation history
+ if ( contains ) {
+ setGlobalEval( tmp );
+ }
+
+ // Capture executables
+ if ( scripts ) {
+ j = 0;
+ while ( ( elem = tmp[ j++ ] ) ) {
+ if ( rscriptType.test( elem.type || "" ) ) {
+ scripts.push( elem );
+ }
+ }
+ }
+ }
+
+ tmp = null;
+
+ return safe;
+}
+
+
+( function() {
+ var i, eventName,
+ div = document.createElement( "div" );
+
+ // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
+ for ( i in { submit: true, change: true, focusin: true } ) {
+ eventName = "on" + i;
+
+ if ( !( support[ i ] = eventName in window ) ) {
+
+ // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
+ div.setAttribute( eventName, "t" );
+ support[ i ] = div.attributes[ eventName ].expando === false;
+ }
+ }
+
+ // Null elements to avoid leaks in IE.
+ div = null;
+} )();
+
+
+var rformElems = /^(?:input|select|textarea)$/i,
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
+ rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
+
+function returnTrue() {
+ return true;
+}
+
+function returnFalse() {
+ return false;
+}
+
+// Support: IE9
+// See #13393 for more info
+function safeActiveElement() {
+ try {
+ return document.activeElement;
+ } catch ( err ) { }
+}
+
+function on( elem, types, selector, data, fn, one ) {
+ var origFn, type;
+
+ // Types can be a map of types/handlers
+ if ( typeof types === "object" ) {
+
+ // ( types-Object, selector, data )
+ if ( typeof selector !== "string" ) {
+
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for ( type in types ) {
+ on( elem, type, selector, data, types[ type ], one );
+ }
+ return elem;
+ }
+
+ if ( data == null && fn == null ) {
+
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if ( fn == null ) {
+ if ( typeof selector === "string" ) {
+
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ } else if ( !fn ) {
+ return elem;
+ }
+
+ if ( one === 1 ) {
+ origFn = fn;
+ fn = function( event ) {
+
+ // Can use an empty set, since event contains the info
+ jQuery().off( event );
+ return origFn.apply( this, arguments );
+ };
+
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return elem.each( function() {
+ jQuery.event.add( this, types, fn, data, selector );
+ } );
+}
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+ global: {},
+
+ add: function( elem, types, handler, data, selector ) {
+ var tmp, events, t, handleObjIn,
+ special, eventHandle, handleObj,
+ handlers, type, namespaces, origType,
+ elemData = jQuery._data( elem );
+
+ // Don't attach events to noData or text/comment nodes (but allow plain objects)
+ if ( !elemData ) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ if ( !( events = elemData.events ) ) {
+ events = elemData.events = {};
+ }
+ if ( !( eventHandle = elemData.handle ) ) {
+ eventHandle = elemData.handle = function( e ) {
+
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" &&
+ ( !e || jQuery.event.triggered !== e.type ) ?
+ jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ // Add elem as a property of the handle fn to prevent a memory leak
+ // with IE non-native events
+ eventHandle.elem = elem;
+ }
+
+ // Handle multiple events separated by a space
+ types = ( types || "" ).match( rnotwhite ) || [ "" ];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[ t ] ) || [];
+ type = origType = tmp[ 1 ];
+ namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+ // There *must* be a type, no attaching namespace-only handlers
+ if ( !type ) {
+ continue;
+ }
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[ type ] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[ type ] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend( {
+ type: type,
+ origType: origType,
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+ namespace: namespaces.join( "." )
+ }, handleObjIn );
+
+ // Init the event handler queue if we're the first
+ if ( !( handlers = events[ type ] ) ) {
+ handlers = events[ type ] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener/attachEvent if the special events handler returns false
+ if ( !special.setup ||
+ special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if ( selector ) {
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
+ } else {
+ handlers.push( handleObj );
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, selector, mappedTypes ) {
+ var j, handleObj, tmp,
+ origCount, t, events,
+ special, handlers, type,
+ namespaces, origType,
+ elemData = jQuery.hasData( elem ) && jQuery._data( elem );
+
+ if ( !elemData || !( events = elemData.events ) ) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = ( types || "" ).match( rnotwhite ) || [ "" ];
+ t = types.length;
+ while ( t-- ) {
+ tmp = rtypenamespace.exec( types[ t ] ) || [];
+ type = origType = tmp[ 1 ];
+ namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if ( !type ) {
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+ handlers = events[ type ] || [];
+ tmp = tmp[ 2 ] &&
+ new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
+
+ // Remove matching events
+ origCount = j = handlers.length;
+ while ( j-- ) {
+ handleObj = handlers[ j ];
+
+ if ( ( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !tmp || tmp.test( handleObj.namespace ) ) &&
+ ( !selector || selector === handleObj.selector ||
+ selector === "**" && handleObj.selector ) ) {
+ handlers.splice( j, 1 );
+
+ if ( handleObj.selector ) {
+ handlers.delegateCount--;
+ }
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if ( origCount && !handlers.length ) {
+ if ( !special.teardown ||
+ special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ delete elemData.handle;
+
+ // removeData also checks for emptiness and clears the expando if empty
+ // so use it instead of delete
+ jQuery._removeData( elem, "events" );
+ }
+ },
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+ var handle, ontype, cur,
+ bubbleType, special, tmp, i,
+ eventPath = [ elem || document ],
+ type = hasOwn.call( event, "type" ) ? event.type : event,
+ namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
+
+ cur = tmp = elem = elem || document;
+
+ // Don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+ return;
+ }
+
+ if ( type.indexOf( "." ) > -1 ) {
+
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split( "." );
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+ ontype = type.indexOf( ":" ) < 0 && "on" + type;
+
+ // Caller can pass in a jQuery.Event object, Object, or just an event type string
+ event = event[ jQuery.expando ] ?
+ event :
+ new jQuery.Event( type, typeof event === "object" && event );
+
+ // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
+ event.isTrigger = onlyHandlers ? 2 : 3;
+ event.namespace = namespaces.join( "." );
+ event.rnamespace = event.namespace ?
+ new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
+ null;
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if ( !event.target ) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data == null ?
+ [ event ] :
+ jQuery.makeArray( data, [ event ] );
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[ type ] || {};
+ if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
+
+ bubbleType = special.delegateType || type;
+ if ( !rfocusMorph.test( bubbleType + type ) ) {
+ cur = cur.parentNode;
+ }
+ for ( ; cur; cur = cur.parentNode ) {
+ eventPath.push( cur );
+ tmp = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if ( tmp === ( elem.ownerDocument || document ) ) {
+ eventPath.push( tmp.defaultView || tmp.parentWindow || window );
+ }
+ }
+
+ // Fire handlers on the event path
+ i = 0;
+ while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
+
+ event.type = i > 1 ?
+ bubbleType :
+ special.bindType || type;
+
+ // jQuery handler
+ handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
+ jQuery._data( cur, "handle" );
+
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+
+ // Native handler
+ handle = ontype && cur[ ontype ];
+ if ( handle && handle.apply && acceptData( cur ) ) {
+ event.result = handle.apply( cur, data );
+ if ( event.result === false ) {
+ event.preventDefault();
+ }
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+ if (
+ ( !special._default ||
+ special._default.apply( eventPath.pop(), data ) === false
+ ) && acceptData( elem )
+ ) {
+
+ // Call a native DOM method on the target with the same name name as the event.
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ tmp = elem[ ontype ];
+
+ if ( tmp ) {
+ elem[ ontype ] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+ try {
+ elem[ type ]();
+ } catch ( e ) {
+
+ // IE<9 dies on focus/blur to hidden element (#1486,#12518)
+ // only reproducible on winXP IE8 native, not IE9 in IE8 mode
+ }
+ jQuery.event.triggered = undefined;
+
+ if ( tmp ) {
+ elem[ ontype ] = tmp;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ dispatch: function( event ) {
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix( event );
+
+ var i, j, ret, matched, handleObj,
+ handlerQueue = [],
+ args = slice.call( arguments ),
+ handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
+ special = jQuery.event.special[ event.type ] || {};
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[ 0 ] = event;
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
+ // Determine handlers
+ handlerQueue = jQuery.event.handlers.call( this, event, handlers );
+
+ // Run delegates first; they may want to stop propagation beneath us
+ i = 0;
+ while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
+ event.currentTarget = matched.elem;
+
+ j = 0;
+ while ( ( handleObj = matched.handlers[ j++ ] ) &&
+ !event.isImmediatePropagationStopped() ) {
+
+ // Triggered event must either 1) have no namespace, or 2) have namespace(s)
+ // a subset or equal to those in the bound event (both can have no namespace).
+ if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
+
+ event.handleObj = handleObj;
+ event.data = handleObj.data;
+
+ ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
+ handleObj.handler ).apply( matched.elem, args );
+
+ if ( ret !== undefined ) {
+ if ( ( event.result = ret ) === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
+ return event.result;
+ },
+
+ handlers: function( event, handlers ) {
+ var i, matches, sel, handleObj,
+ handlerQueue = [],
+ delegateCount = handlers.delegateCount,
+ cur = event.target;
+
+ // Support (at least): Chrome, IE9
+ // Find delegate handlers
+ // Black-hole SVG <use> instance trees (#13180)
+ //
+ // Support: Firefox<=42+
+ // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
+ if ( delegateCount && cur.nodeType &&
+ ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
+
+ /* jshint eqeqeq: false */
+ for ( ; cur != this; cur = cur.parentNode || this ) {
+ /* jshint eqeqeq: true */
+
+ // Don't check non-elements (#13208)
+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
+ matches = [];
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
+
+ if ( matches[ sel ] === undefined ) {
+ matches[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) > -1 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( matches[ sel ] ) {
+ matches.push( handleObj );
+ }
+ }
+ if ( matches.length ) {
+ handlerQueue.push( { elem: cur, handlers: matches } );
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ if ( delegateCount < handlers.length ) {
+ handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
+ }
+
+ return handlerQueue;
+ },
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // Create a writable copy of the event object and normalize some properties
+ var i, prop, copy,
+ type = event.type,
+ originalEvent = event,
+ fixHook = this.fixHooks[ type ];
+
+ if ( !fixHook ) {
+ this.fixHooks[ type ] = fixHook =
+ rmouseEvent.test( type ) ? this.mouseHooks :
+ rkeyEvent.test( type ) ? this.keyHooks :
+ {};
+ }
+ copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
+
+ event = new jQuery.Event( originalEvent );
+
+ i = copy.length;
+ while ( i-- ) {
+ prop = copy[ i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Support: IE<9
+ // Fix target property (#1925)
+ if ( !event.target ) {
+ event.target = originalEvent.srcElement || document;
+ }
+
+ // Support: Safari 6-8+
+ // Target should not be a text node (#504, #13143)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Support: IE<9
+ // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
+ event.metaKey = !!event.metaKey;
+
+ return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
+ },
+
+ // Includes some event props shared by KeyEvent and MouseEvent
+ props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
+ "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
+
+ fixHooks: {},
+
+ keyHooks: {
+ props: "char charCode key keyCode".split( " " ),
+ filter: function( event, original ) {
+
+ // Add which for key events
+ if ( event.which == null ) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+
+ return event;
+ }
+ },
+
+ mouseHooks: {
+ props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
+ "pageX pageY screenX screenY toElement" ).split( " " ),
+ filter: function( event, original ) {
+ var body, eventDoc, doc,
+ button = original.button,
+ fromElement = original.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && original.clientX != null ) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+
+ event.pageX = original.clientX +
+ ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
+ ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+ event.pageY = original.clientY +
+ ( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
+ ( doc && doc.clientTop || body && body.clientTop || 0 );
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && fromElement ) {
+ event.relatedTarget = fromElement === event.target ?
+ original.toElement :
+ fromElement;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && button !== undefined ) {
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+ }
+
+ return event;
+ }
+ },
+
+ special: {
+ load: {
+
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+ focus: {
+
+ // Fire native event if possible so blur/focus sequence is correct
+ trigger: function() {
+ if ( this !== safeActiveElement() && this.focus ) {
+ try {
+ this.focus();
+ return false;
+ } catch ( e ) {
+
+ // Support: IE<9
+ // If we error on focus to hidden element (#1486, #12518),
+ // let .trigger() run the handlers
+ }
+ }
+ },
+ delegateType: "focusin"
+ },
+ blur: {
+ trigger: function() {
+ if ( this === safeActiveElement() && this.blur ) {
+ this.blur();
+ return false;
+ }
+ },
+ delegateType: "focusout"
+ },
+ click: {
+
+ // For checkbox, fire native event so checked state will be right
+ trigger: function() {
+ if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
+ this.click();
+ return false;
+ }
+ },
+
+ // For cross-browser consistency, don't fire native .click() on links
+ _default: function( event ) {
+ return jQuery.nodeName( event.target, "a" );
+ }
+ },
+
+ beforeunload: {
+ postDispatch: function( event ) {
+
+ // Support: Firefox 20+
+ // Firefox doesn't alert if the returnValue field is not set.
+ if ( event.result !== undefined && event.originalEvent ) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ },
+
+ // Piggyback on a donor event to simulate a different one
+ simulate: function( type, elem, event ) {
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ {
+ type: type,
+ isSimulated: true
+
+ // Previously, `originalEvent: {}` was set here, so stopPropagation call
+ // would not be triggered on donor event, since in our own
+ // jQuery.event.stopPropagation function we had a check for existence of
+ // originalEvent.stopPropagation method, so, consequently it would be a noop.
+ //
+ // Guard for simulated events was moved to jQuery.event.stopPropagation function
+ // since `originalEvent` should point to the original event for the
+ // constancy with other events and for more focused logic
+ }
+ );
+
+ jQuery.event.trigger( e, null, elem );
+
+ if ( e.isDefaultPrevented() ) {
+ event.preventDefault();
+ }
+ }
+};
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+
+ // This "if" is needed for plain objects
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle );
+ }
+ } :
+ function( elem, type, handle ) {
+ var name = "on" + type;
+
+ if ( elem.detachEvent ) {
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
+ // detachEvent needed property on element, by name of that event,
+ // to properly expose it to GC
+ if ( typeof elem[ name ] === "undefined" ) {
+ elem[ name ] = null;
+ }
+
+ elem.detachEvent( name, handle );
+ }
+ };
+
+jQuery.Event = function( src, props ) {
+
+ // Allow instantiation without the 'new' keyword
+ if ( !( this instanceof jQuery.Event ) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = src.defaultPrevented ||
+ src.defaultPrevented === undefined &&
+
+ // Support: IE < 9, Android < 4.0
+ src.returnValue === false ?
+ returnTrue :
+ returnFalse;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ constructor: jQuery.Event,
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+
+ preventDefault: function() {
+ var e = this.originalEvent;
+
+ this.isDefaultPrevented = returnTrue;
+ if ( !e ) {
+ return;
+ }
+
+ // If preventDefault exists, run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // Support: IE
+ // Otherwise set the returnValue property of the original event to false
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ var e = this.originalEvent;
+
+ this.isPropagationStopped = returnTrue;
+
+ if ( !e || this.isSimulated ) {
+ return;
+ }
+
+ // If stopPropagation exists, run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+
+ // Support: IE
+ // Set the cancelBubble property of the original event to true
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ var e = this.originalEvent;
+
+ this.isImmediatePropagationStopped = returnTrue;
+
+ if ( e && e.stopImmediatePropagation ) {
+ e.stopImmediatePropagation();
+ }
+
+ this.stopPropagation();
+ }
+};
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+// so that event delegation works in jQuery.
+// Do the same for pointerenter/pointerleave and pointerover/pointerout
+//
+// Support: Safari 7 only
+// Safari sends mouseenter too often; see:
+// https://code.google.com/p/chromium/issues/detail?id=470258
+// for the description of the bug (it existed in older Chrome versions as well).
+jQuery.each( {
+ mouseenter: "mouseover",
+ mouseleave: "mouseout",
+ pointerenter: "pointerover",
+ pointerleave: "pointerout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj;
+
+ // For mouseenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+} );
+
+// IE submit delegation
+if ( !support.submit ) {
+
+ jQuery.event.special.submit = {
+ setup: function() {
+
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
+ jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
+
+ // Node name check avoids a VML-related crash in IE (#9807)
+ var elem = e.target,
+ form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
+
+ // Support: IE <=8
+ // We use jQuery.prop instead of elem.form
+ // to allow fixing the IE8 delegated submit issue (gh-2332)
+ // by 3rd party polyfills/workarounds.
+ jQuery.prop( elem, "form" ) :
+ undefined;
+
+ if ( form && !jQuery._data( form, "submit" ) ) {
+ jQuery.event.add( form, "submit._submit", function( event ) {
+ event._submitBubble = true;
+ } );
+ jQuery._data( form, "submit", true );
+ }
+ } );
+
+ // return undefined since we don't need an event listener
+ },
+
+ postDispatch: function( event ) {
+
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submitBubble ) {
+ delete event._submitBubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event );
+ }
+ }
+ },
+
+ teardown: function() {
+
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+ jQuery.event.remove( this, "._submit" );
+ }
+ };
+}
+
+// IE change delegation and checkbox/radio fix
+if ( !support.change ) {
+
+ jQuery.event.special.change = {
+
+ setup: function() {
+
+ if ( rformElems.test( this.nodeName ) ) {
+
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
+ // after a propertychange. Eat the blur-change in special.change.handle.
+ // This still fires onchange a second time for check/radio after blur.
+ if ( this.type === "checkbox" || this.type === "radio" ) {
+ jQuery.event.add( this, "propertychange._change", function( event ) {
+ if ( event.originalEvent.propertyName === "checked" ) {
+ this._justChanged = true;
+ }
+ } );
+ jQuery.event.add( this, "click._change", function( event ) {
+ if ( this._justChanged && !event.isTrigger ) {
+ this._justChanged = false;
+ }
+
+ // Allow triggered, simulated change events (#11500)
+ jQuery.event.simulate( "change", this, event );
+ } );
+ }
+ return false;
+ }
+
+ // Delegated event; lazy-add a change handler on descendant inputs
+ jQuery.event.add( this, "beforeactivate._change", function( e ) {
+ var elem = e.target;
+
+ if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
+ jQuery.event.add( elem, "change._change", function( event ) {
+ if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
+ jQuery.event.simulate( "change", this.parentNode, event );
+ }
+ } );
+ jQuery._data( elem, "change", true );
+ }
+ } );
+ },
+
+ handle: function( event ) {
+ var elem = event.target;
+
+ // Swallow native change events from checkbox/radio, we already triggered them above
+ if ( this !== elem || event.isSimulated || event.isTrigger ||
+ ( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
+
+ return event.handleObj.handler.apply( this, arguments );
+ }
+ },
+
+ teardown: function() {
+ jQuery.event.remove( this, "._change" );
+
+ return !rformElems.test( this.nodeName );
+ }
+ };
+}
+
+// Support: Firefox
+// Firefox doesn't have focus(in | out) events
+// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
+//
+// Support: Chrome, Safari
+// focus(in | out) events fire after focus & blur events,
+// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
+// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
+if ( !support.focusin ) {
+ jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler on the document while someone wants focusin/focusout
+ var handler = function( event ) {
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
+ };
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ var doc = this.ownerDocument || this,
+ attaches = jQuery._data( doc, fix );
+
+ if ( !attaches ) {
+ doc.addEventListener( orig, handler, true );
+ }
+ jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
+ },
+ teardown: function() {
+ var doc = this.ownerDocument || this,
+ attaches = jQuery._data( doc, fix ) - 1;
+
+ if ( !attaches ) {
+ doc.removeEventListener( orig, handler, true );
+ jQuery._removeData( doc, fix );
+ } else {
+ jQuery._data( doc, fix, attaches );
+ }
+ }
+ };
+ } );
+}
+
+jQuery.fn.extend( {
+
+ on: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn );
+ },
+ one: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ?
+ handleObj.origType + "." + handleObj.namespace :
+ handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each( function() {
+ jQuery.event.remove( this, types, fn, selector );
+ } );
+ },
+
+ trigger: function( type, data ) {
+ return this.each( function() {
+ jQuery.event.trigger( type, data, this );
+ } );
+ },
+ triggerHandler: function( type, data ) {
+ var elem = this[ 0 ];
+ if ( elem ) {
+ return jQuery.event.trigger( type, data, elem, true );
+ }
+ }
+} );
+
+
+var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+ rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
+
+ // Support: IE 10-11, Edge 10240+
+ // In IE/Edge using regex groups here causes severe slowdowns.
+ // See https://connect.microsoft.com/IE/feedback/details/1736512/
+ rnoInnerhtml = /<script|<style|<link/i,
+
+ // checked="checked" or checked
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+ rscriptTypeMasked = /^true\/(.*)/,
+ rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
+ safeFragment = createSafeFragment( document ),
+ fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
+
+// Support: IE<8
+// Manipulating tables requires a tbody
+function manipulationTarget( elem, content ) {
+ return jQuery.nodeName( elem, "table" ) &&
+ jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
+
+ elem.getElementsByTagName( "tbody" )[ 0 ] ||
+ elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
+ elem;
+}
+
+// Replace/restore the type attribute of script elements for safe DOM manipulation
+function disableScript( elem ) {
+ elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
+ return elem;
+}
+function restoreScript( elem ) {
+ var match = rscriptTypeMasked.exec( elem.type );
+ if ( match ) {
+ elem.type = match[ 1 ];
+ } else {
+ elem.removeAttribute( "type" );
+ }
+ return elem;
+}
+
+function cloneCopyEvent( src, dest ) {
+ if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
+ return;
+ }
+
+ var type, i, l,
+ oldData = jQuery._data( src ),
+ curData = jQuery._data( dest, oldData ),
+ events = oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( type in events ) {
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+ jQuery.event.add( dest, type, events[ type ][ i ] );
+ }
+ }
+ }
+
+ // make the cloned public data object a copy from the original
+ if ( curData.data ) {
+ curData.data = jQuery.extend( {}, curData.data );
+ }
+}
+
+function fixCloneNodeIssues( src, dest ) {
+ var nodeName, e, data;
+
+ // We do not need to do anything for non-Elements
+ if ( dest.nodeType !== 1 ) {
+ return;
+ }
+
+ nodeName = dest.nodeName.toLowerCase();
+
+ // IE6-8 copies events bound via attachEvent when using cloneNode.
+ if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
+ data = jQuery._data( dest );
+
+ for ( e in data.events ) {
+ jQuery.removeEvent( dest, e, data.handle );
+ }
+
+ // Event data gets referenced instead of copied if the expando gets copied too
+ dest.removeAttribute( jQuery.expando );
+ }
+
+ // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
+ if ( nodeName === "script" && dest.text !== src.text ) {
+ disableScript( dest ).text = src.text;
+ restoreScript( dest );
+
+ // IE6-10 improperly clones children of object elements using classid.
+ // IE10 throws NoModificationAllowedError if parent is null, #12132.
+ } else if ( nodeName === "object" ) {
+ if ( dest.parentNode ) {
+ dest.outerHTML = src.outerHTML;
+ }
+
+ // This path appears unavoidable for IE9. When cloning an object
+ // element in IE9, the outerHTML strategy above is not sufficient.
+ // If the src has innerHTML and the destination does not,
+ // copy the src.innerHTML into the dest.innerHTML. #10324
+ if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
+ dest.innerHTML = src.innerHTML;
+ }
+
+ } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+
+ // IE6-8 fails to persist the checked state of a cloned checkbox
+ // or radio button. Worse, IE6-7 fail to give the cloned element
+ // a checked appearance if the defaultChecked value isn't also set
+
+ dest.defaultChecked = dest.checked = src.checked;
+
+ // IE6-7 get confused and end up setting the value of a cloned
+ // checkbox/radio button to an empty string instead of "on"
+ if ( dest.value !== src.value ) {
+ dest.value = src.value;
+ }
+
+ // IE6-8 fails to return the selected option to the default selected
+ // state when cloning options
+ } else if ( nodeName === "option" ) {
+ dest.defaultSelected = dest.selected = src.defaultSelected;
+
+ // IE6-8 fails to set the defaultValue to the correct value when
+ // cloning other types of input fields
+ } else if ( nodeName === "input" || nodeName === "textarea" ) {
+ dest.defaultValue = src.defaultValue;
+ }
+}
+
+function domManip( collection, args, callback, ignored ) {
+
+ // Flatten any nested arrays
+ args = concat.apply( [], args );
+
+ var first, node, hasScripts,
+ scripts, doc, fragment,
+ i = 0,
+ l = collection.length,
+ iNoClone = l - 1,
+ value = args[ 0 ],
+ isFunction = jQuery.isFunction( value );
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( isFunction ||
+ ( l > 1 && typeof value === "string" &&
+ !support.checkClone && rchecked.test( value ) ) ) {
+ return collection.each( function( index ) {
+ var self = collection.eq( index );
+ if ( isFunction ) {
+ args[ 0 ] = value.call( this, index, self.html() );
+ }
+ domManip( self, args, callback, ignored );
+ } );
+ }
+
+ if ( l ) {
+ fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
+ first = fragment.firstChild;
+
+ if ( fragment.childNodes.length === 1 ) {
+ fragment = first;
+ }
+
+ // Require either new content or an interest in ignored elements to invoke the callback
+ if ( first || ignored ) {
+ scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
+ hasScripts = scripts.length;
+
+ // Use the original fragment for the last item
+ // instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ for ( ; i < l; i++ ) {
+ node = fragment;
+
+ if ( i !== iNoClone ) {
+ node = jQuery.clone( node, true, true );
+
+ // Keep references to cloned scripts for later restoration
+ if ( hasScripts ) {
+
+ // Support: Android<4.1, PhantomJS<2
+ // push.apply(_, arraylike) throws on ancient WebKit
+ jQuery.merge( scripts, getAll( node, "script" ) );
+ }
+ }
+
+ callback.call( collection[ i ], node, i );
+ }
+
+ if ( hasScripts ) {
+ doc = scripts[ scripts.length - 1 ].ownerDocument;
+
+ // Reenable scripts
+ jQuery.map( scripts, restoreScript );
+
+ // Evaluate executable scripts on first document insertion
+ for ( i = 0; i < hasScripts; i++ ) {
+ node = scripts[ i ];
+ if ( rscriptType.test( node.type || "" ) &&
+ !jQuery._data( node, "globalEval" ) &&
+ jQuery.contains( doc, node ) ) {
+
+ if ( node.src ) {
+
+ // Optional AJAX dependency, but won't run scripts if not present
+ if ( jQuery._evalUrl ) {
+ jQuery._evalUrl( node.src );
+ }
+ } else {
+ jQuery.globalEval(
+ ( node.text || node.textContent || node.innerHTML || "" )
+ .replace( rcleanScript, "" )
+ );
+ }
+ }
+ }
+ }
+
+ // Fix #11809: Avoid leaking memory
+ fragment = first = null;
+ }
+ }
+
+ return collection;
+}
+
+function remove( elem, selector, keepData ) {
+ var node,
+ elems = selector ? jQuery.filter( selector, elem ) : elem,
+ i = 0;
+
+ for ( ; ( node = elems[ i ] ) != null; i++ ) {
+
+ if ( !keepData && node.nodeType === 1 ) {
+ jQuery.cleanData( getAll( node ) );
+ }
+
+ if ( node.parentNode ) {
+ if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
+ setGlobalEval( getAll( node, "script" ) );
+ }
+ node.parentNode.removeChild( node );
+ }
+ }
+
+ return elem;
+}
+
+jQuery.extend( {
+ htmlPrefilter: function( html ) {
+ return html.replace( rxhtmlTag, "<$1></$2>" );
+ },
+
+ clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+ var destElements, node, clone, i, srcElements,
+ inPage = jQuery.contains( elem.ownerDocument, elem );
+
+ if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
+ !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+
+ clone = elem.cloneNode( true );
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+ }
+
+ if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
+ ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
+
+ // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
+ destElements = getAll( clone );
+ srcElements = getAll( elem );
+
+ // Fix all IE cloning issues
+ for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
+
+ // Ensure that the destination node is not null; Fixes #9587
+ if ( destElements[ i ] ) {
+ fixCloneNodeIssues( node, destElements[ i ] );
+ }
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if ( dataAndEvents ) {
+ if ( deepDataAndEvents ) {
+ srcElements = srcElements || getAll( elem );
+ destElements = destElements || getAll( clone );
+
+ for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
+ cloneCopyEvent( node, destElements[ i ] );
+ }
+ } else {
+ cloneCopyEvent( elem, clone );
+ }
+ }
+
+ // Preserve script evaluation history
+ destElements = getAll( clone, "script" );
+ if ( destElements.length > 0 ) {
+ setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
+ }
+
+ destElements = srcElements = node = null;
+
+ // Return the cloned set
+ return clone;
+ },
+
+ cleanData: function( elems, /* internal */ forceAcceptData ) {
+ var elem, type, id, data,
+ i = 0,
+ internalKey = jQuery.expando,
+ cache = jQuery.cache,
+ attributes = support.attributes,
+ special = jQuery.event.special;
+
+ for ( ; ( elem = elems[ i ] ) != null; i++ ) {
+ if ( forceAcceptData || acceptData( elem ) ) {
+
+ id = elem[ internalKey ];
+ data = id && cache[ id ];
+
+ if ( data ) {
+ if ( data.events ) {
+ for ( type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ // Remove cache only if it was not already removed by jQuery.event.remove
+ if ( cache[ id ] ) {
+
+ delete cache[ id ];
+
+ // Support: IE<9
+ // IE does not allow us to delete expando properties from nodes
+ // IE creates expando attributes along with the property
+ // IE does not have a removeAttribute function on Document nodes
+ if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
+ elem.removeAttribute( internalKey );
+
+ // Webkit & Blink performance suffers when deleting properties
+ // from DOM nodes, so set to undefined instead
+ // https://code.google.com/p/chromium/issues/detail?id=378607
+ } else {
+ elem[ internalKey ] = undefined;
+ }
+
+ deletedIds.push( id );
+ }
+ }
+ }
+ }
+ }
+} );
+
+jQuery.fn.extend( {
+
+ // Keep domManip exposed until 3.0 (gh-2225)
+ domManip: domManip,
+
+ detach: function( selector ) {
+ return remove( this, selector, true );
+ },
+
+ remove: function( selector ) {
+ return remove( this, selector );
+ },
+
+ text: function( value ) {
+ return access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().append(
+ ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
+ );
+ }, null, value, arguments.length );
+ },
+
+ append: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ var target = manipulationTarget( this, elem );
+ target.appendChild( elem );
+ }
+ } );
+ },
+
+ prepend: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+ var target = manipulationTarget( this, elem );
+ target.insertBefore( elem, target.firstChild );
+ }
+ } );
+ },
+
+ before: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this );
+ }
+ } );
+ },
+
+ after: function() {
+ return domManip( this, arguments, function( elem ) {
+ if ( this.parentNode ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ }
+ } );
+ },
+
+ empty: function() {
+ var elem,
+ i = 0;
+
+ for ( ; ( elem = this[ i ] ) != null; i++ ) {
+
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem, false ) );
+ }
+
+ // Remove any remaining nodes
+ while ( elem.firstChild ) {
+ elem.removeChild( elem.firstChild );
+ }
+
+ // If this is a select, ensure that it displays empty (#12336)
+ // Support: IE<9
+ if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
+ elem.options.length = 0;
+ }
+ }
+
+ return this;
+ },
+
+ clone: function( dataAndEvents, deepDataAndEvents ) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map( function() {
+ return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+ } );
+ },
+
+ html: function( value ) {
+ return access( this, function( value ) {
+ var elem = this[ 0 ] || {},
+ i = 0,
+ l = this.length;
+
+ if ( value === undefined ) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace( rinlinejQuery, "" ) :
+ undefined;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
+ ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+ !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
+
+ value = jQuery.htmlPrefilter( value );
+
+ try {
+ for ( ; i < l; i++ ) {
+
+ // Remove element nodes and prevent memory leaks
+ elem = this[ i ] || {};
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( getAll( elem, false ) );
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch ( e ) {}
+ }
+
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
+ },
+
+ replaceWith: function() {
+ var ignored = [];
+
+ // Make the changes, replacing each non-ignored context element with the new content
+ return domManip( this, arguments, function( elem ) {
+ var parent = this.parentNode;
+
+ if ( jQuery.inArray( this, ignored ) < 0 ) {
+ jQuery.cleanData( getAll( this ) );
+ if ( parent ) {
+ parent.replaceChild( elem, this );
+ }
+ }
+
+ // Force callback invocation
+ }, ignored );
+ }
+} );
+
+jQuery.each( {
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var elems,
+ i = 0,
+ ret = [],
+ insert = jQuery( selector ),
+ last = insert.length - 1;
+
+ for ( ; i <= last; i++ ) {
+ elems = i === last ? this : this.clone( true );
+ jQuery( insert[ i ] )[ original ]( elems );
+
+ // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
+ push.apply( ret, elems.get() );
+ }
+
+ return this.pushStack( ret );
+ };
+} );
+
+
+var iframe,
+ elemdisplay = {
+
+ // Support: Firefox
+ // We have to pre-define these values for FF (#10227)
+ HTML: "block",
+ BODY: "block"
+ };
+
+/**
+ * Retrieve the actual display of a element
+ * @param {String} name nodeName of the element
+ * @param {Object} doc Document object
+ */
+
+// Called only from within defaultDisplay
+function actualDisplay( name, doc ) {
+ var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
+
+ display = jQuery.css( elem[ 0 ], "display" );
+
+ // We don't have any data stored on the element,
+ // so use "detach" method as fast way to get rid of the element
+ elem.detach();
+
+ return display;
+}
+
+/**
+ * Try to determine the default display value of an element
+ * @param {String} nodeName
+ */
+function defaultDisplay( nodeName ) {
+ var doc = document,
+ display = elemdisplay[ nodeName ];
+
+ if ( !display ) {
+ display = actualDisplay( nodeName, doc );
+
+ // If the simple way fails, read from inside an iframe
+ if ( display === "none" || !display ) {
+
+ // Use the already-created iframe if possible
+ iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
+ .appendTo( doc.documentElement );
+
+ // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
+ doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
+
+ // Support: IE
+ doc.write();
+ doc.close();
+
+ display = actualDisplay( nodeName, doc );
+ iframe.detach();
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+ }
+
+ return display;
+}
+var rmargin = ( /^margin/ );
+
+var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
+
+var swap = function( elem, options, callback, args ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.apply( elem, args || [] );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+};
+
+
+var documentElement = document.documentElement;
+
+
+
+( function() {
+ var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
+ reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
+ container = document.createElement( "div" ),
+ div = document.createElement( "div" );
+
+ // Finish early in limited (non-browser) environments
+ if ( !div.style ) {
+ return;
+ }
+
+ div.style.cssText = "float:left;opacity:.5";
+
+ // Support: IE<9
+ // Make sure that element opacity exists (as opposed to filter)
+ support.opacity = div.style.opacity === "0.5";
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ support.cssFloat = !!div.style.cssFloat;
+
+ div.style.backgroundClip = "content-box";
+ div.cloneNode( true ).style.backgroundClip = "";
+ support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+ container = document.createElement( "div" );
+ container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
+ "padding:0;margin-top:1px;position:absolute";
+ div.innerHTML = "";
+ container.appendChild( div );
+
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
+ div.style.WebkitBoxSizing === "";
+
+ jQuery.extend( support, {
+ reliableHiddenOffsets: function() {
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return reliableHiddenOffsetsVal;
+ },
+
+ boxSizingReliable: function() {
+
+ // We're checking for pixelPositionVal here instead of boxSizingReliableVal
+ // since that compresses better and they're computed together anyway.
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return boxSizingReliableVal;
+ },
+
+ pixelMarginRight: function() {
+
+ // Support: Android 4.0-4.3
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return pixelMarginRightVal;
+ },
+
+ pixelPosition: function() {
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return pixelPositionVal;
+ },
+
+ reliableMarginRight: function() {
+
+ // Support: Android 2.3
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return reliableMarginRightVal;
+ },
+
+ reliableMarginLeft: function() {
+
+ // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
+ if ( pixelPositionVal == null ) {
+ computeStyleTests();
+ }
+ return reliableMarginLeftVal;
+ }
+ } );
+
+ function computeStyleTests() {
+ var contents, divStyle,
+ documentElement = document.documentElement;
+
+ // Setup
+ documentElement.appendChild( container );
+
+ div.style.cssText =
+
+ // Support: Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:border-box;box-sizing:border-box;" +
+ "position:relative;display:block;" +
+ "margin:auto;border:1px;padding:1px;" +
+ "top:1%;width:50%";
+
+ // Support: IE<9
+ // Assume reasonable values in the absence of getComputedStyle
+ pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
+ pixelMarginRightVal = reliableMarginRightVal = true;
+
+ // Check for getComputedStyle so that this code is not run in IE<9.
+ if ( window.getComputedStyle ) {
+ divStyle = window.getComputedStyle( div );
+ pixelPositionVal = ( divStyle || {} ).top !== "1%";
+ reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
+ boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
+
+ // Support: Android 4.0 - 4.3 only
+ // Some styles come back with percentage values, even though they shouldn't
+ div.style.marginRight = "50%";
+ pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
+
+ // Support: Android 2.3 only
+ // Div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container (#3333)
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ contents = div.appendChild( document.createElement( "div" ) );
+
+ // Reset CSS: box-sizing; display; margin; border; padding
+ contents.style.cssText = div.style.cssText =
+
+ // Support: Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
+ "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
+ contents.style.marginRight = contents.style.width = "0";
+ div.style.width = "1px";
+
+ reliableMarginRightVal =
+ !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
+
+ div.removeChild( contents );
+ }
+
+ // Support: IE6-8
+ // First check that getClientRects works as expected
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ div.style.display = "none";
+ reliableHiddenOffsetsVal = div.getClientRects().length === 0;
+ if ( reliableHiddenOffsetsVal ) {
+ div.style.display = "";
+ div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
+ div.childNodes[ 0 ].style.borderCollapse = "separate";
+ contents = div.getElementsByTagName( "td" );
+ contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
+ reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
+ if ( reliableHiddenOffsetsVal ) {
+ contents[ 0 ].style.display = "";
+ contents[ 1 ].style.display = "none";
+ reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
+ }
+ }
+
+ // Teardown
+ documentElement.removeChild( container );
+ }
+
+} )();
+
+
+var getStyles, curCSS,
+ rposition = /^(top|right|bottom|left)$/;
+
+if ( window.getComputedStyle ) {
+ getStyles = function( elem ) {
+
+ // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
+ // IE throws on elements created in popups
+ // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
+ var view = elem.ownerDocument.defaultView;
+
+ if ( !view || !view.opener ) {
+ view = window;
+ }
+
+ return view.getComputedStyle( elem );
+ };
+
+ curCSS = function( elem, name, computed ) {
+ var width, minWidth, maxWidth, ret,
+ style = elem.style;
+
+ computed = computed || getStyles( elem );
+
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+ ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
+
+ // Support: Opera 12.1x only
+ // Fall back to style even without computed
+ // computed is undefined for elems on document fragments
+ if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
+ ret = jQuery.style( elem, name );
+ }
+
+ if ( computed ) {
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Chrome < 17 and Safari 5.0 uses "computed value"
+ // instead of "used value" for margin-right
+ // Safari 5.1.7 (at least) returns percentage for a larger set of values,
+ // but width seems to be reliably pixels
+ // this is against the CSSOM draft spec:
+ // http://dev.w3.org/csswg/cssom/#resolved-values
+ if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+
+ // Remember the original values
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ // Put in the new values to get a computed value out
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ // Revert the changed values
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ // Support: IE
+ // IE returns zIndex value as an integer.
+ return ret === undefined ?
+ ret :
+ ret + "";
+ };
+} else if ( documentElement.currentStyle ) {
+ getStyles = function( elem ) {
+ return elem.currentStyle;
+ };
+
+ curCSS = function( elem, name, computed ) {
+ var left, rs, rsLeft, ret,
+ style = elem.style;
+
+ computed = computed || getStyles( elem );
+ ret = computed ? computed[ name ] : undefined;
+
+ // Avoid setting ret to empty string here
+ // so we don't default to auto
+ if ( ret == null && style && style[ name ] ) {
+ ret = style[ name ];
+ }
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ // but not position css attributes, as those are
+ // proportional to the parent element instead
+ // and we can't measure the parent instead because it
+ // might trigger a "stacking dolls" problem
+ if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
+
+ // Remember the original values
+ left = style.left;
+ rs = elem.runtimeStyle;
+ rsLeft = rs && rs.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
+ style.left = name === "fontSize" ? "1em" : ret;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
+ }
+
+ // Support: IE
+ // IE returns zIndex value as an integer.
+ return ret === undefined ?
+ ret :
+ ret + "" || "auto";
+ };
+}
+
+
+
+
+function addGetHookIf( conditionFn, hookFn ) {
+
+ // Define the hook, we'll check on the first run if it's really needed.
+ return {
+ get: function() {
+ if ( conditionFn() ) {
+
+ // Hook not needed (or it's not possible to use it due
+ // to missing dependency), remove it.
+ delete this.get;
+ return;
+ }
+
+ // Hook needed; redefine it so that the support test is not executed again.
+ return ( this.get = hookFn ).apply( this, arguments );
+ }
+ };
+}
+
+
+var
+
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity\s*=\s*([^)]*)/i,
+
+ // swappable if display is none or starts with table except
+ // "table", "table-cell", or "table-caption"
+ // see here for display values:
+ // https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
+
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssNormalTransform = {
+ letterSpacing: "0",
+ fontWeight: "400"
+ },
+
+ cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
+ emptyStyle = document.createElement( "div" ).style;
+
+
+// return a css property mapped to a potentially vendor prefixed property
+function vendorPropName( name ) {
+
+ // shortcut for names that are not vendor prefixed
+ if ( name in emptyStyle ) {
+ return name;
+ }
+
+ // check for vendor prefixed names
+ var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
+ i = cssPrefixes.length;
+
+ while ( i-- ) {
+ name = cssPrefixes[ i ] + capName;
+ if ( name in emptyStyle ) {
+ return name;
+ }
+ }
+}
+
+function showHide( elements, show ) {
+ var display, elem, hidden,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ for ( ; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+
+ values[ index ] = jQuery._data( elem, "olddisplay" );
+ display = elem.style.display;
+ if ( show ) {
+
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if ( !values[ index ] && display === "none" ) {
+ elem.style.display = "";
+ }
+
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if ( elem.style.display === "" && isHidden( elem ) ) {
+ values[ index ] =
+ jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
+ }
+ } else {
+ hidden = isHidden( elem );
+
+ if ( display && display !== "none" || !hidden ) {
+ jQuery._data(
+ elem,
+ "olddisplay",
+ hidden ? display : jQuery.css( elem, "display" )
+ );
+ }
+ }
+ }
+
+ // Set the display of most of the elements in a second loop
+ // to avoid the constant reflow
+ for ( index = 0; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
+ elem.style.display = show ? values[ index ] || "" : "none";
+ }
+ }
+
+ return elements;
+}
+
+function setPositiveNumber( elem, value, subtract ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+
+ // Guard against undefined "subtract", e.g., when used as in cssHooks
+ Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
+ value;
+}
+
+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
+ var i = extra === ( isBorderBox ? "border" : "content" ) ?
+
+ // If we already have the right measurement, avoid augmentation
+ 4 :
+
+ // Otherwise initialize for horizontal or vertical properties
+ name === "width" ? 1 : 0,
+
+ val = 0;
+
+ for ( ; i < 4; i += 2 ) {
+
+ // both box models exclude margin, so add it if we want it
+ if ( extra === "margin" ) {
+ val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
+ }
+
+ if ( isBorderBox ) {
+
+ // border-box includes padding, so remove it if we want content
+ if ( extra === "content" ) {
+ val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+ }
+
+ // at this point, extra isn't border nor margin, so remove border
+ if ( extra !== "margin" ) {
+ val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ } else {
+
+ // at this point, extra isn't content, so add padding
+ val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+ // at this point, extra isn't content nor padding, so add border
+ if ( extra !== "padding" ) {
+ val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ }
+ }
+
+ return val;
+}
+
+function getWidthOrHeight( elem, name, extra ) {
+
+ // Start with offset property, which is equivalent to the border-box value
+ var valueIsBorderBox = true,
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+ styles = getStyles( elem ),
+ isBorderBox = support.boxSizing &&
+ jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
+
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if ( val <= 0 || val == null ) {
+
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS( elem, name, styles );
+ if ( val < 0 || val == null ) {
+ val = elem.style[ name ];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test( val ) ) {
+ return val;
+ }
+
+ // we need the check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox &&
+ ( support.boxSizingReliable() || val === elem.style[ name ] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat( val ) || 0;
+ }
+
+ // use the active box-sizing model to add/subtract irrelevant styles
+ return ( val +
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox,
+ styles
+ )
+ ) + "px";
+}
+
+jQuery.extend( {
+
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function( elem, computed ) {
+ if ( computed ) {
+
+ // We should always get a number back from opacity
+ var ret = curCSS( elem, "opacity" );
+ return ret === "" ? "1" : ret;
+ }
+ }
+ }
+ },
+
+ // Don't automatically add "px" to these possibly-unitless properties
+ cssNumber: {
+ "animationIterationCount": true,
+ "columnCount": true,
+ "fillOpacity": true,
+ "flexGrow": true,
+ "flexShrink": true,
+ "fontWeight": true,
+ "lineHeight": true,
+ "opacity": true,
+ "order": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {
+
+ // normalize float css property
+ "float": support.cssFloat ? "cssFloat" : "styleFloat"
+ },
+
+ // Get and set the style property on a DOM Node
+ style: function( elem, name, value, extra ) {
+
+ // Don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = jQuery.camelCase( name ),
+ style = elem.style;
+
+ name = jQuery.cssProps[ origName ] ||
+ ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // Check if we're setting a value
+ if ( value !== undefined ) {
+ type = typeof value;
+
+ // Convert "+=" or "-=" to relative numbers (#7345)
+ if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
+ value = adjustCSS( elem, name, ret );
+
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that null and NaN values aren't set. See: #7116
+ if ( value == null || value !== value ) {
+ return;
+ }
+
+ // If a number was passed in, add the unit (except for certain CSS properties)
+ if ( type === "number" ) {
+ value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
+ }
+
+ // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
+ // but it would mean to define eight
+ // (for every problematic property) identical functions
+ if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
+ style[ name ] = "inherit";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if ( !hooks || !( "set" in hooks ) ||
+ ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
+
+ // Support: IE
+ // Swallow errors from 'invalid' CSS values (#5509)
+ try {
+ style[ name ] = value;
+ } catch ( e ) {}
+ }
+
+ } else {
+
+ // If a hook was provided get the non-computed value from there
+ if ( hooks && "get" in hooks &&
+ ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
+
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[ name ];
+ }
+ },
+
+ css: function( elem, name, extra, styles ) {
+ var num, val, hooks,
+ origName = jQuery.camelCase( name );
+
+ // Make sure that we're working with the right name
+ name = jQuery.cssProps[ origName ] ||
+ ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // If a hook was provided get the computed value from there
+ if ( hooks && "get" in hooks ) {
+ val = hooks.get( elem, true, extra );
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if ( val === undefined ) {
+ val = curCSS( elem, name, styles );
+ }
+
+ //convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
+ // Return, converting to number if forced or a qualifier was provided and val looks numeric
+ if ( extra === "" || extra ) {
+ num = parseFloat( val );
+ return extra === true || isFinite( num ) ? num || 0 : val;
+ }
+ return val;
+ }
+} );
+
+jQuery.each( [ "height", "width" ], function( i, name ) {
+ jQuery.cssHooks[ name ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+
+ // certain elements can have dimension info if we invisibly show them
+ // however, it must have a current display style that would benefit from this
+ return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
+ elem.offsetWidth === 0 ?
+ swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, name, extra );
+ } ) :
+ getWidthOrHeight( elem, name, extra );
+ }
+ },
+
+ set: function( elem, value, extra ) {
+ var styles = extra && getStyles( elem );
+ return setPositiveNumber( elem, value, extra ?
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra,
+ support.boxSizing &&
+ jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+ styles
+ ) : 0
+ );
+ }
+ };
+} );
+
+if ( !support.opacity ) {
+ jQuery.cssHooks.opacity = {
+ get: function( elem, computed ) {
+
+ // IE uses filters for opacity
+ return ropacity.test( ( computed && elem.currentStyle ?
+ elem.currentStyle.filter :
+ elem.style.filter ) || "" ) ?
+ ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function( elem, value ) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist -
+ // attempt to remove filter attribute #6652
+ // if value === "", then remove inline opacity #12685
+ if ( ( value >= 1 || value === "" ) &&
+ jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
+ style.removeAttribute ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute( "filter" );
+
+ // if there is no filter style applied in a css rule
+ // or unset inline opacity, we are done
+ if ( value === "" || currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test( filter ) ?
+ filter.replace( ralpha, opacity ) :
+ filter + " " + opacity;
+ }
+ };
+}
+
+jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
+ function( elem, computed ) {
+ if ( computed ) {
+ return swap( elem, { "display": "inline-block" },
+ curCSS, [ elem, "marginRight" ] );
+ }
+ }
+);
+
+jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
+ function( elem, computed ) {
+ if ( computed ) {
+ return (
+ parseFloat( curCSS( elem, "marginLeft" ) ) ||
+
+ // Support: IE<=11+
+ // Running getBoundingClientRect on a disconnected node in IE throws an error
+ // Support: IE8 only
+ // getClientRects() errors on disconnected elems
+ ( jQuery.contains( elem.ownerDocument, elem ) ?
+ elem.getBoundingClientRect().left -
+ swap( elem, { marginLeft: 0 }, function() {
+ return elem.getBoundingClientRect().left;
+ } ) :
+ 0
+ )
+ ) + "px";
+ }
+ }
+);
+
+// These hooks are used by animate to expand properties
+jQuery.each( {
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i = 0,
+ expanded = {},
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split( " " ) : [ value ];
+
+ for ( ; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
+} );
+
+jQuery.fn.extend( {
+ css: function( name, value ) {
+ return access( this, function( elem, name, value ) {
+ var styles, len,
+ map = {},
+ i = 0;
+
+ if ( jQuery.isArray( name ) ) {
+ styles = getStyles( elem );
+ len = name.length;
+
+ for ( ; i < len; i++ ) {
+ map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
+ }
+
+ return map;
+ }
+
+ return value !== undefined ?
+ jQuery.style( elem, name, value ) :
+ jQuery.css( elem, name );
+ }, name, value, arguments.length > 1 );
+ },
+ show: function() {
+ return showHide( this, true );
+ },
+ hide: function() {
+ return showHide( this );
+ },
+ toggle: function( state ) {
+ if ( typeof state === "boolean" ) {
+ return state ? this.show() : this.hide();
+ }
+
+ return this.each( function() {
+ if ( isHidden( this ) ) {
+ jQuery( this ).show();
+ } else {
+ jQuery( this ).hide();
+ }
+ } );
+ }
+} );
+
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || jQuery.easing._default;
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ // Use a property on the element directly when it is not a DOM element,
+ // or when there is no matching style property that exists.
+ if ( tween.elem.nodeType !== 1 ||
+ tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, "" );
+
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.nodeType === 1 &&
+ ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
+ jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Support: IE <=9
+// Panic based approach to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p * Math.PI ) / 2;
+ },
+ _default: "swing"
+};
+
+jQuery.fx = Tween.prototype.init;
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+
+
+
+var
+ fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rrun = /queueHooks$/;
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ window.setTimeout( function() {
+ fxNow = undefined;
+ } );
+ return ( fxNow = jQuery.now() );
+}
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ attrs = { height: type },
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth ? 1 : 0;
+ for ( ; i < 4 ; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+function createTween( value, prop, animation ) {
+ var tween,
+ collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
+
+ // we're done with this property
+ return tween;
+ }
+ }
+}
+
+function defaultPrefilter( elem, props, opts ) {
+ /* jshint validthis: true */
+ var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
+ anim = this,
+ orig = {},
+ style = elem.style,
+ hidden = elem.nodeType && isHidden( elem ),
+ dataShow = jQuery._data( elem, "fxshow" );
+
+ // handle queue: false promises
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always( function() {
+
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always( function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ } );
+ } );
+ }
+
+ // height/width overflow pass
+ if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ display = jQuery.css( elem, "display" );
+
+ // Test default display if display is currently "none"
+ checkDisplay = display === "none" ?
+ jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
+
+ if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
+ style.display = "inline-block";
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ if ( !support.shrinkWrapBlocks() ) {
+ anim.always( function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ } );
+ }
+ }
+
+ // show/hide pass
+ for ( prop in props ) {
+ value = props[ prop ];
+ if ( rfxtypes.exec( value ) ) {
+ delete props[ prop ];
+ toggle = toggle || value === "toggle";
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+
+ // If there is dataShow left over from a stopped hide or show
+ // and we are going to proceed with show, we should pretend to be hidden
+ if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
+ hidden = true;
+ } else {
+ continue;
+ }
+ }
+ orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
+
+ // Any non-fx value stops us from restoring the original display value
+ } else {
+ display = undefined;
+ }
+ }
+
+ if ( !jQuery.isEmptyObject( orig ) ) {
+ if ( dataShow ) {
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+ } else {
+ dataShow = jQuery._data( elem, "fxshow", {} );
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
+ if ( hidden ) {
+ jQuery( elem ).show();
+ } else {
+ anim.done( function() {
+ jQuery( elem ).hide();
+ } );
+ }
+ anim.done( function() {
+ var prop;
+ jQuery._removeData( elem, "fxshow" );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ } );
+ for ( prop in orig ) {
+ tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
+
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = tween.start;
+ if ( hidden ) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+
+ // If this is a noop like .hide().hide(), restore an overwritten display value
+ } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
+ style.display = display;
+ }
+}
+
+function propFilter( props, specialEasing ) {
+ var index, name, easing, value, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = jQuery.camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( jQuery.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ stopped,
+ index = 0,
+ length = Animation.prefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ } ),
+ tick = function() {
+ if ( stopped ) {
+ return false;
+ }
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+
+ // Support: Android 2.3
+ // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ] );
+
+ if ( percent < 1 && length ) {
+ return remaining;
+ } else {
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ }
+ },
+ animation = deferred.promise( {
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, {
+ specialEasing: {},
+ easing: jQuery.easing._default
+ }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+ if ( stopped ) {
+ return this;
+ }
+ stopped = true;
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if ( gotoEnd ) {
+ deferred.notifyWith( elem, [ animation, 1, 0 ] );
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ } ),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length ; index++ ) {
+ result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ if ( jQuery.isFunction( result.stop ) ) {
+ jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
+ jQuery.proxy( result.stop, result );
+ }
+ return result;
+ }
+ }
+
+ jQuery.map( props, createTween, animation );
+
+ if ( jQuery.isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ elem: elem,
+ anim: animation,
+ queue: animation.opts.queue
+ } )
+ );
+
+ // attach callbacks from options
+ return animation.progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweeners: {
+ "*": [ function( prop, value ) {
+ var tween = this.createTween( prop, value );
+ adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
+ return tween;
+ } ]
+ },
+
+ tweener: function( props, callback ) {
+ if ( jQuery.isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.match( rnotwhite );
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length ; index++ ) {
+ prop = props[ index ];
+ Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
+ Animation.tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilters: [ defaultPrefilter ],
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ Animation.prefilters.unshift( callback );
+ } else {
+ Animation.prefilters.push( callback );
+ }
+ }
+} );
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ opt.duration in jQuery.fx.speeds ?
+ jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.fn.extend( {
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+ // animate to the value specified
+ .end().animate( { opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+ // Empty animations, or finishing resolves immediately
+ if ( empty || jQuery._data( this, "finish" ) ) {
+ anim.stop( true );
+ }
+ };
+ doAnimation.finish = doAnimation;
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue && type !== false ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each( function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this &&
+ ( type == null || timers[ index ].queue === type ) ) {
+
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ } );
+ },
+ finish: function( type ) {
+ if ( type !== false ) {
+ type = type || "fx";
+ }
+ return this.each( function() {
+ var index,
+ data = jQuery._data( this ),
+ queue = data[ type + "queue" ],
+ hooks = data[ type + "queueHooks" ],
+ timers = jQuery.timers,
+ length = queue ? queue.length : 0;
+
+ // enable finishing flag on private data
+ data.finish = true;
+
+ // empty the queue first
+ jQuery.queue( this, type, [] );
+
+ if ( hooks && hooks.stop ) {
+ hooks.stop.call( this, true );
+ }
+
+ // look for any active animations, and finish them
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+ timers[ index ].anim.stop( true );
+ timers.splice( index, 1 );
+ }
+ }
+
+ // look for any animations in the old queue and finish them
+ for ( index = 0; index < length; index++ ) {
+ if ( queue[ index ] && queue[ index ].finish ) {
+ queue[ index ].finish.call( this );
+ }
+ }
+
+ // turn off finishing flag
+ delete data.finish;
+ } );
+ }
+} );
+
+jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+} );
+
+// Generate shortcuts for custom animations
+jQuery.each( {
+ slideDown: genFx( "show" ),
+ slideUp: genFx( "hide" ),
+ slideToggle: genFx( "toggle" ),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+} );
+
+jQuery.timers = [];
+jQuery.fx.tick = function() {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ fxNow = jQuery.now();
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+
+ // Checks the timer has not already been removed
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+ jQuery.timers.push( timer );
+ if ( timer() ) {
+ jQuery.fx.start();
+ } else {
+ jQuery.timers.pop();
+ }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.start = function() {
+ if ( !timerId ) {
+ timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
+ }
+};
+
+jQuery.fx.stop = function() {
+ window.clearInterval( timerId );
+ timerId = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+
+ // Default speed
+ _default: 400
+};
+
+
+// Based off of the plugin by Clint Helfers, with permission.
+// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
+jQuery.fn.delay = function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = window.setTimeout( next, time );
+ hooks.stop = function() {
+ window.clearTimeout( timeout );
+ };
+ } );
+};
+
+
+( function() {
+ var a,
+ input = document.createElement( "input" ),
+ div = document.createElement( "div" ),
+ select = document.createElement( "select" ),
+ opt = select.appendChild( document.createElement( "option" ) );
+
+ // Setup
+ div = document.createElement( "div" );
+ div.setAttribute( "className", "t" );
+ div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+ a = div.getElementsByTagName( "a" )[ 0 ];
+
+ // Support: Windows Web Apps (WWA)
+ // `type` must use .setAttribute for WWA (#14901)
+ input.setAttribute( "type", "checkbox" );
+ div.appendChild( input );
+
+ a = div.getElementsByTagName( "a" )[ 0 ];
+
+ // First batch of tests.
+ a.style.cssText = "top:1px";
+
+ // Test setAttribute on camelCase class.
+ // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ support.getSetAttribute = div.className !== "t";
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ support.style = /top/.test( a.getAttribute( "style" ) );
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ support.hrefNormalized = a.getAttribute( "href" ) === "/a";
+
+ // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
+ support.checkOn = !!input.value;
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ support.optSelected = opt.selected;
+
+ // Tests for enctype support on a form (#6743)
+ support.enctype = !!document.createElement( "form" ).enctype;
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as disabled)
+ select.disabled = true;
+ support.optDisabled = !opt.disabled;
+
+ // Support: IE8 only
+ // Check if we can trust getAttribute("value")
+ input = document.createElement( "input" );
+ input.setAttribute( "value", "" );
+ support.input = input.getAttribute( "value" ) === "";
+
+ // Check if an input maintains its value after becoming a radio
+ input.value = "t";
+ input.setAttribute( "type", "radio" );
+ support.radioValue = input.value === "t";
+} )();
+
+
+var rreturn = /\r/g,
+ rspaces = /[\x20\t\r\n\f]+/g;
+
+jQuery.fn.extend( {
+ val: function( value ) {
+ var hooks, ret, isFunction,
+ elem = this[ 0 ];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] ||
+ jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if (
+ hooks &&
+ "get" in hooks &&
+ ( ret = hooks.get( elem, "value" ) ) !== undefined
+ ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+
+ // handle most common string cases
+ ret.replace( rreturn, "" ) :
+
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction( value );
+
+ return this.each( function( i ) {
+ var val;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, jQuery( this ).val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map( val, function( value ) {
+ return value == null ? "" : value + "";
+ } );
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ } );
+ }
+} );
+
+jQuery.extend( {
+ valHooks: {
+ option: {
+ get: function( elem ) {
+ var val = jQuery.find.attr( elem, "value" );
+ return val != null ?
+ val :
+
+ // Support: IE10-11+
+ // option.text throws exceptions (#14686, #14858)
+ // Strip and collapse whitespace
+ // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
+ jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, option,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
+
+ // Loop through all the selected options
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // oldIE doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+
+ // Don't return options that are disabled or in a disabled optgroup
+ ( support.optDisabled ?
+ !option.disabled :
+ option.getAttribute( "disabled" ) === null ) &&
+ ( !option.parentNode.disabled ||
+ !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var optionSet, option,
+ options = elem.options,
+ values = jQuery.makeArray( value ),
+ i = options.length;
+
+ while ( i-- ) {
+ option = options[ i ];
+
+ if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {
+
+ // Support: IE6
+ // When new option element is added to select box we need to
+ // force reflow of newly added node in order to workaround delay
+ // of initialization properties
+ try {
+ option.selected = optionSet = true;
+
+ } catch ( _ ) {
+
+ // Will be executed only in IE6
+ option.scrollHeight;
+ }
+
+ } else {
+ option.selected = false;
+ }
+ }
+
+ // Force browsers to behave consistently when non-matching value is set
+ if ( !optionSet ) {
+ elem.selectedIndex = -1;
+ }
+
+ return options;
+ }
+ }
+ }
+} );
+
+// Radios and checkboxes getter/setter
+jQuery.each( [ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
+ }
+ }
+ };
+ if ( !support.checkOn ) {
+ jQuery.valHooks[ this ].get = function( elem ) {
+ return elem.getAttribute( "value" ) === null ? "on" : elem.value;
+ };
+ }
+} );
+
+
+
+
+var nodeHook, boolHook,
+ attrHandle = jQuery.expr.attrHandle,
+ ruseDefault = /^(?:checked|selected)$/i,
+ getSetAttribute = support.getSetAttribute,
+ getSetInput = support.input;
+
+jQuery.fn.extend( {
+ attr: function( name, value ) {
+ return access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each( function() {
+ jQuery.removeAttr( this, name );
+ } );
+ }
+} );
+
+jQuery.extend( {
+ attr: function( elem, name, value ) {
+ var ret, hooks,
+ nType = elem.nodeType;
+
+ // Don't get/set attributes on text, comment and attribute nodes
+ if ( nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === "undefined" ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[ name ] ||
+ ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
+ }
+
+ if ( value !== undefined ) {
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+ return;
+ }
+
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+ return ret;
+ }
+
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+ return ret;
+ }
+
+ ret = jQuery.find.attr( elem, name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ? undefined : ret;
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ if ( !support.radioValue && value === "radio" &&
+ jQuery.nodeName( elem, "input" ) ) {
+
+ // Setting the type on a radio button after the value resets the value in IE8-9
+ // Reset value to default in case type is set after value during creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var name, propName,
+ i = 0,
+ attrNames = value && value.match( rnotwhite );
+
+ if ( attrNames && elem.nodeType === 1 ) {
+ while ( ( name = attrNames[ i++ ] ) ) {
+ propName = jQuery.propFix[ name ] || name;
+
+ // Boolean attributes get special treatment (#10870)
+ if ( jQuery.expr.match.bool.test( name ) ) {
+
+ // Set corresponding property to false
+ if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+ elem[ propName ] = false;
+
+ // Support: IE<9
+ // Also clear defaultChecked/defaultSelected (if appropriate)
+ } else {
+ elem[ jQuery.camelCase( "default-" + name ) ] =
+ elem[ propName ] = false;
+ }
+
+ // See #9699 for explanation of this approach (setting first, then removal)
+ } else {
+ jQuery.attr( elem, name, "" );
+ }
+
+ elem.removeAttribute( getSetAttribute ? name : propName );
+ }
+ }
+ }
+} );
+
+// Hooks for boolean attributes
+boolHook = {
+ set: function( elem, value, name ) {
+ if ( value === false ) {
+
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+
+ // IE<8 needs the *property* name
+ elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
+
+ } else {
+
+ // Support: IE<9
+ // Use defaultChecked and defaultSelected for oldIE
+ elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
+ }
+ return name;
+ }
+};
+
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
+ var getter = attrHandle[ name ] || jQuery.find.attr;
+
+ if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+ attrHandle[ name ] = function( elem, name, isXML ) {
+ var ret, handle;
+ if ( !isXML ) {
+
+ // Avoid an infinite loop by temporarily removing this function from the getter
+ handle = attrHandle[ name ];
+ attrHandle[ name ] = ret;
+ ret = getter( elem, name, isXML ) != null ?
+ name.toLowerCase() :
+ null;
+ attrHandle[ name ] = handle;
+ }
+ return ret;
+ };
+ } else {
+ attrHandle[ name ] = function( elem, name, isXML ) {
+ if ( !isXML ) {
+ return elem[ jQuery.camelCase( "default-" + name ) ] ?
+ name.toLowerCase() :
+ null;
+ }
+ };
+ }
+} );
+
+// fix oldIE attroperties
+if ( !getSetInput || !getSetAttribute ) {
+ jQuery.attrHooks.value = {
+ set: function( elem, value, name ) {
+ if ( jQuery.nodeName( elem, "input" ) ) {
+
+ // Does not return so that setAttribute is also used
+ elem.defaultValue = value;
+ } else {
+
+ // Use nodeHook if defined (#1954); otherwise setAttribute is fine
+ return nodeHook && nodeHook.set( elem, value, name );
+ }
+ }
+ };
+}
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = {
+ set: function( elem, value, name ) {
+
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode( name );
+ if ( !ret ) {
+ elem.setAttributeNode(
+ ( ret = elem.ownerDocument.createAttribute( name ) )
+ );
+ }
+
+ ret.value = value += "";
+
+ // Break association with cloned elements by also using setAttribute (#9646)
+ if ( name === "value" || value === elem.getAttribute( name ) ) {
+ return value;
+ }
+ }
+ };
+
+ // Some attributes are constructed with empty-string values when not defined
+ attrHandle.id = attrHandle.name = attrHandle.coords =
+ function( elem, name, isXML ) {
+ var ret;
+ if ( !isXML ) {
+ return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
+ ret.value :
+ null;
+ }
+ };
+
+ // Fixing value retrieval on a button requires this module
+ jQuery.valHooks.button = {
+ get: function( elem, name ) {
+ var ret = elem.getAttributeNode( name );
+ if ( ret && ret.specified ) {
+ return ret.value;
+ }
+ },
+ set: nodeHook.set
+ };
+
+ // Set contenteditable to false on removals(#10429)
+ // Setting to empty string throws an error as an invalid value
+ jQuery.attrHooks.contenteditable = {
+ set: function( elem, value, name ) {
+ nodeHook.set( elem, value === "" ? false : value, name );
+ }
+ };
+
+ // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+ // This is for removals
+ jQuery.each( [ "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = {
+ set: function( elem, value ) {
+ if ( value === "" ) {
+ elem.setAttribute( name, "auto" );
+ return value;
+ }
+ }
+ };
+ } );
+}
+
+if ( !support.style ) {
+ jQuery.attrHooks.style = {
+ get: function( elem ) {
+
+ // Return undefined in the case of empty string
+ // Note: IE uppercases css property names, but if we were to .toLowerCase()
+ // .cssText, that would destroy case sensitivity in URL's, like in "background"
+ return elem.style.cssText || undefined;
+ },
+ set: function( elem, value ) {
+ return ( elem.style.cssText = value + "" );
+ }
+ };
+}
+
+
+
+
+var rfocusable = /^(?:input|select|textarea|button|object)$/i,
+ rclickable = /^(?:a|area)$/i;
+
+jQuery.fn.extend( {
+ prop: function( name, value ) {
+ return access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ name = jQuery.propFix[ name ] || name;
+ return this.each( function() {
+
+ // try/catch handles cases where IE balks (such as removing a property on window)
+ try {
+ this[ name ] = undefined;
+ delete this[ name ];
+ } catch ( e ) {}
+ } );
+ }
+} );
+
+jQuery.extend( {
+ prop: function( elem, name, value ) {
+ var ret, hooks,
+ nType = elem.nodeType;
+
+ // Don't get/set properties on text, comment and attribute nodes
+ if ( nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+ return ret;
+ }
+
+ return ( elem[ name ] = value );
+ }
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+ return ret;
+ }
+
+ return elem[ name ];
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+
+ // elem.tabIndex doesn't always return the
+ // correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ // Use proper attribute retrieval(#12072)
+ var tabindex = jQuery.find.attr( elem, "tabindex" );
+
+ return tabindex ?
+ parseInt( tabindex, 10 ) :
+ rfocusable.test( elem.nodeName ) ||
+ rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ -1;
+ }
+ }
+ },
+
+ propFix: {
+ "for": "htmlFor",
+ "class": "className"
+ }
+} );
+
+// Some attributes require a special call on IE
+// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !support.hrefNormalized ) {
+
+ // href/src property should get the full normalized URL (#10299/#12915)
+ jQuery.each( [ "href", "src" ], function( i, name ) {
+ jQuery.propHooks[ name ] = {
+ get: function( elem ) {
+ return elem.getAttribute( name, 4 );
+ }
+ };
+ } );
+}
+
+// Support: Safari, IE9+
+// Accessing the selectedIndex property
+// forces the browser to respect setting selected
+// on the option
+// The getter ensures a default option is selected
+// when in an optgroup
+if ( !support.optSelected ) {
+ jQuery.propHooks.selected = {
+ get: function( elem ) {
+ var parent = elem.parentNode;
+
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ return null;
+ },
+ set: function( elem ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+ };
+}
+
+jQuery.each( [
+ "tabIndex",
+ "readOnly",
+ "maxLength",
+ "cellSpacing",
+ "cellPadding",
+ "rowSpan",
+ "colSpan",
+ "useMap",
+ "frameBorder",
+ "contentEditable"
+], function() {
+ jQuery.propFix[ this.toLowerCase() ] = this;
+} );
+
+// IE6/7 call enctype encoding
+if ( !support.enctype ) {
+ jQuery.propFix.enctype = "encoding";
+}
+
+
+
+
+var rclass = /[\t\r\n\f]/g;
+
+function getClass( elem ) {
+ return jQuery.attr( elem, "class" ) || "";
+}
+
+jQuery.fn.extend( {
+ addClass: function( value ) {
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each( function( j ) {
+ jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
+ } );
+ }
+
+ if ( typeof value === "string" && value ) {
+ classes = value.match( rnotwhite ) || [];
+
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+ cur = elem.nodeType === 1 &&
+ ( " " + curValue + " " ).replace( rclass, " " );
+
+ if ( cur ) {
+ j = 0;
+ while ( ( clazz = classes[ j++ ] ) ) {
+ if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+ cur += clazz + " ";
+ }
+ }
+
+ // only assign if different to avoid unneeded rendering.
+ finalValue = jQuery.trim( cur );
+ if ( curValue !== finalValue ) {
+ jQuery.attr( elem, "class", finalValue );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each( function( j ) {
+ jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
+ } );
+ }
+
+ if ( !arguments.length ) {
+ return this.attr( "class", "" );
+ }
+
+ if ( typeof value === "string" && value ) {
+ classes = value.match( rnotwhite ) || [];
+
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+
+ // This expression is here for better compressibility (see addClass)
+ cur = elem.nodeType === 1 &&
+ ( " " + curValue + " " ).replace( rclass, " " );
+
+ if ( cur ) {
+ j = 0;
+ while ( ( clazz = classes[ j++ ] ) ) {
+
+ // Remove *all* instances
+ while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
+ cur = cur.replace( " " + clazz + " ", " " );
+ }
+ }
+
+ // Only assign if different to avoid unneeded rendering.
+ finalValue = jQuery.trim( cur );
+ if ( curValue !== finalValue ) {
+ jQuery.attr( elem, "class", finalValue );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value;
+
+ if ( typeof stateVal === "boolean" && type === "string" ) {
+ return stateVal ? this.addClass( value ) : this.removeClass( value );
+ }
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each( function( i ) {
+ jQuery( this ).toggleClass(
+ value.call( this, i, getClass( this ), stateVal ),
+ stateVal
+ );
+ } );
+ }
+
+ return this.each( function() {
+ var className, i, self, classNames;
+
+ if ( type === "string" ) {
+
+ // Toggle individual class names
+ i = 0;
+ self = jQuery( this );
+ classNames = value.match( rnotwhite ) || [];
+
+ while ( ( className = classNames[ i++ ] ) ) {
+
+ // Check each className given, space separated list
+ if ( self.hasClass( className ) ) {
+ self.removeClass( className );
+ } else {
+ self.addClass( className );
+ }
+ }
+
+ // Toggle whole class name
+ } else if ( value === undefined || type === "boolean" ) {
+ className = getClass( this );
+ if ( className ) {
+
+ // store className if set
+ jQuery._data( this, "__className__", className );
+ }
+
+ // If the element has a class name or if we're passed "false",
+ // then remove the whole classname (if there was one, the above saved it).
+ // Otherwise bring back whatever was previously saved (if anything),
+ // falling back to the empty string if nothing was stored.
+ jQuery.attr( this, "class",
+ className || value === false ?
+ "" :
+ jQuery._data( this, "__className__" ) || ""
+ );
+ }
+ } );
+ },
+
+ hasClass: function( selector ) {
+ var className, elem,
+ i = 0;
+
+ className = " " + selector + " ";
+ while ( ( elem = this[ i++ ] ) ) {
+ if ( elem.nodeType === 1 &&
+ ( " " + getClass( elem ) + " " ).replace( rclass, " " )
+ .indexOf( className ) > -1
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+} );
+
+
+
+
+// Return jQuery for attributes-only inclusion
+
+
+jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
+ function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+} );
+
+jQuery.fn.extend( {
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+} );
+
+
+var location = window.location;
+
+var nonce = jQuery.now();
+
+var rquery = ( /\?/ );
+
+
+
+var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
+
+jQuery.parseJSON = function( data ) {
+
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+
+ // Support: Android 2.3
+ // Workaround failure to string-cast null input
+ return window.JSON.parse( data + "" );
+ }
+
+ var requireNonComma,
+ depth = null,
+ str = jQuery.trim( data + "" );
+
+ // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
+ // after removing valid tokens
+ return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
+
+ // Force termination if we see a misplaced comma
+ if ( requireNonComma && comma ) {
+ depth = 0;
+ }
+
+ // Perform no more replacements after returning to outermost depth
+ if ( depth === 0 ) {
+ return token;
+ }
+
+ // Commas must not follow "[", "{", or ","
+ requireNonComma = open || comma;
+
+ // Determine new depth
+ // array/object open ("[" or "{"): depth += true - false (increment)
+ // array/object close ("]" or "}"): depth += false - true (decrement)
+ // other cases ("," or primitive): depth += true - true (numeric cast)
+ depth += !close - !open;
+
+ // Remove this token
+ return "";
+ } ) ) ?
+ ( Function( "return " + str ) )() :
+ jQuery.error( "Invalid JSON: " + data );
+};
+
+
+// Cross-browser xml parsing
+jQuery.parseXML = function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ try {
+ if ( window.DOMParser ) { // Standard
+ tmp = new window.DOMParser();
+ xml = tmp.parseFromString( data, "text/xml" );
+ } else { // IE
+ xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
+ xml.async = "false";
+ xml.loadXML( data );
+ }
+ } catch ( e ) {
+ xml = undefined;
+ }
+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+};
+
+
+var
+ rhash = /#.*$/,
+ rts = /([?&])_=[^&]*/,
+
+ // IE leaves an \r character at EOL
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
+
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+ rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = "*/".concat( "*" ),
+
+ // Document location
+ ajaxLocation = location.href,
+
+ // Segment location into parts
+ ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function( dataTypeExpression, func ) {
+
+ if ( typeof dataTypeExpression !== "string" ) {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType,
+ i = 0,
+ dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
+
+ if ( jQuery.isFunction( func ) ) {
+
+ // For each dataType in the dataTypeExpression
+ while ( ( dataType = dataTypes[ i++ ] ) ) {
+
+ // Prepend if requested
+ if ( dataType.charAt( 0 ) === "+" ) {
+ dataType = dataType.slice( 1 ) || "*";
+ ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
+
+ // Otherwise append
+ } else {
+ ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
+ }
+ }
+ }
+ };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
+
+ var inspected = {},
+ seekingTransport = ( structure === transports );
+
+ function inspect( dataType ) {
+ var selected;
+ inspected[ dataType ] = true;
+ jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
+ var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
+ if ( typeof dataTypeOrTransport === "string" &&
+ !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
+
+ options.dataTypes.unshift( dataTypeOrTransport );
+ inspect( dataTypeOrTransport );
+ return false;
+ } else if ( seekingTransport ) {
+ return !( selected = dataTypeOrTransport );
+ }
+ } );
+ return selected;
+ }
+
+ return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+ var deep, key,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+ for ( key in src ) {
+ if ( src[ key ] !== undefined ) {
+ ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
+ }
+ }
+ if ( deep ) {
+ jQuery.extend( true, target, deep );
+ }
+
+ return target;
+}
+
+/* Handles responses to an ajax request:
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+ var firstDataType, ct, finalDataType, type,
+ contents = s.contents,
+ dataTypes = s.dataTypes;
+
+ // Remove auto dataType and get content-type in the process
+ while ( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+/* Chain conversions given the request and the original response
+ * Also sets the responseXXX fields on the jqXHR instance
+ */
+function ajaxConvert( s, response, jqXHR, isSuccess ) {
+ var conv2, current, conv, tmp, prev,
+ converters = {},
+
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice();
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ current = dataTypes.shift();
+
+ // Convert to each sequential dataType
+ while ( current ) {
+
+ if ( s.responseFields[ current ] ) {
+ jqXHR[ s.responseFields[ current ] ] = response;
+ }
+
+ // Apply the dataFilter if provided
+ if ( !prev && isSuccess && s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ prev = current;
+ current = dataTypes.shift();
+
+ if ( current ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current === "*" ) {
+
+ current = prev;
+
+ // Convert response if prev dataType is non-auto and differs from current
+ } else if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split( " " );
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.unshift( tmp[ 1 ] );
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return {
+ state: "parsererror",
+ error: conv ? e : "No conversion from " + prev + " to " + current
+ };
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return { state: "success", data: response };
+}
+
+jQuery.extend( {
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ type: "GET",
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+ global: true,
+ processData: true,
+ async: true,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ "*": allTypes,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+
+ contents: {
+ xml: /\bxml\b/,
+ html: /\bhtml/,
+ json: /\bjson\b/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText",
+ json: "responseJSON"
+ },
+
+ // Data converters
+ // Keys separate source (or catchall "*") and destination types with a single space
+ converters: {
+
+ // Convert anything to text
+ "* text": String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ url: true,
+ context: true
+ }
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ return settings ?
+
+ // Building a settings object
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+ // Extending ajaxSettings
+ ajaxExtend( jQuery.ajaxSettings, target );
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var
+
+ // Cross-domain detection vars
+ parts,
+
+ // Loop variable
+ i,
+
+ // URL without anti-cache param
+ cacheURL,
+
+ // Response headers as string
+ responseHeadersString,
+
+ // timeout handle
+ timeoutTimer,
+
+ // To know if global events are to be dispatched
+ fireGlobals,
+
+ transport,
+
+ // Response headers
+ responseHeaders,
+
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+
+ // Callbacks context
+ callbackContext = s.context || s,
+
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
+ globalEventContext = s.context &&
+ ( callbackContext.nodeType || callbackContext.jquery ) ?
+ jQuery( callbackContext ) :
+ jQuery.event,
+
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks( "once memory" ),
+
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+
+ // The jqXHR state
+ state = 0,
+
+ // Default abort message
+ strAbort = "canceled",
+
+ // Fake xhr
+ jqXHR = {
+ readyState: 0,
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( state === 2 ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
+ responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() ];
+ }
+ return match == null ? null : match;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ var lname = name.toLowerCase();
+ if ( !state ) {
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Status-dependent callbacks
+ statusCode: function( map ) {
+ var code;
+ if ( map ) {
+ if ( state < 2 ) {
+ for ( code in map ) {
+
+ // Lazy-add the new callback in a way that preserves old ones
+ statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+ }
+ } else {
+
+ // Execute the appropriate callbacks
+ jqXHR.always( map[ jqXHR.status ] );
+ }
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ var finalText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( finalText );
+ }
+ done( 0, finalText );
+ return this;
+ }
+ };
+
+ // Attach deferreds
+ deferred.promise( jqXHR ).complete = completeDeferred.add;
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url || ajaxLocation ) + "" )
+ .replace( rhash, "" )
+ .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+ // Alias method option to type as per ticket #12004
+ s.type = options.method || options.type || s.method || s.type;
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if ( s.crossDomain == null ) {
+ parts = rurl.exec( s.url.toLowerCase() );
+ s.crossDomain = !!( parts &&
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
+ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
+ );
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
+ fireGlobals = jQuery.event && s.global;
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Save the URL in case we're toying with the If-Modified-Since
+ // and/or If-None-Match header later on
+ cacheURL = s.url;
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // If data is available, append data to url
+ if ( s.data ) {
+ cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
+
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Add anti-cache in url if needed
+ if ( s.cache === false ) {
+ s.url = rts.test( cacheURL ) ?
+
+ // If there is already a '_' parameter, set its value
+ cacheURL.replace( rts, "$1_=" + nonce++ ) :
+
+ // Otherwise add one to the end
+ cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
+ }
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+ }
+ if ( jQuery.etag[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
+ s.accepts[ s.dataTypes[ 0 ] ] +
+ ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend &&
+ ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+
+ // Abort if not done already and return
+ return jqXHR.abort();
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+
+ // If request was aborted inside ajaxSend, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = window.setTimeout( function() {
+ jqXHR.abort( "timeout" );
+ }, s.timeout );
+ }
+
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch ( e ) {
+
+ // Propagate exception as error if not done
+ if ( state < 2 ) {
+ done( -1, e );
+
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ // Callback for when everything is done
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if ( state === 2 ) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ window.clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Determine if successful
+ isSuccess = status >= 200 && status < 300 || status === 304;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // Convert no matter what (that way responseXXX fields are always set)
+ response = ajaxConvert( s, response, jqXHR, isSuccess );
+
+ // If successful, handle type chaining
+ if ( isSuccess ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ modified = jqXHR.getResponseHeader( "Last-Modified" );
+ if ( modified ) {
+ jQuery.lastModified[ cacheURL ] = modified;
+ }
+ modified = jqXHR.getResponseHeader( "etag" );
+ if ( modified ) {
+ jQuery.etag[ cacheURL ] = modified;
+ }
+ }
+
+ // if no content
+ if ( status === 204 || s.type === "HEAD" ) {
+ statusText = "nocontent";
+
+ // if not modified
+ } else if ( status === 304 ) {
+ statusText = "notmodified";
+
+ // If we have data, let's convert it
+ } else {
+ statusText = response.state;
+ success = response.data;
+ error = response.error;
+ isSuccess = !error;
+ }
+ } else {
+
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if ( status || !statusText ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ }
+} );
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+
+ // shift arguments if data argument was omitted
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ // The url can be an options object (which then must have .url)
+ return jQuery.ajax( jQuery.extend( {
+ url: url,
+ type: method,
+ dataType: type,
+ data: data,
+ success: callback
+ }, jQuery.isPlainObject( url ) && url ) );
+ };
+} );
+
+
+jQuery._evalUrl = function( url ) {
+ return jQuery.ajax( {
+ url: url,
+
+ // Make this explicit, since user can override this through ajaxSetup (#11264)
+ type: "GET",
+ dataType: "script",
+ cache: true,
+ async: false,
+ global: false,
+ "throws": true
+ } );
+};
+
+
+jQuery.fn.extend( {
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each( function( i ) {
+ jQuery( this ).wrapAll( html.call( this, i ) );
+ } );
+ }
+
+ if ( this[ 0 ] ) {
+
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
+
+ if ( this[ 0 ].parentNode ) {
+ wrap.insertBefore( this[ 0 ] );
+ }
+
+ wrap.map( function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ } ).append( this );
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each( function( i ) {
+ jQuery( this ).wrapInner( html.call( this, i ) );
+ } );
+ }
+
+ return this.each( function() {
+ var self = jQuery( this ),
+ contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ } );
+ },
+
+ wrap: function( html ) {
+ var isFunction = jQuery.isFunction( html );
+
+ return this.each( function( i ) {
+ jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
+ } );
+ },
+
+ unwrap: function() {
+ return this.parent().each( function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ } ).end();
+ }
+} );
+
+
+function getDisplay( elem ) {
+ return elem.style && elem.style.display || jQuery.css( elem, "display" );
+}
+
+function filterHidden( elem ) {
+
+ // Disconnected elements are considered hidden
+ if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
+ return true;
+ }
+ while ( elem && elem.nodeType === 1 ) {
+ if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
+ return true;
+ }
+ elem = elem.parentNode;
+ }
+ return false;
+}
+
+jQuery.expr.filters.hidden = function( elem ) {
+
+ // Support: Opera <= 12.12
+ // Opera reports offsetWidths and offsetHeights less than zero on some elements
+ return support.reliableHiddenOffsets() ?
+ ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
+ !elem.getClientRects().length ) :
+ filterHidden( elem );
+};
+
+jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+};
+
+
+
+
+var r20 = /%20/g,
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+ rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+function buildParams( prefix, obj, traditional, add ) {
+ var name;
+
+ if ( jQuery.isArray( obj ) ) {
+
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional || rbracket.test( prefix ) ) {
+
+ // Treat each array item as a scalar.
+ add( prefix, v );
+
+ } else {
+
+ // Item is non-scalar (array or object), encode its numeric index.
+ buildParams(
+ prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
+ v,
+ traditional,
+ add
+ );
+ }
+ } );
+
+ } else if ( !traditional && jQuery.type( obj ) === "object" ) {
+
+ // Serialize object item.
+ for ( name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
+
+ } else {
+
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+}
+
+// Serialize an array of form elements or a set of
+// key/values into a query string
+jQuery.param = function( a, traditional ) {
+ var prefix,
+ s = [],
+ add = function( key, value ) {
+
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
+ s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+ };
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ } );
+
+ } else {
+
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for ( prefix in a ) {
+ buildParams( prefix, a[ prefix ], traditional, add );
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join( "&" ).replace( r20, "+" );
+};
+
+jQuery.fn.extend( {
+ serialize: function() {
+ return jQuery.param( this.serializeArray() );
+ },
+ serializeArray: function() {
+ return this.map( function() {
+
+ // Can add propHook for "elements" to filter or add form elements
+ var elements = jQuery.prop( this, "elements" );
+ return elements ? jQuery.makeArray( elements ) : this;
+ } )
+ .filter( function() {
+ var type = this.type;
+
+ // Use .is(":disabled") so that fieldset[disabled] works
+ return this.name && !jQuery( this ).is( ":disabled" ) &&
+ rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
+ ( this.checked || !rcheckableType.test( type ) );
+ } )
+ .map( function( i, elem ) {
+ var val = jQuery( this ).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray( val ) ?
+ jQuery.map( val, function( val ) {
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ } ) :
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ } ).get();
+ }
+} );
+
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
+
+ // Support: IE6-IE8
+ function() {
+
+ // XHR cannot access local files, always use ActiveX for that case
+ if ( this.isLocal ) {
+ return createActiveXHR();
+ }
+
+ // Support: IE 9-11
+ // IE seems to error on cross-domain PATCH requests when ActiveX XHR
+ // is used. In IE 9+ always use the native XHR.
+ // Note: this condition won't catch Edge as it doesn't define
+ // document.documentMode but it also doesn't support ActiveX so it won't
+ // reach this code.
+ if ( document.documentMode > 8 ) {
+ return createStandardXHR();
+ }
+
+ // Support: IE<9
+ // oldIE XHR does not support non-RFC2616 methods (#13240)
+ // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
+ // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
+ // Although this check for six methods instead of eight
+ // since IE also does not support "trace" and "connect"
+ return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
+ createStandardXHR() || createActiveXHR();
+ } :
+
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+var xhrId = 0,
+ xhrCallbacks = {},
+ xhrSupported = jQuery.ajaxSettings.xhr();
+
+// Support: IE<10
+// Open requests must be manually aborted on unload (#5280)
+// See https://support.microsoft.com/kb/2856746 for more info
+if ( window.attachEvent ) {
+ window.attachEvent( "onunload", function() {
+ for ( var key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( undefined, true );
+ }
+ } );
+}
+
+// Determine support properties
+support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+xhrSupported = support.ajax = !!xhrSupported;
+
+// Create transport if the browser can provide an xhr
+if ( xhrSupported ) {
+
+ jQuery.ajaxTransport( function( options ) {
+
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( !options.crossDomain || support.cors ) {
+
+ var callback;
+
+ return {
+ send: function( headers, complete ) {
+ var i,
+ xhr = options.xhr(),
+ id = ++xhrId;
+
+ // Open the socket
+ xhr.open(
+ options.type,
+ options.url,
+ options.async,
+ options.username,
+ options.password
+ );
+
+ // Apply custom fields if provided
+ if ( options.xhrFields ) {
+ for ( i in options.xhrFields ) {
+ xhr[ i ] = options.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( options.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( options.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
+ }
+
+ // Set headers
+ for ( i in headers ) {
+
+ // Support: IE<9
+ // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
+ // request header to a null-value.
+ //
+ // To keep consistent with other XHR implementations, cast the value
+ // to string and ignore `undefined`.
+ if ( headers[ i ] !== undefined ) {
+ xhr.setRequestHeader( i, headers[ i ] + "" );
+ }
+ }
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send( ( options.hasContent && options.data ) || null );
+
+ // Listener
+ callback = function( _, isAbort ) {
+ var status, statusText, responses;
+
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+
+ // Clean up
+ delete xhrCallbacks[ id ];
+ callback = undefined;
+ xhr.onreadystatechange = jQuery.noop;
+
+ // Abort manually if needed
+ if ( isAbort ) {
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ responses = {};
+ status = xhr.status;
+
+ // Support: IE<10
+ // Accessing binary-data responseText throws an exception
+ // (#11426)
+ if ( typeof xhr.responseText === "string" ) {
+ responses.text = xhr.responseText;
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch ( e ) {
+
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && options.isLocal && !options.crossDomain ) {
+ status = responses.text ? 200 : 404;
+
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
+ }
+ }
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, xhr.getAllResponseHeaders() );
+ }
+ };
+
+ // Do send the request
+ // `xhr.send` may raise an exception, but it will be
+ // handled in jQuery.ajax (so no try/catch here)
+ if ( !options.async ) {
+
+ // If we're in sync mode we fire the callback
+ callback();
+ } else if ( xhr.readyState === 4 ) {
+
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ window.setTimeout( callback );
+ } else {
+
+ // Register the callback, but delay it in case `xhr.send` throws
+ // Add to the list of active xhr callbacks
+ xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback( undefined, true );
+ }
+ }
+ };
+ }
+ } );
+}
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch ( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
+ } catch ( e ) {}
+}
+
+
+
+
+// Install script dataType
+jQuery.ajaxSetup( {
+ accepts: {
+ script: "text/javascript, application/javascript, " +
+ "application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /\b(?:java|ecma)script\b/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+} );
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ s.global = false;
+ }
+} );
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function( s ) {
+
+ // This transport only deals with cross domain requests
+ if ( s.crossDomain ) {
+
+ var script,
+ head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
+
+ return {
+
+ send: function( _, callback ) {
+
+ script = document.createElement( "script" );
+
+ script.async = true;
+
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ script.src = s.url;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+ if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+
+ // Remove the script
+ if ( script.parentNode ) {
+ script.parentNode.removeChild( script );
+ }
+
+ // Dereference the script
+ script = null;
+
+ // Callback if not abort
+ if ( !isAbort ) {
+ callback( 200, "success" );
+ }
+ }
+ };
+
+ // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
+ head.insertBefore( script, head.firstChild );
+ },
+
+ abort: function() {
+ if ( script ) {
+ script.onload( undefined, true );
+ }
+ }
+ };
+ }
+} );
+
+
+
+
+var oldCallbacks = [],
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup( {
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+} );
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+ "url" :
+ typeof s.data === "string" &&
+ ( s.contentType || "" )
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
+ rjsonp.test( s.data ) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if ( jsonProp ) {
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+ } else if ( s.jsonp !== false ) {
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters[ "script json" ] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ overwritten = window[ callbackName ];
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always( function() {
+
+ // If previous value didn't exist - remove it
+ if ( overwritten === undefined ) {
+ jQuery( window ).removeProp( callbackName );
+
+ // Otherwise restore preexisting value
+ } else {
+ window[ callbackName ] = overwritten;
+ }
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ } );
+
+ // Delegate to script
+ return "script";
+ }
+} );
+
+
+
+
+// data: string of html
+// context (optional): If specified, the fragment will be created in this context,
+// defaults to document
+// keepScripts (optional): If true, will include scripts passed in the html string
+jQuery.parseHTML = function( data, context, keepScripts ) {
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ if ( typeof context === "boolean" ) {
+ keepScripts = context;
+ context = false;
+ }
+ context = context || document;
+
+ var parsed = rsingleTag.exec( data ),
+ scripts = !keepScripts && [];
+
+ // Single tag
+ if ( parsed ) {
+ return [ context.createElement( parsed[ 1 ] ) ];
+ }
+
+ parsed = buildFragment( [ data ], context, scripts );
+
+ if ( scripts && scripts.length ) {
+ jQuery( scripts ).remove();
+ }
+
+ return jQuery.merge( [], parsed.childNodes );
+};
+
+
+// Keep a copy of the old load method
+var _load = jQuery.fn.load;
+
+/**
+ * Load a url into a page
+ */
+jQuery.fn.load = function( url, params, callback ) {
+ if ( typeof url !== "string" && _load ) {
+ return _load.apply( this, arguments );
+ }
+
+ var selector, type, response,
+ self = this,
+ off = url.indexOf( " " );
+
+ if ( off > -1 ) {
+ selector = jQuery.trim( url.slice( off, url.length ) );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // If we have elements to modify, make the request
+ if ( self.length > 0 ) {
+ jQuery.ajax( {
+ url: url,
+
+ // If "type" variable is undefined, then "GET" method will be used.
+ // Make value of this field explicit since
+ // user can override it through ajaxSetup method
+ type: type || "GET",
+ dataType: "html",
+ data: params
+ } ).done( function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ self.html( selector ?
+
+ // If a selector was specified, locate the right elements in a dummy div
+ // Exclude scripts to avoid IE 'Permission Denied' errors
+ jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+ // Otherwise use the full result
+ responseText );
+
+ // If the request succeeds, this function gets "data", "status", "jqXHR"
+ // but they are ignored because response was set above.
+ // If it fails, this function gets "jqXHR", "status", "error"
+ } ).always( callback && function( jqXHR, status ) {
+ self.each( function() {
+ callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
+ } );
+ } );
+ }
+
+ return this;
+};
+
+
+
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( [
+ "ajaxStart",
+ "ajaxStop",
+ "ajaxComplete",
+ "ajaxError",
+ "ajaxSuccess",
+ "ajaxSend"
+], function( i, type ) {
+ jQuery.fn[ type ] = function( fn ) {
+ return this.on( type, fn );
+ };
+} );
+
+
+
+
+jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep( jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ } ).length;
+};
+
+
+
+
+
+/**
+ * Gets a window from an element
+ */
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+
+jQuery.offset = {
+ setOffset: function( elem, options, i ) {
+ var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
+ position = jQuery.css( elem, "position" ),
+ curElem = jQuery( elem ),
+ props = {};
+
+ // set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ curOffset = curElem.offset();
+ curCSSTop = jQuery.css( elem, "top" );
+ curCSSLeft = jQuery.css( elem, "left" );
+ calculatePosition = ( position === "absolute" || position === "fixed" ) &&
+ jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
+
+ // need to be able to calculate position if either top or left
+ // is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( jQuery.isFunction( options ) ) {
+
+ // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
+ options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+jQuery.fn.extend( {
+ offset: function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each( function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ } );
+ }
+
+ var docElem, win,
+ box = { top: 0, left: 0 },
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return;
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if ( !jQuery.contains( docElem, elem ) ) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow( doc );
+ return {
+ top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
+ left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
+ };
+ },
+
+ position: function() {
+ if ( !this[ 0 ] ) {
+ return;
+ }
+
+ var offsetParent, offset,
+ parentOffset = { top: 0, left: 0 },
+ elem = this[ 0 ];
+
+ // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
+ // because it is its only offset parent
+ if ( jQuery.css( elem, "position" ) === "fixed" ) {
+
+ // we assume that getBoundingClientRect is available when computed position is fixed
+ offset = elem.getBoundingClientRect();
+ } else {
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent();
+
+ // Get correct offsets
+ offset = this.offset();
+ if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
+ parentOffset = offsetParent.offset();
+ }
+
+ // Add offsetParent borders
+ parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
+ parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
+ }
+
+ // Subtract parent offsets and element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ return {
+ top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+ left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
+ };
+ },
+
+ offsetParent: function() {
+ return this.map( function() {
+ var offsetParent = this.offsetParent;
+
+ while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
+ jQuery.css( offsetParent, "position" ) === "static" ) ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || documentElement;
+ } );
+ }
+} );
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
+ var top = /Y/.test( prop );
+
+ jQuery.fn[ method ] = function( val ) {
+ return access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
+
+ if ( val === undefined ) {
+ return win ? ( prop in win ) ? win[ prop ] :
+ win.document.documentElement[ method ] :
+ elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length, null );
+ };
+} );
+
+// Support: Safari<7-8+, Chrome<37-44+
+// Add the top/left cssHooks using jQuery.fn.position
+// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+// getComputedStyle returns percent when specified for top/left/bottom/right
+// rather than make the css module depend on the offset module, we just check for it here
+jQuery.each( [ "top", "left" ], function( i, prop ) {
+ jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
+ function( elem, computed ) {
+ if ( computed ) {
+ computed = curCSS( elem, prop );
+
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( computed ) ?
+ jQuery( elem ).position()[ prop ] + "px" :
+ computed;
+ }
+ }
+ );
+} );
+
+
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
+ function( defaultExtra, funcName ) {
+
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( jQuery.isWindow( elem ) ) {
+
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
+ // whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only,
+ // but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable, null );
+ };
+ } );
+} );
+
+
+jQuery.fn.extend( {
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ?
+ this.off( selector, "**" ) :
+ this.off( types, selector || "**", fn );
+ }
+} );
+
+// The number of elements contained in the matched element set
+jQuery.fn.size = function() {
+ return this.length;
+};
+
+jQuery.fn.andSelf = jQuery.fn.addBack;
+
+
+
+
+// Register as a named AMD module, since jQuery can be concatenated with other
+// files that may use define, but not via a proper concatenation script that
+// understands anonymous AMD modules. A named AMD is safest and most robust
+// way to register. Lowercase jquery is used because AMD module names are
+// derived from file names, and jQuery is normally delivered in a lowercase
+// file name. Do this after creating the global so that if an AMD module wants
+// to call noConflict to hide this version of jQuery, it will work.
+
+// Note that for maximum portability, libraries that are not jQuery should
+// declare themselves as anonymous modules, and avoid setting a global if an
+// AMD loader is present. jQuery is a special case. For more information, see
+// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
+
+if ( typeof define === "function" && define.amd ) {
+ define( "jquery", [], function() {
+ return jQuery;
+ } );
+}
+
+
+
+var
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$;
+
+jQuery.noConflict = function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+};
+
+// Expose jQuery and $ identifiers, even in
+// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
+// and CommonJS for browser emulators (#13566)
+if ( !noGlobal ) {
+ window.jQuery = window.$ = jQuery;
+}
+
+return jQuery;
+}));
--- /dev/null
+++ b/js/jqueryui/jquery-ui.js
@@ -1,0 +1,18706 @@
+/*! jQuery UI - v1.12.1 - 2016-09-14
+* http://jqueryui.com
+* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+(function( factory ) {
+ if ( typeof define === "function" && define.amd ) {
+
+ // AMD. Register as an anonymous module.
+ define([ "jquery" ], factory );
+ } else {
+
+ // Browser globals
+ factory( jQuery );
+ }
+}(function( $ ) {
+
+$.ui = $.ui || {};
+
+var version = $.ui.version = "1.12.1";
+
+
+/*!
+ * jQuery UI Widget 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Widget
+//>>group: Core
+//>>description: Provides a factory for creating stateful widgets with a common API.
+//>>docs: http://api.jqueryui.com/jQuery.widget/
+//>>demos: http://jqueryui.com/widget/
+
+
+
+var widgetUuid = 0;
+var widgetSlice = Array.prototype.slice;
+
+$.cleanData = ( function( orig ) {
+ return function( elems ) {
+ var events, elem, i;
+ for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
+ try {
+
+ // Only trigger remove when necessary to save time
+ events = $._data( elem, "events" );
+ if ( events && events.remove ) {
+ $( elem ).triggerHandler( "remove" );
+ }
+
+ // Http://bugs.jquery.com/ticket/8235
+ } catch ( e ) {}
+ }
+ orig( elems );
+ };
+} )( $.cleanData );
+
+$.widget = function( name, base, prototype ) {
+ var existingConstructor, constructor, basePrototype;
+
+ // ProxiedPrototype allows the provided prototype to remain unmodified
+ // so that it can be used as a mixin for multiple widgets (#8876)
+ var proxiedPrototype = {};
+
+ var namespace = name.split( "." )[ 0 ];
+ name = name.split( "." )[ 1 ];
+ var fullName = namespace + "-" + name;
+
+ if ( !prototype ) {
+ prototype = base;
+ base = $.Widget;
+ }
+
+ if ( $.isArray( prototype ) ) {
+ prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
+ }
+
+ // Create selector for plugin
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
+ return !!$.data( elem, fullName );
+ };
+
+ $[ namespace ] = $[ namespace ] || {};
+ existingConstructor = $[ namespace ][ name ];
+ constructor = $[ namespace ][ name ] = function( options, element ) {
+
+ // Allow instantiation without "new" keyword
+ if ( !this._createWidget ) {
+ return new constructor( options, element );
+ }
+
+ // Allow instantiation without initializing for simple inheritance
+ // must use "new" keyword (the code above always passes args)
+ if ( arguments.length ) {
+ this._createWidget( options, element );
+ }
+ };
+
+ // Extend with the existing constructor to carry over any static properties
+ $.extend( constructor, existingConstructor, {
+ version: prototype.version,
+
+ // Copy the object used to create the prototype in case we need to
+ // redefine the widget later
+ _proto: $.extend( {}, prototype ),
+
+ // Track widgets that inherit from this widget in case this widget is
+ // redefined after a widget inherits from it
+ _childConstructors: []
+ } );
+
+ basePrototype = new base();
+
+ // We need to make the options hash a property directly on the new instance
+ // otherwise we'll modify the options hash on the prototype that we're
+ // inheriting from
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
+ $.each( prototype, function( prop, value ) {
+ if ( !$.isFunction( value ) ) {
+ proxiedPrototype[ prop ] = value;
+ return;
+ }
+ proxiedPrototype[ prop ] = ( function() {
+ function _super() {
+ return base.prototype[ prop ].apply( this, arguments );
+ }
+
+ function _superApply( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ }
+
+ return function() {
+ var __super = this._super;
+ var __superApply = this._superApply;
+ var returnValue;
+
+ this._super = _super;
+ this._superApply = _superApply;
+
+ returnValue = value.apply( this, arguments );
+
+ this._super = __super;
+ this._superApply = __superApply;
+
+ return returnValue;
+ };
+ } )();
+ } );
+ constructor.prototype = $.widget.extend( basePrototype, {
+
+ // TODO: remove support for widgetEventPrefix
+ // always use the name + a colon as the prefix, e.g., draggable:start
+ // don't prefix for widgets that aren't DOM-based
+ widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
+ }, proxiedPrototype, {
+ constructor: constructor,
+ namespace: namespace,
+ widgetName: name,
+ widgetFullName: fullName
+ } );
+
+ // If this widget is being redefined then we need to find all widgets that
+ // are inheriting from it and redefine all of them so that they inherit from
+ // the new version of this widget. We're essentially trying to replace one
+ // level in the prototype chain.
+ if ( existingConstructor ) {
+ $.each( existingConstructor._childConstructors, function( i, child ) {
+ var childPrototype = child.prototype;
+
+ // Redefine the child widget using the same prototype that was
+ // originally used, but inherit from the new version of the base
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
+ child._proto );
+ } );
+
+ // Remove the list of existing child constructors from the old constructor
+ // so the old child constructors can be garbage collected
+ delete existingConstructor._childConstructors;
+ } else {
+ base._childConstructors.push( constructor );
+ }
+
+ $.widget.bridge( name, constructor );
+
+ return constructor;
+};
+
+$.widget.extend = function( target ) {
+ var input = widgetSlice.call( arguments, 1 );
+ var inputIndex = 0;
+ var inputLength = input.length;
+ var key;
+ var value;
+
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
+ for ( key in input[ inputIndex ] ) {
+ value = input[ inputIndex ][ key ];
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+
+ // Clone objects
+ if ( $.isPlainObject( value ) ) {
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
+ $.widget.extend( {}, target[ key ], value ) :
+
+ // Don't extend strings, arrays, etc. with objects
+ $.widget.extend( {}, value );
+
+ // Copy everything else by reference
+ } else {
+ target[ key ] = value;
+ }
+ }
+ }
+ }
+ return target;
+};
+
+$.widget.bridge = function( name, object ) {
+ var fullName = object.prototype.widgetFullName || name;
+ $.fn[ name ] = function( options ) {
+ var isMethodCall = typeof options === "string";
+ var args = widgetSlice.call( arguments, 1 );
+ var returnValue = this;
+
+ if ( isMethodCall ) {
+
+ // If this is an empty collection, we need to have the instance method
+ // return undefined instead of the jQuery instance
+ if ( !this.length && options === "instance" ) {
+ returnValue = undefined;
+ } else {
+ this.each( function() {
+ var methodValue;
+ var instance = $.data( this, fullName );
+
+ if ( options === "instance" ) {
+ returnValue = instance;
+ return false;
+ }
+
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name +
+ " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+
+ if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
+ return $.error( "no such method '" + options + "' for " + name +
+ " widget instance" );
+ }
+
+ methodValue = instance[ options ].apply( instance, args );
+
+ if ( methodValue !== instance && methodValue !== undefined ) {
+ returnValue = methodValue && methodValue.jquery ?
+ returnValue.pushStack( methodValue.get() ) :
+ methodValue;
+ return false;
+ }
+ } );
+ }
+ } else {
+
+ // Allow multiple hashes to be passed on init
+ if ( args.length ) {
+ options = $.widget.extend.apply( null, [ options ].concat( args ) );
+ }
+
+ this.each( function() {
+ var instance = $.data( this, fullName );
+ if ( instance ) {
+ instance.option( options || {} );
+ if ( instance._init ) {
+ instance._init();
+ }
+ } else {
+ $.data( this, fullName, new object( options, this ) );
+ }
+ } );
+ }
+
+ return returnValue;
+ };
+};
+
+$.Widget = function( /* options, element */ ) {};
+$.Widget._childConstructors = [];
+
+$.Widget.prototype = {
+ widgetName: "widget",
+ widgetEventPrefix: "",
+ defaultElement: "<div>",
+
+ options: {
+ classes: {},
+ disabled: false,
+
+ // Callbacks
+ create: null
+ },
+
+ _createWidget: function( options, element ) {
+ element = $( element || this.defaultElement || this )[ 0 ];
+ this.element = $( element );
+ this.uuid = widgetUuid++;
+ this.eventNamespace = "." + this.widgetName + this.uuid;
+
+ this.bindings = $();
+ this.hoverable = $();
+ this.focusable = $();
+ this.classesElementLookup = {};
+
+ if ( element !== this ) {
+ $.data( element, this.widgetFullName, this );
+ this._on( true, this.element, {
+ remove: function( event ) {
+ if ( event.target === element ) {
+ this.destroy();
+ }
+ }
+ } );
+ this.document = $( element.style ?
+
+ // Element within the document
+ element.ownerDocument :
+
+ // Element is window or document
+ element.document || element );
+ this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
+ }
+
+ this.options = $.widget.extend( {},
+ this.options,
+ this._getCreateOptions(),
+ options );
+
+ this._create();
+
+ if ( this.options.disabled ) {
+ this._setOptionDisabled( this.options.disabled );
+ }
+
+ this._trigger( "create", null, this._getCreateEventData() );
+ this._init();
+ },
+
+ _getCreateOptions: function() {
+ return {};
+ },
+
+ _getCreateEventData: $.noop,
+
+ _create: $.noop,
+
+ _init: $.noop,
+
+ destroy: function() {
+ var that = this;
+
+ this._destroy();
+ $.each( this.classesElementLookup, function( key, value ) {
+ that._removeClass( value, key );
+ } );
+
+ // We can probably remove the unbind calls in 2.0
+ // all event bindings should go through this._on()
+ this.element
+ .off( this.eventNamespace )
+ .removeData( this.widgetFullName );
+ this.widget()
+ .off( this.eventNamespace )
+ .removeAttr( "aria-disabled" );
+
+ // Clean up events and states
+ this.bindings.off( this.eventNamespace );
+ },
+
+ _destroy: $.noop,
+
+ widget: function() {
+ return this.element;
+ },
+
+ option: function( key, value ) {
+ var options = key;
+ var parts;
+ var curOption;
+ var i;
+
+ if ( arguments.length === 0 ) {
+
+ // Don't return a reference to the internal hash
+ return $.widget.extend( {}, this.options );
+ }
+
+ if ( typeof key === "string" ) {
+
+ // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
+ options = {};
+ parts = key.split( "." );
+ key = parts.shift();
+ if ( parts.length ) {
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
+ for ( i = 0; i < parts.length - 1; i++ ) {
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
+ curOption = curOption[ parts[ i ] ];
+ }
+ key = parts.pop();
+ if ( arguments.length === 1 ) {
+ return curOption[ key ] === undefined ? null : curOption[ key ];
+ }
+ curOption[ key ] = value;
+ } else {
+ if ( arguments.length === 1 ) {
+ return this.options[ key ] === undefined ? null : this.options[ key ];
+ }
+ options[ key ] = value;
+ }
+ }
+
+ this._setOptions( options );
+
+ return this;
+ },
+
+ _setOptions: function( options ) {
+ var key;
+
+ for ( key in options ) {
+ this._setOption( key, options[ key ] );
+ }
+
+ return this;
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "classes" ) {
+ this._setOptionClasses( value );
+ }
+
+ this.options[ key ] = value;
+
+ if ( key === "disabled" ) {
+ this._setOptionDisabled( value );
+ }
+
+ return this;
+ },
+
+ _setOptionClasses: function( value ) {
+ var classKey, elements, currentElements;
+
+ for ( classKey in value ) {
+ currentElements = this.classesElementLookup[ classKey ];
+ if ( value[ classKey ] === this.options.classes[ classKey ] ||
+ !currentElements ||
+ !currentElements.length ) {
+ continue;
+ }
+
+ // We are doing this to create a new jQuery object because the _removeClass() call
+ // on the next line is going to destroy the reference to the current elements being
+ // tracked. We need to save a copy of this collection so that we can add the new classes
+ // below.
+ elements = $( currentElements.get() );
+ this._removeClass( currentElements, classKey );
+
+ // We don't use _addClass() here, because that uses this.options.classes
+ // for generating the string of classes. We want to use the value passed in from
+ // _setOption(), this is the new value of the classes option which was passed to
+ // _setOption(). We pass this value directly to _classes().
+ elements.addClass( this._classes( {
+ element: elements,
+ keys: classKey,
+ classes: value,
+ add: true
+ } ) );
+ }
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
+
+ // If the widget is becoming disabled, then nothing is interactive
+ if ( value ) {
+ this._removeClass( this.hoverable, null, "ui-state-hover" );
+ this._removeClass( this.focusable, null, "ui-state-focus" );
+ }
+ },
+
+ enable: function() {
+ return this._setOptions( { disabled: false } );
+ },
+
+ disable: function() {
+ return this._setOptions( { disabled: true } );
+ },
+
+ _classes: function( options ) {
+ var full = [];
+ var that = this;
+
+ options = $.extend( {
+ element: this.element,
+ classes: this.options.classes || {}
+ }, options );
+
+ function processClassString( classes, checkOption ) {
+ var current, i;
+ for ( i = 0; i < classes.length; i++ ) {
+ current = that.classesElementLookup[ classes[ i ] ] || $();
+ if ( options.add ) {
+ current = $( $.unique( current.get().concat( options.element.get() ) ) );
+ } else {
+ current = $( current.not( options.element ).get() );
+ }
+ that.classesElementLookup[ classes[ i ] ] = current;
+ full.push( classes[ i ] );
+ if ( checkOption && options.classes[ classes[ i ] ] ) {
+ full.push( options.classes[ classes[ i ] ] );
+ }
+ }
+ }
+
+ this._on( options.element, {
+ "remove": "_untrackClassesElement"
+ } );
+
+ if ( options.keys ) {
+ processClassString( options.keys.match( /\S+/g ) || [], true );
+ }
+ if ( options.extra ) {
+ processClassString( options.extra.match( /\S+/g ) || [] );
+ }
+
+ return full.join( " " );
+ },
+
+ _untrackClassesElement: function( event ) {
+ var that = this;
+ $.each( that.classesElementLookup, function( key, value ) {
+ if ( $.inArray( event.target, value ) !== -1 ) {
+ that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
+ }
+ } );
+ },
+
+ _removeClass: function( element, keys, extra ) {
+ return this._toggleClass( element, keys, extra, false );
+ },
+
+ _addClass: function( element, keys, extra ) {
+ return this._toggleClass( element, keys, extra, true );
+ },
+
+ _toggleClass: function( element, keys, extra, add ) {
+ add = ( typeof add === "boolean" ) ? add : extra;
+ var shift = ( typeof element === "string" || element === null ),
+ options = {
+ extra: shift ? keys : extra,
+ keys: shift ? element : keys,
+ element: shift ? this.element : element,
+ add: add
+ };
+ options.element.toggleClass( this._classes( options ), add );
+ return this;
+ },
+
+ _on: function( suppressDisabledCheck, element, handlers ) {
+ var delegateElement;
+ var instance = this;
+
+ // No suppressDisabledCheck flag, shuffle arguments
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
+ handlers = element;
+ element = suppressDisabledCheck;
+ suppressDisabledCheck = false;
+ }
+
+ // No element argument, shuffle and use this.element
+ if ( !handlers ) {
+ handlers = element;
+ element = this.element;
+ delegateElement = this.widget();
+ } else {
+ element = delegateElement = $( element );
+ this.bindings = this.bindings.add( element );
+ }
+
+ $.each( handlers, function( event, handler ) {
+ function handlerProxy() {
+
+ // Allow widgets to customize the disabled handling
+ // - disabled as an array instead of boolean
+ // - disabled class as method for disabling individual parts
+ if ( !suppressDisabledCheck &&
+ ( instance.options.disabled === true ||
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
+ return;
+ }
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+
+ // Copy the guid so direct unbinding works
+ if ( typeof handler !== "string" ) {
+ handlerProxy.guid = handler.guid =
+ handler.guid || handlerProxy.guid || $.guid++;
+ }
+
+ var match = event.match( /^([\w:-]*)\s*(.*)$/ );
+ var eventName = match[ 1 ] + instance.eventNamespace;
+ var selector = match[ 2 ];
+
+ if ( selector ) {
+ delegateElement.on( eventName, selector, handlerProxy );
+ } else {
+ element.on( eventName, handlerProxy );
+ }
+ } );
+ },
+
+ _off: function( element, eventName ) {
+ eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
+ this.eventNamespace;
+ element.off( eventName ).off( eventName );
+
+ // Clear the stack to avoid memory leaks (#10056)
+ this.bindings = $( this.bindings.not( element ).get() );
+ this.focusable = $( this.focusable.not( element ).get() );
+ this.hoverable = $( this.hoverable.not( element ).get() );
+ },
+
+ _delay: function( handler, delay ) {
+ function handlerProxy() {
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+ var instance = this;
+ return setTimeout( handlerProxy, delay || 0 );
+ },
+
+ _hoverable: function( element ) {
+ this.hoverable = this.hoverable.add( element );
+ this._on( element, {
+ mouseenter: function( event ) {
+ this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
+ },
+ mouseleave: function( event ) {
+ this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
+ }
+ } );
+ },
+
+ _focusable: function( element ) {
+ this.focusable = this.focusable.add( element );
+ this._on( element, {
+ focusin: function( event ) {
+ this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
+ },
+ focusout: function( event ) {
+ this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
+ }
+ } );
+ },
+
+ _trigger: function( type, event, data ) {
+ var prop, orig;
+ var callback = this.options[ type ];
+
+ data = data || {};
+ event = $.Event( event );
+ event.type = ( type === this.widgetEventPrefix ?
+ type :
+ this.widgetEventPrefix + type ).toLowerCase();
+
+ // The original event may come from any element
+ // so we need to reset the target on the new event
+ event.target = this.element[ 0 ];
+
+ // Copy original event properties over to the new event
+ orig = event.originalEvent;
+ if ( orig ) {
+ for ( prop in orig ) {
+ if ( !( prop in event ) ) {
+ event[ prop ] = orig[ prop ];
+ }
+ }
+ }
+
+ this.element.trigger( event, data );
+ return !( $.isFunction( callback ) &&
+ callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
+ event.isDefaultPrevented() );
+ }
+};
+
+$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
+ if ( typeof options === "string" ) {
+ options = { effect: options };
+ }
+
+ var hasOptions;
+ var effectName = !options ?
+ method :
+ options === true || typeof options === "number" ?
+ defaultEffect :
+ options.effect || defaultEffect;
+
+ options = options || {};
+ if ( typeof options === "number" ) {
+ options = { duration: options };
+ }
+
+ hasOptions = !$.isEmptyObject( options );
+ options.complete = callback;
+
+ if ( options.delay ) {
+ element.delay( options.delay );
+ }
+
+ if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
+ element[ method ]( options );
+ } else if ( effectName !== method && element[ effectName ] ) {
+ element[ effectName ]( options.duration, options.easing, callback );
+ } else {
+ element.queue( function( next ) {
+ $( this )[ method ]();
+ if ( callback ) {
+ callback.call( element[ 0 ] );
+ }
+ next();
+ } );
+ }
+ };
+} );
+
+var widget = $.widget;
+
+
+/*!
+ * jQuery UI Position 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ * http://api.jqueryui.com/position/
+ */
+
+//>>label: Position
+//>>group: Core
+//>>description: Positions elements relative to other elements.
+//>>docs: http://api.jqueryui.com/position/
+//>>demos: http://jqueryui.com/position/
+
+
+( function() {
+var cachedScrollbarWidth,
+ max = Math.max,
+ abs = Math.abs,
+ rhorizontal = /left|center|right/,
+ rvertical = /top|center|bottom/,
+ roffset = /[\+\-]\d+(\.[\d]+)?%?/,
+ rposition = /^\w+/,
+ rpercent = /%$/,
+ _position = $.fn.position;
+
+function getOffsets( offsets, width, height ) {
+ return [
+ parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
+}
+
+function parseCss( element, property ) {
+ return parseInt( $.css( element, property ), 10 ) || 0;
+}
+
+function getDimensions( elem ) {
+ var raw = elem[ 0 ];
+ if ( raw.nodeType === 9 ) {
+ return {
+ width: elem.width(),
+ height: elem.height(),
+ offset: { top: 0, left: 0 }
+ };
+ }
+ if ( $.isWindow( raw ) ) {
+ return {
+ width: elem.width(),
+ height: elem.height(),
+ offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
+ };
+ }
+ if ( raw.preventDefault ) {
+ return {
+ width: 0,
+ height: 0,
+ offset: { top: raw.pageY, left: raw.pageX }
+ };
+ }
+ return {
+ width: elem.outerWidth(),
+ height: elem.outerHeight(),
+ offset: elem.offset()
+ };
+}
+
+$.position = {
+ scrollbarWidth: function() {
+ if ( cachedScrollbarWidth !== undefined ) {
+ return cachedScrollbarWidth;
+ }
+ var w1, w2,
+ div = $( "<div " +
+ "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
+ "<div style='height:100px;width:auto;'></div></div>" ),
+ innerDiv = div.children()[ 0 ];
+
+ $( "body" ).append( div );
+ w1 = innerDiv.offsetWidth;
+ div.css( "overflow", "scroll" );
+
+ w2 = innerDiv.offsetWidth;
+
+ if ( w1 === w2 ) {
+ w2 = div[ 0 ].clientWidth;
+ }
+
+ div.remove();
+
+ return ( cachedScrollbarWidth = w1 - w2 );
+ },
+ getScrollInfo: function( within ) {
+ var overflowX = within.isWindow || within.isDocument ? "" :
+ within.element.css( "overflow-x" ),
+ overflowY = within.isWindow || within.isDocument ? "" :
+ within.element.css( "overflow-y" ),
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
+ return {
+ width: hasOverflowY ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowX ? $.position.scrollbarWidth() : 0
+ };
+ },
+ getWithinInfo: function( element ) {
+ var withinElement = $( element || window ),
+ isWindow = $.isWindow( withinElement[ 0 ] ),
+ isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
+ hasOffset = !isWindow && !isDocument;
+ return {
+ element: withinElement,
+ isWindow: isWindow,
+ isDocument: isDocument,
+ offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
+ scrollLeft: withinElement.scrollLeft(),
+ scrollTop: withinElement.scrollTop(),
+ width: withinElement.outerWidth(),
+ height: withinElement.outerHeight()
+ };
+ }
+};
+
+$.fn.position = function( options ) {
+ if ( !options || !options.of ) {
+ return _position.apply( this, arguments );
+ }
+
+ // Make a copy, we don't want to modify arguments
+ options = $.extend( {}, options );
+
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
+ target = $( options.of ),
+ within = $.position.getWithinInfo( options.within ),
+ scrollInfo = $.position.getScrollInfo( within ),
+ collision = ( options.collision || "flip" ).split( " " ),
+ offsets = {};
+
+ dimensions = getDimensions( target );
+ if ( target[ 0 ].preventDefault ) {
+
+ // Force left top to allow flipping
+ options.at = "left top";
+ }
+ targetWidth = dimensions.width;
+ targetHeight = dimensions.height;
+ targetOffset = dimensions.offset;
+
+ // Clone to reuse original targetOffset later
+ basePosition = $.extend( {}, targetOffset );
+
+ // Force my and at to have valid horizontal and vertical positions
+ // if a value is missing or invalid, it will be converted to center
+ $.each( [ "my", "at" ], function() {
+ var pos = ( options[ this ] || "" ).split( " " ),
+ horizontalOffset,
+ verticalOffset;
+
+ if ( pos.length === 1 ) {
+ pos = rhorizontal.test( pos[ 0 ] ) ?
+ pos.concat( [ "center" ] ) :
+ rvertical.test( pos[ 0 ] ) ?
+ [ "center" ].concat( pos ) :
+ [ "center", "center" ];
+ }
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
+
+ // Calculate offsets
+ horizontalOffset = roffset.exec( pos[ 0 ] );
+ verticalOffset = roffset.exec( pos[ 1 ] );
+ offsets[ this ] = [
+ horizontalOffset ? horizontalOffset[ 0 ] : 0,
+ verticalOffset ? verticalOffset[ 0 ] : 0
+ ];
+
+ // Reduce to just the positions without the offsets
+ options[ this ] = [
+ rposition.exec( pos[ 0 ] )[ 0 ],
+ rposition.exec( pos[ 1 ] )[ 0 ]
+ ];
+ } );
+
+ // Normalize collision option
+ if ( collision.length === 1 ) {
+ collision[ 1 ] = collision[ 0 ];
+ }
+
+ if ( options.at[ 0 ] === "right" ) {
+ basePosition.left += targetWidth;
+ } else if ( options.at[ 0 ] === "center" ) {
+ basePosition.left += targetWidth / 2;
+ }
+
+ if ( options.at[ 1 ] === "bottom" ) {
+ basePosition.top += targetHeight;
+ } else if ( options.at[ 1 ] === "center" ) {
+ basePosition.top += targetHeight / 2;
+ }
+
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
+ basePosition.left += atOffset[ 0 ];
+ basePosition.top += atOffset[ 1 ];
+
+ return this.each( function() {
+ var collisionPosition, using,
+ elem = $( this ),
+ elemWidth = elem.outerWidth(),
+ elemHeight = elem.outerHeight(),
+ marginLeft = parseCss( this, "marginLeft" ),
+ marginTop = parseCss( this, "marginTop" ),
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
+ scrollInfo.width,
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
+ scrollInfo.height,
+ position = $.extend( {}, basePosition ),
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
+
+ if ( options.my[ 0 ] === "right" ) {
+ position.left -= elemWidth;
+ } else if ( options.my[ 0 ] === "center" ) {
+ position.left -= elemWidth / 2;
+ }
+
+ if ( options.my[ 1 ] === "bottom" ) {
+ position.top -= elemHeight;
+ } else if ( options.my[ 1 ] === "center" ) {
+ position.top -= elemHeight / 2;
+ }
+
+ position.left += myOffset[ 0 ];
+ position.top += myOffset[ 1 ];
+
+ collisionPosition = {
+ marginLeft: marginLeft,
+ marginTop: marginTop
+ };
+
+ $.each( [ "left", "top" ], function( i, dir ) {
+ if ( $.ui.position[ collision[ i ] ] ) {
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
+ targetWidth: targetWidth,
+ targetHeight: targetHeight,
+ elemWidth: elemWidth,
+ elemHeight: elemHeight,
+ collisionPosition: collisionPosition,
+ collisionWidth: collisionWidth,
+ collisionHeight: collisionHeight,
+ offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
+ my: options.my,
+ at: options.at,
+ within: within,
+ elem: elem
+ } );
+ }
+ } );
+
+ if ( options.using ) {
+
+ // Adds feedback as second argument to using callback, if present
+ using = function( props ) {
+ var left = targetOffset.left - position.left,
+ right = left + targetWidth - elemWidth,
+ top = targetOffset.top - position.top,
+ bottom = top + targetHeight - elemHeight,
+ feedback = {
+ target: {
+ element: target,
+ left: targetOffset.left,
+ top: targetOffset.top,
+ width: targetWidth,
+ height: targetHeight
+ },
+ element: {
+ element: elem,
+ left: position.left,
+ top: position.top,
+ width: elemWidth,
+ height: elemHeight
+ },
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
+ };
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
+ feedback.horizontal = "center";
+ }
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
+ feedback.vertical = "middle";
+ }
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
+ feedback.important = "horizontal";
+ } else {
+ feedback.important = "vertical";
+ }
+ options.using.call( this, props, feedback );
+ };
+ }
+
+ elem.offset( $.extend( position, { using: using } ) );
+ } );
+};
+
+$.ui.position = {
+ fit: {
+ left: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
+ outerWidth = within.width,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = withinOffset - collisionPosLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
+ newOverRight;
+
+ // Element is wider than within
+ if ( data.collisionWidth > outerWidth ) {
+
+ // Element is initially over the left side of within
+ if ( overLeft > 0 && overRight <= 0 ) {
+ newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
+ withinOffset;
+ position.left += overLeft - newOverRight;
+
+ // Element is initially over right side of within
+ } else if ( overRight > 0 && overLeft <= 0 ) {
+ position.left = withinOffset;
+
+ // Element is initially over both left and right sides of within
+ } else {
+ if ( overLeft > overRight ) {
+ position.left = withinOffset + outerWidth - data.collisionWidth;
+ } else {
+ position.left = withinOffset;
+ }
+ }
+
+ // Too far left -> align with left edge
+ } else if ( overLeft > 0 ) {
+ position.left += overLeft;
+
+ // Too far right -> align with right edge
+ } else if ( overRight > 0 ) {
+ position.left -= overRight;
+
+ // Adjust based on position and margin
+ } else {
+ position.left = max( position.left - collisionPosLeft, position.left );
+ }
+ },
+ top: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
+ outerHeight = data.within.height,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = withinOffset - collisionPosTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
+ newOverBottom;
+
+ // Element is taller than within
+ if ( data.collisionHeight > outerHeight ) {
+
+ // Element is initially over the top of within
+ if ( overTop > 0 && overBottom <= 0 ) {
+ newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
+ withinOffset;
+ position.top += overTop - newOverBottom;
+
+ // Element is initially over bottom of within
+ } else if ( overBottom > 0 && overTop <= 0 ) {
+ position.top = withinOffset;
+
+ // Element is initially over both top and bottom of within
+ } else {
+ if ( overTop > overBottom ) {
+ position.top = withinOffset + outerHeight - data.collisionHeight;
+ } else {
+ position.top = withinOffset;
+ }
+ }
+
+ // Too far up -> align with top
+ } else if ( overTop > 0 ) {
+ position.top += overTop;
+
+ // Too far down -> align with bottom edge
+ } else if ( overBottom > 0 ) {
+ position.top -= overBottom;
+
+ // Adjust based on position and margin
+ } else {
+ position.top = max( position.top - collisionPosTop, position.top );
+ }
+ }
+ },
+ flip: {
+ left: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.offset.left + within.scrollLeft,
+ outerWidth = within.width,
+ offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = collisionPosLeft - offsetLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
+ myOffset = data.my[ 0 ] === "left" ?
+ -data.elemWidth :
+ data.my[ 0 ] === "right" ?
+ data.elemWidth :
+ 0,
+ atOffset = data.at[ 0 ] === "left" ?
+ data.targetWidth :
+ data.at[ 0 ] === "right" ?
+ -data.targetWidth :
+ 0,
+ offset = -2 * data.offset[ 0 ],
+ newOverRight,
+ newOverLeft;
+
+ if ( overLeft < 0 ) {
+ newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
+ outerWidth - withinOffset;
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ } else if ( overRight > 0 ) {
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
+ atOffset + offset - offsetLeft;
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ }
+ },
+ top: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.offset.top + within.scrollTop,
+ outerHeight = within.height,
+ offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = collisionPosTop - offsetTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
+ top = data.my[ 1 ] === "top",
+ myOffset = top ?
+ -data.elemHeight :
+ data.my[ 1 ] === "bottom" ?
+ data.elemHeight :
+ 0,
+ atOffset = data.at[ 1 ] === "top" ?
+ data.targetHeight :
+ data.at[ 1 ] === "bottom" ?
+ -data.targetHeight :
+ 0,
+ offset = -2 * data.offset[ 1 ],
+ newOverTop,
+ newOverBottom;
+ if ( overTop < 0 ) {
+ newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
+ outerHeight - withinOffset;
+ if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ } else if ( overBottom > 0 ) {
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
+ offset - offsetTop;
+ if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ }
+ }
+ },
+ flipfit: {
+ left: function() {
+ $.ui.position.flip.left.apply( this, arguments );
+ $.ui.position.fit.left.apply( this, arguments );
+ },
+ top: function() {
+ $.ui.position.flip.top.apply( this, arguments );
+ $.ui.position.fit.top.apply( this, arguments );
+ }
+ }
+};
+
+} )();
+
+var position = $.ui.position;
+
+
+/*!
+ * jQuery UI :data 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: :data Selector
+//>>group: Core
+//>>description: Selects elements which have data stored under the specified key.
+//>>docs: http://api.jqueryui.com/data-selector/
+
+
+var data = $.extend( $.expr[ ":" ], {
+ data: $.expr.createPseudo ?
+ $.expr.createPseudo( function( dataName ) {
+ return function( elem ) {
+ return !!$.data( elem, dataName );
+ };
+ } ) :
+
+ // Support: jQuery <1.8
+ function( elem, i, match ) {
+ return !!$.data( elem, match[ 3 ] );
+ }
+} );
+
+/*!
+ * jQuery UI Disable Selection 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: disableSelection
+//>>group: Core
+//>>description: Disable selection of text content within the set of matched elements.
+//>>docs: http://api.jqueryui.com/disableSelection/
+
+// This file is deprecated
+
+
+var disableSelection = $.fn.extend( {
+ disableSelection: ( function() {
+ var eventType = "onselectstart" in document.createElement( "div" ) ?
+ "selectstart" :
+ "mousedown";
+
+ return function() {
+ return this.on( eventType + ".ui-disableSelection", function( event ) {
+ event.preventDefault();
+ } );
+ };
+ } )(),
+
+ enableSelection: function() {
+ return this.off( ".ui-disableSelection" );
+ }
+} );
+
+
+/*!
+ * jQuery UI Effects 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Effects Core
+//>>group: Effects
+// jscs:disable maximumLineLength
+//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
+// jscs:enable maximumLineLength
+//>>docs: http://api.jqueryui.com/category/effects-core/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var dataSpace = "ui-effects-",
+ dataSpaceStyle = "ui-effects-style",
+ dataSpaceAnimated = "ui-effects-animated",
+
+ // Create a local jQuery because jQuery Color relies on it and the
+ // global may not exist with AMD and a custom build (#10199)
+ jQuery = $;
+
+$.effects = {
+ effect: {}
+};
+
+/*!
+ * jQuery Color Animations v2.1.2
+ * https://github.com/jquery/jquery-color
+ *
+ * Copyright 2014 jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ * Date: Wed Jan 16 08:47:09 2013 -0600
+ */
+( function( jQuery, undefined ) {
+
+ var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
+ "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
+
+ // Plusequals test for += 100 -= 100
+ rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
+
+ // A set of RE's that can match strings and generate color tuples.
+ stringParsers = [ {
+ re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ],
+ execResult[ 2 ],
+ execResult[ 3 ],
+ execResult[ 4 ]
+ ];
+ }
+ }, {
+ re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ] * 2.55,
+ execResult[ 2 ] * 2.55,
+ execResult[ 3 ] * 2.55,
+ execResult[ 4 ]
+ ];
+ }
+ }, {
+
+ // This regex ignores A-F because it's compared against an already lowercased string
+ re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
+ parse: function( execResult ) {
+ return [
+ parseInt( execResult[ 1 ], 16 ),
+ parseInt( execResult[ 2 ], 16 ),
+ parseInt( execResult[ 3 ], 16 )
+ ];
+ }
+ }, {
+
+ // This regex ignores A-F because it's compared against an already lowercased string
+ re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
+ parse: function( execResult ) {
+ return [
+ parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
+ parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
+ parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
+ ];
+ }
+ }, {
+ re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
+ space: "hsla",
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ],
+ execResult[ 2 ] / 100,
+ execResult[ 3 ] / 100,
+ execResult[ 4 ]
+ ];
+ }
+ } ],
+
+ // JQuery.Color( )
+ color = jQuery.Color = function( color, green, blue, alpha ) {
+ return new jQuery.Color.fn.parse( color, green, blue, alpha );
+ },
+ spaces = {
+ rgba: {
+ props: {
+ red: {
+ idx: 0,
+ type: "byte"
+ },
+ green: {
+ idx: 1,
+ type: "byte"
+ },
+ blue: {
+ idx: 2,
+ type: "byte"
+ }
+ }
+ },
+
+ hsla: {
+ props: {
+ hue: {
+ idx: 0,
+ type: "degrees"
+ },
+ saturation: {
+ idx: 1,
+ type: "percent"
+ },
+ lightness: {
+ idx: 2,
+ type: "percent"
+ }
+ }
+ }
+ },
+ propTypes = {
+ "byte": {
+ floor: true,
+ max: 255
+ },
+ "percent": {
+ max: 1
+ },
+ "degrees": {
+ mod: 360,
+ floor: true
+ }
+ },
+ support = color.support = {},
+
+ // Element for support tests
+ supportElem = jQuery( "<p>" )[ 0 ],
+
+ // Colors = jQuery.Color.names
+ colors,
+
+ // Local aliases of functions called often
+ each = jQuery.each;
+
+// Determine rgba support immediately
+supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
+support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
+
+// Define cache name and alpha properties
+// for rgba and hsla spaces
+each( spaces, function( spaceName, space ) {
+ space.cache = "_" + spaceName;
+ space.props.alpha = {
+ idx: 3,
+ type: "percent",
+ def: 1
+ };
+} );
+
+function clamp( value, prop, allowEmpty ) {
+ var type = propTypes[ prop.type ] || {};
+
+ if ( value == null ) {
+ return ( allowEmpty || !prop.def ) ? null : prop.def;
+ }
+
+ // ~~ is an short way of doing floor for positive numbers
+ value = type.floor ? ~~value : parseFloat( value );
+
+ // IE will pass in empty strings as value for alpha,
+ // which will hit this case
+ if ( isNaN( value ) ) {
+ return prop.def;
+ }
+
+ if ( type.mod ) {
+
+ // We add mod before modding to make sure that negatives values
+ // get converted properly: -10 -> 350
+ return ( value + type.mod ) % type.mod;
+ }
+
+ // For now all property types without mod have min and max
+ return 0 > value ? 0 : type.max < value ? type.max : value;
+}
+
+function stringParse( string ) {
+ var inst = color(),
+ rgba = inst._rgba = [];
+
+ string = string.toLowerCase();
+
+ each( stringParsers, function( i, parser ) {
+ var parsed,
+ match = parser.re.exec( string ),
+ values = match && parser.parse( match ),
+ spaceName = parser.space || "rgba";
+
+ if ( values ) {
+ parsed = inst[ spaceName ]( values );
+
+ // If this was an rgba parse the assignment might happen twice
+ // oh well....
+ inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
+ rgba = inst._rgba = parsed._rgba;
+
+ // Exit each( stringParsers ) here because we matched
+ return false;
+ }
+ } );
+
+ // Found a stringParser that handled it
+ if ( rgba.length ) {
+
+ // If this came from a parsed string, force "transparent" when alpha is 0
+ // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
+ if ( rgba.join() === "0,0,0,0" ) {
+ jQuery.extend( rgba, colors.transparent );
+ }
+ return inst;
+ }
+
+ // Named colors
+ return colors[ string ];
+}
+
+color.fn = jQuery.extend( color.prototype, {
+ parse: function( red, green, blue, alpha ) {
+ if ( red === undefined ) {
+ this._rgba = [ null, null, null, null ];
+ return this;
+ }
+ if ( red.jquery || red.nodeType ) {
+ red = jQuery( red ).css( green );
+ green = undefined;
+ }
+
+ var inst = this,
+ type = jQuery.type( red ),
+ rgba = this._rgba = [];
+
+ // More than 1 argument specified - assume ( red, green, blue, alpha )
+ if ( green !== undefined ) {
+ red = [ red, green, blue, alpha ];
+ type = "array";
+ }
+
+ if ( type === "string" ) {
+ return this.parse( stringParse( red ) || colors._default );
+ }
+
+ if ( type === "array" ) {
+ each( spaces.rgba.props, function( key, prop ) {
+ rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
+ } );
+ return this;
+ }
+
+ if ( type === "object" ) {
+ if ( red instanceof color ) {
+ each( spaces, function( spaceName, space ) {
+ if ( red[ space.cache ] ) {
+ inst[ space.cache ] = red[ space.cache ].slice();
+ }
+ } );
+ } else {
+ each( spaces, function( spaceName, space ) {
+ var cache = space.cache;
+ each( space.props, function( key, prop ) {
+
+ // If the cache doesn't exist, and we know how to convert
+ if ( !inst[ cache ] && space.to ) {
+
+ // If the value was null, we don't need to copy it
+ // if the key was alpha, we don't need to copy it either
+ if ( key === "alpha" || red[ key ] == null ) {
+ return;
+ }
+ inst[ cache ] = space.to( inst._rgba );
+ }
+
+ // This is the only case where we allow nulls for ALL properties.
+ // call clamp with alwaysAllowEmpty
+ inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
+ } );
+
+ // Everything defined but alpha?
+ if ( inst[ cache ] &&
+ jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
+
+ // Use the default of 1
+ inst[ cache ][ 3 ] = 1;
+ if ( space.from ) {
+ inst._rgba = space.from( inst[ cache ] );
+ }
+ }
+ } );
+ }
+ return this;
+ }
+ },
+ is: function( compare ) {
+ var is = color( compare ),
+ same = true,
+ inst = this;
+
+ each( spaces, function( _, space ) {
+ var localCache,
+ isCache = is[ space.cache ];
+ if ( isCache ) {
+ localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
+ each( space.props, function( _, prop ) {
+ if ( isCache[ prop.idx ] != null ) {
+ same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
+ return same;
+ }
+ } );
+ }
+ return same;
+ } );
+ return same;
+ },
+ _space: function() {
+ var used = [],
+ inst = this;
+ each( spaces, function( spaceName, space ) {
+ if ( inst[ space.cache ] ) {
+ used.push( spaceName );
+ }
+ } );
+ return used.pop();
+ },
+ transition: function( other, distance ) {
+ var end = color( other ),
+ spaceName = end._space(),
+ space = spaces[ spaceName ],
+ startColor = this.alpha() === 0 ? color( "transparent" ) : this,
+ start = startColor[ space.cache ] || space.to( startColor._rgba ),
+ result = start.slice();
+
+ end = end[ space.cache ];
+ each( space.props, function( key, prop ) {
+ var index = prop.idx,
+ startValue = start[ index ],
+ endValue = end[ index ],
+ type = propTypes[ prop.type ] || {};
+
+ // If null, don't override start value
+ if ( endValue === null ) {
+ return;
+ }
+
+ // If null - use end
+ if ( startValue === null ) {
+ result[ index ] = endValue;
+ } else {
+ if ( type.mod ) {
+ if ( endValue - startValue > type.mod / 2 ) {
+ startValue += type.mod;
+ } else if ( startValue - endValue > type.mod / 2 ) {
+ startValue -= type.mod;
+ }
+ }
+ result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
+ }
+ } );
+ return this[ spaceName ]( result );
+ },
+ blend: function( opaque ) {
+
+ // If we are already opaque - return ourself
+ if ( this._rgba[ 3 ] === 1 ) {
+ return this;
+ }
+
+ var rgb = this._rgba.slice(),
+ a = rgb.pop(),
+ blend = color( opaque )._rgba;
+
+ return color( jQuery.map( rgb, function( v, i ) {
+ return ( 1 - a ) * blend[ i ] + a * v;
+ } ) );
+ },
+ toRgbaString: function() {
+ var prefix = "rgba(",
+ rgba = jQuery.map( this._rgba, function( v, i ) {
+ return v == null ? ( i > 2 ? 1 : 0 ) : v;
+ } );
+
+ if ( rgba[ 3 ] === 1 ) {
+ rgba.pop();
+ prefix = "rgb(";
+ }
+
+ return prefix + rgba.join() + ")";
+ },
+ toHslaString: function() {
+ var prefix = "hsla(",
+ hsla = jQuery.map( this.hsla(), function( v, i ) {
+ if ( v == null ) {
+ v = i > 2 ? 1 : 0;
+ }
+
+ // Catch 1 and 2
+ if ( i && i < 3 ) {
+ v = Math.round( v * 100 ) + "%";
+ }
+ return v;
+ } );
+
+ if ( hsla[ 3 ] === 1 ) {
+ hsla.pop();
+ prefix = "hsl(";
+ }
+ return prefix + hsla.join() + ")";
+ },
+ toHexString: function( includeAlpha ) {
+ var rgba = this._rgba.slice(),
+ alpha = rgba.pop();
+
+ if ( includeAlpha ) {
+ rgba.push( ~~( alpha * 255 ) );
+ }
+
+ return "#" + jQuery.map( rgba, function( v ) {
+
+ // Default to 0 when nulls exist
+ v = ( v || 0 ).toString( 16 );
+ return v.length === 1 ? "0" + v : v;
+ } ).join( "" );
+ },
+ toString: function() {
+ return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
+ }
+} );
+color.fn.parse.prototype = color.fn;
+
+// Hsla conversions adapted from:
+// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
+
+function hue2rgb( p, q, h ) {
+ h = ( h + 1 ) % 1;
+ if ( h * 6 < 1 ) {
+ return p + ( q - p ) * h * 6;
+ }
+ if ( h * 2 < 1 ) {
+ return q;
+ }
+ if ( h * 3 < 2 ) {
+ return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
+ }
+ return p;
+}
+
+spaces.hsla.to = function( rgba ) {
+ if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
+ return [ null, null, null, rgba[ 3 ] ];
+ }
+ var r = rgba[ 0 ] / 255,
+ g = rgba[ 1 ] / 255,
+ b = rgba[ 2 ] / 255,
+ a = rgba[ 3 ],
+ max = Math.max( r, g, b ),
+ min = Math.min( r, g, b ),
+ diff = max - min,
+ add = max + min,
+ l = add * 0.5,
+ h, s;
+
+ if ( min === max ) {
+ h = 0;
+ } else if ( r === max ) {
+ h = ( 60 * ( g - b ) / diff ) + 360;
+ } else if ( g === max ) {
+ h = ( 60 * ( b - r ) / diff ) + 120;
+ } else {
+ h = ( 60 * ( r - g ) / diff ) + 240;
+ }
+
+ // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
+ // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
+ if ( diff === 0 ) {
+ s = 0;
+ } else if ( l <= 0.5 ) {
+ s = diff / add;
+ } else {
+ s = diff / ( 2 - add );
+ }
+ return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
+};
+
+spaces.hsla.from = function( hsla ) {
+ if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
+ return [ null, null, null, hsla[ 3 ] ];
+ }
+ var h = hsla[ 0 ] / 360,
+ s = hsla[ 1 ],
+ l = hsla[ 2 ],
+ a = hsla[ 3 ],
+ q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
+ p = 2 * l - q;
+
+ return [
+ Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
+ Math.round( hue2rgb( p, q, h ) * 255 ),
+ Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
+ a
+ ];
+};
+
+each( spaces, function( spaceName, space ) {
+ var props = space.props,
+ cache = space.cache,
+ to = space.to,
+ from = space.from;
+
+ // Makes rgba() and hsla()
+ color.fn[ spaceName ] = function( value ) {
+
+ // Generate a cache for this space if it doesn't exist
+ if ( to && !this[ cache ] ) {
+ this[ cache ] = to( this._rgba );
+ }
+ if ( value === undefined ) {
+ return this[ cache ].slice();
+ }
+
+ var ret,
+ type = jQuery.type( value ),
+ arr = ( type === "array" || type === "object" ) ? value : arguments,
+ local = this[ cache ].slice();
+
+ each( props, function( key, prop ) {
+ var val = arr[ type === "object" ? key : prop.idx ];
+ if ( val == null ) {
+ val = local[ prop.idx ];
+ }
+ local[ prop.idx ] = clamp( val, prop );
+ } );
+
+ if ( from ) {
+ ret = color( from( local ) );
+ ret[ cache ] = local;
+ return ret;
+ } else {
+ return color( local );
+ }
+ };
+
+ // Makes red() green() blue() alpha() hue() saturation() lightness()
+ each( props, function( key, prop ) {
+
+ // Alpha is included in more than one space
+ if ( color.fn[ key ] ) {
+ return;
+ }
+ color.fn[ key ] = function( value ) {
+ var vtype = jQuery.type( value ),
+ fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
+ local = this[ fn ](),
+ cur = local[ prop.idx ],
+ match;
+
+ if ( vtype === "undefined" ) {
+ return cur;
+ }
+
+ if ( vtype === "function" ) {
+ value = value.call( this, cur );
+ vtype = jQuery.type( value );
+ }
+ if ( value == null && prop.empty ) {
+ return this;
+ }
+ if ( vtype === "string" ) {
+ match = rplusequals.exec( value );
+ if ( match ) {
+ value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
+ }
+ }
+ local[ prop.idx ] = value;
+ return this[ fn ]( local );
+ };
+ } );
+} );
+
+// Add cssHook and .fx.step function for each named hook.
+// accept a space separated string of properties
+color.hook = function( hook ) {
+ var hooks = hook.split( " " );
+ each( hooks, function( i, hook ) {
+ jQuery.cssHooks[ hook ] = {
+ set: function( elem, value ) {
+ var parsed, curElem,
+ backgroundColor = "";
+
+ if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
+ ( parsed = stringParse( value ) ) ) ) {
+ value = color( parsed || value );
+ if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
+ curElem = hook === "backgroundColor" ? elem.parentNode : elem;
+ while (
+ ( backgroundColor === "" || backgroundColor === "transparent" ) &&
+ curElem && curElem.style
+ ) {
+ try {
+ backgroundColor = jQuery.css( curElem, "backgroundColor" );
+ curElem = curElem.parentNode;
+ } catch ( e ) {
+ }
+ }
+
+ value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
+ backgroundColor :
+ "_default" );
+ }
+
+ value = value.toRgbaString();
+ }
+ try {
+ elem.style[ hook ] = value;
+ } catch ( e ) {
+
+ // Wrapped to prevent IE from throwing errors on "invalid" values like
+ // 'auto' or 'inherit'
+ }
+ }
+ };
+ jQuery.fx.step[ hook ] = function( fx ) {
+ if ( !fx.colorInit ) {
+ fx.start = color( fx.elem, hook );
+ fx.end = color( fx.end );
+ fx.colorInit = true;
+ }
+ jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
+ };
+ } );
+
+};
+
+color.hook( stepHooks );
+
+jQuery.cssHooks.borderColor = {
+ expand: function( value ) {
+ var expanded = {};
+
+ each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
+ expanded[ "border" + part + "Color" ] = value;
+ } );
+ return expanded;
+ }
+};
+
+// Basic color names only.
+// Usage of any of the other color names requires adding yourself or including
+// jquery.color.svg-names.js.
+colors = jQuery.Color.names = {
+
+ // 4.1. Basic color keywords
+ aqua: "#00ffff",
+ black: "#000000",
+ blue: "#0000ff",
+ fuchsia: "#ff00ff",
+ gray: "#808080",
+ green: "#008000",
+ lime: "#00ff00",
+ maroon: "#800000",
+ navy: "#000080",
+ olive: "#808000",
+ purple: "#800080",
+ red: "#ff0000",
+ silver: "#c0c0c0",
+ teal: "#008080",
+ white: "#ffffff",
+ yellow: "#ffff00",
+
+ // 4.2.3. "transparent" color keyword
+ transparent: [ null, null, null, 0 ],
+
+ _default: "#ffffff"
+};
+
+} )( jQuery );
+
+/******************************************************************************/
+/****************************** CLASS ANIMATIONS ******************************/
+/******************************************************************************/
+( function() {
+
+var classAnimationActions = [ "add", "remove", "toggle" ],
+ shorthandStyles = {
+ border: 1,
+ borderBottom: 1,
+ borderColor: 1,
+ borderLeft: 1,
+ borderRight: 1,
+ borderTop: 1,
+ borderWidth: 1,
+ margin: 1,
+ padding: 1
+ };
+
+$.each(
+ [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
+ function( _, prop ) {
+ $.fx.step[ prop ] = function( fx ) {
+ if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
+ jQuery.style( fx.elem, prop, fx.end );
+ fx.setAttr = true;
+ }
+ };
+ }
+);
+
+function getElementStyles( elem ) {
+ var key, len,
+ style = elem.ownerDocument.defaultView ?
+ elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
+ elem.currentStyle,
+ styles = {};
+
+ if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
+ len = style.length;
+ while ( len-- ) {
+ key = style[ len ];
+ if ( typeof style[ key ] === "string" ) {
+ styles[ $.camelCase( key ) ] = style[ key ];
+ }
+ }
+
+ // Support: Opera, IE <9
+ } else {
+ for ( key in style ) {
+ if ( typeof style[ key ] === "string" ) {
+ styles[ key ] = style[ key ];
+ }
+ }
+ }
+
+ return styles;
+}
+
+function styleDifference( oldStyle, newStyle ) {
+ var diff = {},
+ name, value;
+
+ for ( name in newStyle ) {
+ value = newStyle[ name ];
+ if ( oldStyle[ name ] !== value ) {
+ if ( !shorthandStyles[ name ] ) {
+ if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
+ diff[ name ] = value;
+ }
+ }
+ }
+ }
+
+ return diff;
+}
+
+// Support: jQuery <1.8
+if ( !$.fn.addBack ) {
+ $.fn.addBack = function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter( selector )
+ );
+ };
+}
+
+$.effects.animateClass = function( value, duration, easing, callback ) {
+ var o = $.speed( duration, easing, callback );
+
+ return this.queue( function() {
+ var animated = $( this ),
+ baseClass = animated.attr( "class" ) || "",
+ applyClassChange,
+ allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
+
+ // Map the animated objects to store the original styles.
+ allAnimations = allAnimations.map( function() {
+ var el = $( this );
+ return {
+ el: el,
+ start: getElementStyles( this )
+ };
+ } );
+
+ // Apply class change
+ applyClassChange = function() {
+ $.each( classAnimationActions, function( i, action ) {
+ if ( value[ action ] ) {
+ animated[ action + "Class" ]( value[ action ] );
+ }
+ } );
+ };
+ applyClassChange();
+
+ // Map all animated objects again - calculate new styles and diff
+ allAnimations = allAnimations.map( function() {
+ this.end = getElementStyles( this.el[ 0 ] );
+ this.diff = styleDifference( this.start, this.end );
+ return this;
+ } );
+
+ // Apply original class
+ animated.attr( "class", baseClass );
+
+ // Map all animated objects again - this time collecting a promise
+ allAnimations = allAnimations.map( function() {
+ var styleInfo = this,
+ dfd = $.Deferred(),
+ opts = $.extend( {}, o, {
+ queue: false,
+ complete: function() {
+ dfd.resolve( styleInfo );
+ }
+ } );
+
+ this.el.animate( this.diff, opts );
+ return dfd.promise();
+ } );
+
+ // Once all animations have completed:
+ $.when.apply( $, allAnimations.get() ).done( function() {
+
+ // Set the final class
+ applyClassChange();
+
+ // For each animated element,
+ // clear all css properties that were animated
+ $.each( arguments, function() {
+ var el = this.el;
+ $.each( this.diff, function( key ) {
+ el.css( key, "" );
+ } );
+ } );
+
+ // This is guarnteed to be there if you use jQuery.speed()
+ // it also handles dequeuing the next anim...
+ o.complete.call( animated[ 0 ] );
+ } );
+ } );
+};
+
+$.fn.extend( {
+ addClass: ( function( orig ) {
+ return function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( this,
+ { add: classNames }, speed, easing, callback ) :
+ orig.apply( this, arguments );
+ };
+ } )( $.fn.addClass ),
+
+ removeClass: ( function( orig ) {
+ return function( classNames, speed, easing, callback ) {
+ return arguments.length > 1 ?
+ $.effects.animateClass.call( this,
+ { remove: classNames }, speed, easing, callback ) :
+ orig.apply( this, arguments );
+ };
+ } )( $.fn.removeClass ),
+
+ toggleClass: ( function( orig ) {
+ return function( classNames, force, speed, easing, callback ) {
+ if ( typeof force === "boolean" || force === undefined ) {
+ if ( !speed ) {
+
+ // Without speed parameter
+ return orig.apply( this, arguments );
+ } else {
+ return $.effects.animateClass.call( this,
+ ( force ? { add: classNames } : { remove: classNames } ),
+ speed, easing, callback );
+ }
+ } else {
+
+ // Without force parameter
+ return $.effects.animateClass.call( this,
+ { toggle: classNames }, force, speed, easing );
+ }
+ };
+ } )( $.fn.toggleClass ),
+
+ switchClass: function( remove, add, speed, easing, callback ) {
+ return $.effects.animateClass.call( this, {
+ add: add,
+ remove: remove
+ }, speed, easing, callback );
+ }
+} );
+
+} )();
+
+/******************************************************************************/
+/*********************************** EFFECTS **********************************/
+/******************************************************************************/
+
+( function() {
+
+if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
+ $.expr.filters.animated = ( function( orig ) {
+ return function( elem ) {
+ return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
+ };
+ } )( $.expr.filters.animated );
+}
+
+if ( $.uiBackCompat !== false ) {
+ $.extend( $.effects, {
+
+ // Saves a set of properties in a data storage
+ save: function( element, set ) {
+ var i = 0, length = set.length;
+ for ( ; i < length; i++ ) {
+ if ( set[ i ] !== null ) {
+ element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
+ }
+ }
+ },
+
+ // Restores a set of previously saved properties from a data storage
+ restore: function( element, set ) {
+ var val, i = 0, length = set.length;
+ for ( ; i < length; i++ ) {
+ if ( set[ i ] !== null ) {
+ val = element.data( dataSpace + set[ i ] );
+ element.css( set[ i ], val );
+ }
+ }
+ },
+
+ setMode: function( el, mode ) {
+ if ( mode === "toggle" ) {
+ mode = el.is( ":hidden" ) ? "show" : "hide";
+ }
+ return mode;
+ },
+
+ // Wraps the element around a wrapper that copies position properties
+ createWrapper: function( element ) {
+
+ // If the element is already wrapped, return it
+ if ( element.parent().is( ".ui-effects-wrapper" ) ) {
+ return element.parent();
+ }
+
+ // Wrap the element
+ var props = {
+ width: element.outerWidth( true ),
+ height: element.outerHeight( true ),
+ "float": element.css( "float" )
+ },
+ wrapper = $( "<div></div>" )
+ .addClass( "ui-effects-wrapper" )
+ .css( {
+ fontSize: "100%",
+ background: "transparent",
+ border: "none",
+ margin: 0,
+ padding: 0
+ } ),
+
+ // Store the size in case width/height are defined in % - Fixes #5245
+ size = {
+ width: element.width(),
+ height: element.height()
+ },
+ active = document.activeElement;
+
+ // Support: Firefox
+ // Firefox incorrectly exposes anonymous content
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
+ try {
+ active.id;
+ } catch ( e ) {
+ active = document.body;
+ }
+
+ element.wrap( wrapper );
+
+ // Fixes #7595 - Elements lose focus when wrapped.
+ if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
+ $( active ).trigger( "focus" );
+ }
+
+ // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
+ // lose the reference to the wrapped element
+ wrapper = element.parent();
+
+ // Transfer positioning properties to the wrapper
+ if ( element.css( "position" ) === "static" ) {
+ wrapper.css( { position: "relative" } );
+ element.css( { position: "relative" } );
+ } else {
+ $.extend( props, {
+ position: element.css( "position" ),
+ zIndex: element.css( "z-index" )
+ } );
+ $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
+ props[ pos ] = element.css( pos );
+ if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
+ props[ pos ] = "auto";
+ }
+ } );
+ element.css( {
+ position: "relative",
+ top: 0,
+ left: 0,
+ right: "auto",
+ bottom: "auto"
+ } );
+ }
+ element.css( size );
+
+ return wrapper.css( props ).show();
+ },
+
+ removeWrapper: function( element ) {
+ var active = document.activeElement;
+
+ if ( element.parent().is( ".ui-effects-wrapper" ) ) {
+ element.parent().replaceWith( element );
+
+ // Fixes #7595 - Elements lose focus when wrapped.
+ if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
+ $( active ).trigger( "focus" );
+ }
+ }
+
+ return element;
+ }
+ } );
+}
+
+$.extend( $.effects, {
+ version: "1.12.1",
+
+ define: function( name, mode, effect ) {
+ if ( !effect ) {
+ effect = mode;
+ mode = "effect";
+ }
+
+ $.effects.effect[ name ] = effect;
+ $.effects.effect[ name ].mode = mode;
+
+ return effect;
+ },
+
+ scaledDimensions: function( element, percent, direction ) {
+ if ( percent === 0 ) {
+ return {
+ height: 0,
+ width: 0,
+ outerHeight: 0,
+ outerWidth: 0
+ };
+ }
+
+ var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
+ y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
+
+ return {
+ height: element.height() * y,
+ width: element.width() * x,
+ outerHeight: element.outerHeight() * y,
+ outerWidth: element.outerWidth() * x
+ };
+
+ },
+
+ clipToBox: function( animation ) {
+ return {
+ width: animation.clip.right - animation.clip.left,
+ height: animation.clip.bottom - animation.clip.top,
+ left: animation.clip.left,
+ top: animation.clip.top
+ };
+ },
+
+ // Injects recently queued functions to be first in line (after "inprogress")
+ unshift: function( element, queueLength, count ) {
+ var queue = element.queue();
+
+ if ( queueLength > 1 ) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
+ }
+ element.dequeue();
+ },
+
+ saveStyle: function( element ) {
+ element.data( dataSpaceStyle, element[ 0 ].style.cssText );
+ },
+
+ restoreStyle: function( element ) {
+ element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
+ element.removeData( dataSpaceStyle );
+ },
+
+ mode: function( element, mode ) {
+ var hidden = element.is( ":hidden" );
+
+ if ( mode === "toggle" ) {
+ mode = hidden ? "show" : "hide";
+ }
+ if ( hidden ? mode === "hide" : mode === "show" ) {
+ mode = "none";
+ }
+ return mode;
+ },
+
+ // Translates a [top,left] array into a baseline value
+ getBaseline: function( origin, original ) {
+ var y, x;
+
+ switch ( origin[ 0 ] ) {
+ case "top":
+ y = 0;
+ break;
+ case "middle":
+ y = 0.5;
+ break;
+ case "bottom":
+ y = 1;
+ break;
+ default:
+ y = origin[ 0 ] / original.height;
+ }
+
+ switch ( origin[ 1 ] ) {
+ case "left":
+ x = 0;
+ break;
+ case "center":
+ x = 0.5;
+ break;
+ case "right":
+ x = 1;
+ break;
+ default:
+ x = origin[ 1 ] / original.width;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ },
+
+ // Creates a placeholder element so that the original element can be made absolute
+ createPlaceholder: function( element ) {
+ var placeholder,
+ cssPosition = element.css( "position" ),
+ position = element.position();
+
+ // Lock in margins first to account for form elements, which
+ // will change margin if you explicitly set height
+ // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
+ // Support: Safari
+ element.css( {
+ marginTop: element.css( "marginTop" ),
+ marginBottom: element.css( "marginBottom" ),
+ marginLeft: element.css( "marginLeft" ),
+ marginRight: element.css( "marginRight" )
+ } )
+ .outerWidth( element.outerWidth() )
+ .outerHeight( element.outerHeight() );
+
+ if ( /^(static|relative)/.test( cssPosition ) ) {
+ cssPosition = "absolute";
+
+ placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
+
+ // Convert inline to inline block to account for inline elements
+ // that turn to inline block based on content (like img)
+ display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
+ "inline-block" :
+ "block",
+ visibility: "hidden",
+
+ // Margins need to be set to account for margin collapse
+ marginTop: element.css( "marginTop" ),
+ marginBottom: element.css( "marginBottom" ),
+ marginLeft: element.css( "marginLeft" ),
+ marginRight: element.css( "marginRight" ),
+ "float": element.css( "float" )
+ } )
+ .outerWidth( element.outerWidth() )
+ .outerHeight( element.outerHeight() )
+ .addClass( "ui-effects-placeholder" );
+
+ element.data( dataSpace + "placeholder", placeholder );
+ }
+
+ element.css( {
+ position: cssPosition,
+ left: position.left,
+ top: position.top
+ } );
+
+ return placeholder;
+ },
+
+ removePlaceholder: function( element ) {
+ var dataKey = dataSpace + "placeholder",
+ placeholder = element.data( dataKey );
+
+ if ( placeholder ) {
+ placeholder.remove();
+ element.removeData( dataKey );
+ }
+ },
+
+ // Removes a placeholder if it exists and restores
+ // properties that were modified during placeholder creation
+ cleanUp: function( element ) {
+ $.effects.restoreStyle( element );
+ $.effects.removePlaceholder( element );
+ },
+
+ setTransition: function( element, list, factor, value ) {
+ value = value || {};
+ $.each( list, function( i, x ) {
+ var unit = element.cssUnit( x );
+ if ( unit[ 0 ] > 0 ) {
+ value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
+ }
+ } );
+ return value;
+ }
+} );
+
+// Return an effect options object for the given parameters:
+function _normalizeArguments( effect, options, speed, callback ) {
+
+ // Allow passing all options as the first parameter
+ if ( $.isPlainObject( effect ) ) {
+ options = effect;
+ effect = effect.effect;
+ }
+
+ // Convert to an object
+ effect = { effect: effect };
+
+ // Catch (effect, null, ...)
+ if ( options == null ) {
+ options = {};
+ }
+
+ // Catch (effect, callback)
+ if ( $.isFunction( options ) ) {
+ callback = options;
+ speed = null;
+ options = {};
+ }
+
+ // Catch (effect, speed, ?)
+ if ( typeof options === "number" || $.fx.speeds[ options ] ) {
+ callback = speed;
+ speed = options;
+ options = {};
+ }
+
+ // Catch (effect, options, callback)
+ if ( $.isFunction( speed ) ) {
+ callback = speed;
+ speed = null;
+ }
+
+ // Add options to effect
+ if ( options ) {
+ $.extend( effect, options );
+ }
+
+ speed = speed || options.duration;
+ effect.duration = $.fx.off ? 0 :
+ typeof speed === "number" ? speed :
+ speed in $.fx.speeds ? $.fx.speeds[ speed ] :
+ $.fx.speeds._default;
+
+ effect.complete = callback || options.complete;
+
+ return effect;
+}
+
+function standardAnimationOption( option ) {
+
+ // Valid standard speeds (nothing, number, named speed)
+ if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
+ return true;
+ }
+
+ // Invalid strings - treat as "normal" speed
+ if ( typeof option === "string" && !$.effects.effect[ option ] ) {
+ return true;
+ }
+
+ // Complete callback
+ if ( $.isFunction( option ) ) {
+ return true;
+ }
+
+ // Options hash (but not naming an effect)
+ if ( typeof option === "object" && !option.effect ) {
+ return true;
+ }
+
+ // Didn't match any standard API
+ return false;
+}
+
+$.fn.extend( {
+ effect: function( /* effect, options, speed, callback */ ) {
+ var args = _normalizeArguments.apply( this, arguments ),
+ effectMethod = $.effects.effect[ args.effect ],
+ defaultMode = effectMethod.mode,
+ queue = args.queue,
+ queueName = queue || "fx",
+ complete = args.complete,
+ mode = args.mode,
+ modes = [],
+ prefilter = function( next ) {
+ var el = $( this ),
+ normalizedMode = $.effects.mode( el, mode ) || defaultMode;
+
+ // Sentinel for duck-punching the :animated psuedo-selector
+ el.data( dataSpaceAnimated, true );
+
+ // Save effect mode for later use,
+ // we can't just call $.effects.mode again later,
+ // as the .show() below destroys the initial state
+ modes.push( normalizedMode );
+
+ // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
+ if ( defaultMode && ( normalizedMode === "show" ||
+ ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
+ el.show();
+ }
+
+ if ( !defaultMode || normalizedMode !== "none" ) {
+ $.effects.saveStyle( el );
+ }
+
+ if ( $.isFunction( next ) ) {
+ next();
+ }
+ };
+
+ if ( $.fx.off || !effectMethod ) {
+
+ // Delegate to the original method (e.g., .show()) if possible
+ if ( mode ) {
+ return this[ mode ]( args.duration, complete );
+ } else {
+ return this.each( function() {
+ if ( complete ) {
+ complete.call( this );
+ }
+ } );
+ }
+ }
+
+ function run( next ) {
+ var elem = $( this );
+
+ function cleanup() {
+ elem.removeData( dataSpaceAnimated );
+
+ $.effects.cleanUp( elem );
+
+ if ( args.mode === "hide" ) {
+ elem.hide();
+ }
+
+ done();
+ }
+
+ function done() {
+ if ( $.isFunction( complete ) ) {
+ complete.call( elem[ 0 ] );
+ }
+
+ if ( $.isFunction( next ) ) {
+ next();
+ }
+ }
+
+ // Override mode option on a per element basis,
+ // as toggle can be either show or hide depending on element state
+ args.mode = modes.shift();
+
+ if ( $.uiBackCompat !== false && !defaultMode ) {
+ if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
+
+ // Call the core method to track "olddisplay" properly
+ elem[ mode ]();
+ done();
+ } else {
+ effectMethod.call( elem[ 0 ], args, done );
+ }
+ } else {
+ if ( args.mode === "none" ) {
+
+ // Call the core method to track "olddisplay" properly
+ elem[ mode ]();
+ done();
+ } else {
+ effectMethod.call( elem[ 0 ], args, cleanup );
+ }
+ }
+ }
+
+ // Run prefilter on all elements first to ensure that
+ // any showing or hiding happens before placeholder creation,
+ // which ensures that any layout changes are correctly captured.
+ return queue === false ?
+ this.each( prefilter ).each( run ) :
+ this.queue( queueName, prefilter ).queue( queueName, run );
+ },
+
+ show: ( function( orig ) {
+ return function( option ) {
+ if ( standardAnimationOption( option ) ) {
+ return orig.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "show";
+ return this.effect.call( this, args );
+ }
+ };
+ } )( $.fn.show ),
+
+ hide: ( function( orig ) {
+ return function( option ) {
+ if ( standardAnimationOption( option ) ) {
+ return orig.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "hide";
+ return this.effect.call( this, args );
+ }
+ };
+ } )( $.fn.hide ),
+
+ toggle: ( function( orig ) {
+ return function( option ) {
+ if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
+ return orig.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "toggle";
+ return this.effect.call( this, args );
+ }
+ };
+ } )( $.fn.toggle ),
+
+ cssUnit: function( key ) {
+ var style = this.css( key ),
+ val = [];
+
+ $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
+ if ( style.indexOf( unit ) > 0 ) {
+ val = [ parseFloat( style ), unit ];
+ }
+ } );
+ return val;
+ },
+
+ cssClip: function( clipObj ) {
+ if ( clipObj ) {
+ return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
+ clipObj.bottom + "px " + clipObj.left + "px)" );
+ }
+ return parseClip( this.css( "clip" ), this );
+ },
+
+ transfer: function( options, done ) {
+ var element = $( this ),
+ target = $( options.to ),
+ targetFixed = target.css( "position" ) === "fixed",
+ body = $( "body" ),
+ fixTop = targetFixed ? body.scrollTop() : 0,
+ fixLeft = targetFixed ? body.scrollLeft() : 0,
+ endPosition = target.offset(),
+ animation = {
+ top: endPosition.top - fixTop,
+ left: endPosition.left - fixLeft,
+ height: target.innerHeight(),
+ width: target.innerWidth()
+ },
+ startPosition = element.offset(),
+ transfer = $( "<div class='ui-effects-transfer'></div>" )
+ .appendTo( "body" )
+ .addClass( options.className )
+ .css( {
+ top: startPosition.top - fixTop,
+ left: startPosition.left - fixLeft,
+ height: element.innerHeight(),
+ width: element.innerWidth(),
+ position: targetFixed ? "fixed" : "absolute"
+ } )
+ .animate( animation, options.duration, options.easing, function() {
+ transfer.remove();
+ if ( $.isFunction( done ) ) {
+ done();
+ }
+ } );
+ }
+} );
+
+function parseClip( str, element ) {
+ var outerWidth = element.outerWidth(),
+ outerHeight = element.outerHeight(),
+ clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
+ values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
+
+ return {
+ top: parseFloat( values[ 1 ] ) || 0,
+ right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
+ bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
+ left: parseFloat( values[ 4 ] ) || 0
+ };
+}
+
+$.fx.step.clip = function( fx ) {
+ if ( !fx.clipInit ) {
+ fx.start = $( fx.elem ).cssClip();
+ if ( typeof fx.end === "string" ) {
+ fx.end = parseClip( fx.end, fx.elem );
+ }
+ fx.clipInit = true;
+ }
+
+ $( fx.elem ).cssClip( {
+ top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
+ right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
+ bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
+ left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
+ } );
+};
+
+} )();
+
+/******************************************************************************/
+/*********************************** EASING ***********************************/
+/******************************************************************************/
+
+( function() {
+
+// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
+
+var baseEasings = {};
+
+$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
+ baseEasings[ name ] = function( p ) {
+ return Math.pow( p, i + 2 );
+ };
+} );
+
+$.extend( baseEasings, {
+ Sine: function( p ) {
+ return 1 - Math.cos( p * Math.PI / 2 );
+ },
+ Circ: function( p ) {
+ return 1 - Math.sqrt( 1 - p * p );
+ },
+ Elastic: function( p ) {
+ return p === 0 || p === 1 ? p :
+ -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
+ },
+ Back: function( p ) {
+ return p * p * ( 3 * p - 2 );
+ },
+ Bounce: function( p ) {
+ var pow2,
+ bounce = 4;
+
+ while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
+ return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
+ }
+} );
+
+$.each( baseEasings, function( name, easeIn ) {
+ $.easing[ "easeIn" + name ] = easeIn;
+ $.easing[ "easeOut" + name ] = function( p ) {
+ return 1 - easeIn( 1 - p );
+ };
+ $.easing[ "easeInOut" + name ] = function( p ) {
+ return p < 0.5 ?
+ easeIn( p * 2 ) / 2 :
+ 1 - easeIn( p * -2 + 2 ) / 2;
+ };
+} );
+
+} )();
+
+var effect = $.effects;
+
+
+/*!
+ * jQuery UI Effects Blind 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Blind Effect
+//>>group: Effects
+//>>description: Blinds the element.
+//>>docs: http://api.jqueryui.com/blind-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
+ var map = {
+ up: [ "bottom", "top" ],
+ vertical: [ "bottom", "top" ],
+ down: [ "top", "bottom" ],
+ left: [ "right", "left" ],
+ horizontal: [ "right", "left" ],
+ right: [ "left", "right" ]
+ },
+ element = $( this ),
+ direction = options.direction || "up",
+ start = element.cssClip(),
+ animate = { clip: $.extend( {}, start ) },
+ placeholder = $.effects.createPlaceholder( element );
+
+ animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
+
+ if ( options.mode === "show" ) {
+ element.cssClip( animate.clip );
+ if ( placeholder ) {
+ placeholder.css( $.effects.clipToBox( animate ) );
+ }
+
+ animate.clip = start;
+ }
+
+ if ( placeholder ) {
+ placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
+ }
+
+ element.animate( animate, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+} );
+
+
+/*!
+ * jQuery UI Effects Bounce 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Bounce Effect
+//>>group: Effects
+//>>description: Bounces an element horizontally or vertically n times.
+//>>docs: http://api.jqueryui.com/bounce-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
+ var upAnim, downAnim, refValue,
+ element = $( this ),
+
+ // Defaults:
+ mode = options.mode,
+ hide = mode === "hide",
+ show = mode === "show",
+ direction = options.direction || "up",
+ distance = options.distance,
+ times = options.times || 5,
+
+ // Number of internal animations
+ anims = times * 2 + ( show || hide ? 1 : 0 ),
+ speed = options.duration / anims,
+ easing = options.easing,
+
+ // Utility:
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ),
+ i = 0,
+
+ queuelen = element.queue().length;
+
+ $.effects.createPlaceholder( element );
+
+ refValue = element.css( ref );
+
+ // Default distance for the BIGGEST bounce is the outer Distance / 3
+ if ( !distance ) {
+ distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
+ }
+
+ if ( show ) {
+ downAnim = { opacity: 1 };
+ downAnim[ ref ] = refValue;
+
+ // If we are showing, force opacity 0 and set the initial position
+ // then do the "first" animation
+ element
+ .css( "opacity", 0 )
+ .css( ref, motion ? -distance * 2 : distance * 2 )
+ .animate( downAnim, speed, easing );
+ }
+
+ // Start at the smallest distance if we are hiding
+ if ( hide ) {
+ distance = distance / Math.pow( 2, times - 1 );
+ }
+
+ downAnim = {};
+ downAnim[ ref ] = refValue;
+
+ // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
+ for ( ; i < times; i++ ) {
+ upAnim = {};
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ element
+ .animate( upAnim, speed, easing )
+ .animate( downAnim, speed, easing );
+
+ distance = hide ? distance * 2 : distance / 2;
+ }
+
+ // Last Bounce when Hiding
+ if ( hide ) {
+ upAnim = { opacity: 0 };
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ element.animate( upAnim, speed, easing );
+ }
+
+ element.queue( done );
+
+ $.effects.unshift( element, queuelen, anims + 1 );
+} );
+
+
+/*!
+ * jQuery UI Effects Clip 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Clip Effect
+//>>group: Effects
+//>>description: Clips the element on and off like an old TV.
+//>>docs: http://api.jqueryui.com/clip-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
+ var start,
+ animate = {},
+ element = $( this ),
+ direction = options.direction || "vertical",
+ both = direction === "both",
+ horizontal = both || direction === "horizontal",
+ vertical = both || direction === "vertical";
+
+ start = element.cssClip();
+ animate.clip = {
+ top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
+ right: horizontal ? ( start.right - start.left ) / 2 : start.right,
+ bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
+ left: horizontal ? ( start.right - start.left ) / 2 : start.left
+ };
+
+ $.effects.createPlaceholder( element );
+
+ if ( options.mode === "show" ) {
+ element.cssClip( animate.clip );
+ animate.clip = start;
+ }
+
+ element.animate( animate, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+
+} );
+
+
+/*!
+ * jQuery UI Effects Drop 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Drop Effect
+//>>group: Effects
+//>>description: Moves an element in one direction and hides it at the same time.
+//>>docs: http://api.jqueryui.com/drop-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
+
+ var distance,
+ element = $( this ),
+ mode = options.mode,
+ show = mode === "show",
+ direction = options.direction || "left",
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
+ oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
+ animation = {
+ opacity: 0
+ };
+
+ $.effects.createPlaceholder( element );
+
+ distance = options.distance ||
+ element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
+
+ animation[ ref ] = motion + distance;
+
+ if ( show ) {
+ element.css( animation );
+
+ animation[ ref ] = oppositeMotion + distance;
+ animation.opacity = 1;
+ }
+
+ // Animate
+ element.animate( animation, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+} );
+
+
+/*!
+ * jQuery UI Effects Explode 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Explode Effect
+//>>group: Effects
+// jscs:disable maximumLineLength
+//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
+// jscs:enable maximumLineLength
+//>>docs: http://api.jqueryui.com/explode-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
+
+ var i, j, left, top, mx, my,
+ rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
+ cells = rows,
+ element = $( this ),
+ mode = options.mode,
+ show = mode === "show",
+
+ // Show and then visibility:hidden the element before calculating offset
+ offset = element.show().css( "visibility", "hidden" ).offset(),
+
+ // Width and height of a piece
+ width = Math.ceil( element.outerWidth() / cells ),
+ height = Math.ceil( element.outerHeight() / rows ),
+ pieces = [];
+
+ // Children animate complete:
+ function childComplete() {
+ pieces.push( this );
+ if ( pieces.length === rows * cells ) {
+ animComplete();
+ }
+ }
+
+ // Clone the element for each row and cell.
+ for ( i = 0; i < rows; i++ ) { // ===>
+ top = offset.top + i * height;
+ my = i - ( rows - 1 ) / 2;
+
+ for ( j = 0; j < cells; j++ ) { // |||
+ left = offset.left + j * width;
+ mx = j - ( cells - 1 ) / 2;
+
+ // Create a clone of the now hidden main element that will be absolute positioned
+ // within a wrapper div off the -left and -top equal to size of our pieces
+ element
+ .clone()
+ .appendTo( "body" )
+ .wrap( "<div></div>" )
+ .css( {
+ position: "absolute",
+ visibility: "visible",
+ left: -j * width,
+ top: -i * height
+ } )
+
+ // Select the wrapper - make it overflow: hidden and absolute positioned based on
+ // where the original was located +left and +top equal to the size of pieces
+ .parent()
+ .addClass( "ui-effects-explode" )
+ .css( {
+ position: "absolute",
+ overflow: "hidden",
+ width: width,
+ height: height,
+ left: left + ( show ? mx * width : 0 ),
+ top: top + ( show ? my * height : 0 ),
+ opacity: show ? 0 : 1
+ } )
+ .animate( {
+ left: left + ( show ? 0 : mx * width ),
+ top: top + ( show ? 0 : my * height ),
+ opacity: show ? 1 : 0
+ }, options.duration || 500, options.easing, childComplete );
+ }
+ }
+
+ function animComplete() {
+ element.css( {
+ visibility: "visible"
+ } );
+ $( pieces ).remove();
+ done();
+ }
+} );
+
+
+/*!
+ * jQuery UI Effects Fade 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Fade Effect
+//>>group: Effects
+//>>description: Fades the element.
+//>>docs: http://api.jqueryui.com/fade-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
+ var show = options.mode === "show";
+
+ $( this )
+ .css( "opacity", show ? 0 : 1 )
+ .animate( {
+ opacity: show ? 1 : 0
+ }, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+} );
+
+
+/*!
+ * jQuery UI Effects Fold 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Fold Effect
+//>>group: Effects
+//>>description: Folds an element first horizontally and then vertically.
+//>>docs: http://api.jqueryui.com/fold-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
+
+ // Create element
+ var element = $( this ),
+ mode = options.mode,
+ show = mode === "show",
+ hide = mode === "hide",
+ size = options.size || 15,
+ percent = /([0-9]+)%/.exec( size ),
+ horizFirst = !!options.horizFirst,
+ ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
+ duration = options.duration / 2,
+
+ placeholder = $.effects.createPlaceholder( element ),
+
+ start = element.cssClip(),
+ animation1 = { clip: $.extend( {}, start ) },
+ animation2 = { clip: $.extend( {}, start ) },
+
+ distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
+
+ queuelen = element.queue().length;
+
+ if ( percent ) {
+ size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
+ }
+ animation1.clip[ ref[ 0 ] ] = size;
+ animation2.clip[ ref[ 0 ] ] = size;
+ animation2.clip[ ref[ 1 ] ] = 0;
+
+ if ( show ) {
+ element.cssClip( animation2.clip );
+ if ( placeholder ) {
+ placeholder.css( $.effects.clipToBox( animation2 ) );
+ }
+
+ animation2.clip = start;
+ }
+
+ // Animate
+ element
+ .queue( function( next ) {
+ if ( placeholder ) {
+ placeholder
+ .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
+ .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
+ }
+
+ next();
+ } )
+ .animate( animation1, duration, options.easing )
+ .animate( animation2, duration, options.easing )
+ .queue( done );
+
+ $.effects.unshift( element, queuelen, 4 );
+} );
+
+
+/*!
+ * jQuery UI Effects Highlight 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Highlight Effect
+//>>group: Effects
+//>>description: Highlights the background of an element in a defined color for a custom duration.
+//>>docs: http://api.jqueryui.com/highlight-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
+ var element = $( this ),
+ animation = {
+ backgroundColor: element.css( "backgroundColor" )
+ };
+
+ if ( options.mode === "hide" ) {
+ animation.opacity = 0;
+ }
+
+ $.effects.saveStyle( element );
+
+ element
+ .css( {
+ backgroundImage: "none",
+ backgroundColor: options.color || "#ffff99"
+ } )
+ .animate( animation, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+} );
+
+
+/*!
+ * jQuery UI Effects Size 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Size Effect
+//>>group: Effects
+//>>description: Resize an element to a specified width and height.
+//>>docs: http://api.jqueryui.com/size-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectSize = $.effects.define( "size", function( options, done ) {
+
+ // Create element
+ var baseline, factor, temp,
+ element = $( this ),
+
+ // Copy for children
+ cProps = [ "fontSize" ],
+ vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
+ hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
+
+ // Set options
+ mode = options.mode,
+ restore = mode !== "effect",
+ scale = options.scale || "both",
+ origin = options.origin || [ "middle", "center" ],
+ position = element.css( "position" ),
+ pos = element.position(),
+ original = $.effects.scaledDimensions( element ),
+ from = options.from || original,
+ to = options.to || $.effects.scaledDimensions( element, 0 );
+
+ $.effects.createPlaceholder( element );
+
+ if ( mode === "show" ) {
+ temp = from;
+ from = to;
+ to = temp;
+ }
+
+ // Set scaling factor
+ factor = {
+ from: {
+ y: from.height / original.height,
+ x: from.width / original.width
+ },
+ to: {
+ y: to.height / original.height,
+ x: to.width / original.width
+ }
+ };
+
+ // Scale the css box
+ if ( scale === "box" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ from = $.effects.setTransition( element, vProps, factor.from.y, from );
+ to = $.effects.setTransition( element, vProps, factor.to.y, to );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ from = $.effects.setTransition( element, hProps, factor.from.x, from );
+ to = $.effects.setTransition( element, hProps, factor.to.x, to );
+ }
+ }
+
+ // Scale the content
+ if ( scale === "content" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ from = $.effects.setTransition( element, cProps, factor.from.y, from );
+ to = $.effects.setTransition( element, cProps, factor.to.y, to );
+ }
+ }
+
+ // Adjust the position properties based on the provided origin points
+ if ( origin ) {
+ baseline = $.effects.getBaseline( origin, original );
+ from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
+ from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
+ to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
+ to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
+ }
+ element.css( from );
+
+ // Animate the children if desired
+ if ( scale === "content" || scale === "both" ) {
+
+ vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
+ hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
+
+ // Only animate children with width attributes specified
+ // TODO: is this right? should we include anything with css width specified as well
+ element.find( "*[width]" ).each( function() {
+ var child = $( this ),
+ childOriginal = $.effects.scaledDimensions( child ),
+ childFrom = {
+ height: childOriginal.height * factor.from.y,
+ width: childOriginal.width * factor.from.x,
+ outerHeight: childOriginal.outerHeight * factor.from.y,
+ outerWidth: childOriginal.outerWidth * factor.from.x
+ },
+ childTo = {
+ height: childOriginal.height * factor.to.y,
+ width: childOriginal.width * factor.to.x,
+ outerHeight: childOriginal.height * factor.to.y,
+ outerWidth: childOriginal.width * factor.to.x
+ };
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
+ childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
+ childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
+ }
+
+ if ( restore ) {
+ $.effects.saveStyle( child );
+ }
+
+ // Animate children
+ child.css( childFrom );
+ child.animate( childTo, options.duration, options.easing, function() {
+
+ // Restore children
+ if ( restore ) {
+ $.effects.restoreStyle( child );
+ }
+ } );
+ } );
+ }
+
+ // Animate
+ element.animate( to, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: function() {
+
+ var offset = element.offset();
+
+ if ( to.opacity === 0 ) {
+ element.css( "opacity", from.opacity );
+ }
+
+ if ( !restore ) {
+ element
+ .css( "position", position === "static" ? "relative" : position )
+ .offset( offset );
+
+ // Need to save style here so that automatic style restoration
+ // doesn't restore to the original styles from before the animation.
+ $.effects.saveStyle( element );
+ }
+
+ done();
+ }
+ } );
+
+} );
+
+
+/*!
+ * jQuery UI Effects Scale 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Scale Effect
+//>>group: Effects
+//>>description: Grows or shrinks an element and its content.
+//>>docs: http://api.jqueryui.com/scale-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
+
+ // Create element
+ var el = $( this ),
+ mode = options.mode,
+ percent = parseInt( options.percent, 10 ) ||
+ ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
+
+ newOptions = $.extend( true, {
+ from: $.effects.scaledDimensions( el ),
+ to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
+ origin: options.origin || [ "middle", "center" ]
+ }, options );
+
+ // Fade option to support puff
+ if ( options.fade ) {
+ newOptions.from.opacity = 1;
+ newOptions.to.opacity = 0;
+ }
+
+ $.effects.effect.size.call( this, newOptions, done );
+} );
+
+
+/*!
+ * jQuery UI Effects Puff 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Puff Effect
+//>>group: Effects
+//>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
+//>>docs: http://api.jqueryui.com/puff-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
+ var newOptions = $.extend( true, {}, options, {
+ fade: true,
+ percent: parseInt( options.percent, 10 ) || 150
+ } );
+
+ $.effects.effect.scale.call( this, newOptions, done );
+} );
+
+
+/*!
+ * jQuery UI Effects Pulsate 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Pulsate Effect
+//>>group: Effects
+//>>description: Pulsates an element n times by changing the opacity to zero and back.
+//>>docs: http://api.jqueryui.com/pulsate-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
+ var element = $( this ),
+ mode = options.mode,
+ show = mode === "show",
+ hide = mode === "hide",
+ showhide = show || hide,
+
+ // Showing or hiding leaves off the "last" animation
+ anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
+ duration = options.duration / anims,
+ animateTo = 0,
+ i = 1,
+ queuelen = element.queue().length;
+
+ if ( show || !element.is( ":visible" ) ) {
+ element.css( "opacity", 0 ).show();
+ animateTo = 1;
+ }
+
+ // Anims - 1 opacity "toggles"
+ for ( ; i < anims; i++ ) {
+ element.animate( { opacity: animateTo }, duration, options.easing );
+ animateTo = 1 - animateTo;
+ }
+
+ element.animate( { opacity: animateTo }, duration, options.easing );
+
+ element.queue( done );
+
+ $.effects.unshift( element, queuelen, anims + 1 );
+} );
+
+
+/*!
+ * jQuery UI Effects Shake 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Shake Effect
+//>>group: Effects
+//>>description: Shakes an element horizontally or vertically n times.
+//>>docs: http://api.jqueryui.com/shake-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
+
+ var i = 1,
+ element = $( this ),
+ direction = options.direction || "left",
+ distance = options.distance || 20,
+ times = options.times || 3,
+ anims = times * 2 + 1,
+ speed = Math.round( options.duration / anims ),
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ positiveMotion = ( direction === "up" || direction === "left" ),
+ animation = {},
+ animation1 = {},
+ animation2 = {},
+
+ queuelen = element.queue().length;
+
+ $.effects.createPlaceholder( element );
+
+ // Animation
+ animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
+ animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
+ animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
+
+ // Animate
+ element.animate( animation, speed, options.easing );
+
+ // Shakes
+ for ( ; i < times; i++ ) {
+ element
+ .animate( animation1, speed, options.easing )
+ .animate( animation2, speed, options.easing );
+ }
+
+ element
+ .animate( animation1, speed, options.easing )
+ .animate( animation, speed / 2, options.easing )
+ .queue( done );
+
+ $.effects.unshift( element, queuelen, anims + 1 );
+} );
+
+
+/*!
+ * jQuery UI Effects Slide 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Slide Effect
+//>>group: Effects
+//>>description: Slides an element in and out of the viewport.
+//>>docs: http://api.jqueryui.com/slide-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
+ var startClip, startRef,
+ element = $( this ),
+ map = {
+ up: [ "bottom", "top" ],
+ down: [ "top", "bottom" ],
+ left: [ "right", "left" ],
+ right: [ "left", "right" ]
+ },
+ mode = options.mode,
+ direction = options.direction || "left",
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ positiveMotion = ( direction === "up" || direction === "left" ),
+ distance = options.distance ||
+ element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
+ animation = {};
+
+ $.effects.createPlaceholder( element );
+
+ startClip = element.cssClip();
+ startRef = element.position()[ ref ];
+
+ // Define hide animation
+ animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
+ animation.clip = element.cssClip();
+ animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
+
+ // Reverse the animation if we're showing
+ if ( mode === "show" ) {
+ element.cssClip( animation.clip );
+ element.css( ref, animation[ ref ] );
+ animation.clip = startClip;
+ animation[ ref ] = startRef;
+ }
+
+ // Actually animate
+ element.animate( animation, {
+ queue: false,
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
+ } );
+} );
+
+
+/*!
+ * jQuery UI Effects Transfer 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Transfer Effect
+//>>group: Effects
+//>>description: Displays a transfer effect from one element to another.
+//>>docs: http://api.jqueryui.com/transfer-effect/
+//>>demos: http://jqueryui.com/effect/
+
+
+
+var effect;
+if ( $.uiBackCompat !== false ) {
+ effect = $.effects.define( "transfer", function( options, done ) {
+ $( this ).transfer( options, done );
+ } );
+}
+var effectsEffectTransfer = effect;
+
+
+/*!
+ * jQuery UI Focusable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: :focusable Selector
+//>>group: Core
+//>>description: Selects elements which can be focused.
+//>>docs: http://api.jqueryui.com/focusable-selector/
+
+
+
+// Selectors
+$.ui.focusable = function( element, hasTabindex ) {
+ var map, mapName, img, focusableIfVisible, fieldset,
+ nodeName = element.nodeName.toLowerCase();
+
+ if ( "area" === nodeName ) {
+ map = element.parentNode;
+ mapName = map.name;
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
+ return false;
+ }
+ img = $( "img[usemap='#" + mapName + "']" );
+ return img.length > 0 && img.is( ":visible" );
+ }
+
+ if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
+ focusableIfVisible = !element.disabled;
+
+ if ( focusableIfVisible ) {
+
+ // Form controls within a disabled fieldset are disabled.
+ // However, controls within the fieldset's legend do not get disabled.
+ // Since controls generally aren't placed inside legends, we skip
+ // this portion of the check.
+ fieldset = $( element ).closest( "fieldset" )[ 0 ];
+ if ( fieldset ) {
+ focusableIfVisible = !fieldset.disabled;
+ }
+ }
+ } else if ( "a" === nodeName ) {
+ focusableIfVisible = element.href || hasTabindex;
+ } else {
+ focusableIfVisible = hasTabindex;
+ }
+
+ return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
+};
+
+// Support: IE 8 only
+// IE 8 doesn't resolve inherit to visible/hidden for computed values
+function visible( element ) {
+ var visibility = element.css( "visibility" );
+ while ( visibility === "inherit" ) {
+ element = element.parent();
+ visibility = element.css( "visibility" );
+ }
+ return visibility !== "hidden";
+}
+
+$.extend( $.expr[ ":" ], {
+ focusable: function( element ) {
+ return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
+ }
+} );
+
+var focusable = $.ui.focusable;
+
+
+
+
+// Support: IE8 Only
+// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
+// with a string, so we need to find the proper form.
+var form = $.fn.form = function() {
+ return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
+};
+
+
+/*!
+ * jQuery UI Form Reset Mixin 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Form Reset Mixin
+//>>group: Core
+//>>description: Refresh input widgets when their form is reset
+//>>docs: http://api.jqueryui.com/form-reset-mixin/
+
+
+
+var formResetMixin = $.ui.formResetMixin = {
+ _formResetHandler: function() {
+ var form = $( this );
+
+ // Wait for the form reset to actually happen before refreshing
+ setTimeout( function() {
+ var instances = form.data( "ui-form-reset-instances" );
+ $.each( instances, function() {
+ this.refresh();
+ } );
+ } );
+ },
+
+ _bindFormResetHandler: function() {
+ this.form = this.element.form();
+ if ( !this.form.length ) {
+ return;
+ }
+
+ var instances = this.form.data( "ui-form-reset-instances" ) || [];
+ if ( !instances.length ) {
+
+ // We don't use _on() here because we use a single event handler per form
+ this.form.on( "reset.ui-form-reset", this._formResetHandler );
+ }
+ instances.push( this );
+ this.form.data( "ui-form-reset-instances", instances );
+ },
+
+ _unbindFormResetHandler: function() {
+ if ( !this.form.length ) {
+ return;
+ }
+
+ var instances = this.form.data( "ui-form-reset-instances" );
+ instances.splice( $.inArray( this, instances ), 1 );
+ if ( instances.length ) {
+ this.form.data( "ui-form-reset-instances", instances );
+ } else {
+ this.form
+ .removeData( "ui-form-reset-instances" )
+ .off( "reset.ui-form-reset" );
+ }
+ }
+};
+
+
+/*!
+ * jQuery UI Support for jQuery core 1.7.x 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ */
+
+//>>label: jQuery 1.7 Support
+//>>group: Core
+//>>description: Support version 1.7.x of jQuery core
+
+
+
+// Support: jQuery 1.7 only
+// Not a great way to check versions, but since we only support 1.7+ and only
+// need to detect <1.8, this is a simple check that should suffice. Checking
+// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
+// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
+// 1.7 anymore). See #11197 for why we're not using feature detection.
+if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
+
+ // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
+ // Unlike jQuery Core 1.8+, these only support numeric values to set the
+ // dimensions in pixels
+ $.each( [ "Width", "Height" ], function( i, name ) {
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
+ type = name.toLowerCase(),
+ orig = {
+ innerWidth: $.fn.innerWidth,
+ innerHeight: $.fn.innerHeight,
+ outerWidth: $.fn.outerWidth,
+ outerHeight: $.fn.outerHeight
+ };
+
+ function reduce( elem, size, border, margin ) {
+ $.each( side, function() {
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
+ if ( border ) {
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
+ }
+ if ( margin ) {
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
+ }
+ } );
+ return size;
+ }
+
+ $.fn[ "inner" + name ] = function( size ) {
+ if ( size === undefined ) {
+ return orig[ "inner" + name ].call( this );
+ }
+
+ return this.each( function() {
+ $( this ).css( type, reduce( this, size ) + "px" );
+ } );
+ };
+
+ $.fn[ "outer" + name ] = function( size, margin ) {
+ if ( typeof size !== "number" ) {
+ return orig[ "outer" + name ].call( this, size );
+ }
+
+ return this.each( function() {
+ $( this ).css( type, reduce( this, size, true, margin ) + "px" );
+ } );
+ };
+ } );
+
+ $.fn.addBack = function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter( selector )
+ );
+ };
+}
+
+;
+/*!
+ * jQuery UI Keycode 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Keycode
+//>>group: Core
+//>>description: Provide keycodes as keynames
+//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
+
+
+var keycode = $.ui.keyCode = {
+ BACKSPACE: 8,
+ COMMA: 188,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ LEFT: 37,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+};
+
+
+
+
+// Internal use only
+var escapeSelector = $.ui.escapeSelector = ( function() {
+ var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
+ return function( selector ) {
+ return selector.replace( selectorEscape, "\\$1" );
+ };
+} )();
+
+
+/*!
+ * jQuery UI Labels 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: labels
+//>>group: Core
+//>>description: Find all the labels associated with a given input
+//>>docs: http://api.jqueryui.com/labels/
+
+
+
+var labels = $.fn.labels = function() {
+ var ancestor, selector, id, labels, ancestors;
+
+ // Check control.labels first
+ if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
+ return this.pushStack( this[ 0 ].labels );
+ }
+
+ // Support: IE <= 11, FF <= 37, Android <= 2.3 only
+ // Above browsers do not support control.labels. Everything below is to support them
+ // as well as document fragments. control.labels does not work on document fragments
+ labels = this.eq( 0 ).parents( "label" );
+
+ // Look for the label based on the id
+ id = this.attr( "id" );
+ if ( id ) {
+
+ // We don't search against the document in case the element
+ // is disconnected from the DOM
+ ancestor = this.eq( 0 ).parents().last();
+
+ // Get a full set of top level ancestors
+ ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
+
+ // Create a selector for the label based on the id
+ selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
+
+ labels = labels.add( ancestors.find( selector ).addBack( selector ) );
+
+ }
+
+ // Return whatever we have found for labels
+ return this.pushStack( labels );
+};
+
+
+/*!
+ * jQuery UI Scroll Parent 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: scrollParent
+//>>group: Core
+//>>description: Get the closest ancestor element that is scrollable.
+//>>docs: http://api.jqueryui.com/scrollParent/
+
+
+
+var scrollParent = $.fn.scrollParent = function( includeHidden ) {
+ var position = this.css( "position" ),
+ excludeStaticParent = position === "absolute",
+ overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
+ scrollParent = this.parents().filter( function() {
+ var parent = $( this );
+ if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
+ return false;
+ }
+ return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
+ parent.css( "overflow-x" ) );
+ } ).eq( 0 );
+
+ return position === "fixed" || !scrollParent.length ?
+ $( this[ 0 ].ownerDocument || document ) :
+ scrollParent;
+};
+
+
+/*!
+ * jQuery UI Tabbable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: :tabbable Selector
+//>>group: Core
+//>>description: Selects elements which can be tabbed to.
+//>>docs: http://api.jqueryui.com/tabbable-selector/
+
+
+
+var tabbable = $.extend( $.expr[ ":" ], {
+ tabbable: function( element ) {
+ var tabIndex = $.attr( element, "tabindex" ),
+ hasTabindex = tabIndex != null;
+ return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
+ }
+} );
+
+
+/*!
+ * jQuery UI Unique ID 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: uniqueId
+//>>group: Core
+//>>description: Functions to generate and remove uniqueId's
+//>>docs: http://api.jqueryui.com/uniqueId/
+
+
+
+var uniqueId = $.fn.extend( {
+ uniqueId: ( function() {
+ var uuid = 0;
+
+ return function() {
+ return this.each( function() {
+ if ( !this.id ) {
+ this.id = "ui-id-" + ( ++uuid );
+ }
+ } );
+ };
+ } )(),
+
+ removeUniqueId: function() {
+ return this.each( function() {
+ if ( /^ui-id-\d+$/.test( this.id ) ) {
+ $( this ).removeAttr( "id" );
+ }
+ } );
+ }
+} );
+
+
+/*!
+ * jQuery UI Accordion 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Accordion
+//>>group: Widgets
+// jscs:disable maximumLineLength
+//>>description: Displays collapsible content panels for presenting information in a limited amount of space.
+// jscs:enable maximumLineLength
+//>>docs: http://api.jqueryui.com/accordion/
+//>>demos: http://jqueryui.com/accordion/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/accordion.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+var widgetsAccordion = $.widget( "ui.accordion", {
+ version: "1.12.1",
+ options: {
+ active: 0,
+ animate: {},
+ classes: {
+ "ui-accordion-header": "ui-corner-top",
+ "ui-accordion-header-collapsed": "ui-corner-all",
+ "ui-accordion-content": "ui-corner-bottom"
+ },
+ collapsible: false,
+ event: "click",
+ header: "> li > :first-child, > :not(li):even",
+ heightStyle: "auto",
+ icons: {
+ activeHeader: "ui-icon-triangle-1-s",
+ header: "ui-icon-triangle-1-e"
+ },
+
+ // Callbacks
+ activate: null,
+ beforeActivate: null
+ },
+
+ hideProps: {
+ borderTopWidth: "hide",
+ borderBottomWidth: "hide",
+ paddingTop: "hide",
+ paddingBottom: "hide",
+ height: "hide"
+ },
+
+ showProps: {
+ borderTopWidth: "show",
+ borderBottomWidth: "show",
+ paddingTop: "show",
+ paddingBottom: "show",
+ height: "show"
+ },
+
+ _create: function() {
+ var options = this.options;
+
+ this.prevShow = this.prevHide = $();
+ this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
+ this.element.attr( "role", "tablist" );
+
+ // Don't allow collapsible: false and active: false / null
+ if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
+ options.active = 0;
+ }
+
+ this._processPanels();
+
+ // handle negative values
+ if ( options.active < 0 ) {
+ options.active += this.headers.length;
+ }
+ this._refresh();
+ },
+
+ _getCreateEventData: function() {
+ return {
+ header: this.active,
+ panel: !this.active.length ? $() : this.active.next()
+ };
+ },
+
+ _createIcons: function() {
+ var icon, children,
+ icons = this.options.icons;
+
+ if ( icons ) {
+ icon = $( "<span>" );
+ this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
+ icon.prependTo( this.headers );
+ children = this.active.children( ".ui-accordion-header-icon" );
+ this._removeClass( children, icons.header )
+ ._addClass( children, null, icons.activeHeader )
+ ._addClass( this.headers, "ui-accordion-icons" );
+ }
+ },
+
+ _destroyIcons: function() {
+ this._removeClass( this.headers, "ui-accordion-icons" );
+ this.headers.children( ".ui-accordion-header-icon" ).remove();
+ },
+
+ _destroy: function() {
+ var contents;
+
+ // Clean up main element
+ this.element.removeAttr( "role" );
+
+ // Clean up headers
+ this.headers
+ .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
+ .removeUniqueId();
+
+ this._destroyIcons();
+
+ // Clean up content panels
+ contents = this.headers.next()
+ .css( "display", "" )
+ .removeAttr( "role aria-hidden aria-labelledby" )
+ .removeUniqueId();
+
+ if ( this.options.heightStyle !== "content" ) {
+ contents.css( "height", "" );
+ }
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "active" ) {
+
+ // _activate() will handle invalid values and update this.options
+ this._activate( value );
+ return;
+ }
+
+ if ( key === "event" ) {
+ if ( this.options.event ) {
+ this._off( this.headers, this.options.event );
+ }
+ this._setupEvents( value );
+ }
+
+ this._super( key, value );
+
+ // Setting collapsible: false while collapsed; open first panel
+ if ( key === "collapsible" && !value && this.options.active === false ) {
+ this._activate( 0 );
+ }
+
+ if ( key === "icons" ) {
+ this._destroyIcons();
+ if ( value ) {
+ this._createIcons();
+ }
+ }
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", value );
+
+ // Support: IE8 Only
+ // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
+ // so we need to add the disabled class to the headers and panels
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
+ !!value );
+ },
+
+ _keydown: function( event ) {
+ if ( event.altKey || event.ctrlKey ) {
+ return;
+ }
+
+ var keyCode = $.ui.keyCode,
+ length = this.headers.length,
+ currentIndex = this.headers.index( event.target ),
+ toFocus = false;
+
+ switch ( event.keyCode ) {
+ case keyCode.RIGHT:
+ case keyCode.DOWN:
+ toFocus = this.headers[ ( currentIndex + 1 ) % length ];
+ break;
+ case keyCode.LEFT:
+ case keyCode.UP:
+ toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
+ break;
+ case keyCode.SPACE:
+ case keyCode.ENTER:
+ this._eventHandler( event );
+ break;
+ case keyCode.HOME:
+ toFocus = this.headers[ 0 ];
+ break;
+ case keyCode.END:
+ toFocus = this.headers[ length - 1 ];
+ break;
+ }
+
+ if ( toFocus ) {
+ $( event.target ).attr( "tabIndex", -1 );
+ $( toFocus ).attr( "tabIndex", 0 );
+ $( toFocus ).trigger( "focus" );
+ event.preventDefault();
+ }
+ },
+
+ _panelKeyDown: function( event ) {
+ if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
+ $( event.currentTarget ).prev().trigger( "focus" );
+ }
+ },
+
+ refresh: function() {
+ var options = this.options;
+ this._processPanels();
+
+ // Was collapsed or no panel
+ if ( ( options.active === false && options.collapsible === true ) ||
+ !this.headers.length ) {
+ options.active = false;
+ this.active = $();
+
+ // active false only when collapsible is true
+ } else if ( options.active === false ) {
+ this._activate( 0 );
+
+ // was active, but active panel is gone
+ } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+
+ // all remaining panel are disabled
+ if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
+ options.active = false;
+ this.active = $();
+
+ // activate previous panel
+ } else {
+ this._activate( Math.max( 0, options.active - 1 ) );
+ }
+
+ // was active, active panel still exists
+ } else {
+
+ // make sure active index is correct
+ options.active = this.headers.index( this.active );
+ }
+
+ this._destroyIcons();
+
+ this._refresh();
+ },
+
+ _processPanels: function() {
+ var prevHeaders = this.headers,
+ prevPanels = this.panels;
+
+ this.headers = this.element.find( this.options.header );
+ this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
+ "ui-state-default" );
+
+ this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
+ this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
+
+ // Avoid memory leaks (#10056)
+ if ( prevPanels ) {
+ this._off( prevHeaders.not( this.headers ) );
+ this._off( prevPanels.not( this.panels ) );
+ }
+ },
+
+ _refresh: function() {
+ var maxHeight,
+ options = this.options,
+ heightStyle = options.heightStyle,
+ parent = this.element.parent();
+
+ this.active = this._findActive( options.active );
+ this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
+ ._removeClass( this.active, "ui-accordion-header-collapsed" );
+ this._addClass( this.active.next(), "ui-accordion-content-active" );
+ this.active.next().show();
+
+ this.headers
+ .attr( "role", "tab" )
+ .each( function() {
+ var header = $( this ),
+ headerId = header.uniqueId().attr( "id" ),
+ panel = header.next(),
+ panelId = panel.uniqueId().attr( "id" );
+ header.attr( "aria-controls", panelId );
+ panel.attr( "aria-labelledby", headerId );
+ } )
+ .next()
+ .attr( "role", "tabpanel" );
+
+ this.headers
+ .not( this.active )
+ .attr( {
+ "aria-selected": "false",
+ "aria-expanded": "false",
+ tabIndex: -1
+ } )
+ .next()
+ .attr( {
+ "aria-hidden": "true"
+ } )
+ .hide();
+
+ // Make sure at least one header is in the tab order
+ if ( !this.active.length ) {
+ this.headers.eq( 0 ).attr( "tabIndex", 0 );
+ } else {
+ this.active.attr( {
+ "aria-selected": "true",
+ "aria-expanded": "true",
+ tabIndex: 0
+ } )
+ .next()
+ .attr( {
+ "aria-hidden": "false"
+ } );
+ }
+
+ this._createIcons();
+
+ this._setupEvents( options.event );
+
+ if ( heightStyle === "fill" ) {
+ maxHeight = parent.height();
+ this.element.siblings( ":visible" ).each( function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ } );
+
+ this.headers.each( function() {
+ maxHeight -= $( this ).outerHeight( true );
+ } );
+
+ this.headers.next()
+ .each( function() {
+ $( this ).height( Math.max( 0, maxHeight -
+ $( this ).innerHeight() + $( this ).height() ) );
+ } )
+ .css( "overflow", "auto" );
+ } else if ( heightStyle === "auto" ) {
+ maxHeight = 0;
+ this.headers.next()
+ .each( function() {
+ var isVisible = $( this ).is( ":visible" );
+ if ( !isVisible ) {
+ $( this ).show();
+ }
+ maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
+ if ( !isVisible ) {
+ $( this ).hide();
+ }
+ } )
+ .height( maxHeight );
+ }
+ },
+
+ _activate: function( index ) {
+ var active = this._findActive( index )[ 0 ];
+
+ // Trying to activate the already active panel
+ if ( active === this.active[ 0 ] ) {
+ return;
+ }
+
+ // Trying to collapse, simulate a click on the currently active header
+ active = active || this.active[ 0 ];
+
+ this._eventHandler( {
+ target: active,
+ currentTarget: active,
+ preventDefault: $.noop
+ } );
+ },
+
+ _findActive: function( selector ) {
+ return typeof selector === "number" ? this.headers.eq( selector ) : $();
+ },
+
+ _setupEvents: function( event ) {
+ var events = {
+ keydown: "_keydown"
+ };
+ if ( event ) {
+ $.each( event.split( " " ), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ } );
+ }
+
+ this._off( this.headers.add( this.headers.next() ) );
+ this._on( this.headers, events );
+ this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
+ this._hoverable( this.headers );
+ this._focusable( this.headers );
+ },
+
+ _eventHandler: function( event ) {
+ var activeChildren, clickedChildren,
+ options = this.options,
+ active = this.active,
+ clicked = $( event.currentTarget ),
+ clickedIsActive = clicked[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : clicked.next(),
+ toHide = active.next(),
+ eventData = {
+ oldHeader: active,
+ oldPanel: toHide,
+ newHeader: collapsing ? $() : clicked,
+ newPanel: toShow
+ };
+
+ event.preventDefault();
+
+ if (
+
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+ return;
+ }
+
+ options.active = collapsing ? false : this.headers.index( clicked );
+
+ // When the call to ._toggle() comes after the class changes
+ // it causes a very odd bug in IE 8 (see #6720)
+ this.active = clickedIsActive ? $() : clicked;
+ this._toggle( eventData );
+
+ // Switch classes
+ // corner classes on the previously active header stay after the animation
+ this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
+ if ( options.icons ) {
+ activeChildren = active.children( ".ui-accordion-header-icon" );
+ this._removeClass( activeChildren, null, options.icons.activeHeader )
+ ._addClass( activeChildren, null, options.icons.header );
+ }
+
+ if ( !clickedIsActive ) {
+ this._removeClass( clicked, "ui-accordion-header-collapsed" )
+ ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
+ if ( options.icons ) {
+ clickedChildren = clicked.children( ".ui-accordion-header-icon" );
+ this._removeClass( clickedChildren, null, options.icons.header )
+ ._addClass( clickedChildren, null, options.icons.activeHeader );
+ }
+
+ this._addClass( clicked.next(), "ui-accordion-content-active" );
+ }
+ },
+
+ _toggle: function( data ) {
+ var toShow = data.newPanel,
+ toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
+
+ // Handle activating a panel during the animation for another activation
+ this.prevShow.add( this.prevHide ).stop( true, true );
+ this.prevShow = toShow;
+ this.prevHide = toHide;
+
+ if ( this.options.animate ) {
+ this._animate( toShow, toHide, data );
+ } else {
+ toHide.hide();
+ toShow.show();
+ this._toggleComplete( data );
+ }
+
+ toHide.attr( {
+ "aria-hidden": "true"
+ } );
+ toHide.prev().attr( {
+ "aria-selected": "false",
+ "aria-expanded": "false"
+ } );
+
+ // if we're switching panels, remove the old header from the tab order
+ // if we're opening from collapsed state, remove the previous header from the tab order
+ // if we're collapsing, then keep the collapsing header in the tab order
+ if ( toShow.length && toHide.length ) {
+ toHide.prev().attr( {
+ "tabIndex": -1,
+ "aria-expanded": "false"
+ } );
+ } else if ( toShow.length ) {
+ this.headers.filter( function() {
+ return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
+ } )
+ .attr( "tabIndex", -1 );
+ }
+
+ toShow
+ .attr( "aria-hidden", "false" )
+ .prev()
+ .attr( {
+ "aria-selected": "true",
+ "aria-expanded": "true",
+ tabIndex: 0
+ } );
+ },
+
+ _animate: function( toShow, toHide, data ) {
+ var total, easing, duration,
+ that = this,
+ adjust = 0,
+ boxSizing = toShow.css( "box-sizing" ),
+ down = toShow.length &&
+ ( !toHide.length || ( toShow.index() < toHide.index() ) ),
+ animate = this.options.animate || {},
+ options = down && animate.down || animate,
+ complete = function() {
+ that._toggleComplete( data );
+ };
+
+ if ( typeof options === "number" ) {
+ duration = options;
+ }
+ if ( typeof options === "string" ) {
+ easing = options;
+ }
+
+ // fall back from options to animation in case of partial down settings
+ easing = easing || options.easing || animate.easing;
+ duration = duration || options.duration || animate.duration;
+
+ if ( !toHide.length ) {
+ return toShow.animate( this.showProps, duration, easing, complete );
+ }
+ if ( !toShow.length ) {
+ return toHide.animate( this.hideProps, duration, easing, complete );
+ }
+
+ total = toShow.show().outerHeight();
+ toHide.animate( this.hideProps, {
+ duration: duration,
+ easing: easing,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
+ }
+ } );
+ toShow
+ .hide()
+ .animate( this.showProps, {
+ duration: duration,
+ easing: easing,
+ complete: complete,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
+ if ( fx.prop !== "height" ) {
+ if ( boxSizing === "content-box" ) {
+ adjust += fx.now;
+ }
+ } else if ( that.options.heightStyle !== "content" ) {
+ fx.now = Math.round( total - toHide.outerHeight() - adjust );
+ adjust = 0;
+ }
+ }
+ } );
+ },
+
+ _toggleComplete: function( data ) {
+ var toHide = data.oldPanel,
+ prev = toHide.prev();
+
+ this._removeClass( toHide, "ui-accordion-content-active" );
+ this._removeClass( prev, "ui-accordion-header-active" )
+ ._addClass( prev, "ui-accordion-header-collapsed" );
+
+ // Work around for rendering bug in IE (#5421)
+ if ( toHide.length ) {
+ toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
+ }
+ this._trigger( "activate", null, data );
+ }
+} );
+
+
+
+var safeActiveElement = $.ui.safeActiveElement = function( document ) {
+ var activeElement;
+
+ // Support: IE 9 only
+ // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
+ try {
+ activeElement = document.activeElement;
+ } catch ( error ) {
+ activeElement = document.body;
+ }
+
+ // Support: IE 9 - 11 only
+ // IE may return null instead of an element
+ // Interestingly, this only seems to occur when NOT in an iframe
+ if ( !activeElement ) {
+ activeElement = document.body;
+ }
+
+ // Support: IE 11 only
+ // IE11 returns a seemingly empty object in some cases when accessing
+ // document.activeElement from an <iframe>
+ if ( !activeElement.nodeName ) {
+ activeElement = document.body;
+ }
+
+ return activeElement;
+};
+
+
+/*!
+ * jQuery UI Menu 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Menu
+//>>group: Widgets
+//>>description: Creates nestable menus.
+//>>docs: http://api.jqueryui.com/menu/
+//>>demos: http://jqueryui.com/menu/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/menu.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+var widgetsMenu = $.widget( "ui.menu", {
+ version: "1.12.1",
+ defaultElement: "<ul>",
+ delay: 300,
+ options: {
+ icons: {
+ submenu: "ui-icon-caret-1-e"
+ },
+ items: "> *",
+ menus: "ul",
+ position: {
+ my: "left top",
+ at: "right top"
+ },
+ role: "menu",
+
+ // Callbacks
+ blur: null,
+ focus: null,
+ select: null
+ },
+
+ _create: function() {
+ this.activeMenu = this.element;
+
+ // Flag used to prevent firing of the click handler
+ // as the event bubbles up through nested menus
+ this.mouseHandled = false;
+ this.element
+ .uniqueId()
+ .attr( {
+ role: this.options.role,
+ tabIndex: 0
+ } );
+
+ this._addClass( "ui-menu", "ui-widget ui-widget-content" );
+ this._on( {
+
+ // Prevent focus from sticking to links inside menu after clicking
+ // them (focus should always stay on UL during navigation).
+ "mousedown .ui-menu-item": function( event ) {
+ event.preventDefault();
+ },
+ "click .ui-menu-item": function( event ) {
+ var target = $( event.target );
+ var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+ this.select( event );
+
+ // Only set the mouseHandled flag if the event will bubble, see #9469.
+ if ( !event.isPropagationStopped() ) {
+ this.mouseHandled = true;
+ }
+
+ // Open submenu on click
+ if ( target.has( ".ui-menu" ).length ) {
+ this.expand( event );
+ } else if ( !this.element.is( ":focus" ) &&
+ active.closest( ".ui-menu" ).length ) {
+
+ // Redirect focus to the menu
+ this.element.trigger( "focus", [ true ] );
+
+ // If the active item is on the top level, let it stay active.
+ // Otherwise, blur the active item since it is no longer visible.
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
+ clearTimeout( this.timer );
+ }
+ }
+ }
+ },
+ "mouseenter .ui-menu-item": function( event ) {
+
+ // Ignore mouse events while typeahead is active, see #10458.
+ // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
+ // is over an item in the menu
+ if ( this.previousFilter ) {
+ return;
+ }
+
+ var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
+ target = $( event.currentTarget );
+
+ // Ignore bubbled events on parent items, see #11641
+ if ( actualTarget[ 0 ] !== target[ 0 ] ) {
+ return;
+ }
+
+ // Remove ui-state-active class from siblings of the newly focused menu item
+ // to avoid a jump caused by adjacent elements both having a class with a border
+ this._removeClass( target.siblings().children( ".ui-state-active" ),
+ null, "ui-state-active" );
+ this.focus( event, target );
+ },
+ mouseleave: "collapseAll",
+ "mouseleave .ui-menu": "collapseAll",
+ focus: function( event, keepActiveItem ) {
+
+ // If there's already an active item, keep it active
+ // If not, activate the first item
+ var item = this.active || this.element.find( this.options.items ).eq( 0 );
+
+ if ( !keepActiveItem ) {
+ this.focus( event, item );
+ }
+ },
+ blur: function( event ) {
+ this._delay( function() {
+ var notContained = !$.contains(
+ this.element[ 0 ],
+ $.ui.safeActiveElement( this.document[ 0 ] )
+ );
+ if ( notContained ) {
+ this.collapseAll( event );
+ }
+ } );
+ },
+ keydown: "_keydown"
+ } );
+
+ this.refresh();
+
+ // Clicks outside of a menu collapse any open menus
+ this._on( this.document, {
+ click: function( event ) {
+ if ( this._closeOnDocumentClick( event ) ) {
+ this.collapseAll( event );
+ }
+
+ // Reset the mouseHandled flag
+ this.mouseHandled = false;
+ }
+ } );
+ },
+
+ _destroy: function() {
+ var items = this.element.find( ".ui-menu-item" )
+ .removeAttr( "role aria-disabled" ),
+ submenus = items.children( ".ui-menu-item-wrapper" )
+ .removeUniqueId()
+ .removeAttr( "tabIndex role aria-haspopup" );
+
+ // Destroy (sub)menus
+ this.element
+ .removeAttr( "aria-activedescendant" )
+ .find( ".ui-menu" ).addBack()
+ .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
+ "tabIndex" )
+ .removeUniqueId()
+ .show();
+
+ submenus.children().each( function() {
+ var elem = $( this );
+ if ( elem.data( "ui-menu-submenu-caret" ) ) {
+ elem.remove();
+ }
+ } );
+ },
+
+ _keydown: function( event ) {
+ var match, prev, character, skip,
+ preventDefault = true;
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ this.previousPage( event );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ this.nextPage( event );
+ break;
+ case $.ui.keyCode.HOME:
+ this._move( "first", "first", event );
+ break;
+ case $.ui.keyCode.END:
+ this._move( "last", "last", event );
+ break;
+ case $.ui.keyCode.UP:
+ this.previous( event );
+ break;
+ case $.ui.keyCode.DOWN:
+ this.next( event );
+ break;
+ case $.ui.keyCode.LEFT:
+ this.collapse( event );
+ break;
+ case $.ui.keyCode.RIGHT:
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
+ this.expand( event );
+ }
+ break;
+ case $.ui.keyCode.ENTER:
+ case $.ui.keyCode.SPACE:
+ this._activate( event );
+ break;
+ case $.ui.keyCode.ESCAPE:
+ this.collapse( event );
+ break;
+ default:
+ preventDefault = false;
+ prev = this.previousFilter || "";
+ skip = false;
+
+ // Support number pad values
+ character = event.keyCode >= 96 && event.keyCode <= 105 ?
+ ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
+
+ clearTimeout( this.filterTimer );
+
+ if ( character === prev ) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+
+ match = this._filterMenuItems( character );
+ match = skip && match.index( this.active.next() ) !== -1 ?
+ this.active.nextAll( ".ui-menu-item" ) :
+ match;
+
+ // If no matches on the current filter, reset to the last character pressed
+ // to move down the menu to the first item that starts with that character
+ if ( !match.length ) {
+ character = String.fromCharCode( event.keyCode );
+ match = this._filterMenuItems( character );
+ }
+
+ if ( match.length ) {
+ this.focus( event, match );
+ this.previousFilter = character;
+ this.filterTimer = this._delay( function() {
+ delete this.previousFilter;
+ }, 1000 );
+ } else {
+ delete this.previousFilter;
+ }
+ }
+
+ if ( preventDefault ) {
+ event.preventDefault();
+ }
+ },
+
+ _activate: function( event ) {
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
+ if ( this.active.children( "[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ } else {
+ this.select( event );
+ }
+ }
+ },
+
+ refresh: function() {
+ var menus, items, newSubmenus, newItems, newWrappers,
+ that = this,
+ icon = this.options.icons.submenu,
+ submenus = this.element.find( this.options.menus );
+
+ this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
+
+ // Initialize nested menus
+ newSubmenus = submenus.filter( ":not(.ui-menu)" )
+ .hide()
+ .attr( {
+ role: this.options.role,
+ "aria-hidden": "true",
+ "aria-expanded": "false"
+ } )
+ .each( function() {
+ var menu = $( this ),
+ item = menu.prev(),
+ submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
+
+ that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
+ item
+ .attr( "aria-haspopup", "true" )
+ .prepend( submenuCaret );
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
+ } );
+
+ this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
+
+ menus = submenus.add( this.element );
+ items = menus.find( this.options.items );
+
+ // Initialize menu-items containing spaces and/or dashes only as dividers
+ items.not( ".ui-menu-item" ).each( function() {
+ var item = $( this );
+ if ( that._isDivider( item ) ) {
+ that._addClass( item, "ui-menu-divider", "ui-widget-content" );
+ }
+ } );
+
+ // Don't refresh list items that are already adapted
+ newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
+ newWrappers = newItems.children()
+ .not( ".ui-menu" )
+ .uniqueId()
+ .attr( {
+ tabIndex: -1,
+ role: this._itemRole()
+ } );
+ this._addClass( newItems, "ui-menu-item" )
+ ._addClass( newWrappers, "ui-menu-item-wrapper" );
+
+ // Add aria-disabled attribute to any disabled menu item
+ items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
+
+ // If the active item has been removed, blur the menu
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+ this.blur();
+ }
+ },
+
+ _itemRole: function() {
+ return {
+ menu: "menuitem",
+ listbox: "option"
+ }[ this.options.role ];
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "icons" ) {
+ var icons = this.element.find( ".ui-menu-icon" );
+ this._removeClass( icons, null, this.options.icons.submenu )
+ ._addClass( icons, null, value.submenu );
+ }
+ this._super( key, value );
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", String( value ) );
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
+ focus: function( event, item ) {
+ var nested, focused, activeParent;
+ this.blur( event, event && event.type === "focus" );
+
+ this._scrollIntoView( item );
+
+ this.active = item.first();
+
+ focused = this.active.children( ".ui-menu-item-wrapper" );
+ this._addClass( focused, null, "ui-state-active" );
+
+ // Only update aria-activedescendant if there's a role
+ // otherwise we assume focus is managed elsewhere
+ if ( this.options.role ) {
+ this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
+ }
+
+ // Highlight active parent menu item, if any
+ activeParent = this.active
+ .parent()
+ .closest( ".ui-menu-item" )
+ .children( ".ui-menu-item-wrapper" );
+ this._addClass( activeParent, null, "ui-state-active" );
+
+ if ( event && event.type === "keydown" ) {
+ this._close();
+ } else {
+ this.timer = this._delay( function() {
+ this._close();
+ }, this.delay );
+ }
+
+ nested = item.children( ".ui-menu" );
+ if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
+ this._startOpening( nested );
+ }
+ this.activeMenu = item.parent();
+
+ this._trigger( "focus", event, { item: item } );
+ },
+
+ _scrollIntoView: function( item ) {
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
+ if ( this._hasScroll() ) {
+ borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
+ paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
+ scroll = this.activeMenu.scrollTop();
+ elementHeight = this.activeMenu.height();
+ itemHeight = item.outerHeight();
+
+ if ( offset < 0 ) {
+ this.activeMenu.scrollTop( scroll + offset );
+ } else if ( offset + itemHeight > elementHeight ) {
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
+ }
+ }
+ },
+
+ blur: function( event, fromFocus ) {
+ if ( !fromFocus ) {
+ clearTimeout( this.timer );
+ }
+
+ if ( !this.active ) {
+ return;
+ }
+
+ this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
+ null, "ui-state-active" );
+
+ this._trigger( "blur", event, { item: this.active } );
+ this.active = null;
+ },
+
+ _startOpening: function( submenu ) {
+ clearTimeout( this.timer );
+
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
+ // shift in the submenu position when mousing over the caret icon
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
+ return;
+ }
+
+ this.timer = this._delay( function() {
+ this._close();
+ this._open( submenu );
+ }, this.delay );
+ },
+
+ _open: function( submenu ) {
+ var position = $.extend( {
+ of: this.active
+ }, this.options.position );
+
+ clearTimeout( this.timer );
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
+ .hide()
+ .attr( "aria-hidden", "true" );
+
+ submenu
+ .show()
+ .removeAttr( "aria-hidden" )
+ .attr( "aria-expanded", "true" )
+ .position( position );
+ },
+
+ collapseAll: function( event, all ) {
+ clearTimeout( this.timer );
+ this.timer = this._delay( function() {
+
+ // If we were passed an event, look for the submenu that contains the event
+ var currentMenu = all ? this.element :
+ $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
+
+ // If we found no valid submenu ancestor, use the main menu to close all
+ // sub menus anyway
+ if ( !currentMenu.length ) {
+ currentMenu = this.element;
+ }
+
+ this._close( currentMenu );
+
+ this.blur( event );
+
+ // Work around active item staying active after menu is blurred
+ this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
+
+ this.activeMenu = currentMenu;
+ }, this.delay );
+ },
+
+ // With no arguments, closes the currently active menu - if nothing is active
+ // it closes all menus. If passed an argument, it will search for menus BELOW
+ _close: function( startMenu ) {
+ if ( !startMenu ) {
+ startMenu = this.active ? this.active.parent() : this.element;
+ }
+
+ startMenu.find( ".ui-menu" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" );
+ },
+
+ _closeOnDocumentClick: function( event ) {
+ return !$( event.target ).closest( ".ui-menu" ).length;
+ },
+
+ _isDivider: function( item ) {
+
+ // Match hyphen, em dash, en dash
+ return !/[^\-\u2014\u2013\s]/.test( item.text() );
+ },
+
+ collapse: function( event ) {
+ var newItem = this.active &&
+ this.active.parent().closest( ".ui-menu-item", this.element );
+ if ( newItem && newItem.length ) {
+ this._close();
+ this.focus( event, newItem );
+ }
+ },
+
+ expand: function( event ) {
+ var newItem = this.active &&
+ this.active
+ .children( ".ui-menu " )
+ .find( this.options.items )
+ .first();
+
+ if ( newItem && newItem.length ) {
+ this._open( newItem.parent() );
+
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
+ this._delay( function() {
+ this.focus( event, newItem );
+ } );
+ }
+ },
+
+ next: function( event ) {
+ this._move( "next", "first", event );
+ },
+
+ previous: function( event ) {
+ this._move( "prev", "last", event );
+ },
+
+ isFirstItem: function() {
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
+ },
+
+ isLastItem: function() {
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
+ },
+
+ _move: function( direction, filter, event ) {
+ var next;
+ if ( this.active ) {
+ if ( direction === "first" || direction === "last" ) {
+ next = this.active
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
+ .eq( -1 );
+ } else {
+ next = this.active
+ [ direction + "All" ]( ".ui-menu-item" )
+ .eq( 0 );
+ }
+ }
+ if ( !next || !next.length || !this.active ) {
+ next = this.activeMenu.find( this.options.items )[ filter ]();
+ }
+
+ this.focus( event, next );
+ },
+
+ nextPage: function( event ) {
+ var item, base, height;
+
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isLastItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.nextAll( ".ui-menu-item" ).each( function() {
+ item = $( this );
+ return item.offset().top - base - height < 0;
+ } );
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.find( this.options.items )
+ [ !this.active ? "first" : "last" ]() );
+ }
+ },
+
+ previousPage: function( event ) {
+ var item, base, height;
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isFirstItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.prevAll( ".ui-menu-item" ).each( function() {
+ item = $( this );
+ return item.offset().top - base + height > 0;
+ } );
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.find( this.options.items ).first() );
+ }
+ },
+
+ _hasScroll: function() {
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
+ },
+
+ select: function( event ) {
+
+ // TODO: It should never be possible to not have an active item at this
+ // point, but the tests don't trigger mouseenter before click.
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
+ var ui = { item: this.active };
+ if ( !this.active.has( ".ui-menu" ).length ) {
+ this.collapseAll( event, true );
+ }
+ this._trigger( "select", event, ui );
+ },
+
+ _filterMenuItems: function( character ) {
+ var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
+ regex = new RegExp( "^" + escapedCharacter, "i" );
+
+ return this.activeMenu
+ .find( this.options.items )
+
+ // Only match on items, not dividers or other content (#10571)
+ .filter( ".ui-menu-item" )
+ .filter( function() {
+ return regex.test(
+ $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
+ } );
+ }
+} );
+
+
+/*!
+ * jQuery UI Autocomplete 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Autocomplete
+//>>group: Widgets
+//>>description: Lists suggested words as the user is typing.
+//>>docs: http://api.jqueryui.com/autocomplete/
+//>>demos: http://jqueryui.com/autocomplete/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/autocomplete.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.autocomplete", {
+ version: "1.12.1",
+ defaultElement: "<input>",
+ options: {
+ appendTo: null,
+ autoFocus: false,
+ delay: 300,
+ minLength: 1,
+ position: {
+ my: "left top",
+ at: "left bottom",
+ collision: "none"
+ },
+ source: null,
+
+ // Callbacks
+ change: null,
+ close: null,
+ focus: null,
+ open: null,
+ response: null,
+ search: null,
+ select: null
+ },
+
+ requestIndex: 0,
+ pending: 0,
+
+ _create: function() {
+
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
+ nodeName = this.element[ 0 ].nodeName.toLowerCase(),
+ isTextarea = nodeName === "textarea",
+ isInput = nodeName === "input";
+
+ // Textareas are always multi-line
+ // Inputs are always single-line, even if inside a contentEditable element
+ // IE also treats inputs as contentEditable
+ // All other element types are determined by whether or not they're contentEditable
+ this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
+
+ this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
+ this.isNewMenu = true;
+
+ this._addClass( "ui-autocomplete-input" );
+ this.element.attr( "autocomplete", "off" );
+
+ this._on( this.element, {
+ keydown: function( event ) {
+ if ( this.element.prop( "readOnly" ) ) {
+ suppressKeyPress = true;
+ suppressInput = true;
+ suppressKeyPressRepeat = true;
+ return;
+ }
+
+ suppressKeyPress = false;
+ suppressInput = false;
+ suppressKeyPressRepeat = false;
+ var keyCode = $.ui.keyCode;
+ switch ( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ suppressKeyPress = true;
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ suppressKeyPress = true;
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ suppressKeyPress = true;
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ suppressKeyPress = true;
+ this._keyEvent( "next", event );
+ break;
+ case keyCode.ENTER:
+
+ // when menu is open and has focus
+ if ( this.menu.active ) {
+
+ // #6055 - Opera still allows the keypress to occur
+ // which causes forms to submit
+ suppressKeyPress = true;
+ event.preventDefault();
+ this.menu.select( event );
+ }
+ break;
+ case keyCode.TAB:
+ if ( this.menu.active ) {
+ this.menu.select( event );
+ }
+ break;
+ case keyCode.ESCAPE:
+ if ( this.menu.element.is( ":visible" ) ) {
+ if ( !this.isMultiLine ) {
+ this._value( this.term );
+ }
+ this.close( event );
+
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
+ }
+ break;
+ default:
+ suppressKeyPressRepeat = true;
+
+ // search timeout should be triggered before the input value is changed
+ this._searchTimeout( event );
+ break;
+ }
+ },
+ keypress: function( event ) {
+ if ( suppressKeyPress ) {
+ suppressKeyPress = false;
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ event.preventDefault();
+ }
+ return;
+ }
+ if ( suppressKeyPressRepeat ) {
+ return;
+ }
+
+ // Replicate some key handlers to allow them to repeat in Firefox and Opera
+ var keyCode = $.ui.keyCode;
+ switch ( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ this._keyEvent( "next", event );
+ break;
+ }
+ },
+ input: function( event ) {
+ if ( suppressInput ) {
+ suppressInput = false;
+ event.preventDefault();
+ return;
+ }
+ this._searchTimeout( event );
+ },
+ focus: function() {
+ this.selectedItem = null;
+ this.previous = this._value();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
+ clearTimeout( this.searching );
+ this.close( event );
+ this._change( event );
+ }
+ } );
+
+ this._initSource();
+ this.menu = $( "<ul>" )
+ .appendTo( this._appendTo() )
+ .menu( {
+
+ // disable ARIA support, the live region takes care of that
+ role: null
+ } )
+ .hide()
+ .menu( "instance" );
+
+ this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
+ this._on( this.menu.element, {
+ mousedown: function( event ) {
+
+ // prevent moving focus out of the text field
+ event.preventDefault();
+
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ this.cancelBlur = true;
+ this._delay( function() {
+ delete this.cancelBlur;
+
+ // Support: IE 8 only
+ // Right clicking a menu item or selecting text from the menu items will
+ // result in focus moving out of the input. However, we've already received
+ // and ignored the blur event because of the cancelBlur flag set above. So
+ // we restore focus to ensure that the menu closes properly based on the user's
+ // next actions.
+ if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
+ this.element.trigger( "focus" );
+ }
+ } );
+ },
+ menufocus: function( event, ui ) {
+ var label, item;
+
+ // support: Firefox
+ // Prevent accidental activation of menu items in Firefox (#7024 #9118)
+ if ( this.isNewMenu ) {
+ this.isNewMenu = false;
+ if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
+ this.menu.blur();
+
+ this.document.one( "mousemove", function() {
+ $( event.target ).trigger( event.originalEvent );
+ } );
+
+ return;
+ }
+ }
+
+ item = ui.item.data( "ui-autocomplete-item" );
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
+
+ // use value to match what will end up in the input, if it was a key event
+ if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
+ this._value( item.value );
+ }
+ }
+
+ // Announce the value in the liveRegion
+ label = ui.item.attr( "aria-label" ) || item.value;
+ if ( label && $.trim( label ).length ) {
+ this.liveRegion.children().hide();
+ $( "<div>" ).text( label ).appendTo( this.liveRegion );
+ }
+ },
+ menuselect: function( event, ui ) {
+ var item = ui.item.data( "ui-autocomplete-item" ),
+ previous = this.previous;
+
+ // Only trigger when focus was lost (click on menu)
+ if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
+ this.element.trigger( "focus" );
+ this.previous = previous;
+
+ // #6109 - IE triggers two focus events and the second
+ // is asynchronous, so we need to reset the previous
+ // term synchronously and asynchronously :-(
+ this._delay( function() {
+ this.previous = previous;
+ this.selectedItem = item;
+ } );
+ }
+
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
+ this._value( item.value );
+ }
+
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ this.term = this._value();
+
+ this.close( event );
+ this.selectedItem = item;
+ }
+ } );
+
+ this.liveRegion = $( "<div>", {
+ role: "status",
+ "aria-live": "assertive",
+ "aria-relevant": "additions"
+ } )
+ .appendTo( this.document[ 0 ].body );
+
+ this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
+
+ // Turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ } );
+ },
+
+ _destroy: function() {
+ clearTimeout( this.searching );
+ this.element.removeAttr( "autocomplete" );
+ this.menu.element.remove();
+ this.liveRegion.remove();
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+ if ( key === "source" ) {
+ this._initSource();
+ }
+ if ( key === "appendTo" ) {
+ this.menu.element.appendTo( this._appendTo() );
+ }
+ if ( key === "disabled" && value && this.xhr ) {
+ this.xhr.abort();
+ }
+ },
+
+ _isEventTargetInWidget: function( event ) {
+ var menuElement = this.menu.element[ 0 ];
+
+ return event.target === this.element[ 0 ] ||
+ event.target === menuElement ||
+ $.contains( menuElement, event.target );
+ },
+
+ _closeOnClickOutside: function( event ) {
+ if ( !this._isEventTargetInWidget( event ) ) {
+ this.close();
+ }
+ },
+
+ _appendTo: function() {
+ var element = this.options.appendTo;
+
+ if ( element ) {
+ element = element.jquery || element.nodeType ?
+ $( element ) :
+ this.document.find( element ).eq( 0 );
+ }
+
+ if ( !element || !element[ 0 ] ) {
+ element = this.element.closest( ".ui-front, dialog" );
+ }
+
+ if ( !element.length ) {
+ element = this.document[ 0 ].body;
+ }
+
+ return element;
+ },
+
+ _initSource: function() {
+ var array, url,
+ that = this;
+ if ( $.isArray( this.options.source ) ) {
+ array = this.options.source;
+ this.source = function( request, response ) {
+ response( $.ui.autocomplete.filter( array, request.term ) );
+ };
+ } else if ( typeof this.options.source === "string" ) {
+ url = this.options.source;
+ this.source = function( request, response ) {
+ if ( that.xhr ) {
+ that.xhr.abort();
+ }
+ that.xhr = $.ajax( {
+ url: url,
+ data: request,
+ dataType: "json",
+ success: function( data ) {
+ response( data );
+ },
+ error: function() {
+ response( [] );
+ }
+ } );
+ };
+ } else {
+ this.source = this.options.source;
+ }
+ },
+
+ _searchTimeout: function( event ) {
+ clearTimeout( this.searching );
+ this.searching = this._delay( function() {
+
+ // Search if the value has changed, or if the user retypes the same value (see #7434)
+ var equalValues = this.term === this._value(),
+ menuVisible = this.menu.element.is( ":visible" ),
+ modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
+
+ if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
+ this.selectedItem = null;
+ this.search( null, event );
+ }
+ }, this.options.delay );
+ },
+
+ search: function( value, event ) {
+ value = value != null ? value : this._value();
+
+ // Always save the actual value, not the one passed as an argument
+ this.term = this._value();
+
+ if ( value.length < this.options.minLength ) {
+ return this.close( event );
+ }
+
+ if ( this._trigger( "search", event ) === false ) {
+ return;
+ }
+
+ return this._search( value );
+ },
+
+ _search: function( value ) {
+ this.pending++;
+ this._addClass( "ui-autocomplete-loading" );
+ this.cancelSearch = false;
+
+ this.source( { term: value }, this._response() );
+ },
+
+ _response: function() {
+ var index = ++this.requestIndex;
+
+ return $.proxy( function( content ) {
+ if ( index === this.requestIndex ) {
+ this.__response( content );
+ }
+
+ this.pending--;
+ if ( !this.pending ) {
+ this._removeClass( "ui-autocomplete-loading" );
+ }
+ }, this );
+ },
+
+ __response: function( content ) {
+ if ( content ) {
+ content = this._normalize( content );
+ }
+ this._trigger( "response", null, { content: content } );
+ if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
+ this._suggest( content );
+ this._trigger( "open" );
+ } else {
+
+ // use ._close() instead of .close() so we don't cancel future searches
+ this._close();
+ }
+ },
+
+ close: function( event ) {
+ this.cancelSearch = true;
+ this._close( event );
+ },
+
+ _close: function( event ) {
+
+ // Remove the handler that closes the menu on outside clicks
+ this._off( this.document, "mousedown" );
+
+ if ( this.menu.element.is( ":visible" ) ) {
+ this.menu.element.hide();
+ this.menu.blur();
+ this.isNewMenu = true;
+ this._trigger( "close", event );
+ }
+ },
+
+ _change: function( event ) {
+ if ( this.previous !== this._value() ) {
+ this._trigger( "change", event, { item: this.selectedItem } );
+ }
+ },
+
+ _normalize: function( items ) {
+
+ // assume all items have the right format when the first item is complete
+ if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
+ return items;
+ }
+ return $.map( items, function( item ) {
+ if ( typeof item === "string" ) {
+ return {
+ label: item,
+ value: item
+ };
+ }
+ return $.extend( {}, item, {
+ label: item.label || item.value,
+ value: item.value || item.label
+ } );
+ } );
+ },
+
+ _suggest: function( items ) {
+ var ul = this.menu.element.empty();
+ this._renderMenu( ul, items );
+ this.isNewMenu = true;
+ this.menu.refresh();
+
+ // Size and position menu
+ ul.show();
+ this._resizeMenu();
+ ul.position( $.extend( {
+ of: this.element
+ }, this.options.position ) );
+
+ if ( this.options.autoFocus ) {
+ this.menu.next();
+ }
+
+ // Listen for interactions outside of the widget (#6642)
+ this._on( this.document, {
+ mousedown: "_closeOnClickOutside"
+ } );
+ },
+
+ _resizeMenu: function() {
+ var ul = this.menu.element;
+ ul.outerWidth( Math.max(
+
+ // Firefox wraps long text (possibly a rounding bug)
+ // so we add 1px to avoid the wrapping (#7513)
+ ul.width( "" ).outerWidth() + 1,
+ this.element.outerWidth()
+ ) );
+ },
+
+ _renderMenu: function( ul, items ) {
+ var that = this;
+ $.each( items, function( index, item ) {
+ that._renderItemData( ul, item );
+ } );
+ },
+
+ _renderItemData: function( ul, item ) {
+ return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
+ },
+
+ _renderItem: function( ul, item ) {
+ return $( "<li>" )
+ .append( $( "<div>" ).text( item.label ) )
+ .appendTo( ul );
+ },
+
+ _move: function( direction, event ) {
+ if ( !this.menu.element.is( ":visible" ) ) {
+ this.search( null, event );
+ return;
+ }
+ if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
+ this.menu.isLastItem() && /^next/.test( direction ) ) {
+
+ if ( !this.isMultiLine ) {
+ this._value( this.term );
+ }
+
+ this.menu.blur();
+ return;
+ }
+ this.menu[ direction ]( event );
+ },
+
+ widget: function() {
+ return this.menu.element;
+ },
+
+ _value: function() {
+ return this.valueMethod.apply( this.element, arguments );
+ },
+
+ _keyEvent: function( keyEvent, event ) {
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ this._move( keyEvent, event );
+
+ // Prevents moving cursor to beginning/end of the text field in some browsers
+ event.preventDefault();
+ }
+ },
+
+ // Support: Chrome <=50
+ // We should be able to just use this.element.prop( "isContentEditable" )
+ // but hidden elements always report false in Chrome.
+ // https://code.google.com/p/chromium/issues/detail?id=313082
+ _isContentEditable: function( element ) {
+ if ( !element.length ) {
+ return false;
+ }
+
+ var editable = element.prop( "contentEditable" );
+
+ if ( editable === "inherit" ) {
+ return this._isContentEditable( element.parent() );
+ }
+
+ return editable === "true";
+ }
+} );
+
+$.extend( $.ui.autocomplete, {
+ escapeRegex: function( value ) {
+ return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
+ },
+ filter: function( array, term ) {
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
+ return $.grep( array, function( value ) {
+ return matcher.test( value.label || value.value || value );
+ } );
+ }
+} );
+
+// Live region extension, adding a `messages` option
+// NOTE: This is an experimental API. We are still investigating
+// a full solution for string manipulation and internationalization.
+$.widget( "ui.autocomplete", $.ui.autocomplete, {
+ options: {
+ messages: {
+ noResults: "No search results.",
+ results: function( amount ) {
+ return amount + ( amount > 1 ? " results are" : " result is" ) +
+ " available, use up and down arrow keys to navigate.";
+ }
+ }
+ },
+
+ __response: function( content ) {
+ var message;
+ this._superApply( arguments );
+ if ( this.options.disabled || this.cancelSearch ) {
+ return;
+ }
+ if ( content && content.length ) {
+ message = this.options.messages.results( content.length );
+ } else {
+ message = this.options.messages.noResults;
+ }
+ this.liveRegion.children().hide();
+ $( "<div>" ).text( message ).appendTo( this.liveRegion );
+ }
+} );
+
+var widgetsAutocomplete = $.ui.autocomplete;
+
+
+/*!
+ * jQuery UI Controlgroup 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Controlgroup
+//>>group: Widgets
+//>>description: Visually groups form control widgets
+//>>docs: http://api.jqueryui.com/controlgroup/
+//>>demos: http://jqueryui.com/controlgroup/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/controlgroup.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
+
+var widgetsControlgroup = $.widget( "ui.controlgroup", {
+ version: "1.12.1",
+ defaultElement: "<div>",
+ options: {
+ direction: "horizontal",
+ disabled: null,
+ onlyVisible: true,
+ items: {
+ "button": "input[type=button], input[type=submit], input[type=reset], button, a",
+ "controlgroupLabel": ".ui-controlgroup-label",
+ "checkboxradio": "input[type='checkbox'], input[type='radio']",
+ "selectmenu": "select",
+ "spinner": ".ui-spinner-input"
+ }
+ },
+
+ _create: function() {
+ this._enhance();
+ },
+
+ // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
+ _enhance: function() {
+ this.element.attr( "role", "toolbar" );
+ this.refresh();
+ },
+
+ _destroy: function() {
+ this._callChildMethod( "destroy" );
+ this.childWidgets.removeData( "ui-controlgroup-data" );
+ this.element.removeAttr( "role" );
+ if ( this.options.items.controlgroupLabel ) {
+ this.element
+ .find( this.options.items.controlgroupLabel )
+ .find( ".ui-controlgroup-label-contents" )
+ .contents().unwrap();
+ }
+ },
+
+ _initWidgets: function() {
+ var that = this,
+ childWidgets = [];
+
+ // First we iterate over each of the items options
+ $.each( this.options.items, function( widget, selector ) {
+ var labels;
+ var options = {};
+
+ // Make sure the widget has a selector set
+ if ( !selector ) {
+ return;
+ }
+
+ if ( widget === "controlgroupLabel" ) {
+ labels = that.element.find( selector );
+ labels.each( function() {
+ var element = $( this );
+
+ if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
+ return;
+ }
+ element.contents()
+ .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
+ } );
+ that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
+ childWidgets = childWidgets.concat( labels.get() );
+ return;
+ }
+
+ // Make sure the widget actually exists
+ if ( !$.fn[ widget ] ) {
+ return;
+ }
+
+ // We assume everything is in the middle to start because we can't determine
+ // first / last elements until all enhancments are done.
+ if ( that[ "_" + widget + "Options" ] ) {
+ options = that[ "_" + widget + "Options" ]( "middle" );
+ } else {
+ options = { classes: {} };
+ }
+
+ // Find instances of this widget inside controlgroup and init them
+ that.element
+ .find( selector )
+ .each( function() {
+ var element = $( this );
+ var instance = element[ widget ]( "instance" );
+
+ // We need to clone the default options for this type of widget to avoid
+ // polluting the variable options which has a wider scope than a single widget.
+ var instanceOptions = $.widget.extend( {}, options );
+
+ // If the button is the child of a spinner ignore it
+ // TODO: Find a more generic solution
+ if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
+ return;
+ }
+
+ // Create the widget if it doesn't exist
+ if ( !instance ) {
+ instance = element[ widget ]()[ widget ]( "instance" );
+ }
+ if ( instance ) {
+ instanceOptions.classes =
+ that._resolveClassesValues( instanceOptions.classes, instance );
+ }
+ element[ widget ]( instanceOptions );
+
+ // Store an instance of the controlgroup to be able to reference
+ // from the outermost element for changing options and refresh
+ var widgetElement = element[ widget ]( "widget" );
+ $.data( widgetElement[ 0 ], "ui-controlgroup-data",
+ instance ? instance : element[ widget ]( "instance" ) );
+
+ childWidgets.push( widgetElement[ 0 ] );
+ } );
+ } );
+
+ this.childWidgets = $( $.unique( childWidgets ) );
+ this._addClass( this.childWidgets, "ui-controlgroup-item" );
+ },
+
+ _callChildMethod: function( method ) {
+ this.childWidgets.each( function() {
+ var element = $( this ),
+ data = element.data( "ui-controlgroup-data" );
+ if ( data && data[ method ] ) {
+ data[ method ]();
+ }
+ } );
+ },
+
+ _updateCornerClass: function( element, position ) {
+ var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
+ var add = this._buildSimpleOptions( position, "label" ).classes.label;
+
+ this._removeClass( element, null, remove );
+ this._addClass( element, null, add );
+ },
+
+ _buildSimpleOptions: function( position, key ) {
+ var direction = this.options.direction === "vertical";
+ var result = {
+ classes: {}
+ };
+ result.classes[ key ] = {
+ "middle": "",
+ "first": "ui-corner-" + ( direction ? "top" : "left" ),
+ "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
+ "only": "ui-corner-all"
+ }[ position ];
+
+ return result;
+ },
+
+ _spinnerOptions: function( position ) {
+ var options = this._buildSimpleOptions( position, "ui-spinner" );
+
+ options.classes[ "ui-spinner-up" ] = "";
+ options.classes[ "ui-spinner-down" ] = "";
+
+ return options;
+ },
+
+ _buttonOptions: function( position ) {
+ return this._buildSimpleOptions( position, "ui-button" );
+ },
+
+ _checkboxradioOptions: function( position ) {
+ return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
+ },
+
+ _selectmenuOptions: function( position ) {
+ var direction = this.options.direction === "vertical";
+ return {
+ width: direction ? "auto" : false,
+ classes: {
+ middle: {
+ "ui-selectmenu-button-open": "",
+ "ui-selectmenu-button-closed": ""
+ },
+ first: {
+ "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
+ "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
+ },
+ last: {
+ "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
+ "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
+ },
+ only: {
+ "ui-selectmenu-button-open": "ui-corner-top",
+ "ui-selectmenu-button-closed": "ui-corner-all"
+ }
+
+ }[ position ]
+ };
+ },
+
+ _resolveClassesValues: function( classes, instance ) {
+ var result = {};
+ $.each( classes, function( key ) {
+ var current = instance.options.classes[ key ] || "";
+ current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
+ result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
+ } );
+ return result;
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "direction" ) {
+ this._removeClass( "ui-controlgroup-" + this.options.direction );
+ }
+
+ this._super( key, value );
+ if ( key === "disabled" ) {
+ this._callChildMethod( value ? "disable" : "enable" );
+ return;
+ }
+
+ this.refresh();
+ },
+
+ refresh: function() {
+ var children,
+ that = this;
+
+ this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
+
+ if ( this.options.direction === "horizontal" ) {
+ this._addClass( null, "ui-helper-clearfix" );
+ }
+ this._initWidgets();
+
+ children = this.childWidgets;
+
+ // We filter here because we need to track all childWidgets not just the visible ones
+ if ( this.options.onlyVisible ) {
+ children = children.filter( ":visible" );
+ }
+
+ if ( children.length ) {
+
+ // We do this last because we need to make sure all enhancment is done
+ // before determining first and last
+ $.each( [ "first", "last" ], function( index, value ) {
+ var instance = children[ value ]().data( "ui-controlgroup-data" );
+
+ if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
+ var options = that[ "_" + instance.widgetName + "Options" ](
+ children.length === 1 ? "only" : value
+ );
+ options.classes = that._resolveClassesValues( options.classes, instance );
+ instance.element[ instance.widgetName ]( options );
+ } else {
+ that._updateCornerClass( children[ value ](), value );
+ }
+ } );
+
+ // Finally call the refresh method on each of the child widgets.
+ this._callChildMethod( "refresh" );
+ }
+ }
+} );
+
+/*!
+ * jQuery UI Checkboxradio 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Checkboxradio
+//>>group: Widgets
+//>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
+//>>docs: http://api.jqueryui.com/checkboxradio/
+//>>demos: http://jqueryui.com/checkboxradio/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/button.css
+//>>css.structure: ../../themes/base/checkboxradio.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
+ version: "1.12.1",
+ options: {
+ disabled: null,
+ label: null,
+ icon: true,
+ classes: {
+ "ui-checkboxradio-label": "ui-corner-all",
+ "ui-checkboxradio-icon": "ui-corner-all"
+ }
+ },
+
+ _getCreateOptions: function() {
+ var disabled, labels;
+ var that = this;
+ var options = this._super() || {};
+
+ // We read the type here, because it makes more sense to throw a element type error first,
+ // rather then the error for lack of a label. Often if its the wrong type, it
+ // won't have a label (e.g. calling on a div, btn, etc)
+ this._readType();
+
+ labels = this.element.labels();
+
+ // If there are multiple labels, use the last one
+ this.label = $( labels[ labels.length - 1 ] );
+ if ( !this.label.length ) {
+ $.error( "No label found for checkboxradio widget" );
+ }
+
+ this.originalLabel = "";
+
+ // We need to get the label text but this may also need to make sure it does not contain the
+ // input itself.
+ this.label.contents().not( this.element[ 0 ] ).each( function() {
+
+ // The label contents could be text, html, or a mix. We concat each element to get a
+ // string representation of the label, without the input as part of it.
+ that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
+ } );
+
+ // Set the label option if we found label text
+ if ( this.originalLabel ) {
+ options.label = this.originalLabel;
+ }
+
+ disabled = this.element[ 0 ].disabled;
+ if ( disabled != null ) {
+ options.disabled = disabled;
+ }
+ return options;
+ },
+
+ _create: function() {
+ var checked = this.element[ 0 ].checked;
+
+ this._bindFormResetHandler();
+
+ if ( this.options.disabled == null ) {
+ this.options.disabled = this.element[ 0 ].disabled;
+ }
+
+ this._setOption( "disabled", this.options.disabled );
+ this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
+ this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
+
+ if ( this.type === "radio" ) {
+ this._addClass( this.label, "ui-checkboxradio-radio-label" );
+ }
+
+ if ( this.options.label && this.options.label !== this.originalLabel ) {
+ this._updateLabel();
+ } else if ( this.originalLabel ) {
+ this.options.label = this.originalLabel;
+ }
+
+ this._enhance();
+
+ if ( checked ) {
+ this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
+ if ( this.icon ) {
+ this._addClass( this.icon, null, "ui-state-hover" );
+ }
+ }
+
+ this._on( {
+ change: "_toggleClasses",
+ focus: function() {
+ this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
+ },
+ blur: function() {
+ this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
+ }
+ } );
+ },
+
+ _readType: function() {
+ var nodeName = this.element[ 0 ].nodeName.toLowerCase();
+ this.type = this.element[ 0 ].type;
+ if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
+ $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
+ " and element.type=" + this.type );
+ }
+ },
+
+ // Support jQuery Mobile enhanced option
+ _enhance: function() {
+ this._updateIcon( this.element[ 0 ].checked );
+ },
+
+ widget: function() {
+ return this.label;
+ },
+
+ _getRadioGroup: function() {
+ var group;
+ var name = this.element[ 0 ].name;
+ var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
+
+ if ( !name ) {
+ return $( [] );
+ }
+
+ if ( this.form.length ) {
+ group = $( this.form[ 0 ].elements ).filter( nameSelector );
+ } else {
+
+ // Not inside a form, check all inputs that also are not inside a form
+ group = $( nameSelector ).filter( function() {
+ return $( this ).form().length === 0;
+ } );
+ }
+
+ return group.not( this.element );
+ },
+
+ _toggleClasses: function() {
+ var checked = this.element[ 0 ].checked;
+ this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
+
+ if ( this.options.icon && this.type === "checkbox" ) {
+ this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
+ ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
+ }
+
+ if ( this.type === "radio" ) {
+ this._getRadioGroup()
+ .each( function() {
+ var instance = $( this ).checkboxradio( "instance" );
+
+ if ( instance ) {
+ instance._removeClass( instance.label,
+ "ui-checkboxradio-checked", "ui-state-active" );
+ }
+ } );
+ }
+ },
+
+ _destroy: function() {
+ this._unbindFormResetHandler();
+
+ if ( this.icon ) {
+ this.icon.remove();
+ this.iconSpace.remove();
+ }
+ },
+
+ _setOption: function( key, value ) {
+
+ // We don't allow the value to be set to nothing
+ if ( key === "label" && !value ) {
+ return;
+ }
+
+ this._super( key, value );
+
+ if ( key === "disabled" ) {
+ this._toggleClass( this.label, null, "ui-state-disabled", value );
+ this.element[ 0 ].disabled = value;
+
+ // Don't refresh when setting disabled
+ return;
+ }
+ this.refresh();
+ },
+
+ _updateIcon: function( checked ) {
+ var toAdd = "ui-icon ui-icon-background ";
+
+ if ( this.options.icon ) {
+ if ( !this.icon ) {
+ this.icon = $( "<span>" );
+ this.iconSpace = $( "<span> </span>" );
+ this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
+ }
+
+ if ( this.type === "checkbox" ) {
+ toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
+ this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
+ } else {
+ toAdd += "ui-icon-blank";
+ }
+ this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
+ if ( !checked ) {
+ this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
+ }
+ this.icon.prependTo( this.label ).after( this.iconSpace );
+ } else if ( this.icon !== undefined ) {
+ this.icon.remove();
+ this.iconSpace.remove();
+ delete this.icon;
+ }
+ },
+
+ _updateLabel: function() {
+
+ // Remove the contents of the label ( minus the icon, icon space, and input )
+ var contents = this.label.contents().not( this.element[ 0 ] );
+ if ( this.icon ) {
+ contents = contents.not( this.icon[ 0 ] );
+ }
+ if ( this.iconSpace ) {
+ contents = contents.not( this.iconSpace[ 0 ] );
+ }
+ contents.remove();
+
+ this.label.append( this.options.label );
+ },
+
+ refresh: function() {
+ var checked = this.element[ 0 ].checked,
+ isDisabled = this.element[ 0 ].disabled;
+
+ this._updateIcon( checked );
+ this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
+ if ( this.options.label !== null ) {
+ this._updateLabel();
+ }
+
+ if ( isDisabled !== this.options.disabled ) {
+ this._setOptions( { "disabled": isDisabled } );
+ }
+ }
+
+} ] );
+
+var widgetsCheckboxradio = $.ui.checkboxradio;
+
+
+/*!
+ * jQuery UI Button 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Button
+//>>group: Widgets
+//>>description: Enhances a form with themeable buttons.
+//>>docs: http://api.jqueryui.com/button/
+//>>demos: http://jqueryui.com/button/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/button.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.button", {
+ version: "1.12.1",
+ defaultElement: "<button>",
+ options: {
+ classes: {
+ "ui-button": "ui-corner-all"
+ },
+ disabled: null,
+ icon: null,
+ iconPosition: "beginning",
+ label: null,
+ showLabel: true
+ },
+
+ _getCreateOptions: function() {
+ var disabled,
+
+ // This is to support cases like in jQuery Mobile where the base widget does have
+ // an implementation of _getCreateOptions
+ options = this._super() || {};
+
+ this.isInput = this.element.is( "input" );
+
+ disabled = this.element[ 0 ].disabled;
+ if ( disabled != null ) {
+ options.disabled = disabled;
+ }
+
+ this.originalLabel = this.isInput ? this.element.val() : this.element.html();
+ if ( this.originalLabel ) {
+ options.label = this.originalLabel;
+ }
+
+ return options;
+ },
+
+ _create: function() {
+ if ( !this.option.showLabel & !this.options.icon ) {
+ this.options.showLabel = true;
+ }
+
+ // We have to check the option again here even though we did in _getCreateOptions,
+ // because null may have been passed on init which would override what was set in
+ // _getCreateOptions
+ if ( this.options.disabled == null ) {
+ this.options.disabled = this.element[ 0 ].disabled || false;
+ }
+
+ this.hasTitle = !!this.element.attr( "title" );
+
+ // Check to see if the label needs to be set or if its already correct
+ if ( this.options.label && this.options.label !== this.originalLabel ) {
+ if ( this.isInput ) {
+ this.element.val( this.options.label );
+ } else {
+ this.element.html( this.options.label );
+ }
+ }
+ this._addClass( "ui-button", "ui-widget" );
+ this._setOption( "disabled", this.options.disabled );
+ this._enhance();
+
+ if ( this.element.is( "a" ) ) {
+ this._on( {
+ "keyup": function( event ) {
+ if ( event.keyCode === $.ui.keyCode.SPACE ) {
+ event.preventDefault();
+
+ // Support: PhantomJS <= 1.9, IE 8 Only
+ // If a native click is available use it so we actually cause navigation
+ // otherwise just trigger a click event
+ if ( this.element[ 0 ].click ) {
+ this.element[ 0 ].click();
+ } else {
+ this.element.trigger( "click" );
+ }
+ }
+ }
+ } );
+ }
+ },
+
+ _enhance: function() {
+ if ( !this.element.is( "button" ) ) {
+ this.element.attr( "role", "button" );
+ }
+
+ if ( this.options.icon ) {
+ this._updateIcon( "icon", this.options.icon );
+ this._updateTooltip();
+ }
+ },
+
+ _updateTooltip: function() {
+ this.title = this.element.attr( "title" );
+
+ if ( !this.options.showLabel && !this.title ) {
+ this.element.attr( "title", this.options.label );
+ }
+ },
+
+ _updateIcon: function( option, value ) {
+ var icon = option !== "iconPosition",
+ position = icon ? this.options.iconPosition : value,
+ displayBlock = position === "top" || position === "bottom";
+
+ // Create icon
+ if ( !this.icon ) {
+ this.icon = $( "<span>" );
+
+ this._addClass( this.icon, "ui-button-icon", "ui-icon" );
+
+ if ( !this.options.showLabel ) {
+ this._addClass( "ui-button-icon-only" );
+ }
+ } else if ( icon ) {
+
+ // If we are updating the icon remove the old icon class
+ this._removeClass( this.icon, null, this.options.icon );
+ }
+
+ // If we are updating the icon add the new icon class
+ if ( icon ) {
+ this._addClass( this.icon, null, value );
+ }
+
+ this._attachIcon( position );
+
+ // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
+ // the iconSpace if there is one.
+ if ( displayBlock ) {
+ this._addClass( this.icon, null, "ui-widget-icon-block" );
+ if ( this.iconSpace ) {
+ this.iconSpace.remove();
+ }
+ } else {
+
+ // Position is beginning or end so remove the ui-widget-icon-block class and add the
+ // space if it does not exist
+ if ( !this.iconSpace ) {
+ this.iconSpace = $( "<span> </span>" );
+ this._addClass( this.iconSpace, "ui-button-icon-space" );
+ }
+ this._removeClass( this.icon, null, "ui-wiget-icon-block" );
+ this._attachIconSpace( position );
+ }
+ },
+
+ _destroy: function() {
+ this.element.removeAttr( "role" );
+
+ if ( this.icon ) {
+ this.icon.remove();
+ }
+ if ( this.iconSpace ) {
+ this.iconSpace.remove();
+ }
+ if ( !this.hasTitle ) {
+ this.element.removeAttr( "title" );
+ }
+ },
+
+ _attachIconSpace: function( iconPosition ) {
+ this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
+ },
+
+ _attachIcon: function( iconPosition ) {
+ this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
+ },
+
+ _setOptions: function( options ) {
+ var newShowLabel = options.showLabel === undefined ?
+ this.options.showLabel :
+ options.showLabel,
+ newIcon = options.icon === undefined ? this.options.icon : options.icon;
+
+ if ( !newShowLabel && !newIcon ) {
+ options.showLabel = true;
+ }
+ this._super( options );
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "icon" ) {
+ if ( value ) {
+ this._updateIcon( key, value );
+ } else if ( this.icon ) {
+ this.icon.remove();
+ if ( this.iconSpace ) {
+ this.iconSpace.remove();
+ }
+ }
+ }
+
+ if ( key === "iconPosition" ) {
+ this._updateIcon( key, value );
+ }
+
+ // Make sure we can't end up with a button that has neither text nor icon
+ if ( key === "showLabel" ) {
+ this._toggleClass( "ui-button-icon-only", null, !value );
+ this._updateTooltip();
+ }
+
+ if ( key === "label" ) {
+ if ( this.isInput ) {
+ this.element.val( value );
+ } else {
+
+ // If there is an icon, append it, else nothing then append the value
+ // this avoids removal of the icon when setting label text
+ this.element.html( value );
+ if ( this.icon ) {
+ this._attachIcon( this.options.iconPosition );
+ this._attachIconSpace( this.options.iconPosition );
+ }
+ }
+ }
+
+ this._super( key, value );
+
+ if ( key === "disabled" ) {
+ this._toggleClass( null, "ui-state-disabled", value );
+ this.element[ 0 ].disabled = value;
+ if ( value ) {
+ this.element.blur();
+ }
+ }
+ },
+
+ refresh: function() {
+
+ // Make sure to only check disabled if its an element that supports this otherwise
+ // check for the disabled class to determine state
+ var isDisabled = this.element.is( "input, button" ) ?
+ this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
+
+ if ( isDisabled !== this.options.disabled ) {
+ this._setOptions( { disabled: isDisabled } );
+ }
+
+ this._updateTooltip();
+ }
+} );
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+
+ // Text and Icons options
+ $.widget( "ui.button", $.ui.button, {
+ options: {
+ text: true,
+ icons: {
+ primary: null,
+ secondary: null
+ }
+ },
+
+ _create: function() {
+ if ( this.options.showLabel && !this.options.text ) {
+ this.options.showLabel = this.options.text;
+ }
+ if ( !this.options.showLabel && this.options.text ) {
+ this.options.text = this.options.showLabel;
+ }
+ if ( !this.options.icon && ( this.options.icons.primary ||
+ this.options.icons.secondary ) ) {
+ if ( this.options.icons.primary ) {
+ this.options.icon = this.options.icons.primary;
+ } else {
+ this.options.icon = this.options.icons.secondary;
+ this.options.iconPosition = "end";
+ }
+ } else if ( this.options.icon ) {
+ this.options.icons.primary = this.options.icon;
+ }
+ this._super();
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "text" ) {
+ this._super( "showLabel", value );
+ return;
+ }
+ if ( key === "showLabel" ) {
+ this.options.text = value;
+ }
+ if ( key === "icon" ) {
+ this.options.icons.primary = value;
+ }
+ if ( key === "icons" ) {
+ if ( value.primary ) {
+ this._super( "icon", value.primary );
+ this._super( "iconPosition", "beginning" );
+ } else if ( value.secondary ) {
+ this._super( "icon", value.secondary );
+ this._super( "iconPosition", "end" );
+ }
+ }
+ this._superApply( arguments );
+ }
+ } );
+
+ $.fn.button = ( function( orig ) {
+ return function() {
+ if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
+ ( this.length && this[ 0 ].tagName === "INPUT" && (
+ this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
+ ) ) ) {
+ return orig.apply( this, arguments );
+ }
+ if ( !$.ui.checkboxradio ) {
+ $.error( "Checkboxradio widget missing" );
+ }
+ if ( arguments.length === 0 ) {
+ return this.checkboxradio( {
+ "icon": false
+ } );
+ }
+ return this.checkboxradio.apply( this, arguments );
+ };
+ } )( $.fn.button );
+
+ $.fn.buttonset = function() {
+ if ( !$.ui.controlgroup ) {
+ $.error( "Controlgroup widget missing" );
+ }
+ if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
+ return this.controlgroup.apply( this,
+ [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
+ }
+ if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
+ return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
+ }
+ if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
+ arguments[ 0 ].items = {
+ button: arguments[ 0 ].items
+ };
+ }
+ return this.controlgroup.apply( this, arguments );
+ };
+}
+
+var widgetsButton = $.ui.button;
+
+
+// jscs:disable maximumLineLength
+/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
+/*!
+ * jQuery UI Datepicker 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Datepicker
+//>>group: Widgets
+//>>description: Displays a calendar from an input or inline for selecting dates.
+//>>docs: http://api.jqueryui.com/datepicker/
+//>>demos: http://jqueryui.com/datepicker/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/datepicker.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.extend( $.ui, { datepicker: { version: "1.12.1" } } );
+
+var datepicker_instActive;
+
+function datepicker_getZindex( elem ) {
+ var position, value;
+ while ( elem.length && elem[ 0 ] !== document ) {
+
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
+ // This makes behavior of this function consistent across browsers
+ // WebKit always returns auto if the element is positioned
+ position = elem.css( "position" );
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
+
+ // IE returns 0 when zIndex is not specified
+ // other browsers return a string
+ // we ignore the case of nested elements with an explicit value of 0
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt( elem.css( "zIndex" ), 10 );
+ if ( !isNaN( value ) && value !== 0 ) {
+ return value;
+ }
+ }
+ elem = elem.parent();
+ }
+
+ return 0;
+}
+/* Date picker manager.
+ Use the singleton instance of this class, $.datepicker, to interact with the date picker.
+ Settings for (groups of) date pickers are maintained in an instance object,
+ allowing multiple different settings on the same page. */
+
+function Datepicker() {
+ this._curInst = null; // The current instance in use
+ this._keyEvent = false; // If the last event was a key event
+ this._disabledInputs = []; // List of date picker inputs that have been disabled
+ this._datepickerShowing = false; // True if the popup picker is showing , false if not
+ this._inDialog = false; // True if showing within a "dialog", false if not
+ this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
+ this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
+ this._appendClass = "ui-datepicker-append"; // The name of the append marker class
+ this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
+ this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
+ this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
+ this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
+ this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
+ this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[ "" ] = { // Default regional settings
+ closeText: "Done", // Display text for close link
+ prevText: "Prev", // Display text for previous month link
+ nextText: "Next", // Display text for next month link
+ currentText: "Today", // Display text for current month link
+ monthNames: [ "January","February","March","April","May","June",
+ "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
+ monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
+ dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
+ dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
+ dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
+ weekHeader: "Wk", // Column header for week of the year
+ dateFormat: "mm/dd/yy", // See format options on parseDate
+ firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
+ isRTL: false, // True if right-to-left language, false if left-to-right
+ showMonthAfterYear: false, // True if the year select precedes month, false for month then year
+ yearSuffix: "" // Additional text to append to the year in the month headers
+ };
+ this._defaults = { // Global defaults for all the date picker instances
+ showOn: "focus", // "focus" for popup on focus,
+ // "button" for trigger button, or "both" for either
+ showAnim: "fadeIn", // Name of jQuery animation for popup
+ showOptions: {}, // Options for enhanced animations
+ defaultDate: null, // Used when field is blank: actual date,
+ // +/-number for offset from today, null for today
+ appendText: "", // Display text following the input box, e.g. showing the format
+ buttonText: "...", // Text for trigger button
+ buttonImage: "", // URL for trigger button image
+ buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
+ hideIfNoPrevNext: false, // True to hide next/previous month links
+ // if not applicable, false to just disable them
+ navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
+ gotoCurrent: false, // True if today link goes back to current selection instead
+ changeMonth: false, // True if month can be selected directly, false if only prev/next
+ changeYear: false, // True if year can be selected directly, false if only prev/next
+ yearRange: "c-10:c+10", // Range of years to display in drop-down,
+ // either relative to today's year (-nn:+nn), relative to currently displayed year
+ // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
+ showOtherMonths: false, // True to show dates in other months, false to leave blank
+ selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
+ showWeek: false, // True to show week of the year, false to not show it
+ calculateWeek: this.iso8601Week, // How to calculate the week of the year,
+ // takes a Date and returns the number of the week for it
+ shortYearCutoff: "+10", // Short year values < this are in the current century,
+ // > this are in the previous century,
+ // string value starting with "+" for current year + value
+ minDate: null, // The earliest selectable date, or null for no limit
+ maxDate: null, // The latest selectable date, or null for no limit
+ duration: "fast", // Duration of display/closure
+ beforeShowDay: null, // Function that takes a date and returns an array with
+ // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
+ // [2] = cell title (optional), e.g. $.datepicker.noWeekends
+ beforeShow: null, // Function that takes an input field and
+ // returns a set of custom settings for the date picker
+ onSelect: null, // Define a callback function when a date is selected
+ onChangeMonthYear: null, // Define a callback function when the month or year is changed
+ onClose: null, // Define a callback function when the datepicker is closed
+ numberOfMonths: 1, // Number of months to show at a time
+ showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
+ stepMonths: 1, // Number of months to step back/forward
+ stepBigMonths: 12, // Number of months to step back/forward for the big links
+ altField: "", // Selector for an alternate field to store selected dates into
+ altFormat: "", // The date format to use for the alternate field
+ constrainInput: true, // The input is constrained by the current date format
+ showButtonPanel: false, // True to show button panel, false to not show it
+ autoSize: false, // True to size the input for the date format, false to leave as is
+ disabled: false // The initial disabled state
+ };
+ $.extend( this._defaults, this.regional[ "" ] );
+ this.regional.en = $.extend( true, {}, this.regional[ "" ] );
+ this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
+ this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
+}
+
+$.extend( Datepicker.prototype, {
+ /* Class name added to elements to indicate already configured with a date picker. */
+ markerClassName: "hasDatepicker",
+
+ //Keep track of the maximum number of rows displayed (see #7043)
+ maxRows: 4,
+
+ // TODO rename to "widget" when switching to widget factory
+ _widgetDatepicker: function() {
+ return this.dpDiv;
+ },
+
+ /* Override the default settings for all instances of the date picker.
+ * @param settings object - the new settings to use as defaults (anonymous object)
+ * @return the manager object
+ */
+ setDefaults: function( settings ) {
+ datepicker_extendRemove( this._defaults, settings || {} );
+ return this;
+ },
+
+ /* Attach the date picker to a jQuery selection.
+ * @param target element - the target input field or division or span
+ * @param settings object - the new settings to use for this date picker instance (anonymous)
+ */
+ _attachDatepicker: function( target, settings ) {
+ var nodeName, inline, inst;
+ nodeName = target.nodeName.toLowerCase();
+ inline = ( nodeName === "div" || nodeName === "span" );
+ if ( !target.id ) {
+ this.uuid += 1;
+ target.id = "dp" + this.uuid;
+ }
+ inst = this._newInst( $( target ), inline );
+ inst.settings = $.extend( {}, settings || {} );
+ if ( nodeName === "input" ) {
+ this._connectDatepicker( target, inst );
+ } else if ( inline ) {
+ this._inlineDatepicker( target, inst );
+ }
+ },
+
+ /* Create a new instance object. */
+ _newInst: function( target, inline ) {
+ var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
+ return { id: id, input: target, // associated target
+ selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
+ drawMonth: 0, drawYear: 0, // month being drawn
+ inline: inline, // is datepicker inline or not
+ dpDiv: ( !inline ? this.dpDiv : // presentation div
+ datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
+ },
+
+ /* Attach the date picker to an input field. */
+ _connectDatepicker: function( target, inst ) {
+ var input = $( target );
+ inst.append = $( [] );
+ inst.trigger = $( [] );
+ if ( input.hasClass( this.markerClassName ) ) {
+ return;
+ }
+ this._attachments( input, inst );
+ input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
+ on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
+ this._autoSize( inst );
+ $.data( target, "datepicker", inst );
+
+ //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
+ if ( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
+ },
+
+ /* Make attachments based on settings. */
+ _attachments: function( input, inst ) {
+ var showOn, buttonText, buttonImage,
+ appendText = this._get( inst, "appendText" ),
+ isRTL = this._get( inst, "isRTL" );
+
+ if ( inst.append ) {
+ inst.append.remove();
+ }
+ if ( appendText ) {
+ inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
+ input[ isRTL ? "before" : "after" ]( inst.append );
+ }
+
+ input.off( "focus", this._showDatepicker );
+
+ if ( inst.trigger ) {
+ inst.trigger.remove();
+ }
+
+ showOn = this._get( inst, "showOn" );
+ if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
+ input.on( "focus", this._showDatepicker );
+ }
+ if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
+ buttonText = this._get( inst, "buttonText" );
+ buttonImage = this._get( inst, "buttonImage" );
+ inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
+ $( "<img/>" ).addClass( this._triggerClass ).
+ attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
+ $( "<button type='button'></button>" ).addClass( this._triggerClass ).
+ html( !buttonImage ? buttonText : $( "<img/>" ).attr(
+ { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
+ input[ isRTL ? "before" : "after" ]( inst.trigger );
+ inst.trigger.on( "click", function() {
+ if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
+ $.datepicker._hideDatepicker();
+ } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
+ $.datepicker._hideDatepicker();
+ $.datepicker._showDatepicker( input[ 0 ] );
+ } else {
+ $.datepicker._showDatepicker( input[ 0 ] );
+ }
+ return false;
+ } );
+ }
+ },
+
+ /* Apply the maximum length for the date format. */
+ _autoSize: function( inst ) {
+ if ( this._get( inst, "autoSize" ) && !inst.inline ) {
+ var findMax, max, maxI, i,
+ date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
+ dateFormat = this._get( inst, "dateFormat" );
+
+ if ( dateFormat.match( /[DM]/ ) ) {
+ findMax = function( names ) {
+ max = 0;
+ maxI = 0;
+ for ( i = 0; i < names.length; i++ ) {
+ if ( names[ i ].length > max ) {
+ max = names[ i ].length;
+ maxI = i;
+ }
+ }
+ return maxI;
+ };
+ date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
+ "monthNames" : "monthNamesShort" ) ) ) );
+ date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
+ "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
+ }
+ inst.input.attr( "size", this._formatDate( inst, date ).length );
+ }
+ },
+
+ /* Attach an inline date picker to a div. */
+ _inlineDatepicker: function( target, inst ) {
+ var divSpan = $( target );
+ if ( divSpan.hasClass( this.markerClassName ) ) {
+ return;
+ }
+ divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
+ $.data( target, "datepicker", inst );
+ this._setDate( inst, this._getDefaultDate( inst ), true );
+ this._updateDatepicker( inst );
+ this._updateAlternate( inst );
+
+ //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
+ if ( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
+
+ // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
+ // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
+ inst.dpDiv.css( "display", "block" );
+ },
+
+ /* Pop-up the date picker in a "dialog" box.
+ * @param input element - ignored
+ * @param date string or Date - the initial date to display
+ * @param onSelect function - the function to call when a date is selected
+ * @param settings object - update the dialog date picker instance's settings (anonymous object)
+ * @param pos int[2] - coordinates for the dialog's position within the screen or
+ * event - with x/y coordinates or
+ * leave empty for default (screen centre)
+ * @return the manager object
+ */
+ _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
+ var id, browserWidth, browserHeight, scrollX, scrollY,
+ inst = this._dialogInst; // internal instance
+
+ if ( !inst ) {
+ this.uuid += 1;
+ id = "dp" + this.uuid;
+ this._dialogInput = $( "<input type='text' id='" + id +
+ "' style='position: absolute; top: -100px; width: 0px;'/>" );
+ this._dialogInput.on( "keydown", this._doKeyDown );
+ $( "body" ).append( this._dialogInput );
+ inst = this._dialogInst = this._newInst( this._dialogInput, false );
+ inst.settings = {};
+ $.data( this._dialogInput[ 0 ], "datepicker", inst );
+ }
+ datepicker_extendRemove( inst.settings, settings || {} );
+ date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
+ this._dialogInput.val( date );
+
+ this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
+ if ( !this._pos ) {
+ browserWidth = document.documentElement.clientWidth;
+ browserHeight = document.documentElement.clientHeight;
+ scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+ this._pos = // should use actual width/height below
+ [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
+ }
+
+ // Move input on screen for focus, but hidden behind dialog
+ this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
+ inst.settings.onSelect = onSelect;
+ this._inDialog = true;
+ this.dpDiv.addClass( this._dialogClass );
+ this._showDatepicker( this._dialogInput[ 0 ] );
+ if ( $.blockUI ) {
+ $.blockUI( this.dpDiv );
+ }
+ $.data( this._dialogInput[ 0 ], "datepicker", inst );
+ return this;
+ },
+
+ /* Detach a datepicker from its control.
+ * @param target element - the target input field or division or span
+ */
+ _destroyDatepicker: function( target ) {
+ var nodeName,
+ $target = $( target ),
+ inst = $.data( target, "datepicker" );
+
+ if ( !$target.hasClass( this.markerClassName ) ) {
+ return;
+ }
+
+ nodeName = target.nodeName.toLowerCase();
+ $.removeData( target, "datepicker" );
+ if ( nodeName === "input" ) {
+ inst.append.remove();
+ inst.trigger.remove();
+ $target.removeClass( this.markerClassName ).
+ off( "focus", this._showDatepicker ).
+ off( "keydown", this._doKeyDown ).
+ off( "keypress", this._doKeyPress ).
+ off( "keyup", this._doKeyUp );
+ } else if ( nodeName === "div" || nodeName === "span" ) {
+ $target.removeClass( this.markerClassName ).empty();
+ }
+
+ if ( datepicker_instActive === inst ) {
+ datepicker_instActive = null;
+ }
+ },
+
+ /* Enable the date picker to a jQuery selection.
+ * @param target element - the target input field or division or span
+ */
+ _enableDatepicker: function( target ) {
+ var nodeName, inline,
+ $target = $( target ),
+ inst = $.data( target, "datepicker" );
+
+ if ( !$target.hasClass( this.markerClassName ) ) {
+ return;
+ }
+
+ nodeName = target.nodeName.toLowerCase();
+ if ( nodeName === "input" ) {
+ target.disabled = false;
+ inst.trigger.filter( "button" ).
+ each( function() { this.disabled = false; } ).end().
+ filter( "img" ).css( { opacity: "1.0", cursor: "" } );
+ } else if ( nodeName === "div" || nodeName === "span" ) {
+ inline = $target.children( "." + this._inlineClass );
+ inline.children().removeClass( "ui-state-disabled" );
+ inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
+ prop( "disabled", false );
+ }
+ this._disabledInputs = $.map( this._disabledInputs,
+ function( value ) { return ( value === target ? null : value ); } ); // delete entry
+ },
+
+ /* Disable the date picker to a jQuery selection.
+ * @param target element - the target input field or division or span
+ */
+ _disableDatepicker: function( target ) {
+ var nodeName, inline,
+ $target = $( target ),
+ inst = $.data( target, "datepicker" );
+
+ if ( !$target.hasClass( this.markerClassName ) ) {
+ return;
+ }
+
+ nodeName = target.nodeName.toLowerCase();
+ if ( nodeName === "input" ) {
+ target.disabled = true;
+ inst.trigger.filter( "button" ).
+ each( function() { this.disabled = true; } ).end().
+ filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
+ } else if ( nodeName === "div" || nodeName === "span" ) {
+ inline = $target.children( "." + this._inlineClass );
+ inline.children().addClass( "ui-state-disabled" );
+ inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
+ prop( "disabled", true );
+ }
+ this._disabledInputs = $.map( this._disabledInputs,
+ function( value ) { return ( value === target ? null : value ); } ); // delete entry
+ this._disabledInputs[ this._disabledInputs.length ] = target;
+ },
+
+ /* Is the first field in a jQuery collection disabled as a datepicker?
+ * @param target element - the target input field or division or span
+ * @return boolean - true if disabled, false if enabled
+ */
+ _isDisabledDatepicker: function( target ) {
+ if ( !target ) {
+ return false;
+ }
+ for ( var i = 0; i < this._disabledInputs.length; i++ ) {
+ if ( this._disabledInputs[ i ] === target ) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ /* Retrieve the instance data for the target control.
+ * @param target element - the target input field or division or span
+ * @return object - the associated instance data
+ * @throws error if a jQuery problem getting data
+ */
+ _getInst: function( target ) {
+ try {
+ return $.data( target, "datepicker" );
+ }
+ catch ( err ) {
+ throw "Missing instance data for this datepicker";
+ }
+ },
+
+ /* Update or retrieve the settings for a date picker attached to an input field or division.
+ * @param target element - the target input field or division or span
+ * @param name object - the new settings to update or
+ * string - the name of the setting to change or retrieve,
+ * when retrieving also "all" for all instance settings or
+ * "defaults" for all global defaults
+ * @param value any - the new value for the setting
+ * (omit if above is an object or to retrieve a value)
+ */
+ _optionDatepicker: function( target, name, value ) {
+ var settings, date, minDate, maxDate,
+ inst = this._getInst( target );
+
+ if ( arguments.length === 2 && typeof name === "string" ) {
+ return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
+ ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
+ this._get( inst, name ) ) : null ) );
+ }
+
+ settings = name || {};
+ if ( typeof name === "string" ) {
+ settings = {};
+ settings[ name ] = value;
+ }
+
+ if ( inst ) {
+ if ( this._curInst === inst ) {
+ this._hideDatepicker();
+ }
+
+ date = this._getDateDatepicker( target, true );
+ minDate = this._getMinMaxDate( inst, "min" );
+ maxDate = this._getMinMaxDate( inst, "max" );
+ datepicker_extendRemove( inst.settings, settings );
+
+ // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
+ if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
+ inst.settings.minDate = this._formatDate( inst, minDate );
+ }
+ if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
+ inst.settings.maxDate = this._formatDate( inst, maxDate );
+ }
+ if ( "disabled" in settings ) {
+ if ( settings.disabled ) {
+ this._disableDatepicker( target );
+ } else {
+ this._enableDatepicker( target );
+ }
+ }
+ this._attachments( $( target ), inst );
+ this._autoSize( inst );
+ this._setDate( inst, date );
+ this._updateAlternate( inst );
+ this._updateDatepicker( inst );
+ }
+ },
+
+ // Change method deprecated
+ _changeDatepicker: function( target, name, value ) {
+ this._optionDatepicker( target, name, value );
+ },
+
+ /* Redraw the date picker attached to an input field or division.
+ * @param target element - the target input field or division or span
+ */
+ _refreshDatepicker: function( target ) {
+ var inst = this._getInst( target );
+ if ( inst ) {
+ this._updateDatepicker( inst );
+ }
+ },
+
+ /* Set the dates for a jQuery selection.
+ * @param target element - the target input field or division or span
+ * @param date Date - the new date
+ */
+ _setDateDatepicker: function( target, date ) {
+ var inst = this._getInst( target );
+ if ( inst ) {
+ this._setDate( inst, date );
+ this._updateDatepicker( inst );
+ this._updateAlternate( inst );
+ }
+ },
+
+ /* Get the date(s) for the first entry in a jQuery selection.
+ * @param target element - the target input field or division or span
+ * @param noDefault boolean - true if no default date is to be used
+ * @return Date - the current date
+ */
+ _getDateDatepicker: function( target, noDefault ) {
+ var inst = this._getInst( target );
+ if ( inst && !inst.inline ) {
+ this._setDateFromField( inst, noDefault );
+ }
+ return ( inst ? this._getDate( inst ) : null );
+ },
+
+ /* Handle keystrokes. */
+ _doKeyDown: function( event ) {
+ var onSelect, dateStr, sel,
+ inst = $.datepicker._getInst( event.target ),
+ handled = true,
+ isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
+
+ inst._keyEvent = true;
+ if ( $.datepicker._datepickerShowing ) {
+ switch ( event.keyCode ) {
+ case 9: $.datepicker._hideDatepicker();
+ handled = false;
+ break; // hide on tab out
+ case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
+ $.datepicker._currentClass + ")", inst.dpDiv );
+ if ( sel[ 0 ] ) {
+ $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
+ }
+
+ onSelect = $.datepicker._get( inst, "onSelect" );
+ if ( onSelect ) {
+ dateStr = $.datepicker._formatDate( inst );
+
+ // Trigger custom callback
+ onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
+ } else {
+ $.datepicker._hideDatepicker();
+ }
+
+ return false; // don't submit the form
+ case 27: $.datepicker._hideDatepicker();
+ break; // hide on escape
+ case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
+ -$.datepicker._get( inst, "stepBigMonths" ) :
+ -$.datepicker._get( inst, "stepMonths" ) ), "M" );
+ break; // previous month/year on page up/+ ctrl
+ case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
+ +$.datepicker._get( inst, "stepBigMonths" ) :
+ +$.datepicker._get( inst, "stepMonths" ) ), "M" );
+ break; // next month/year on page down/+ ctrl
+ case 35: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._clearDate( event.target );
+ }
+ handled = event.ctrlKey || event.metaKey;
+ break; // clear on ctrl or command +end
+ case 36: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._gotoToday( event.target );
+ }
+ handled = event.ctrlKey || event.metaKey;
+ break; // current on ctrl or command +home
+ case 37: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
+ }
+ handled = event.ctrlKey || event.metaKey;
+
+ // -1 day on ctrl or command +left
+ if ( event.originalEvent.altKey ) {
+ $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
+ -$.datepicker._get( inst, "stepBigMonths" ) :
+ -$.datepicker._get( inst, "stepMonths" ) ), "M" );
+ }
+
+ // next month/year on alt +left on Mac
+ break;
+ case 38: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._adjustDate( event.target, -7, "D" );
+ }
+ handled = event.ctrlKey || event.metaKey;
+ break; // -1 week on ctrl or command +up
+ case 39: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
+ }
+ handled = event.ctrlKey || event.metaKey;
+
+ // +1 day on ctrl or command +right
+ if ( event.originalEvent.altKey ) {
+ $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
+ +$.datepicker._get( inst, "stepBigMonths" ) :
+ +$.datepicker._get( inst, "stepMonths" ) ), "M" );
+ }
+
+ // next month/year on alt +right
+ break;
+ case 40: if ( event.ctrlKey || event.metaKey ) {
+ $.datepicker._adjustDate( event.target, +7, "D" );
+ }
+ handled = event.ctrlKey || event.metaKey;
+ break; // +1 week on ctrl or command +down
+ default: handled = false;
+ }
+ } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
+ $.datepicker._showDatepicker( this );
+ } else {
+ handled = false;
+ }
+
+ if ( handled ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ },
+
+ /* Filter entered characters - based on date format. */
+ _doKeyPress: function( event ) {
+ var chars, chr,
+ inst = $.datepicker._getInst( event.target );
+
+ if ( $.datepicker._get( inst, "constrainInput" ) ) {
+ chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
+ chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
+ return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
+ }
+ },
+
+ /* Synchronise manual entry and field/alternate field. */
+ _doKeyUp: function( event ) {
+ var date,
+ inst = $.datepicker._getInst( event.target );
+
+ if ( inst.input.val() !== inst.lastVal ) {
+ try {
+ date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
+ ( inst.input ? inst.input.val() : null ),
+ $.datepicker._getFormatConfig( inst ) );
+
+ if ( date ) { // only if valid
+ $.datepicker._setDateFromField( inst );
+ $.datepicker._updateAlternate( inst );
+ $.datepicker._updateDatepicker( inst );
+ }
+ }
+ catch ( err ) {
+ }
+ }
+ return true;
+ },
+
+ /* Pop-up the date picker for a given input field.
+ * If false returned from beforeShow event handler do not show.
+ * @param input element - the input field attached to the date picker or
+ * event - if triggered by focus
+ */
+ _showDatepicker: function( input ) {
+ input = input.target || input;
+ if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
+ input = $( "input", input.parentNode )[ 0 ];
+ }
+
+ if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
+ return;
+ }
+
+ var inst, beforeShow, beforeShowSettings, isFixed,
+ offset, showAnim, duration;
+
+ inst = $.datepicker._getInst( input );
+ if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
+ $.datepicker._curInst.dpDiv.stop( true, true );
+ if ( inst && $.datepicker._datepickerShowing ) {
+ $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
+ }
+ }
+
+ beforeShow = $.datepicker._get( inst, "beforeShow" );
+ beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
+ if ( beforeShowSettings === false ) {
+ return;
+ }
+ datepicker_extendRemove( inst.settings, beforeShowSettings );
+
+ inst.lastVal = null;
+ $.datepicker._lastInput = input;
+ $.datepicker._setDateFromField( inst );
+
+ if ( $.datepicker._inDialog ) { // hide cursor
+ input.value = "";
+ }
+ if ( !$.datepicker._pos ) { // position below input
+ $.datepicker._pos = $.datepicker._findPos( input );
+ $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
+ }
+
+ isFixed = false;
+ $( input ).parents().each( function() {
+ isFixed |= $( this ).css( "position" ) === "fixed";
+ return !isFixed;
+ } );
+
+ offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
+ $.datepicker._pos = null;
+
+ //to avoid flashes on Firefox
+ inst.dpDiv.empty();
+
+ // determine sizing offscreen
+ inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
+ $.datepicker._updateDatepicker( inst );
+
+ // fix width for dynamic number of date pickers
+ // and adjust position before showing
+ offset = $.datepicker._checkOffset( inst, offset, isFixed );
+ inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
+ "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
+ left: offset.left + "px", top: offset.top + "px" } );
+
+ if ( !inst.inline ) {
+ showAnim = $.datepicker._get( inst, "showAnim" );
+ duration = $.datepicker._get( inst, "duration" );
+ inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
+ $.datepicker._datepickerShowing = true;
+
+ if ( $.effects && $.effects.effect[ showAnim ] ) {
+ inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
+ } else {
+ inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
+ }
+
+ if ( $.datepicker._shouldFocusInput( inst ) ) {
+ inst.input.trigger( "focus" );
+ }
+
+ $.datepicker._curInst = inst;
+ }
+ },
+
+ /* Generate the date picker content. */
+ _updateDatepicker: function( inst ) {
+ this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
+ datepicker_instActive = inst; // for delegate hover events
+ inst.dpDiv.empty().append( this._generateHTML( inst ) );
+ this._attachHandlers( inst );
+
+ var origyearshtml,
+ numMonths = this._getNumberOfMonths( inst ),
+ cols = numMonths[ 1 ],
+ width = 17,
+ activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
+
+ if ( activeCell.length > 0 ) {
+ datepicker_handleMouseover.apply( activeCell.get( 0 ) );
+ }
+
+ inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
+ if ( cols > 1 ) {
+ inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
+ }
+ inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
+ "Class" ]( "ui-datepicker-multi" );
+ inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
+ "Class" ]( "ui-datepicker-rtl" );
+
+ if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
+ inst.input.trigger( "focus" );
+ }
+
+ // Deffered render of the years select (to avoid flashes on Firefox)
+ if ( inst.yearshtml ) {
+ origyearshtml = inst.yearshtml;
+ setTimeout( function() {
+
+ //assure that inst.yearshtml didn't change.
+ if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
+ inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
+ }
+ origyearshtml = inst.yearshtml = null;
+ }, 0 );
+ }
+ },
+
+ // #6694 - don't focus the input if it's already focused
+ // this breaks the change event in IE
+ // Support: IE and jQuery <1.9
+ _shouldFocusInput: function( inst ) {
+ return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
+ },
+
+ /* Check positioning to remain on screen. */
+ _checkOffset: function( inst, offset, isFixed ) {
+ var dpWidth = inst.dpDiv.outerWidth(),
+ dpHeight = inst.dpDiv.outerHeight(),
+ inputWidth = inst.input ? inst.input.outerWidth() : 0,
+ inputHeight = inst.input ? inst.input.outerHeight() : 0,
+ viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
+ viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
+
+ offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
+ offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
+ offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
+
+ // Now check if datepicker is showing outside window viewport - move to a better place if so.
+ offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
+ Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
+ offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
+ Math.abs( dpHeight + inputHeight ) : 0 );
+
+ return offset;
+ },
+
+ /* Find an object's position on the screen. */
+ _findPos: function( obj ) {
+ var position,
+ inst = this._getInst( obj ),
+ isRTL = this._get( inst, "isRTL" );
+
+ while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
+ obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
+ }
+
+ position = $( obj ).offset();
+ return [ position.left, position.top ];
+ },
+
+ /* Hide the date picker from view.
+ * @param input element - the input field attached to the date picker
+ */
+ _hideDatepicker: function( input ) {
+ var showAnim, duration, postProcess, onClose,
+ inst = this._curInst;
+
+ if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
+ return;
+ }
+
+ if ( this._datepickerShowing ) {
+ showAnim = this._get( inst, "showAnim" );
+ duration = this._get( inst, "duration" );
+ postProcess = function() {
+ $.datepicker._tidyDialog( inst );
+ };
+
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
+ inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
+ } else {
+ inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
+ ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
+ }
+
+ if ( !showAnim ) {
+ postProcess();
+ }
+ this._datepickerShowing = false;
+
+ onClose = this._get( inst, "onClose" );
+ if ( onClose ) {
+ onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
+ }
+
+ this._lastInput = null;
+ if ( this._inDialog ) {
+ this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
+ if ( $.blockUI ) {
+ $.unblockUI();
+ $( "body" ).append( this.dpDiv );
+ }
+ }
+ this._inDialog = false;
+ }
+ },
+
+ /* Tidy up after a dialog display. */
+ _tidyDialog: function( inst ) {
+ inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
+ },
+
+ /* Close date picker if clicked elsewhere. */
+ _checkExternalClick: function( event ) {
+ if ( !$.datepicker._curInst ) {
+ return;
+ }
+
+ var $target = $( event.target ),
+ inst = $.datepicker._getInst( $target[ 0 ] );
+
+ if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
+ $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
+ !$target.hasClass( $.datepicker.markerClassName ) &&
+ !$target.closest( "." + $.datepicker._triggerClass ).length &&
+ $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
+ ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
+ $.datepicker._hideDatepicker();
+ }
+ },
+
+ /* Adjust one of the date sub-fields. */
+ _adjustDate: function( id, offset, period ) {
+ var target = $( id ),
+ inst = this._getInst( target[ 0 ] );
+
+ if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
+ return;
+ }
+ this._adjustInstDate( inst, offset +
+ ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
+ period );
+ this._updateDatepicker( inst );
+ },
+
+ /* Action for current link. */
+ _gotoToday: function( id ) {
+ var date,
+ target = $( id ),
+ inst = this._getInst( target[ 0 ] );
+
+ if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
+ inst.selectedDay = inst.currentDay;
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth;
+ inst.drawYear = inst.selectedYear = inst.currentYear;
+ } else {
+ date = new Date();
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ }
+ this._notifyChange( inst );
+ this._adjustDate( target );
+ },
+
+ /* Action for selecting a new month/year. */
+ _selectMonthYear: function( id, select, period ) {
+ var target = $( id ),
+ inst = this._getInst( target[ 0 ] );
+
+ inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
+ inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
+ parseInt( select.options[ select.selectedIndex ].value, 10 );
+
+ this._notifyChange( inst );
+ this._adjustDate( target );
+ },
+
+ /* Action for selecting a day. */
+ _selectDay: function( id, month, year, td ) {
+ var inst,
+ target = $( id );
+
+ if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
+ return;
+ }
+
+ inst = this._getInst( target[ 0 ] );
+ inst.selectedDay = inst.currentDay = $( "a", td ).html();
+ inst.selectedMonth = inst.currentMonth = month;
+ inst.selectedYear = inst.currentYear = year;
+ this._selectDate( id, this._formatDate( inst,
+ inst.currentDay, inst.currentMonth, inst.currentYear ) );
+ },
+
+ /* Erase the input field and hide the date picker. */
+ _clearDate: function( id ) {
+ var target = $( id );
+ this._selectDate( target, "" );
+ },
+
+ /* Update the input field with the selected date. */
+ _selectDate: function( id, dateStr ) {
+ var onSelect,
+ target = $( id ),
+ inst = this._getInst( target[ 0 ] );
+
+ dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
+ if ( inst.input ) {
+ inst.input.val( dateStr );
+ }
+ this._updateAlternate( inst );
+
+ onSelect = this._get( inst, "onSelect" );
+ if ( onSelect ) {
+ onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
+ } else if ( inst.input ) {
+ inst.input.trigger( "change" ); // fire the change event
+ }
+
+ if ( inst.inline ) {
+ this._updateDatepicker( inst );
+ } else {
+ this._hideDatepicker();
+ this._lastInput = inst.input[ 0 ];
+ if ( typeof( inst.input[ 0 ] ) !== "object" ) {
+ inst.input.trigger( "focus" ); // restore focus
+ }
+ this._lastInput = null;
+ }
+ },
+
+ /* Update any alternate field to synchronise with the main field. */
+ _updateAlternate: function( inst ) {
+ var altFormat, date, dateStr,
+ altField = this._get( inst, "altField" );
+
+ if ( altField ) { // update alternate field too
+ altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
+ date = this._getDate( inst );
+ dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
+ $( altField ).val( dateStr );
+ }
+ },
+
+ /* Set as beforeShowDay function to prevent selection of weekends.
+ * @param date Date - the date to customise
+ * @return [boolean, string] - is this date selectable?, what is its CSS class?
+ */
+ noWeekends: function( date ) {
+ var day = date.getDay();
+ return [ ( day > 0 && day < 6 ), "" ];
+ },
+
+ /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
+ * @param date Date - the date to get the week for
+ * @return number - the number of the week within the year that contains this date
+ */
+ iso8601Week: function( date ) {
+ var time,
+ checkDate = new Date( date.getTime() );
+
+ // Find Thursday of this week starting on Monday
+ checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
+
+ time = checkDate.getTime();
+ checkDate.setMonth( 0 ); // Compare with Jan 1
+ checkDate.setDate( 1 );
+ return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
+ },
+
+ /* Parse a string value into a date object.
+ * See formatDate below for the possible formats.
+ *
+ * @param format string - the expected format of the date
+ * @param value string - the date in the above format
+ * @param settings Object - attributes include:
+ * shortYearCutoff number - the cutoff year for determining the century (optional)
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
+ * dayNames string[7] - names of the days from Sunday (optional)
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
+ * monthNames string[12] - names of the months (optional)
+ * @return Date - the extracted date value or null if value is blank
+ */
+ parseDate: function( format, value, settings ) {
+ if ( format == null || value == null ) {
+ throw "Invalid arguments";
+ }
+
+ value = ( typeof value === "object" ? value.toString() : value + "" );
+ if ( value === "" ) {
+ return null;
+ }
+
+ var iFormat, dim, extra,
+ iValue = 0,
+ shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
+ shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
+ new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
+ dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
+ dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
+ monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
+ monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
+ year = -1,
+ month = -1,
+ day = -1,
+ doy = -1,
+ literal = false,
+ date,
+
+ // Check whether a format character is doubled
+ lookAhead = function( match ) {
+ var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
+ if ( matches ) {
+ iFormat++;
+ }
+ return matches;
+ },
+
+ // Extract a number from the string value
+ getNumber = function( match ) {
+ var isDoubled = lookAhead( match ),
+ size = ( match === "@" ? 14 : ( match === "!" ? 20 :
+ ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
+ minSize = ( match === "y" ? size : 1 ),
+ digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
+ num = value.substring( iValue ).match( digits );
+ if ( !num ) {
+ throw "Missing number at position " + iValue;
+ }
+ iValue += num[ 0 ].length;
+ return parseInt( num[ 0 ], 10 );
+ },
+
+ // Extract a name from the string value and convert to an index
+ getName = function( match, shortNames, longNames ) {
+ var index = -1,
+ names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
+ return [ [ k, v ] ];
+ } ).sort( function( a, b ) {
+ return -( a[ 1 ].length - b[ 1 ].length );
+ } );
+
+ $.each( names, function( i, pair ) {
+ var name = pair[ 1 ];
+ if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
+ index = pair[ 0 ];
+ iValue += name.length;
+ return false;
+ }
+ } );
+ if ( index !== -1 ) {
+ return index + 1;
+ } else {
+ throw "Unknown name at position " + iValue;
+ }
+ },
+
+ // Confirm that a literal character matches the string value
+ checkLiteral = function() {
+ if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
+ throw "Unexpected literal at position " + iValue;
+ }
+ iValue++;
+ };
+
+ for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
+ if ( literal ) {
+ if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
+ literal = false;
+ } else {
+ checkLiteral();
+ }
+ } else {
+ switch ( format.charAt( iFormat ) ) {
+ case "d":
+ day = getNumber( "d" );
+ break;
+ case "D":
+ getName( "D", dayNamesShort, dayNames );
+ break;
+ case "o":
+ doy = getNumber( "o" );
+ break;
+ case "m":
+ month = getNumber( "m" );
+ break;
+ case "M":
+ month = getName( "M", monthNamesShort, monthNames );
+ break;
+ case "y":
+ year = getNumber( "y" );
+ break;
+ case "@":
+ date = new Date( getNumber( "@" ) );
+ year = date.getFullYear();
+ month = date.getMonth() + 1;
+ day = date.getDate();
+ break;
+ case "!":
+ date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
+ year = date.getFullYear();
+ month = date.getMonth() + 1;
+ day = date.getDate();
+ break;
+ case "'":
+ if ( lookAhead( "'" ) ) {
+ checkLiteral();
+ } else {
+ literal = true;
+ }
+ break;
+ default:
+ checkLiteral();
+ }
+ }
+ }
+
+ if ( iValue < value.length ) {
+ extra = value.substr( iValue );
+ if ( !/^\s+/.test( extra ) ) {
+ throw "Extra/unparsed characters found in date: " + extra;
+ }
+ }
+
+ if ( year === -1 ) {
+ year = new Date().getFullYear();
+ } else if ( year < 100 ) {
+ year += new Date().getFullYear() - new Date().getFullYear() % 100 +
+ ( year <= shortYearCutoff ? 0 : -100 );
+ }
+
+ if ( doy > -1 ) {
+ month = 1;
+ day = doy;
+ do {
+ dim = this._getDaysInMonth( year, month - 1 );
+ if ( day <= dim ) {
+ break;
+ }
+ month++;
+ day -= dim;
+ } while ( true );
+ }
+
+ date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
+ if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
+ throw "Invalid date"; // E.g. 31/02/00
+ }
+ return date;
+ },
+
+ /* Standard date formats. */
+ ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
+ COOKIE: "D, dd M yy",
+ ISO_8601: "yy-mm-dd",
+ RFC_822: "D, d M y",
+ RFC_850: "DD, dd-M-y",
+ RFC_1036: "D, d M y",
+ RFC_1123: "D, d M yy",
+ RFC_2822: "D, d M yy",
+ RSS: "D, d M y", // RFC 822
+ TICKS: "!",
+ TIMESTAMP: "@",
+ W3C: "yy-mm-dd", // ISO 8601
+
+ _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
+ Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
+
+ /* Format a date object into a string value.
+ * The format can be combinations of the following:
+ * d - day of month (no leading zero)
+ * dd - day of month (two digit)
+ * o - day of year (no leading zeros)
+ * oo - day of year (three digit)
+ * D - day name short
+ * DD - day name long
+ * m - month of year (no leading zero)
+ * mm - month of year (two digit)
+ * M - month name short
+ * MM - month name long
+ * y - year (two digit)
+ * yy - year (four digit)
+ * @ - Unix timestamp (ms since 01/01/1970)
+ * ! - Windows ticks (100ns since 01/01/0001)
+ * "..." - literal text
+ * '' - single quote
+ *
+ * @param format string - the desired format of the date
+ * @param date Date - the date value to format
+ * @param settings Object - attributes include:
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
+ * dayNames string[7] - names of the days from Sunday (optional)
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
+ * monthNames string[12] - names of the months (optional)
+ * @return string - the date in the above format
+ */
+ formatDate: function( format, date, settings ) {
+ if ( !date ) {
+ return "";
+ }
+
+ var iFormat,
+ dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
+ dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
+ monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
+ monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
+
+ // Check whether a format character is doubled
+ lookAhead = function( match ) {
+ var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
+ if ( matches ) {
+ iFormat++;
+ }
+ return matches;
+ },
+
+ // Format a number, with leading zero if necessary
+ formatNumber = function( match, value, len ) {
+ var num = "" + value;
+ if ( lookAhead( match ) ) {
+ while ( num.length < len ) {
+ num = "0" + num;
+ }
+ }
+ return num;
+ },
+
+ // Format a name, short or long as requested
+ formatName = function( match, value, shortNames, longNames ) {
+ return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
+ },
+ output = "",
+ literal = false;
+
+ if ( date ) {
+ for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
+ if ( literal ) {
+ if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
+ literal = false;
+ } else {
+ output += format.charAt( iFormat );
+ }
+ } else {
+ switch ( format.charAt( iFormat ) ) {
+ case "d":
+ output += formatNumber( "d", date.getDate(), 2 );
+ break;
+ case "D":
+ output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
+ break;
+ case "o":
+ output += formatNumber( "o",
+ Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
+ break;
+ case "m":
+ output += formatNumber( "m", date.getMonth() + 1, 2 );
+ break;
+ case "M":
+ output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
+ break;
+ case "y":
+ output += ( lookAhead( "y" ) ? date.getFullYear() :
+ ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
+ break;
+ case "@":
+ output += date.getTime();
+ break;
+ case "!":
+ output += date.getTime() * 10000 + this._ticksTo1970;
+ break;
+ case "'":
+ if ( lookAhead( "'" ) ) {
+ output += "'";
+ } else {
+ literal = true;
+ }
+ break;
+ default:
+ output += format.charAt( iFormat );
+ }
+ }
+ }
+ }
+ return output;
+ },
+
+ /* Extract all possible characters from the date format. */
+ _possibleChars: function( format ) {
+ var iFormat,
+ chars = "",
+ literal = false,
+
+ // Check whether a format character is doubled
+ lookAhead = function( match ) {
+ var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
+ if ( matches ) {
+ iFormat++;
+ }
+ return matches;
+ };
+
+ for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
+ if ( literal ) {
+ if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
+ literal = false;
+ } else {
+ chars += format.charAt( iFormat );
+ }
+ } else {
+ switch ( format.charAt( iFormat ) ) {
+ case "d": case "m": case "y": case "@":
+ chars += "0123456789";
+ break;
+ case "D": case "M":
+ return null; // Accept anything
+ case "'":
+ if ( lookAhead( "'" ) ) {
+ chars += "'";
+ } else {
+ literal = true;
+ }
+ break;
+ default:
+ chars += format.charAt( iFormat );
+ }
+ }
+ }
+ return chars;
+ },
+
+ /* Get a setting value, defaulting if necessary. */
+ _get: function( inst, name ) {
+ return inst.settings[ name ] !== undefined ?
+ inst.settings[ name ] : this._defaults[ name ];
+ },
+
+ /* Parse existing date and initialise date picker. */
+ _setDateFromField: function( inst, noDefault ) {
+ if ( inst.input.val() === inst.lastVal ) {
+ return;
+ }
+
+ var dateFormat = this._get( inst, "dateFormat" ),
+ dates = inst.lastVal = inst.input ? inst.input.val() : null,
+ defaultDate = this._getDefaultDate( inst ),
+ date = defaultDate,
+ settings = this._getFormatConfig( inst );
+
+ try {
+ date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
+ } catch ( event ) {
+ dates = ( noDefault ? "" : dates );
+ }
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ inst.currentDay = ( dates ? date.getDate() : 0 );
+ inst.currentMonth = ( dates ? date.getMonth() : 0 );
+ inst.currentYear = ( dates ? date.getFullYear() : 0 );
+ this._adjustInstDate( inst );
+ },
+
+ /* Retrieve the default date shown on opening. */
+ _getDefaultDate: function( inst ) {
+ return this._restrictMinMax( inst,
+ this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
+ },
+
+ /* A date may be specified as an exact value or a relative one. */
+ _determineDate: function( inst, date, defaultDate ) {
+ var offsetNumeric = function( offset ) {
+ var date = new Date();
+ date.setDate( date.getDate() + offset );
+ return date;
+ },
+ offsetString = function( offset ) {
+ try {
+ return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
+ offset, $.datepicker._getFormatConfig( inst ) );
+ }
+ catch ( e ) {
+
+ // Ignore
+ }
+
+ var date = ( offset.toLowerCase().match( /^c/ ) ?
+ $.datepicker._getDate( inst ) : null ) || new Date(),
+ year = date.getFullYear(),
+ month = date.getMonth(),
+ day = date.getDate(),
+ pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
+ matches = pattern.exec( offset );
+
+ while ( matches ) {
+ switch ( matches[ 2 ] || "d" ) {
+ case "d" : case "D" :
+ day += parseInt( matches[ 1 ], 10 ); break;
+ case "w" : case "W" :
+ day += parseInt( matches[ 1 ], 10 ) * 7; break;
+ case "m" : case "M" :
+ month += parseInt( matches[ 1 ], 10 );
+ day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
+ break;
+ case "y": case "Y" :
+ year += parseInt( matches[ 1 ], 10 );
+ day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
+ break;
+ }
+ matches = pattern.exec( offset );
+ }
+ return new Date( year, month, day );
+ },
+ newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
+ ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
+
+ newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
+ if ( newDate ) {
+ newDate.setHours( 0 );
+ newDate.setMinutes( 0 );
+ newDate.setSeconds( 0 );
+ newDate.setMilliseconds( 0 );
+ }
+ return this._daylightSavingAdjust( newDate );
+ },
+
+ /* Handle switch to/from daylight saving.
+ * Hours may be non-zero on daylight saving cut-over:
+ * > 12 when midnight changeover, but then cannot generate
+ * midnight datetime, so jump to 1AM, otherwise reset.
+ * @param date (Date) the date to check
+ * @return (Date) the corrected date
+ */
+ _daylightSavingAdjust: function( date ) {
+ if ( !date ) {
+ return null;
+ }
+ date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
+ return date;
+ },
+
+ /* Set the date(s) directly. */
+ _setDate: function( inst, date, noChange ) {
+ var clear = !date,
+ origMonth = inst.selectedMonth,
+ origYear = inst.selectedYear,
+ newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
+
+ inst.selectedDay = inst.currentDay = newDate.getDate();
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
+ inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
+ if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
+ this._notifyChange( inst );
+ }
+ this._adjustInstDate( inst );
+ if ( inst.input ) {
+ inst.input.val( clear ? "" : this._formatDate( inst ) );
+ }
+ },
+
+ /* Retrieve the date(s) directly. */
+ _getDate: function( inst ) {
+ var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
+ this._daylightSavingAdjust( new Date(
+ inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
+ return startDate;
+ },
+
+ /* Attach the onxxx handlers. These are declared statically so
+ * they work with static code transformers like Caja.
+ */
+ _attachHandlers: function( inst ) {
+ var stepMonths = this._get( inst, "stepMonths" ),
+ id = "#" + inst.id.replace( /\\\\/g, "\\" );
+ inst.dpDiv.find( "[data-handler]" ).map( function() {
+ var handler = {
+ prev: function() {
+ $.datepicker._adjustDate( id, -stepMonths, "M" );
+ },
+ next: function() {
+ $.datepicker._adjustDate( id, +stepMonths, "M" );
+ },
+ hide: function() {
+ $.datepicker._hideDatepicker();
+ },
+ today: function() {
+ $.datepicker._gotoToday( id );
+ },
+ selectDay: function() {
+ $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
+ return false;
+ },
+ selectMonth: function() {
+ $.datepicker._selectMonthYear( id, this, "M" );
+ return false;
+ },
+ selectYear: function() {
+ $.datepicker._selectMonthYear( id, this, "Y" );
+ return false;
+ }
+ };
+ $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
+ } );
+ },
+
+ /* Generate the HTML for the current state of the date picker. */
+ _generateHTML: function( inst ) {
+ var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
+ controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
+ monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
+ selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
+ cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
+ printDate, dRow, tbody, daySettings, otherMonth, unselectable,
+ tempDate = new Date(),
+ today = this._daylightSavingAdjust(
+ new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
+ isRTL = this._get( inst, "isRTL" ),
+ showButtonPanel = this._get( inst, "showButtonPanel" ),
+ hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
+ navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
+ numMonths = this._getNumberOfMonths( inst ),
+ showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
+ stepMonths = this._get( inst, "stepMonths" ),
+ isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
+ currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
+ new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
+ minDate = this._getMinMaxDate( inst, "min" ),
+ maxDate = this._getMinMaxDate( inst, "max" ),
+ drawMonth = inst.drawMonth - showCurrentAtPos,
+ drawYear = inst.drawYear;
+
+ if ( drawMonth < 0 ) {
+ drawMonth += 12;
+ drawYear--;
+ }
+ if ( maxDate ) {
+ maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
+ maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
+ maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
+ while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
+ drawMonth--;
+ if ( drawMonth < 0 ) {
+ drawMonth = 11;
+ drawYear--;
+ }
+ }
+ }
+ inst.drawMonth = drawMonth;
+ inst.drawYear = drawYear;
+
+ prevText = this._get( inst, "prevText" );
+ prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
+ this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
+ this._getFormatConfig( inst ) ) );
+
+ prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
+ "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
+ " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
+ ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) );
+
+ nextText = this._get( inst, "nextText" );
+ nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
+ this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
+ this._getFormatConfig( inst ) ) );
+
+ next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
+ "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
+ " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
+ ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) );
+
+ currentText = this._get( inst, "currentText" );
+ gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
+ currentText = ( !navigationAsDateFormat ? currentText :
+ this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
+
+ controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
+ this._get( inst, "closeText" ) + "</button>" : "" );
+
+ buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
+ ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
+ ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
+
+ firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
+ firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
+
+ showWeek = this._get( inst, "showWeek" );
+ dayNames = this._get( inst, "dayNames" );
+ dayNamesMin = this._get( inst, "dayNamesMin" );
+ monthNames = this._get( inst, "monthNames" );
+ monthNamesShort = this._get( inst, "monthNamesShort" );
+ beforeShowDay = this._get( inst, "beforeShowDay" );
+ showOtherMonths = this._get( inst, "showOtherMonths" );
+ selectOtherMonths = this._get( inst, "selectOtherMonths" );
+ defaultDate = this._getDefaultDate( inst );
+ html = "";
+
+ for ( row = 0; row < numMonths[ 0 ]; row++ ) {
+ group = "";
+ this.maxRows = 4;
+ for ( col = 0; col < numMonths[ 1 ]; col++ ) {
+ selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
+ cornerClass = " ui-corner-all";
+ calender = "";
+ if ( isMultiMonth ) {
+ calender += "<div class='ui-datepicker-group";
+ if ( numMonths[ 1 ] > 1 ) {
+ switch ( col ) {
+ case 0: calender += " ui-datepicker-group-first";
+ cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
+ case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
+ cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
+ default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
+ }
+ }
+ calender += "'>";
+ }
+ calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
+ ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
+ ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
+ this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
+ row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
+ "</div><table class='ui-datepicker-calendar'><thead>" +
+ "<tr>";
+ thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
+ for ( dow = 0; dow < 7; dow++ ) { // days of the week
+ day = ( dow + firstDay ) % 7;
+ thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
+ "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
+ }
+ calender += thead + "</tr></thead><tbody>";
+ daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
+ if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
+ inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
+ }
+ leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
+ curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
+ numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
+ this.maxRows = numRows;
+ printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
+ for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
+ calender += "<tr>";
+ tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
+ this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
+ for ( dow = 0; dow < 7; dow++ ) { // create date picker days
+ daySettings = ( beforeShowDay ?
+ beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
+ otherMonth = ( printDate.getMonth() !== drawMonth );
+ unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
+ ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
+ tbody += "<td class='" +
+ ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
+ ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
+ ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
+ ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
+
+ // or defaultDate is current printedDate and defaultDate is selectedDate
+ " " + this._dayOverClass : "" ) + // highlight selected day
+ ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
+ ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
+ ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
+ ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
+ ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title
+ ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
+ ( otherMonth && !showOtherMonths ? " " : // display for other months
+ ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
+ ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
+ ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
+ ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
+ "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
+ printDate.setDate( printDate.getDate() + 1 );
+ printDate = this._daylightSavingAdjust( printDate );
+ }
+ calender += tbody + "</tr>";
+ }
+ drawMonth++;
+ if ( drawMonth > 11 ) {
+ drawMonth = 0;
+ drawYear++;
+ }
+ calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
+ ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
+ group += calender;
+ }
+ html += group;
+ }
+ html += buttonPanel;
+ inst._keyEvent = false;
+ return html;
+ },
+
+ /* Generate the month and year header. */
+ _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
+ secondary, monthNames, monthNamesShort ) {
+
+ var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
+ changeMonth = this._get( inst, "changeMonth" ),
+ changeYear = this._get( inst, "changeYear" ),
+ showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
+ html = "<div class='ui-datepicker-title'>",
+ monthHtml = "";
+
+ // Month selection
+ if ( secondary || !changeMonth ) {
+ monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
+ } else {
+ inMinYear = ( minDate && minDate.getFullYear() === drawYear );
+ inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
+ monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
+ for ( month = 0; month < 12; month++ ) {
+ if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
+ monthHtml += "<option value='" + month + "'" +
+ ( month === drawMonth ? " selected='selected'" : "" ) +
+ ">" + monthNamesShort[ month ] + "</option>";
+ }
+ }
+ monthHtml += "</select>";
+ }
+
+ if ( !showMonthAfterYear ) {
+ html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? " " : "" );
+ }
+
+ // Year selection
+ if ( !inst.yearshtml ) {
+ inst.yearshtml = "";
+ if ( secondary || !changeYear ) {
+ html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
+ } else {
+
+ // determine range of years to display
+ years = this._get( inst, "yearRange" ).split( ":" );
+ thisYear = new Date().getFullYear();
+ determineYear = function( value ) {
+ var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
+ ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
+ parseInt( value, 10 ) ) );
+ return ( isNaN( year ) ? thisYear : year );
+ };
+ year = determineYear( years[ 0 ] );
+ endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
+ year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
+ endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
+ inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
+ for ( ; year <= endYear; year++ ) {
+ inst.yearshtml += "<option value='" + year + "'" +
+ ( year === drawYear ? " selected='selected'" : "" ) +
+ ">" + year + "</option>";
+ }
+ inst.yearshtml += "</select>";
+
+ html += inst.yearshtml;
+ inst.yearshtml = null;
+ }
+ }
+
+ html += this._get( inst, "yearSuffix" );
+ if ( showMonthAfterYear ) {
+ html += ( secondary || !( changeMonth && changeYear ) ? " " : "" ) + monthHtml;
+ }
+ html += "</div>"; // Close datepicker_header
+ return html;
+ },
+
+ /* Adjust one of the date sub-fields. */
+ _adjustInstDate: function( inst, offset, period ) {
+ var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
+ month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
+ day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
+ date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
+
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ if ( period === "M" || period === "Y" ) {
+ this._notifyChange( inst );
+ }
+ },
+
+ /* Ensure a date is within any min/max bounds. */
+ _restrictMinMax: function( inst, date ) {
+ var minDate = this._getMinMaxDate( inst, "min" ),
+ maxDate = this._getMinMaxDate( inst, "max" ),
+ newDate = ( minDate && date < minDate ? minDate : date );
+ return ( maxDate && newDate > maxDate ? maxDate : newDate );
+ },
+
+ /* Notify change of month/year. */
+ _notifyChange: function( inst ) {
+ var onChange = this._get( inst, "onChangeMonthYear" );
+ if ( onChange ) {
+ onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
+ [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
+ }
+ },
+
+ /* Determine the number of months to show. */
+ _getNumberOfMonths: function( inst ) {
+ var numMonths = this._get( inst, "numberOfMonths" );
+ return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
+ },
+
+ /* Determine the current maximum date - ensure no time components are set. */
+ _getMinMaxDate: function( inst, minMax ) {
+ return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
+ },
+
+ /* Find the number of days in a given month. */
+ _getDaysInMonth: function( year, month ) {
+ return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
+ },
+
+ /* Find the day of the week of the first of a month. */
+ _getFirstDayOfMonth: function( year, month ) {
+ return new Date( year, month, 1 ).getDay();
+ },
+
+ /* Determines if we should allow a "next/prev" month display change. */
+ _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
+ var numMonths = this._getNumberOfMonths( inst ),
+ date = this._daylightSavingAdjust( new Date( curYear,
+ curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
+
+ if ( offset < 0 ) {
+ date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
+ }
+ return this._isInRange( inst, date );
+ },
+
+ /* Is the given date in the accepted range? */
+ _isInRange: function( inst, date ) {
+ var yearSplit, currentYear,
+ minDate = this._getMinMaxDate( inst, "min" ),
+ maxDate = this._getMinMaxDate( inst, "max" ),
+ minYear = null,
+ maxYear = null,
+ years = this._get( inst, "yearRange" );
+ if ( years ) {
+ yearSplit = years.split( ":" );
+ currentYear = new Date().getFullYear();
+ minYear = parseInt( yearSplit[ 0 ], 10 );
+ maxYear = parseInt( yearSplit[ 1 ], 10 );
+ if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
+ minYear += currentYear;
+ }
+ if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
+ maxYear += currentYear;
+ }
+ }
+
+ return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
+ ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
+ ( !minYear || date.getFullYear() >= minYear ) &&
+ ( !maxYear || date.getFullYear() <= maxYear ) );
+ },
+
+ /* Provide the configuration settings for formatting/parsing. */
+ _getFormatConfig: function( inst ) {
+ var shortYearCutoff = this._get( inst, "shortYearCutoff" );
+ shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
+ new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
+ return { shortYearCutoff: shortYearCutoff,
+ dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
+ monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
+ },
+
+ /* Format the given date for display. */
+ _formatDate: function( inst, day, month, year ) {
+ if ( !day ) {
+ inst.currentDay = inst.selectedDay;
+ inst.currentMonth = inst.selectedMonth;
+ inst.currentYear = inst.selectedYear;
+ }
+ var date = ( day ? ( typeof day === "object" ? day :
+ this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
+ this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
+ return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
+ }
+} );
+
+/*
+ * Bind hover events for datepicker elements.
+ * Done via delegate so the binding only occurs once in the lifetime of the parent div.
+ * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
+ */
+function datepicker_bindHover( dpDiv ) {
+ var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
+ return dpDiv.on( "mouseout", selector, function() {
+ $( this ).removeClass( "ui-state-hover" );
+ if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
+ $( this ).removeClass( "ui-datepicker-prev-hover" );
+ }
+ if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
+ $( this ).removeClass( "ui-datepicker-next-hover" );
+ }
+ } )
+ .on( "mouseover", selector, datepicker_handleMouseover );
+}
+
+function datepicker_handleMouseover() {
+ if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
+ $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
+ $( this ).addClass( "ui-state-hover" );
+ if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
+ $( this ).addClass( "ui-datepicker-prev-hover" );
+ }
+ if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
+ $( this ).addClass( "ui-datepicker-next-hover" );
+ }
+ }
+}
+
+/* jQuery extend now ignores nulls! */
+function datepicker_extendRemove( target, props ) {
+ $.extend( target, props );
+ for ( var name in props ) {
+ if ( props[ name ] == null ) {
+ target[ name ] = props[ name ];
+ }
+ }
+ return target;
+}
+
+/* Invoke the datepicker functionality.
+ @param options string - a command, optionally followed by additional parameters or
+ Object - settings for attaching new datepicker functionality
+ @return jQuery object */
+$.fn.datepicker = function( options ) {
+
+ /* Verify an empty collection wasn't passed - Fixes #6976 */
+ if ( !this.length ) {
+ return this;
+ }
+
+ /* Initialise the date picker. */
+ if ( !$.datepicker.initialized ) {
+ $( document ).on( "mousedown", $.datepicker._checkExternalClick );
+ $.datepicker.initialized = true;
+ }
+
+ /* Append datepicker main container to body if not exist. */
+ if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
+ $( "body" ).append( $.datepicker.dpDiv );
+ }
+
+ var otherArgs = Array.prototype.slice.call( arguments, 1 );
+ if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
+ return $.datepicker[ "_" + options + "Datepicker" ].
+ apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
+ }
+ if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
+ return $.datepicker[ "_" + options + "Datepicker" ].
+ apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
+ }
+ return this.each( function() {
+ typeof options === "string" ?
+ $.datepicker[ "_" + options + "Datepicker" ].
+ apply( $.datepicker, [ this ].concat( otherArgs ) ) :
+ $.datepicker._attachDatepicker( this, options );
+ } );
+};
+
+$.datepicker = new Datepicker(); // singleton instance
+$.datepicker.initialized = false;
+$.datepicker.uuid = new Date().getTime();
+$.datepicker.version = "1.12.1";
+
+var widgetsDatepicker = $.datepicker;
+
+
+
+
+// This file is deprecated
+var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
+
+/*!
+ * jQuery UI Mouse 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Mouse
+//>>group: Widgets
+//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
+//>>docs: http://api.jqueryui.com/mouse/
+
+
+
+var mouseHandled = false;
+$( document ).on( "mouseup", function() {
+ mouseHandled = false;
+} );
+
+var widgetsMouse = $.widget( "ui.mouse", {
+ version: "1.12.1",
+ options: {
+ cancel: "input, textarea, button, select, option",
+ distance: 1,
+ delay: 0
+ },
+ _mouseInit: function() {
+ var that = this;
+
+ this.element
+ .on( "mousedown." + this.widgetName, function( event ) {
+ return that._mouseDown( event );
+ } )
+ .on( "click." + this.widgetName, function( event ) {
+ if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
+ $.removeData( event.target, that.widgetName + ".preventClickEvent" );
+ event.stopImmediatePropagation();
+ return false;
+ }
+ } );
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.off( "." + this.widgetName );
+ if ( this._mouseMoveDelegate ) {
+ this.document
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
+ }
+ },
+
+ _mouseDown: function( event ) {
+
+ // don't let more than one widget handle mouseStart
+ if ( mouseHandled ) {
+ return;
+ }
+
+ this._mouseMoved = false;
+
+ // We may have missed mouseup (out of window)
+ ( this._mouseStarted && this._mouseUp( event ) );
+
+ this._mouseDownEvent = event;
+
+ var that = this,
+ btnIsLeft = ( event.which === 1 ),
+
+ // event.target.nodeName works around a bug in IE 8 with
+ // disabled inputs (#7620)
+ elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
+ $( event.target ).closest( this.options.cancel ).length : false );
+ if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if ( !this.mouseDelayMet ) {
+ this._mouseDelayTimer = setTimeout( function() {
+ that.mouseDelayMet = true;
+ }, this.options.delay );
+ }
+
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
+ this._mouseStarted = ( this._mouseStart( event ) !== false );
+ if ( !this._mouseStarted ) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // Click event may never have fired (Gecko & Opera)
+ if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
+ $.removeData( event.target, this.widgetName + ".preventClickEvent" );
+ }
+
+ // These delegates are required to keep context
+ this._mouseMoveDelegate = function( event ) {
+ return that._mouseMove( event );
+ };
+ this._mouseUpDelegate = function( event ) {
+ return that._mouseUp( event );
+ };
+
+ this.document
+ .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
+
+ event.preventDefault();
+
+ mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function( event ) {
+
+ // Only check for mouseups outside the document if you've moved inside the document
+ // at least once. This prevents the firing of mouseup in the case of IE<9, which will
+ // fire a mousemove event if content is placed under the cursor. See #7778
+ // Support: IE <9
+ if ( this._mouseMoved ) {
+
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
+ !event.button ) {
+ return this._mouseUp( event );
+
+ // Iframe mouseup check - mouseup occurred in another document
+ } else if ( !event.which ) {
+
+ // Support: Safari <=8 - 9
+ // Safari sets which to 0 if you press any of the following keys
+ // during a drag (#14461)
+ if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
+ event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
+ this.ignoreMissingWhich = true;
+ } else if ( !this.ignoreMissingWhich ) {
+ return this._mouseUp( event );
+ }
+ }
+ }
+
+ if ( event.which || event.button ) {
+ this._mouseMoved = true;
+ }
+
+ if ( this._mouseStarted ) {
+ this._mouseDrag( event );
+ return event.preventDefault();
+ }
+
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
+ this._mouseStarted =
+ ( this._mouseStart( this._mouseDownEvent, event ) !== false );
+ ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function( event ) {
+ this.document
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
+
+ if ( this._mouseStarted ) {
+ this._mouseStarted = false;
+
+ if ( event.target === this._mouseDownEvent.target ) {
+ $.data( event.target, this.widgetName + ".preventClickEvent", true );
+ }
+
+ this._mouseStop( event );
+ }
+
+ if ( this._mouseDelayTimer ) {
+ clearTimeout( this._mouseDelayTimer );
+ delete this._mouseDelayTimer;
+ }
+
+ this.ignoreMissingWhich = false;
+ mouseHandled = false;
+ event.preventDefault();
+ },
+
+ _mouseDistanceMet: function( event ) {
+ return ( Math.max(
+ Math.abs( this._mouseDownEvent.pageX - event.pageX ),
+ Math.abs( this._mouseDownEvent.pageY - event.pageY )
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function( /* event */ ) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function( /* event */ ) {},
+ _mouseDrag: function( /* event */ ) {},
+ _mouseStop: function( /* event */ ) {},
+ _mouseCapture: function( /* event */ ) { return true; }
+} );
+
+
+
+
+// $.ui.plugin is deprecated. Use $.widget() extensions instead.
+var plugin = $.ui.plugin = {
+ add: function( module, option, set ) {
+ var i,
+ proto = $.ui[ module ].prototype;
+ for ( i in set ) {
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
+ }
+ },
+ call: function( instance, name, args, allowDisconnected ) {
+ var i,
+ set = instance.plugins[ name ];
+
+ if ( !set ) {
+ return;
+ }
+
+ if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
+ instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
+ return;
+ }
+
+ for ( i = 0; i < set.length; i++ ) {
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
+ set[ i ][ 1 ].apply( instance.element, args );
+ }
+ }
+ }
+};
+
+
+
+var safeBlur = $.ui.safeBlur = function( element ) {
+
+ // Support: IE9 - 10 only
+ // If the <body> is blurred, IE will switch windows, see #9420
+ if ( element && element.nodeName.toLowerCase() !== "body" ) {
+ $( element ).trigger( "blur" );
+ }
+};
+
+
+/*!
+ * jQuery UI Draggable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Draggable
+//>>group: Interactions
+//>>description: Enables dragging functionality for any element.
+//>>docs: http://api.jqueryui.com/draggable/
+//>>demos: http://jqueryui.com/draggable/
+//>>css.structure: ../../themes/base/draggable.css
+
+
+
+$.widget( "ui.draggable", $.ui.mouse, {
+ version: "1.12.1",
+ widgetEventPrefix: "drag",
+ options: {
+ addClasses: true,
+ appendTo: "parent",
+ axis: false,
+ connectToSortable: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ iframeFix: false,
+ opacity: false,
+ refreshPositions: false,
+ revert: false,
+ revertDuration: 500,
+ scope: "default",
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ snap: false,
+ snapMode: "both",
+ snapTolerance: 20,
+ stack: false,
+ zIndex: false,
+
+ // Callbacks
+ drag: null,
+ start: null,
+ stop: null
+ },
+ _create: function() {
+
+ if ( this.options.helper === "original" ) {
+ this._setPositionRelative();
+ }
+ if ( this.options.addClasses ) {
+ this._addClass( "ui-draggable" );
+ }
+ this._setHandleClassName();
+
+ this._mouseInit();
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+ if ( key === "handle" ) {
+ this._removeHandleClassName();
+ this._setHandleClassName();
+ }
+ },
+
+ _destroy: function() {
+ if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
+ this.destroyOnClear = true;
+ return;
+ }
+ this._removeHandleClassName();
+ this._mouseDestroy();
+ },
+
+ _mouseCapture: function( event ) {
+ var o = this.options;
+
+ // Among others, prevent a drag on a resizable-handle
+ if ( this.helper || o.disabled ||
+ $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
+ return false;
+ }
+
+ //Quit if we're not on a valid handle
+ this.handle = this._getHandle( event );
+ if ( !this.handle ) {
+ return false;
+ }
+
+ this._blurActiveElement( event );
+
+ this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
+
+ return true;
+
+ },
+
+ _blockFrames: function( selector ) {
+ this.iframeBlocks = this.document.find( selector ).map( function() {
+ var iframe = $( this );
+
+ return $( "<div>" )
+ .css( "position", "absolute" )
+ .appendTo( iframe.parent() )
+ .outerWidth( iframe.outerWidth() )
+ .outerHeight( iframe.outerHeight() )
+ .offset( iframe.offset() )[ 0 ];
+ } );
+ },
+
+ _unblockFrames: function() {
+ if ( this.iframeBlocks ) {
+ this.iframeBlocks.remove();
+ delete this.iframeBlocks;
+ }
+ },
+
+ _blurActiveElement: function( event ) {
+ var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
+ target = $( event.target );
+
+ // Don't blur if the event occurred on an element that is within
+ // the currently focused element
+ // See #10527, #12472
+ if ( target.closest( activeElement ).length ) {
+ return;
+ }
+
+ // Blur any element that currently has focus, see #4261
+ $.ui.safeBlur( activeElement );
+ },
+
+ _mouseStart: function( event ) {
+
+ var o = this.options;
+
+ //Create and append the visible helper
+ this.helper = this._createHelper( event );
+
+ this._addClass( this.helper, "ui-draggable-dragging" );
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ //If ddmanager is used for droppables, set the global draggable
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.current = this;
+ }
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Store the helper's css position
+ this.cssPosition = this.helper.css( "position" );
+ this.scrollParent = this.helper.scrollParent( true );
+ this.offsetParent = this.helper.offsetParent();
+ this.hasFixedAncestor = this.helper.parents().filter( function() {
+ return $( this ).css( "position" ) === "fixed";
+ } ).length > 0;
+
+ //The element's absolute position on the page minus margins
+ this.positionAbs = this.element.offset();
+ this._refreshOffsets( event );
+
+ //Generate the original position
+ this.originalPosition = this.position = this._generatePosition( event, false );
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
+
+ //Set a containment if given in the options
+ this._setContainment();
+
+ //Trigger event + callbacks
+ if ( this._trigger( "start", event ) === false ) {
+ this._clear();
+ return false;
+ }
+
+ //Recache the helper size
+ this._cacheHelperProportions();
+
+ //Prepare the droppable offsets
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
+ }
+
+ // Execute the drag once - this causes the helper not to be visible before getting its
+ // correct position
+ this._mouseDrag( event, true );
+
+ // If the ddmanager is used for droppables, inform the manager that dragging has started
+ // (see #5003)
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.dragStart( this, event );
+ }
+
+ return true;
+ },
+
+ _refreshOffsets: function( event ) {
+ this.offset = {
+ top: this.positionAbs.top - this.margins.top,
+ left: this.positionAbs.left - this.margins.left,
+ scroll: false,
+ parent: this._getParentOffset(),
+ relative: this._getRelativeOffset()
+ };
+
+ this.offset.click = {
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ };
+ },
+
+ _mouseDrag: function( event, noPropagation ) {
+
+ // reset any necessary cached properties (see #5009)
+ if ( this.hasFixedAncestor ) {
+ this.offset.parent = this._getParentOffset();
+ }
+
+ //Compute the helpers position
+ this.position = this._generatePosition( event, true );
+ this.positionAbs = this._convertPositionTo( "absolute" );
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ if ( !noPropagation ) {
+ var ui = this._uiHash();
+ if ( this._trigger( "drag", event, ui ) === false ) {
+ this._mouseUp( new $.Event( "mouseup", event ) );
+ return false;
+ }
+ this.position = ui.position;
+ }
+
+ this.helper[ 0 ].style.left = this.position.left + "px";
+ this.helper[ 0 ].style.top = this.position.top + "px";
+
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.drag( this, event );
+ }
+
+ return false;
+ },
+
+ _mouseStop: function( event ) {
+
+ //If we are using droppables, inform the manager about the drop
+ var that = this,
+ dropped = false;
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
+ dropped = $.ui.ddmanager.drop( this, event );
+ }
+
+ //if a drop comes from outside (a sortable)
+ if ( this.dropped ) {
+ dropped = this.dropped;
+ this.dropped = false;
+ }
+
+ if ( ( this.options.revert === "invalid" && !dropped ) ||
+ ( this.options.revert === "valid" && dropped ) ||
+ this.options.revert === true || ( $.isFunction( this.options.revert ) &&
+ this.options.revert.call( this.element, dropped ) )
+ ) {
+ $( this.helper ).animate(
+ this.originalPosition,
+ parseInt( this.options.revertDuration, 10 ),
+ function() {
+ if ( that._trigger( "stop", event ) !== false ) {
+ that._clear();
+ }
+ }
+ );
+ } else {
+ if ( this._trigger( "stop", event ) !== false ) {
+ this._clear();
+ }
+ }
+
+ return false;
+ },
+
+ _mouseUp: function( event ) {
+ this._unblockFrames();
+
+ // If the ddmanager is used for droppables, inform the manager that dragging has stopped
+ // (see #5003)
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.dragStop( this, event );
+ }
+
+ // Only need to focus if the event occurred on the draggable itself, see #10527
+ if ( this.handleElement.is( event.target ) ) {
+
+ // The interaction is over; whether or not the click resulted in a drag,
+ // focus the element
+ this.element.trigger( "focus" );
+ }
+
+ return $.ui.mouse.prototype._mouseUp.call( this, event );
+ },
+
+ cancel: function() {
+
+ if ( this.helper.is( ".ui-draggable-dragging" ) ) {
+ this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
+ } else {
+ this._clear();
+ }
+
+ return this;
+
+ },
+
+ _getHandle: function( event ) {
+ return this.options.handle ?
+ !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
+ true;
+ },
+
+ _setHandleClassName: function() {
+ this.handleElement = this.options.handle ?
+ this.element.find( this.options.handle ) : this.element;
+ this._addClass( this.handleElement, "ui-draggable-handle" );
+ },
+
+ _removeHandleClassName: function() {
+ this._removeClass( this.handleElement, "ui-draggable-handle" );
+ },
+
+ _createHelper: function( event ) {
+
+ var o = this.options,
+ helperIsFunction = $.isFunction( o.helper ),
+ helper = helperIsFunction ?
+ $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
+ ( o.helper === "clone" ?
+ this.element.clone().removeAttr( "id" ) :
+ this.element );
+
+ if ( !helper.parents( "body" ).length ) {
+ helper.appendTo( ( o.appendTo === "parent" ?
+ this.element[ 0 ].parentNode :
+ o.appendTo ) );
+ }
+
+ // Http://bugs.jqueryui.com/ticket/9446
+ // a helper function can return the original element
+ // which wouldn't have been set to relative in _create
+ if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
+ this._setPositionRelative();
+ }
+
+ if ( helper[ 0 ] !== this.element[ 0 ] &&
+ !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
+ helper.css( "position", "absolute" );
+ }
+
+ return helper;
+
+ },
+
+ _setPositionRelative: function() {
+ if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
+ this.element[ 0 ].style.position = "relative";
+ }
+ },
+
+ _adjustOffsetFromHelper: function( obj ) {
+ if ( typeof obj === "string" ) {
+ obj = obj.split( " " );
+ }
+ if ( $.isArray( obj ) ) {
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
+ }
+ if ( "left" in obj ) {
+ this.offset.click.left = obj.left + this.margins.left;
+ }
+ if ( "right" in obj ) {
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ }
+ if ( "top" in obj ) {
+ this.offset.click.top = obj.top + this.margins.top;
+ }
+ if ( "bottom" in obj ) {
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ }
+ },
+
+ _isRootNode: function( element ) {
+ return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
+ },
+
+ _getParentOffset: function() {
+
+ //Get the offsetParent and cache its position
+ var po = this.offsetParent.offset(),
+ document = this.document[ 0 ];
+
+ // This is a special case where we need to modify a offset calculated on start, since the
+ // following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the
+ // next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
+ // the document, which means that the scroll is included in the initial calculation of the
+ // offset of the parent, and never recalculated upon drag
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
+ po = { top: 0, left: 0 };
+ }
+
+ return {
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+ if ( this.cssPosition !== "relative" ) {
+ return { top: 0, left: 0 };
+ }
+
+ var p = this.element.position(),
+ scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
+
+ return {
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
+ ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
+ ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
+ };
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
+ top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
+ right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
+ bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var isUserScrollable, c, ce,
+ o = this.options,
+ document = this.document[ 0 ];
+
+ this.relativeContainer = null;
+
+ if ( !o.containment ) {
+ this.containment = null;
+ return;
+ }
+
+ if ( o.containment === "window" ) {
+ this.containment = [
+ $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
+ $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
+ $( window ).scrollLeft() + $( window ).width() -
+ this.helperProportions.width - this.margins.left,
+ $( window ).scrollTop() +
+ ( $( window ).height() || document.body.parentNode.scrollHeight ) -
+ this.helperProportions.height - this.margins.top
+ ];
+ return;
+ }
+
+ if ( o.containment === "document" ) {
+ this.containment = [
+ 0,
+ 0,
+ $( document ).width() - this.helperProportions.width - this.margins.left,
+ ( $( document ).height() || document.body.parentNode.scrollHeight ) -
+ this.helperProportions.height - this.margins.top
+ ];
+ return;
+ }
+
+ if ( o.containment.constructor === Array ) {
+ this.containment = o.containment;
+ return;
+ }
+
+ if ( o.containment === "parent" ) {
+ o.containment = this.helper[ 0 ].parentNode;
+ }
+
+ c = $( o.containment );
+ ce = c[ 0 ];
+
+ if ( !ce ) {
+ return;
+ }
+
+ isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
+
+ this.containment = [
+ ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
+ ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
+ ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
+ ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
+ ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
+ ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
+ ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
+ this.helperProportions.width -
+ this.margins.left -
+ this.margins.right,
+ ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
+ ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
+ ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
+ this.helperProportions.height -
+ this.margins.top -
+ this.margins.bottom
+ ];
+ this.relativeContainer = c;
+ },
+
+ _convertPositionTo: function( d, pos ) {
+
+ if ( !pos ) {
+ pos = this.position;
+ }
+
+ var mod = d === "absolute" ? 1 : -1,
+ scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
+
+ return {
+ top: (
+
+ // The absolute mouse position
+ pos.top +
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.top * mod +
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.top * mod -
+ ( ( this.cssPosition === "fixed" ?
+ -this.offset.scroll.top :
+ ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
+ ),
+ left: (
+
+ // The absolute mouse position
+ pos.left +
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.left * mod +
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.left * mod -
+ ( ( this.cssPosition === "fixed" ?
+ -this.offset.scroll.left :
+ ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
+ )
+ };
+
+ },
+
+ _generatePosition: function( event, constrainPosition ) {
+
+ var containment, co, top, left,
+ o = this.options,
+ scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
+ pageX = event.pageX,
+ pageY = event.pageY;
+
+ // Cache the scroll
+ if ( !scrollIsRootNode || !this.offset.scroll ) {
+ this.offset.scroll = {
+ top: this.scrollParent.scrollTop(),
+ left: this.scrollParent.scrollLeft()
+ };
+ }
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ // If we are not dragging yet, we won't check for options
+ if ( constrainPosition ) {
+ if ( this.containment ) {
+ if ( this.relativeContainer ) {
+ co = this.relativeContainer.offset();
+ containment = [
+ this.containment[ 0 ] + co.left,
+ this.containment[ 1 ] + co.top,
+ this.containment[ 2 ] + co.left,
+ this.containment[ 3 ] + co.top
+ ];
+ } else {
+ containment = this.containment;
+ }
+
+ if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
+ pageX = containment[ 0 ] + this.offset.click.left;
+ }
+ if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
+ pageY = containment[ 1 ] + this.offset.click.top;
+ }
+ if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
+ pageX = containment[ 2 ] + this.offset.click.left;
+ }
+ if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
+ pageY = containment[ 3 ] + this.offset.click.top;
+ }
+ }
+
+ if ( o.grid ) {
+
+ //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
+ // argument errors in IE (see ticket #6950)
+ top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
+ this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
+ pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
+ top - this.offset.click.top > containment[ 3 ] ) ?
+ top :
+ ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
+ top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
+
+ left = o.grid[ 0 ] ? this.originalPageX +
+ Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
+ this.originalPageX;
+ pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
+ left - this.offset.click.left > containment[ 2 ] ) ?
+ left :
+ ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
+ left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
+ }
+
+ if ( o.axis === "y" ) {
+ pageX = this.originalPageX;
+ }
+
+ if ( o.axis === "x" ) {
+ pageY = this.originalPageY;
+ }
+ }
+
+ return {
+ top: (
+
+ // The absolute mouse position
+ pageY -
+
+ // Click offset (relative to the element)
+ this.offset.click.top -
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.top -
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.top +
+ ( this.cssPosition === "fixed" ?
+ -this.offset.scroll.top :
+ ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
+ ),
+ left: (
+
+ // The absolute mouse position
+ pageX -
+
+ // Click offset (relative to the element)
+ this.offset.click.left -
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.left -
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.left +
+ ( this.cssPosition === "fixed" ?
+ -this.offset.scroll.left :
+ ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
+ )
+ };
+
+ },
+
+ _clear: function() {
+ this._removeClass( this.helper, "ui-draggable-dragging" );
+ if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
+ this.helper.remove();
+ }
+ this.helper = null;
+ this.cancelHelperRemoval = false;
+ if ( this.destroyOnClear ) {
+ this.destroy();
+ }
+ },
+
+ // From now on bulk stuff - mainly helpers
+
+ _trigger: function( type, event, ui ) {
+ ui = ui || this._uiHash();
+ $.ui.plugin.call( this, type, [ event, ui, this ], true );
+
+ // Absolute position and offset (see #6884 ) have to be recalculated after plugins
+ if ( /^(drag|start|stop)/.test( type ) ) {
+ this.positionAbs = this._convertPositionTo( "absolute" );
+ ui.offset = this.positionAbs;
+ }
+ return $.Widget.prototype._trigger.call( this, type, event, ui );
+ },
+
+ plugins: {},
+
+ _uiHash: function() {
+ return {
+ helper: this.helper,
+ position: this.position,
+ originalPosition: this.originalPosition,
+ offset: this.positionAbs
+ };
+ }
+
+} );
+
+$.ui.plugin.add( "draggable", "connectToSortable", {
+ start: function( event, ui, draggable ) {
+ var uiSortable = $.extend( {}, ui, {
+ item: draggable.element
+ } );
+
+ draggable.sortables = [];
+ $( draggable.options.connectToSortable ).each( function() {
+ var sortable = $( this ).sortable( "instance" );
+
+ if ( sortable && !sortable.options.disabled ) {
+ draggable.sortables.push( sortable );
+
+ // RefreshPositions is called at drag start to refresh the containerCache
+ // which is used in drag. This ensures it's initialized and synchronized
+ // with any changes that might have happened on the page since initialization.
+ sortable.refreshPositions();
+ sortable._trigger( "activate", event, uiSortable );
+ }
+ } );
+ },
+ stop: function( event, ui, draggable ) {
+ var uiSortable = $.extend( {}, ui, {
+ item: draggable.element
+ } );
+
+ draggable.cancelHelperRemoval = false;
+
+ $.each( draggable.sortables, function() {
+ var sortable = this;
+
+ if ( sortable.isOver ) {
+ sortable.isOver = 0;
+
+ // Allow this sortable to handle removing the helper
+ draggable.cancelHelperRemoval = true;
+ sortable.cancelHelperRemoval = false;
+
+ // Use _storedCSS To restore properties in the sortable,
+ // as this also handles revert (#9675) since the draggable
+ // may have modified them in unexpected ways (#8809)
+ sortable._storedCSS = {
+ position: sortable.placeholder.css( "position" ),
+ top: sortable.placeholder.css( "top" ),
+ left: sortable.placeholder.css( "left" )
+ };
+
+ sortable._mouseStop( event );
+
+ // Once drag has ended, the sortable should return to using
+ // its original helper, not the shared helper from draggable
+ sortable.options.helper = sortable.options._helper;
+ } else {
+
+ // Prevent this Sortable from removing the helper.
+ // However, don't set the draggable to remove the helper
+ // either as another connected Sortable may yet handle the removal.
+ sortable.cancelHelperRemoval = true;
+
+ sortable._trigger( "deactivate", event, uiSortable );
+ }
+ } );
+ },
+ drag: function( event, ui, draggable ) {
+ $.each( draggable.sortables, function() {
+ var innermostIntersecting = false,
+ sortable = this;
+
+ // Copy over variables that sortable's _intersectsWith uses
+ sortable.positionAbs = draggable.positionAbs;
+ sortable.helperProportions = draggable.helperProportions;
+ sortable.offset.click = draggable.offset.click;
+
+ if ( sortable._intersectsWith( sortable.containerCache ) ) {
+ innermostIntersecting = true;
+
+ $.each( draggable.sortables, function() {
+
+ // Copy over variables that sortable's _intersectsWith uses
+ this.positionAbs = draggable.positionAbs;
+ this.helperProportions = draggable.helperProportions;
+ this.offset.click = draggable.offset.click;
+
+ if ( this !== sortable &&
+ this._intersectsWith( this.containerCache ) &&
+ $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
+ innermostIntersecting = false;
+ }
+
+ return innermostIntersecting;
+ } );
+ }
+
+ if ( innermostIntersecting ) {
+
+ // If it intersects, we use a little isOver variable and set it once,
+ // so that the move-in stuff gets fired only once.
+ if ( !sortable.isOver ) {
+ sortable.isOver = 1;
+
+ // Store draggable's parent in case we need to reappend to it later.
+ draggable._parent = ui.helper.parent();
+
+ sortable.currentItem = ui.helper
+ .appendTo( sortable.element )
+ .data( "ui-sortable-item", true );
+
+ // Store helper option to later restore it
+ sortable.options._helper = sortable.options.helper;
+
+ sortable.options.helper = function() {
+ return ui.helper[ 0 ];
+ };
+
+ // Fire the start events of the sortable with our passed browser event,
+ // and our own helper (so it doesn't create a new one)
+ event.target = sortable.currentItem[ 0 ];
+ sortable._mouseCapture( event, true );
+ sortable._mouseStart( event, true, true );
+
+ // Because the browser event is way off the new appended portlet,
+ // modify necessary variables to reflect the changes
+ sortable.offset.click.top = draggable.offset.click.top;
+ sortable.offset.click.left = draggable.offset.click.left;
+ sortable.offset.parent.left -= draggable.offset.parent.left -
+ sortable.offset.parent.left;
+ sortable.offset.parent.top -= draggable.offset.parent.top -
+ sortable.offset.parent.top;
+
+ draggable._trigger( "toSortable", event );
+
+ // Inform draggable that the helper is in a valid drop zone,
+ // used solely in the revert option to handle "valid/invalid".
+ draggable.dropped = sortable.element;
+
+ // Need to refreshPositions of all sortables in the case that
+ // adding to one sortable changes the location of the other sortables (#9675)
+ $.each( draggable.sortables, function() {
+ this.refreshPositions();
+ } );
+
+ // Hack so receive/update callbacks work (mostly)
+ draggable.currentItem = draggable.element;
+ sortable.fromOutside = draggable;
+ }
+
+ if ( sortable.currentItem ) {
+ sortable._mouseDrag( event );
+
+ // Copy the sortable's position because the draggable's can potentially reflect
+ // a relative position, while sortable is always absolute, which the dragged
+ // element has now become. (#8809)
+ ui.position = sortable.position;
+ }
+ } else {
+
+ // If it doesn't intersect with the sortable, and it intersected before,
+ // we fake the drag stop of the sortable, but make sure it doesn't remove
+ // the helper by using cancelHelperRemoval.
+ if ( sortable.isOver ) {
+
+ sortable.isOver = 0;
+ sortable.cancelHelperRemoval = true;
+
+ // Calling sortable's mouseStop would trigger a revert,
+ // so revert must be temporarily false until after mouseStop is called.
+ sortable.options._revert = sortable.options.revert;
+ sortable.options.revert = false;
+
+ sortable._trigger( "out", event, sortable._uiHash( sortable ) );
+ sortable._mouseStop( event, true );
+
+ // Restore sortable behaviors that were modfied
+ // when the draggable entered the sortable area (#9481)
+ sortable.options.revert = sortable.options._revert;
+ sortable.options.helper = sortable.options._helper;
+
+ if ( sortable.placeholder ) {
+ sortable.placeholder.remove();
+ }
+
+ // Restore and recalculate the draggable's offset considering the sortable
+ // may have modified them in unexpected ways. (#8809, #10669)
+ ui.helper.appendTo( draggable._parent );
+ draggable._refreshOffsets( event );
+ ui.position = draggable._generatePosition( event, true );
+
+ draggable._trigger( "fromSortable", event );
+
+ // Inform draggable that the helper is no longer in a valid drop zone
+ draggable.dropped = false;
+
+ // Need to refreshPositions of all sortables just in case removing
+ // from one sortable changes the location of other sortables (#9675)
+ $.each( draggable.sortables, function() {
+ this.refreshPositions();
+ } );
+ }
+ }
+ } );
+ }
+} );
+
+$.ui.plugin.add( "draggable", "cursor", {
+ start: function( event, ui, instance ) {
+ var t = $( "body" ),
+ o = instance.options;
+
+ if ( t.css( "cursor" ) ) {
+ o._cursor = t.css( "cursor" );
+ }
+ t.css( "cursor", o.cursor );
+ },
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
+ if ( o._cursor ) {
+ $( "body" ).css( "cursor", o._cursor );
+ }
+ }
+} );
+
+$.ui.plugin.add( "draggable", "opacity", {
+ start: function( event, ui, instance ) {
+ var t = $( ui.helper ),
+ o = instance.options;
+ if ( t.css( "opacity" ) ) {
+ o._opacity = t.css( "opacity" );
+ }
+ t.css( "opacity", o.opacity );
+ },
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
+ if ( o._opacity ) {
+ $( ui.helper ).css( "opacity", o._opacity );
+ }
+ }
+} );
+
+$.ui.plugin.add( "draggable", "scroll", {
+ start: function( event, ui, i ) {
+ if ( !i.scrollParentNotHidden ) {
+ i.scrollParentNotHidden = i.helper.scrollParent( false );
+ }
+
+ if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
+ i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
+ i.overflowOffset = i.scrollParentNotHidden.offset();
+ }
+ },
+ drag: function( event, ui, i ) {
+
+ var o = i.options,
+ scrolled = false,
+ scrollParent = i.scrollParentNotHidden[ 0 ],
+ document = i.document[ 0 ];
+
+ if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
+ if ( !o.axis || o.axis !== "x" ) {
+ if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
+ o.scrollSensitivity ) {
+ scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
+ } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
+ scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
+ }
+ }
+
+ if ( !o.axis || o.axis !== "y" ) {
+ if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
+ o.scrollSensitivity ) {
+ scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
+ } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
+ scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
+ }
+ }
+
+ } else {
+
+ if ( !o.axis || o.axis !== "x" ) {
+ if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
+ } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
+ o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
+ }
+ }
+
+ if ( !o.axis || o.axis !== "y" ) {
+ if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft(
+ $( document ).scrollLeft() - o.scrollSpeed
+ );
+ } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
+ o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft(
+ $( document ).scrollLeft() + o.scrollSpeed
+ );
+ }
+ }
+
+ }
+
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( i, event );
+ }
+
+ }
+} );
+
+$.ui.plugin.add( "draggable", "snap", {
+ start: function( event, ui, i ) {
+
+ var o = i.options;
+
+ i.snapElements = [];
+
+ $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
+ .each( function() {
+ var $t = $( this ),
+ $o = $t.offset();
+ if ( this !== i.element[ 0 ] ) {
+ i.snapElements.push( {
+ item: this,
+ width: $t.outerWidth(), height: $t.outerHeight(),
+ top: $o.top, left: $o.left
+ } );
+ }
+ } );
+
+ },
+ drag: function( event, ui, inst ) {
+
+ var ts, bs, ls, rs, l, r, t, b, i, first,
+ o = inst.options,
+ d = o.snapTolerance,
+ x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
+
+ for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
+
+ l = inst.snapElements[ i ].left - inst.margins.left;
+ r = l + inst.snapElements[ i ].width;
+ t = inst.snapElements[ i ].top - inst.margins.top;
+ b = t + inst.snapElements[ i ].height;
+
+ if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
+ !$.contains( inst.snapElements[ i ].item.ownerDocument,
+ inst.snapElements[ i ].item ) ) {
+ if ( inst.snapElements[ i ].snapping ) {
+ ( inst.options.snap.release &&
+ inst.options.snap.release.call(
+ inst.element,
+ event,
+ $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
+ ) );
+ }
+ inst.snapElements[ i ].snapping = false;
+ continue;
+ }
+
+ if ( o.snapMode !== "inner" ) {
+ ts = Math.abs( t - y2 ) <= d;
+ bs = Math.abs( b - y1 ) <= d;
+ ls = Math.abs( l - x2 ) <= d;
+ rs = Math.abs( r - x1 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", {
+ top: t - inst.helperProportions.height,
+ left: 0
+ } ).top;
+ }
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", {
+ top: b,
+ left: 0
+ } ).top;
+ }
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", {
+ top: 0,
+ left: l - inst.helperProportions.width
+ } ).left;
+ }
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", {
+ top: 0,
+ left: r
+ } ).left;
+ }
+ }
+
+ first = ( ts || bs || ls || rs );
+
+ if ( o.snapMode !== "outer" ) {
+ ts = Math.abs( t - y1 ) <= d;
+ bs = Math.abs( b - y2 ) <= d;
+ ls = Math.abs( l - x1 ) <= d;
+ rs = Math.abs( r - x2 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", {
+ top: t,
+ left: 0
+ } ).top;
+ }
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", {
+ top: b - inst.helperProportions.height,
+ left: 0
+ } ).top;
+ }
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", {
+ top: 0,
+ left: l
+ } ).left;
+ }
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", {
+ top: 0,
+ left: r - inst.helperProportions.width
+ } ).left;
+ }
+ }
+
+ if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
+ ( inst.options.snap.snap &&
+ inst.options.snap.snap.call(
+ inst.element,
+ event,
+ $.extend( inst._uiHash(), {
+ snapItem: inst.snapElements[ i ].item
+ } ) ) );
+ }
+ inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
+
+ }
+
+ }
+} );
+
+$.ui.plugin.add( "draggable", "stack", {
+ start: function( event, ui, instance ) {
+ var min,
+ o = instance.options,
+ group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
+ return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
+ ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
+ } );
+
+ if ( !group.length ) { return; }
+
+ min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
+ $( group ).each( function( i ) {
+ $( this ).css( "zIndex", min + i );
+ } );
+ this.css( "zIndex", ( min + group.length ) );
+ }
+} );
+
+$.ui.plugin.add( "draggable", "zIndex", {
+ start: function( event, ui, instance ) {
+ var t = $( ui.helper ),
+ o = instance.options;
+
+ if ( t.css( "zIndex" ) ) {
+ o._zIndex = t.css( "zIndex" );
+ }
+ t.css( "zIndex", o.zIndex );
+ },
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
+
+ if ( o._zIndex ) {
+ $( ui.helper ).css( "zIndex", o._zIndex );
+ }
+ }
+} );
+
+var widgetsDraggable = $.ui.draggable;
+
+
+/*!
+ * jQuery UI Resizable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Resizable
+//>>group: Interactions
+//>>description: Enables resize functionality for any element.
+//>>docs: http://api.jqueryui.com/resizable/
+//>>demos: http://jqueryui.com/resizable/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/resizable.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.resizable", $.ui.mouse, {
+ version: "1.12.1",
+ widgetEventPrefix: "resize",
+ options: {
+ alsoResize: false,
+ animate: false,
+ animateDuration: "slow",
+ animateEasing: "swing",
+ aspectRatio: false,
+ autoHide: false,
+ classes: {
+ "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
+ },
+ containment: false,
+ ghost: false,
+ grid: false,
+ handles: "e,s,se",
+ helper: false,
+ maxHeight: null,
+ maxWidth: null,
+ minHeight: 10,
+ minWidth: 10,
+
+ // See #7960
+ zIndex: 90,
+
+ // Callbacks
+ resize: null,
+ start: null,
+ stop: null
+ },
+
+ _num: function( value ) {
+ return parseFloat( value ) || 0;
+ },
+
+ _isNumber: function( value ) {
+ return !isNaN( parseFloat( value ) );
+ },
+
+ _hasScroll: function( el, a ) {
+
+ if ( $( el ).css( "overflow" ) === "hidden" ) {
+ return false;
+ }
+
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
+ has = false;
+
+ if ( el[ scroll ] > 0 ) {
+ return true;
+ }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[ scroll ] = 1;
+ has = ( el[ scroll ] > 0 );
+ el[ scroll ] = 0;
+ return has;
+ },
+
+ _create: function() {
+
+ var margins,
+ o = this.options,
+ that = this;
+ this._addClass( "ui-resizable" );
+
+ $.extend( this, {
+ _aspectRatio: !!( o.aspectRatio ),
+ aspectRatio: o.aspectRatio,
+ originalElement: this.element,
+ _proportionallyResizeElements: [],
+ _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
+ } );
+
+ // Wrap the element if it cannot hold child nodes
+ if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
+
+ this.element.wrap(
+ $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
+ position: this.element.css( "position" ),
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight(),
+ top: this.element.css( "top" ),
+ left: this.element.css( "left" )
+ } )
+ );
+
+ this.element = this.element.parent().data(
+ "ui-resizable", this.element.resizable( "instance" )
+ );
+
+ this.elementIsWrapper = true;
+
+ margins = {
+ marginTop: this.originalElement.css( "marginTop" ),
+ marginRight: this.originalElement.css( "marginRight" ),
+ marginBottom: this.originalElement.css( "marginBottom" ),
+ marginLeft: this.originalElement.css( "marginLeft" )
+ };
+
+ this.element.css( margins );
+ this.originalElement.css( "margin", 0 );
+
+ // support: Safari
+ // Prevent Safari textarea resize
+ this.originalResizeStyle = this.originalElement.css( "resize" );
+ this.originalElement.css( "resize", "none" );
+
+ this._proportionallyResizeElements.push( this.originalElement.css( {
+ position: "static",
+ zoom: 1,
+ display: "block"
+ } ) );
+
+ // Support: IE9
+ // avoid IE jump (hard set the margin)
+ this.originalElement.css( margins );
+
+ this._proportionallyResize();
+ }
+
+ this._setupHandles();
+
+ if ( o.autoHide ) {
+ $( this.element )
+ .on( "mouseenter", function() {
+ if ( o.disabled ) {
+ return;
+ }
+ that._removeClass( "ui-resizable-autohide" );
+ that._handles.show();
+ } )
+ .on( "mouseleave", function() {
+ if ( o.disabled ) {
+ return;
+ }
+ if ( !that.resizing ) {
+ that._addClass( "ui-resizable-autohide" );
+ that._handles.hide();
+ }
+ } );
+ }
+
+ this._mouseInit();
+ },
+
+ _destroy: function() {
+
+ this._mouseDestroy();
+
+ var wrapper,
+ _destroy = function( exp ) {
+ $( exp )
+ .removeData( "resizable" )
+ .removeData( "ui-resizable" )
+ .off( ".resizable" )
+ .find( ".ui-resizable-handle" )
+ .remove();
+ };
+
+ // TODO: Unwrap at same DOM position
+ if ( this.elementIsWrapper ) {
+ _destroy( this.element );
+ wrapper = this.element;
+ this.originalElement.css( {
+ position: wrapper.css( "position" ),
+ width: wrapper.outerWidth(),
+ height: wrapper.outerHeight(),
+ top: wrapper.css( "top" ),
+ left: wrapper.css( "left" )
+ } ).insertAfter( wrapper );
+ wrapper.remove();
+ }
+
+ this.originalElement.css( "resize", this.originalResizeStyle );
+ _destroy( this.originalElement );
+
+ return this;
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+
+ switch ( key ) {
+ case "handles":
+ this._removeHandles();
+ this._setupHandles();
+ break;
+ default:
+ break;
+ }
+ },
+
+ _setupHandles: function() {
+ var o = this.options, handle, i, n, hname, axis, that = this;
+ this.handles = o.handles ||
+ ( !$( ".ui-resizable-handle", this.element ).length ?
+ "e,s,se" : {
+ n: ".ui-resizable-n",
+ e: ".ui-resizable-e",
+ s: ".ui-resizable-s",
+ w: ".ui-resizable-w",
+ se: ".ui-resizable-se",
+ sw: ".ui-resizable-sw",
+ ne: ".ui-resizable-ne",
+ nw: ".ui-resizable-nw"
+ } );
+
+ this._handles = $();
+ if ( this.handles.constructor === String ) {
+
+ if ( this.handles === "all" ) {
+ this.handles = "n,e,s,w,se,sw,ne,nw";
+ }
+
+ n = this.handles.split( "," );
+ this.handles = {};
+
+ for ( i = 0; i < n.length; i++ ) {
+
+ handle = $.trim( n[ i ] );
+ hname = "ui-resizable-" + handle;
+ axis = $( "<div>" );
+ this._addClass( axis, "ui-resizable-handle " + hname );
+
+ axis.css( { zIndex: o.zIndex } );
+
+ this.handles[ handle ] = ".ui-resizable-" + handle;
+ this.element.append( axis );
+ }
+
+ }
+
+ this._renderAxis = function( target ) {
+
+ var i, axis, padPos, padWrapper;
+
+ target = target || this.element;
+
+ for ( i in this.handles ) {
+
+ if ( this.handles[ i ].constructor === String ) {
+ this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
+ } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
+ this.handles[ i ] = $( this.handles[ i ] );
+ this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
+ }
+
+ if ( this.elementIsWrapper &&
+ this.originalElement[ 0 ]
+ .nodeName
+ .match( /^(textarea|input|select|button)$/i ) ) {
+ axis = $( this.handles[ i ], this.element );
+
+ padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
+ axis.outerHeight() :
+ axis.outerWidth();
+
+ padPos = [ "padding",
+ /ne|nw|n/.test( i ) ? "Top" :
+ /se|sw|s/.test( i ) ? "Bottom" :
+ /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
+
+ target.css( padPos, padWrapper );
+
+ this._proportionallyResize();
+ }
+
+ this._handles = this._handles.add( this.handles[ i ] );
+ }
+ };
+
+ // TODO: make renderAxis a prototype function
+ this._renderAxis( this.element );
+
+ this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
+ this._handles.disableSelection();
+
+ this._handles.on( "mouseover", function() {
+ if ( !that.resizing ) {
+ if ( this.className ) {
+ axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
+ }
+ that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
+ }
+ } );
+
+ if ( o.autoHide ) {
+ this._handles.hide();
+ this._addClass( "ui-resizable-autohide" );
+ }
+ },
+
+ _removeHandles: function() {
+ this._handles.remove();
+ },
+
+ _mouseCapture: function( event ) {
+ var i, handle,
+ capture = false;
+
+ for ( i in this.handles ) {
+ handle = $( this.handles[ i ] )[ 0 ];
+ if ( handle === event.target || $.contains( handle, event.target ) ) {
+ capture = true;
+ }
+ }
+
+ return !this.options.disabled && capture;
+ },
+
+ _mouseStart: function( event ) {
+
+ var curleft, curtop, cursor,
+ o = this.options,
+ el = this.element;
+
+ this.resizing = true;
+
+ this._renderProxy();
+
+ curleft = this._num( this.helper.css( "left" ) );
+ curtop = this._num( this.helper.css( "top" ) );
+
+ if ( o.containment ) {
+ curleft += $( o.containment ).scrollLeft() || 0;
+ curtop += $( o.containment ).scrollTop() || 0;
+ }
+
+ this.offset = this.helper.offset();
+ this.position = { left: curleft, top: curtop };
+
+ this.size = this._helper ? {
+ width: this.helper.width(),
+ height: this.helper.height()
+ } : {
+ width: el.width(),
+ height: el.height()
+ };
+
+ this.originalSize = this._helper ? {
+ width: el.outerWidth(),
+ height: el.outerHeight()
+ } : {
+ width: el.width(),
+ height: el.height()
+ };
+
+ this.sizeDiff = {
+ width: el.outerWidth() - el.width(),
+ height: el.outerHeight() - el.height()
+ };
+
+ this.originalPosition = { left: curleft, top: curtop };
+ this.originalMousePosition = { left: event.pageX, top: event.pageY };
+
+ this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
+ o.aspectRatio :
+ ( ( this.originalSize.width / this.originalSize.height ) || 1 );
+
+ cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
+ $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
+
+ this._addClass( "ui-resizable-resizing" );
+ this._propagate( "start", event );
+ return true;
+ },
+
+ _mouseDrag: function( event ) {
+
+ var data, props,
+ smp = this.originalMousePosition,
+ a = this.axis,
+ dx = ( event.pageX - smp.left ) || 0,
+ dy = ( event.pageY - smp.top ) || 0,
+ trigger = this._change[ a ];
+
+ this._updatePrevProperties();
+
+ if ( !trigger ) {
+ return false;
+ }
+
+ data = trigger.apply( this, [ event, dx, dy ] );
+
+ this._updateVirtualBoundaries( event.shiftKey );
+ if ( this._aspectRatio || event.shiftKey ) {
+ data = this._updateRatio( data, event );
+ }
+
+ data = this._respectSize( data, event );
+
+ this._updateCache( data );
+
+ this._propagate( "resize", event );
+
+ props = this._applyChanges();
+
+ if ( !this._helper && this._proportionallyResizeElements.length ) {
+ this._proportionallyResize();
+ }
+
+ if ( !$.isEmptyObject( props ) ) {
+ this._updatePrevProperties();
+ this._trigger( "resize", event, this.ui() );
+ this._applyChanges();
+ }
+
+ return false;
+ },
+
+ _mouseStop: function( event ) {
+
+ this.resizing = false;
+ var pr, ista, soffseth, soffsetw, s, left, top,
+ o = this.options, that = this;
+
+ if ( this._helper ) {
+
+ pr = this._proportionallyResizeElements;
+ ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
+ soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
+ soffsetw = ista ? 0 : that.sizeDiff.width;
+
+ s = {
+ width: ( that.helper.width() - soffsetw ),
+ height: ( that.helper.height() - soffseth )
+ };
+ left = ( parseFloat( that.element.css( "left" ) ) +
+ ( that.position.left - that.originalPosition.left ) ) || null;
+ top = ( parseFloat( that.element.css( "top" ) ) +
+ ( that.position.top - that.originalPosition.top ) ) || null;
+
+ if ( !o.animate ) {
+ this.element.css( $.extend( s, { top: top, left: left } ) );
+ }
+
+ that.helper.height( that.size.height );
+ that.helper.width( that.size.width );
+
+ if ( this._helper && !o.animate ) {
+ this._proportionallyResize();
+ }
+ }
+
+ $( "body" ).css( "cursor", "auto" );
+
+ this._removeClass( "ui-resizable-resizing" );
+
+ this._propagate( "stop", event );
+
+ if ( this._helper ) {
+ this.helper.remove();
+ }
+
+ return false;
+
+ },
+
+ _updatePrevProperties: function() {
+ this.prevPosition = {
+ top: this.position.top,
+ left: this.position.left
+ };
+ this.prevSize = {
+ width: this.size.width,
+ height: this.size.height
+ };
+ },
+
+ _applyChanges: function() {
+ var props = {};
+
+ if ( this.position.top !== this.prevPosition.top ) {
+ props.top = this.position.top + "px";
+ }
+ if ( this.position.left !== this.prevPosition.left ) {
+ props.left = this.position.left + "px";
+ }
+ if ( this.size.width !== this.prevSize.width ) {
+ props.width = this.size.width + "px";
+ }
+ if ( this.size.height !== this.prevSize.height ) {
+ props.height = this.size.height + "px";
+ }
+
+ this.helper.css( props );
+
+ return props;
+ },
+
+ _updateVirtualBoundaries: function( forceAspectRatio ) {
+ var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
+ o = this.options;
+
+ b = {
+ minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
+ maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
+ minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
+ maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
+ };
+
+ if ( this._aspectRatio || forceAspectRatio ) {
+ pMinWidth = b.minHeight * this.aspectRatio;
+ pMinHeight = b.minWidth / this.aspectRatio;
+ pMaxWidth = b.maxHeight * this.aspectRatio;
+ pMaxHeight = b.maxWidth / this.aspectRatio;
+
+ if ( pMinWidth > b.minWidth ) {
+ b.minWidth = pMinWidth;
+ }
+ if ( pMinHeight > b.minHeight ) {
+ b.minHeight = pMinHeight;
+ }
+ if ( pMaxWidth < b.maxWidth ) {
+ b.maxWidth = pMaxWidth;
+ }
+ if ( pMaxHeight < b.maxHeight ) {
+ b.maxHeight = pMaxHeight;
+ }
+ }
+ this._vBoundaries = b;
+ },
+
+ _updateCache: function( data ) {
+ this.offset = this.helper.offset();
+ if ( this._isNumber( data.left ) ) {
+ this.position.left = data.left;
+ }
+ if ( this._isNumber( data.top ) ) {
+ this.position.top = data.top;
+ }
+ if ( this._isNumber( data.height ) ) {
+ this.size.height = data.height;
+ }
+ if ( this._isNumber( data.width ) ) {
+ this.size.width = data.width;
+ }
+ },
+
+ _updateRatio: function( data ) {
+
+ var cpos = this.position,
+ csize = this.size,
+ a = this.axis;
+
+ if ( this._isNumber( data.height ) ) {
+ data.width = ( data.height * this.aspectRatio );
+ } else if ( this._isNumber( data.width ) ) {
+ data.height = ( data.width / this.aspectRatio );
+ }
+
+ if ( a === "sw" ) {
+ data.left = cpos.left + ( csize.width - data.width );
+ data.top = null;
+ }
+ if ( a === "nw" ) {
+ data.top = cpos.top + ( csize.height - data.height );
+ data.left = cpos.left + ( csize.width - data.width );
+ }
+
+ return data;
+ },
+
+ _respectSize: function( data ) {
+
+ var o = this._vBoundaries,
+ a = this.axis,
+ ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
+ ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
+ isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
+ isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
+ dw = this.originalPosition.left + this.originalSize.width,
+ dh = this.originalPosition.top + this.originalSize.height,
+ cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
+ if ( isminw ) {
+ data.width = o.minWidth;
+ }
+ if ( isminh ) {
+ data.height = o.minHeight;
+ }
+ if ( ismaxw ) {
+ data.width = o.maxWidth;
+ }
+ if ( ismaxh ) {
+ data.height = o.maxHeight;
+ }
+
+ if ( isminw && cw ) {
+ data.left = dw - o.minWidth;
+ }
+ if ( ismaxw && cw ) {
+ data.left = dw - o.maxWidth;
+ }
+ if ( isminh && ch ) {
+ data.top = dh - o.minHeight;
+ }
+ if ( ismaxh && ch ) {
+ data.top = dh - o.maxHeight;
+ }
+
+ // Fixing jump error on top/left - bug #2330
+ if ( !data.width && !data.height && !data.left && data.top ) {
+ data.top = null;
+ } else if ( !data.width && !data.height && !data.top && data.left ) {
+ data.left = null;
+ }
+
+ return data;
+ },
+
+ _getPaddingPlusBorderDimensions: function( element ) {
+ var i = 0,
+ widths = [],
+ borders = [
+ element.css( "borderTopWidth" ),
+ element.css( "borderRightWidth" ),
+ element.css( "borderBottomWidth" ),
+ element.css( "borderLeftWidth" )
+ ],
+ paddings = [
+ element.css( "paddingTop" ),
+ element.css( "paddingRight" ),
+ element.css( "paddingBottom" ),
+ element.css( "paddingLeft" )
+ ];
+
+ for ( ; i < 4; i++ ) {
+ widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
+ widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
+ }
+
+ return {
+ height: widths[ 0 ] + widths[ 2 ],
+ width: widths[ 1 ] + widths[ 3 ]
+ };
+ },
+
+ _proportionallyResize: function() {
+
+ if ( !this._proportionallyResizeElements.length ) {
+ return;
+ }
+
+ var prel,
+ i = 0,
+ element = this.helper || this.element;
+
+ for ( ; i < this._proportionallyResizeElements.length; i++ ) {
+
+ prel = this._proportionallyResizeElements[ i ];
+
+ // TODO: Seems like a bug to cache this.outerDimensions
+ // considering that we are in a loop.
+ if ( !this.outerDimensions ) {
+ this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
+ }
+
+ prel.css( {
+ height: ( element.height() - this.outerDimensions.height ) || 0,
+ width: ( element.width() - this.outerDimensions.width ) || 0
+ } );
+
+ }
+
+ },
+
+ _renderProxy: function() {
+
+ var el = this.element, o = this.options;
+ this.elementOffset = el.offset();
+
+ if ( this._helper ) {
+
+ this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
+
+ this._addClass( this.helper, this._helper );
+ this.helper.css( {
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight(),
+ position: "absolute",
+ left: this.elementOffset.left + "px",
+ top: this.elementOffset.top + "px",
+ zIndex: ++o.zIndex //TODO: Don't modify option
+ } );
+
+ this.helper
+ .appendTo( "body" )
+ .disableSelection();
+
+ } else {
+ this.helper = this.element;
+ }
+
+ },
+
+ _change: {
+ e: function( event, dx ) {
+ return { width: this.originalSize.width + dx };
+ },
+ w: function( event, dx ) {
+ var cs = this.originalSize, sp = this.originalPosition;
+ return { left: sp.left + dx, width: cs.width - dx };
+ },
+ n: function( event, dx, dy ) {
+ var cs = this.originalSize, sp = this.originalPosition;
+ return { top: sp.top + dy, height: cs.height - dy };
+ },
+ s: function( event, dx, dy ) {
+ return { height: this.originalSize.height + dy };
+ },
+ se: function( event, dx, dy ) {
+ return $.extend( this._change.s.apply( this, arguments ),
+ this._change.e.apply( this, [ event, dx, dy ] ) );
+ },
+ sw: function( event, dx, dy ) {
+ return $.extend( this._change.s.apply( this, arguments ),
+ this._change.w.apply( this, [ event, dx, dy ] ) );
+ },
+ ne: function( event, dx, dy ) {
+ return $.extend( this._change.n.apply( this, arguments ),
+ this._change.e.apply( this, [ event, dx, dy ] ) );
+ },
+ nw: function( event, dx, dy ) {
+ return $.extend( this._change.n.apply( this, arguments ),
+ this._change.w.apply( this, [ event, dx, dy ] ) );
+ }
+ },
+
+ _propagate: function( n, event ) {
+ $.ui.plugin.call( this, n, [ event, this.ui() ] );
+ ( n !== "resize" && this._trigger( n, event, this.ui() ) );
+ },
+
+ plugins: {},
+
+ ui: function() {
+ return {
+ originalElement: this.originalElement,
+ element: this.element,
+ helper: this.helper,
+ position: this.position,
+ size: this.size,
+ originalSize: this.originalSize,
+ originalPosition: this.originalPosition
+ };
+ }
+
+} );
+
+/*
+ * Resizable Extensions
+ */
+
+$.ui.plugin.add( "resizable", "animate", {
+
+ stop: function( event ) {
+ var that = $( this ).resizable( "instance" ),
+ o = that.options,
+ pr = that._proportionallyResizeElements,
+ ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
+ soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width,
+ style = {
+ width: ( that.size.width - soffsetw ),
+ height: ( that.size.height - soffseth )
+ },
+ left = ( parseFloat( that.element.css( "left" ) ) +
+ ( that.position.left - that.originalPosition.left ) ) || null,
+ top = ( parseFloat( that.element.css( "top" ) ) +
+ ( that.position.top - that.originalPosition.top ) ) || null;
+
+ that.element.animate(
+ $.extend( style, top && left ? { top: top, left: left } : {} ), {
+ duration: o.animateDuration,
+ easing: o.animateEasing,
+ step: function() {
+
+ var data = {
+ width: parseFloat( that.element.css( "width" ) ),
+ height: parseFloat( that.element.css( "height" ) ),
+ top: parseFloat( that.element.css( "top" ) ),
+ left: parseFloat( that.element.css( "left" ) )
+ };
+
+ if ( pr && pr.length ) {
+ $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
+ }
+
+ // Propagating resize, and updating values for each animation step
+ that._updateCache( data );
+ that._propagate( "resize", event );
+
+ }
+ }
+ );
+ }
+
+} );
+
+$.ui.plugin.add( "resizable", "containment", {
+
+ start: function() {
+ var element, p, co, ch, cw, width, height,
+ that = $( this ).resizable( "instance" ),
+ o = that.options,
+ el = that.element,
+ oc = o.containment,
+ ce = ( oc instanceof $ ) ?
+ oc.get( 0 ) :
+ ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
+
+ if ( !ce ) {
+ return;
+ }
+
+ that.containerElement = $( ce );
+
+ if ( /document/.test( oc ) || oc === document ) {
+ that.containerOffset = {
+ left: 0,
+ top: 0
+ };
+ that.containerPosition = {
+ left: 0,
+ top: 0
+ };
+
+ that.parentData = {
+ element: $( document ),
+ left: 0,
+ top: 0,
+ width: $( document ).width(),
+ height: $( document ).height() || document.body.parentNode.scrollHeight
+ };
+ } else {
+ element = $( ce );
+ p = [];
+ $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
+ p[ i ] = that._num( element.css( "padding" + name ) );
+ } );
+
+ that.containerOffset = element.offset();
+ that.containerPosition = element.position();
+ that.containerSize = {
+ height: ( element.innerHeight() - p[ 3 ] ),
+ width: ( element.innerWidth() - p[ 1 ] )
+ };
+
+ co = that.containerOffset;
+ ch = that.containerSize.height;
+ cw = that.containerSize.width;
+ width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
+ height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
+
+ that.parentData = {
+ element: ce,
+ left: co.left,
+ top: co.top,
+ width: width,
+ height: height
+ };
+ }
+ },
+
+ resize: function( event ) {
+ var woset, hoset, isParent, isOffsetRelative,
+ that = $( this ).resizable( "instance" ),
+ o = that.options,
+ co = that.containerOffset,
+ cp = that.position,
+ pRatio = that._aspectRatio || event.shiftKey,
+ cop = {
+ top: 0,
+ left: 0
+ },
+ ce = that.containerElement,
+ continueResize = true;
+
+ if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
+ cop = co;
+ }
+
+ if ( cp.left < ( that._helper ? co.left : 0 ) ) {
+ that.size.width = that.size.width +
+ ( that._helper ?
+ ( that.position.left - co.left ) :
+ ( that.position.left - cop.left ) );
+
+ if ( pRatio ) {
+ that.size.height = that.size.width / that.aspectRatio;
+ continueResize = false;
+ }
+ that.position.left = o.helper ? co.left : 0;
+ }
+
+ if ( cp.top < ( that._helper ? co.top : 0 ) ) {
+ that.size.height = that.size.height +
+ ( that._helper ?
+ ( that.position.top - co.top ) :
+ that.position.top );
+
+ if ( pRatio ) {
+ that.size.width = that.size.height * that.aspectRatio;
+ continueResize = false;
+ }
+ that.position.top = that._helper ? co.top : 0;
+ }
+
+ isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
+ isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
+
+ if ( isParent && isOffsetRelative ) {
+ that.offset.left = that.parentData.left + that.position.left;
+ that.offset.top = that.parentData.top + that.position.top;
+ } else {
+ that.offset.left = that.element.offset().left;
+ that.offset.top = that.element.offset().top;
+ }
+
+ woset = Math.abs( that.sizeDiff.width +
+ ( that._helper ?
+ that.offset.left - cop.left :
+ ( that.offset.left - co.left ) ) );
+
+ hoset = Math.abs( that.sizeDiff.height +
+ ( that._helper ?
+ that.offset.top - cop.top :
+ ( that.offset.top - co.top ) ) );
+
+ if ( woset + that.size.width >= that.parentData.width ) {
+ that.size.width = that.parentData.width - woset;
+ if ( pRatio ) {
+ that.size.height = that.size.width / that.aspectRatio;
+ continueResize = false;
+ }
+ }
+
+ if ( hoset + that.size.height >= that.parentData.height ) {
+ that.size.height = that.parentData.height - hoset;
+ if ( pRatio ) {
+ that.size.width = that.size.height * that.aspectRatio;
+ continueResize = false;
+ }
+ }
+
+ if ( !continueResize ) {
+ that.position.left = that.prevPosition.left;
+ that.position.top = that.prevPosition.top;
+ that.size.width = that.prevSize.width;
+ that.size.height = that.prevSize.height;
+ }
+ },
+
+ stop: function() {
+ var that = $( this ).resizable( "instance" ),
+ o = that.options,
+ co = that.containerOffset,
+ cop = that.containerPosition,
+ ce = that.containerElement,
+ helper = $( that.helper ),
+ ho = helper.offset(),
+ w = helper.outerWidth() - that.sizeDiff.width,
+ h = helper.outerHeight() - that.sizeDiff.height;
+
+ if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
+ $( this ).css( {
+ left: ho.left - cop.left - co.left,
+ width: w,
+ height: h
+ } );
+ }
+
+ if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
+ $( this ).css( {
+ left: ho.left - cop.left - co.left,
+ width: w,
+ height: h
+ } );
+ }
+ }
+} );
+
+$.ui.plugin.add( "resizable", "alsoResize", {
+
+ start: function() {
+ var that = $( this ).resizable( "instance" ),
+ o = that.options;
+
+ $( o.alsoResize ).each( function() {
+ var el = $( this );
+ el.data( "ui-resizable-alsoresize", {
+ width: parseFloat( el.width() ), height: parseFloat( el.height() ),
+ left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
+ } );
+ } );
+ },
+
+ resize: function( event, ui ) {
+ var that = $( this ).resizable( "instance" ),
+ o = that.options,
+ os = that.originalSize,
+ op = that.originalPosition,
+ delta = {
+ height: ( that.size.height - os.height ) || 0,
+ width: ( that.size.width - os.width ) || 0,
+ top: ( that.position.top - op.top ) || 0,
+ left: ( that.position.left - op.left ) || 0
+ };
+
+ $( o.alsoResize ).each( function() {
+ var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
+ css = el.parents( ui.originalElement[ 0 ] ).length ?
+ [ "width", "height" ] :
+ [ "width", "height", "top", "left" ];
+
+ $.each( css, function( i, prop ) {
+ var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
+ if ( sum && sum >= 0 ) {
+ style[ prop ] = sum || null;
+ }
+ } );
+
+ el.css( style );
+ } );
+ },
+
+ stop: function() {
+ $( this ).removeData( "ui-resizable-alsoresize" );
+ }
+} );
+
+$.ui.plugin.add( "resizable", "ghost", {
+
+ start: function() {
+
+ var that = $( this ).resizable( "instance" ), cs = that.size;
+
+ that.ghost = that.originalElement.clone();
+ that.ghost.css( {
+ opacity: 0.25,
+ display: "block",
+ position: "relative",
+ height: cs.height,
+ width: cs.width,
+ margin: 0,
+ left: 0,
+ top: 0
+ } );
+
+ that._addClass( that.ghost, "ui-resizable-ghost" );
+
+ // DEPRECATED
+ // TODO: remove after 1.12
+ if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
+
+ // Ghost option
+ that.ghost.addClass( this.options.ghost );
+ }
+
+ that.ghost.appendTo( that.helper );
+
+ },
+
+ resize: function() {
+ var that = $( this ).resizable( "instance" );
+ if ( that.ghost ) {
+ that.ghost.css( {
+ position: "relative",
+ height: that.size.height,
+ width: that.size.width
+ } );
+ }
+ },
+
+ stop: function() {
+ var that = $( this ).resizable( "instance" );
+ if ( that.ghost && that.helper ) {
+ that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
+ }
+ }
+
+} );
+
+$.ui.plugin.add( "resizable", "grid", {
+
+ resize: function() {
+ var outerDimensions,
+ that = $( this ).resizable( "instance" ),
+ o = that.options,
+ cs = that.size,
+ os = that.originalSize,
+ op = that.originalPosition,
+ a = that.axis,
+ grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
+ gridX = ( grid[ 0 ] || 1 ),
+ gridY = ( grid[ 1 ] || 1 ),
+ ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
+ oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
+ newWidth = os.width + ox,
+ newHeight = os.height + oy,
+ isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
+ isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
+ isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
+ isMinHeight = o.minHeight && ( o.minHeight > newHeight );
+
+ o.grid = grid;
+
+ if ( isMinWidth ) {
+ newWidth += gridX;
+ }
+ if ( isMinHeight ) {
+ newHeight += gridY;
+ }
+ if ( isMaxWidth ) {
+ newWidth -= gridX;
+ }
+ if ( isMaxHeight ) {
+ newHeight -= gridY;
+ }
+
+ if ( /^(se|s|e)$/.test( a ) ) {
+ that.size.width = newWidth;
+ that.size.height = newHeight;
+ } else if ( /^(ne)$/.test( a ) ) {
+ that.size.width = newWidth;
+ that.size.height = newHeight;
+ that.position.top = op.top - oy;
+ } else if ( /^(sw)$/.test( a ) ) {
+ that.size.width = newWidth;
+ that.size.height = newHeight;
+ that.position.left = op.left - ox;
+ } else {
+ if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
+ outerDimensions = that._getPaddingPlusBorderDimensions( this );
+ }
+
+ if ( newHeight - gridY > 0 ) {
+ that.size.height = newHeight;
+ that.position.top = op.top - oy;
+ } else {
+ newHeight = gridY - outerDimensions.height;
+ that.size.height = newHeight;
+ that.position.top = op.top + os.height - newHeight;
+ }
+ if ( newWidth - gridX > 0 ) {
+ that.size.width = newWidth;
+ that.position.left = op.left - ox;
+ } else {
+ newWidth = gridX - outerDimensions.width;
+ that.size.width = newWidth;
+ that.position.left = op.left + os.width - newWidth;
+ }
+ }
+ }
+
+} );
+
+var widgetsResizable = $.ui.resizable;
+
+
+/*!
+ * jQuery UI Dialog 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Dialog
+//>>group: Widgets
+//>>description: Displays customizable dialog windows.
+//>>docs: http://api.jqueryui.com/dialog/
+//>>demos: http://jqueryui.com/dialog/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/dialog.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.dialog", {
+ version: "1.12.1",
+ options: {
+ appendTo: "body",
+ autoOpen: true,
+ buttons: [],
+ classes: {
+ "ui-dialog": "ui-corner-all",
+ "ui-dialog-titlebar": "ui-corner-all"
+ },
+ closeOnEscape: true,
+ closeText: "Close",
+ draggable: true,
+ hide: null,
+ height: "auto",
+ maxHeight: null,
+ maxWidth: null,
+ minHeight: 150,
+ minWidth: 150,
+ modal: false,
+ position: {
+ my: "center",
+ at: "center",
+ of: window,
+ collision: "fit",
+
+ // Ensure the titlebar is always visible
+ using: function( pos ) {
+ var topOffset = $( this ).css( pos ).offset().top;
+ if ( topOffset < 0 ) {
+ $( this ).css( "top", pos.top - topOffset );
+ }
+ }
+ },
+ resizable: true,
+ show: null,
+ title: null,
+ width: 300,
+
+ // Callbacks
+ beforeClose: null,
+ close: null,
+ drag: null,
+ dragStart: null,
+ dragStop: null,
+ focus: null,
+ open: null,
+ resize: null,
+ resizeStart: null,
+ resizeStop: null
+ },
+
+ sizeRelatedOptions: {
+ buttons: true,
+ height: true,
+ maxHeight: true,
+ maxWidth: true,
+ minHeight: true,
+ minWidth: true,
+ width: true
+ },
+
+ resizableRelatedOptions: {
+ maxHeight: true,
+ maxWidth: true,
+ minHeight: true,
+ minWidth: true
+ },
+
+ _create: function() {
+ this.originalCss = {
+ display: this.element[ 0 ].style.display,
+ width: this.element[ 0 ].style.width,
+ minHeight: this.element[ 0 ].style.minHeight,
+ maxHeight: this.element[ 0 ].style.maxHeight,
+ height: this.element[ 0 ].style.height
+ };
+ this.originalPosition = {
+ parent: this.element.parent(),
+ index: this.element.parent().children().index( this.element )
+ };
+ this.originalTitle = this.element.attr( "title" );
+ if ( this.options.title == null && this.originalTitle != null ) {
+ this.options.title = this.originalTitle;
+ }
+
+ // Dialogs can't be disabled
+ if ( this.options.disabled ) {
+ this.options.disabled = false;
+ }
+
+ this._createWrapper();
+
+ this.element
+ .show()
+ .removeAttr( "title" )
+ .appendTo( this.uiDialog );
+
+ this._addClass( "ui-dialog-content", "ui-widget-content" );
+
+ this._createTitlebar();
+ this._createButtonPane();
+
+ if ( this.options.draggable && $.fn.draggable ) {
+ this._makeDraggable();
+ }
+ if ( this.options.resizable && $.fn.resizable ) {
+ this._makeResizable();
+ }
+
+ this._isOpen = false;
+
+ this._trackFocus();
+ },
+
+ _init: function() {
+ if ( this.options.autoOpen ) {
+ this.open();
+ }
+ },
+
+ _appendTo: function() {
+ var element = this.options.appendTo;
+ if ( element && ( element.jquery || element.nodeType ) ) {
+ return $( element );
+ }
+ return this.document.find( element || "body" ).eq( 0 );
+ },
+
+ _destroy: function() {
+ var next,
+ originalPosition = this.originalPosition;
+
+ this._untrackInstance();
+ this._destroyOverlay();
+
+ this.element
+ .removeUniqueId()
+ .css( this.originalCss )
+
+ // Without detaching first, the following becomes really slow
+ .detach();
+
+ this.uiDialog.remove();
+
+ if ( this.originalTitle ) {
+ this.element.attr( "title", this.originalTitle );
+ }
+
+ next = originalPosition.parent.children().eq( originalPosition.index );
+
+ // Don't try to place the dialog next to itself (#8613)
+ if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
+ next.before( this.element );
+ } else {
+ originalPosition.parent.append( this.element );
+ }
+ },
+
+ widget: function() {
+ return this.uiDialog;
+ },
+
+ disable: $.noop,
+ enable: $.noop,
+
+ close: function( event ) {
+ var that = this;
+
+ if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
+ return;
+ }
+
+ this._isOpen = false;
+ this._focusedElement = null;
+ this._destroyOverlay();
+ this._untrackInstance();
+
+ if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
+
+ // Hiding a focused element doesn't trigger blur in WebKit
+ // so in case we have nothing to focus on, explicitly blur the active element
+ // https://bugs.webkit.org/show_bug.cgi?id=47182
+ $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
+ }
+
+ this._hide( this.uiDialog, this.options.hide, function() {
+ that._trigger( "close", event );
+ } );
+ },
+
+ isOpen: function() {
+ return this._isOpen;
+ },
+
+ moveToTop: function() {
+ this._moveToTop();
+ },
+
+ _moveToTop: function( event, silent ) {
+ var moved = false,
+ zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
+ return +$( this ).css( "z-index" );
+ } ).get(),
+ zIndexMax = Math.max.apply( null, zIndices );
+
+ if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
+ this.uiDialog.css( "z-index", zIndexMax + 1 );
+ moved = true;
+ }
+
+ if ( moved && !silent ) {
+ this._trigger( "focus", event );
+ }
+ return moved;
+ },
+
+ open: function() {
+ var that = this;
+ if ( this._isOpen ) {
+ if ( this._moveToTop() ) {
+ this._focusTabbable();
+ }
+ return;
+ }
+
+ this._isOpen = true;
+ this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
+
+ this._size();
+ this._position();
+ this._createOverlay();
+ this._moveToTop( null, true );
+
+ // Ensure the overlay is moved to the top with the dialog, but only when
+ // opening. The overlay shouldn't move after the dialog is open so that
+ // modeless dialogs opened after the modal dialog stack properly.
+ if ( this.overlay ) {
+ this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
+ }
+
+ this._show( this.uiDialog, this.options.show, function() {
+ that._focusTabbable();
+ that._trigger( "focus" );
+ } );
+
+ // Track the dialog immediately upon openening in case a focus event
+ // somehow occurs outside of the dialog before an element inside the
+ // dialog is focused (#10152)
+ this._makeFocusTarget();
+
+ this._trigger( "open" );
+ },
+
+ _focusTabbable: function() {
+
+ // Set focus to the first match:
+ // 1. An element that was focused previously
+ // 2. First element inside the dialog matching [autofocus]
+ // 3. Tabbable element inside the content element
+ // 4. Tabbable element inside the buttonpane
+ // 5. The close button
+ // 6. The dialog itself
+ var hasFocus = this._focusedElement;
+ if ( !hasFocus ) {
+ hasFocus = this.element.find( "[autofocus]" );
+ }
+ if ( !hasFocus.length ) {
+ hasFocus = this.element.find( ":tabbable" );
+ }
+ if ( !hasFocus.length ) {
+ hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
+ }
+ if ( !hasFocus.length ) {
+ hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
+ }
+ if ( !hasFocus.length ) {
+ hasFocus = this.uiDialog;
+ }
+ hasFocus.eq( 0 ).trigger( "focus" );
+ },
+
+ _keepFocus: function( event ) {
+ function checkFocus() {
+ var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
+ isActive = this.uiDialog[ 0 ] === activeElement ||
+ $.contains( this.uiDialog[ 0 ], activeElement );
+ if ( !isActive ) {
+ this._focusTabbable();
+ }
+ }
+ event.preventDefault();
+ checkFocus.call( this );
+
+ // support: IE
+ // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
+ // so we check again later
+ this._delay( checkFocus );
+ },
+
+ _createWrapper: function() {
+ this.uiDialog = $( "<div>" )
+ .hide()
+ .attr( {
+
+ // Setting tabIndex makes the div focusable
+ tabIndex: -1,
+ role: "dialog"
+ } )
+ .appendTo( this._appendTo() );
+
+ this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
+ this._on( this.uiDialog, {
+ keydown: function( event ) {
+ if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+ event.preventDefault();
+ this.close( event );
+ return;
+ }
+
+ // Prevent tabbing out of dialogs
+ if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
+ return;
+ }
+ var tabbables = this.uiDialog.find( ":tabbable" ),
+ first = tabbables.filter( ":first" ),
+ last = tabbables.filter( ":last" );
+
+ if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
+ !event.shiftKey ) {
+ this._delay( function() {
+ first.trigger( "focus" );
+ } );
+ event.preventDefault();
+ } else if ( ( event.target === first[ 0 ] ||
+ event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
+ this._delay( function() {
+ last.trigger( "focus" );
+ } );
+ event.preventDefault();
+ }
+ },
+ mousedown: function( event ) {
+ if ( this._moveToTop( event ) ) {
+ this._focusTabbable();
+ }
+ }
+ } );
+
+ // We assume that any existing aria-describedby attribute means
+ // that the dialog content is marked up properly
+ // otherwise we brute force the content as the description
+ if ( !this.element.find( "[aria-describedby]" ).length ) {
+ this.uiDialog.attr( {
+ "aria-describedby": this.element.uniqueId().attr( "id" )
+ } );
+ }
+ },
+
+ _createTitlebar: function() {
+ var uiDialogTitle;
+
+ this.uiDialogTitlebar = $( "<div>" );
+ this._addClass( this.uiDialogTitlebar,
+ "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
+ this._on( this.uiDialogTitlebar, {
+ mousedown: function( event ) {
+
+ // Don't prevent click on close button (#8838)
+ // Focusing a dialog that is partially scrolled out of view
+ // causes the browser to scroll it into view, preventing the click event
+ if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
+
+ // Dialog isn't getting focus when dragging (#8063)
+ this.uiDialog.trigger( "focus" );
+ }
+ }
+ } );
+
+ // Support: IE
+ // Use type="button" to prevent enter keypresses in textboxes from closing the
+ // dialog in IE (#9312)
+ this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
+ .button( {
+ label: $( "<a>" ).text( this.options.closeText ).html(),
+ icon: "ui-icon-closethick",
+ showLabel: false
+ } )
+ .appendTo( this.uiDialogTitlebar );
+
+ this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
+ this._on( this.uiDialogTitlebarClose, {
+ click: function( event ) {
+ event.preventDefault();
+ this.close( event );
+ }
+ } );
+
+ uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
+ this._addClass( uiDialogTitle, "ui-dialog-title" );
+ this._title( uiDialogTitle );
+
+ this.uiDialogTitlebar.prependTo( this.uiDialog );
+
+ this.uiDialog.attr( {
+ "aria-labelledby": uiDialogTitle.attr( "id" )
+ } );
+ },
+
+ _title: function( title ) {
+ if ( this.options.title ) {
+ title.text( this.options.title );
+ } else {
+ title.html( " " );
+ }
+ },
+
+ _createButtonPane: function() {
+ this.uiDialogButtonPane = $( "<div>" );
+ this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
+ "ui-widget-content ui-helper-clearfix" );
+
+ this.uiButtonSet = $( "<div>" )
+ .appendTo( this.uiDialogButtonPane );
+ this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
+
+ this._createButtons();
+ },
+
+ _createButtons: function() {
+ var that = this,
+ buttons = this.options.buttons;
+
+ // If we already have a button pane, remove it
+ this.uiDialogButtonPane.remove();
+ this.uiButtonSet.empty();
+
+ if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
+ this._removeClass( this.uiDialog, "ui-dialog-buttons" );
+ return;
+ }
+
+ $.each( buttons, function( name, props ) {
+ var click, buttonOptions;
+ props = $.isFunction( props ) ?
+ { click: props, text: name } :
+ props;
+
+ // Default to a non-submitting button
+ props = $.extend( { type: "button" }, props );
+
+ // Change the context for the click callback to be the main element
+ click = props.click;
+ buttonOptions = {
+ icon: props.icon,
+ iconPosition: props.iconPosition,
+ showLabel: props.showLabel,
+
+ // Deprecated options
+ icons: props.icons,
+ text: props.text
+ };
+
+ delete props.click;
+ delete props.icon;
+ delete props.iconPosition;
+ delete props.showLabel;
+
+ // Deprecated options
+ delete props.icons;
+ if ( typeof props.text === "boolean" ) {
+ delete props.text;
+ }
+
+ $( "<button></button>", props )
+ .button( buttonOptions )
+ .appendTo( that.uiButtonSet )
+ .on( "click", function() {
+ click.apply( that.element[ 0 ], arguments );
+ } );
+ } );
+ this._addClass( this.uiDialog, "ui-dialog-buttons" );
+ this.uiDialogButtonPane.appendTo( this.uiDialog );
+ },
+
+ _makeDraggable: function() {
+ var that = this,
+ options = this.options;
+
+ function filteredUi( ui ) {
+ return {
+ position: ui.position,
+ offset: ui.offset
+ };
+ }
+
+ this.uiDialog.draggable( {
+ cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
+ handle: ".ui-dialog-titlebar",
+ containment: "document",
+ start: function( event, ui ) {
+ that._addClass( $( this ), "ui-dialog-dragging" );
+ that._blockFrames();
+ that._trigger( "dragStart", event, filteredUi( ui ) );
+ },
+ drag: function( event, ui ) {
+ that._trigger( "drag", event, filteredUi( ui ) );
+ },
+ stop: function( event, ui ) {
+ var left = ui.offset.left - that.document.scrollLeft(),
+ top = ui.offset.top - that.document.scrollTop();
+
+ options.position = {
+ my: "left top",
+ at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
+ "top" + ( top >= 0 ? "+" : "" ) + top,
+ of: that.window
+ };
+ that._removeClass( $( this ), "ui-dialog-dragging" );
+ that._unblockFrames();
+ that._trigger( "dragStop", event, filteredUi( ui ) );
+ }
+ } );
+ },
+
+ _makeResizable: function() {
+ var that = this,
+ options = this.options,
+ handles = options.resizable,
+
+ // .ui-resizable has position: relative defined in the stylesheet
+ // but dialogs have to use absolute or fixed positioning
+ position = this.uiDialog.css( "position" ),
+ resizeHandles = typeof handles === "string" ?
+ handles :
+ "n,e,s,w,se,sw,ne,nw";
+
+ function filteredUi( ui ) {
+ return {
+ originalPosition: ui.originalPosition,
+ originalSize: ui.originalSize,
+ position: ui.position,
+ size: ui.size
+ };
+ }
+
+ this.uiDialog.resizable( {
+ cancel: ".ui-dialog-content",
+ containment: "document",
+ alsoResize: this.element,
+ maxWidth: options.maxWidth,
+ maxHeight: options.maxHeight,
+ minWidth: options.minWidth,
+ minHeight: this._minHeight(),
+ handles: resizeHandles,
+ start: function( event, ui ) {
+ that._addClass( $( this ), "ui-dialog-resizing" );
+ that._blockFrames();
+ that._trigger( "resizeStart", event, filteredUi( ui ) );
+ },
+ resize: function( event, ui ) {
+ that._trigger( "resize", event, filteredUi( ui ) );
+ },
+ stop: function( event, ui ) {
+ var offset = that.uiDialog.offset(),
+ left = offset.left - that.document.scrollLeft(),
+ top = offset.top - that.document.scrollTop();
+
+ options.height = that.uiDialog.height();
+ options.width = that.uiDialog.width();
+ options.position = {
+ my: "left top",
+ at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
+ "top" + ( top >= 0 ? "+" : "" ) + top,
+ of: that.window
+ };
+ that._removeClass( $( this ), "ui-dialog-resizing" );
+ that._unblockFrames();
+ that._trigger( "resizeStop", event, filteredUi( ui ) );
+ }
+ } )
+ .css( "position", position );
+ },
+
+ _trackFocus: function() {
+ this._on( this.widget(), {
+ focusin: function( event ) {
+ this._makeFocusTarget();
+ this._focusedElement = $( event.target );
+ }
+ } );
+ },
+
+ _makeFocusTarget: function() {
+ this._untrackInstance();
+ this._trackingInstances().unshift( this );
+ },
+
+ _untrackInstance: function() {
+ var instances = this._trackingInstances(),
+ exists = $.inArray( this, instances );
+ if ( exists !== -1 ) {
+ instances.splice( exists, 1 );
+ }
+ },
+
+ _trackingInstances: function() {
+ var instances = this.document.data( "ui-dialog-instances" );
+ if ( !instances ) {
+ instances = [];
+ this.document.data( "ui-dialog-instances", instances );
+ }
+ return instances;
+ },
+
+ _minHeight: function() {
+ var options = this.options;
+
+ return options.height === "auto" ?
+ options.minHeight :
+ Math.min( options.minHeight, options.height );
+ },
+
+ _position: function() {
+
+ // Need to show the dialog to get the actual offset in the position plugin
+ var isVisible = this.uiDialog.is( ":visible" );
+ if ( !isVisible ) {
+ this.uiDialog.show();
+ }
+ this.uiDialog.position( this.options.position );
+ if ( !isVisible ) {
+ this.uiDialog.hide();
+ }
+ },
+
+ _setOptions: function( options ) {
+ var that = this,
+ resize = false,
+ resizableOptions = {};
+
+ $.each( options, function( key, value ) {
+ that._setOption( key, value );
+
+ if ( key in that.sizeRelatedOptions ) {
+ resize = true;
+ }
+ if ( key in that.resizableRelatedOptions ) {
+ resizableOptions[ key ] = value;
+ }
+ } );
+
+ if ( resize ) {
+ this._size();
+ this._position();
+ }
+ if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
+ this.uiDialog.resizable( "option", resizableOptions );
+ }
+ },
+
+ _setOption: function( key, value ) {
+ var isDraggable, isResizable,
+ uiDialog = this.uiDialog;
+
+ if ( key === "disabled" ) {
+ return;
+ }
+
+ this._super( key, value );
+
+ if ( key === "appendTo" ) {
+ this.uiDialog.appendTo( this._appendTo() );
+ }
+
+ if ( key === "buttons" ) {
+ this._createButtons();
+ }
+
+ if ( key === "closeText" ) {
+ this.uiDialogTitlebarClose.button( {
+
+ // Ensure that we always pass a string
+ label: $( "<a>" ).text( "" + this.options.closeText ).html()
+ } );
+ }
+
+ if ( key === "draggable" ) {
+ isDraggable = uiDialog.is( ":data(ui-draggable)" );
+ if ( isDraggable && !value ) {
+ uiDialog.draggable( "destroy" );
+ }
+
+ if ( !isDraggable && value ) {
+ this._makeDraggable();
+ }
+ }
+
+ if ( key === "position" ) {
+ this._position();
+ }
+
+ if ( key === "resizable" ) {
+
+ // currently resizable, becoming non-resizable
+ isResizable = uiDialog.is( ":data(ui-resizable)" );
+ if ( isResizable && !value ) {
+ uiDialog.resizable( "destroy" );
+ }
+
+ // Currently resizable, changing handles
+ if ( isResizable && typeof value === "string" ) {
+ uiDialog.resizable( "option", "handles", value );
+ }
+
+ // Currently non-resizable, becoming resizable
+ if ( !isResizable && value !== false ) {
+ this._makeResizable();
+ }
+ }
+
+ if ( key === "title" ) {
+ this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
+ }
+ },
+
+ _size: function() {
+
+ // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
+ // divs will both have width and height set, so we need to reset them
+ var nonContentHeight, minContentHeight, maxContentHeight,
+ options = this.options;
+
+ // Reset content sizing
+ this.element.show().css( {
+ width: "auto",
+ minHeight: 0,
+ maxHeight: "none",
+ height: 0
+ } );
+
+ if ( options.minWidth > options.width ) {
+ options.width = options.minWidth;
+ }
+
+ // Reset wrapper sizing
+ // determine the height of all the non-content elements
+ nonContentHeight = this.uiDialog.css( {
+ height: "auto",
+ width: options.width
+ } )
+ .outerHeight();
+ minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
+ maxContentHeight = typeof options.maxHeight === "number" ?
+ Math.max( 0, options.maxHeight - nonContentHeight ) :
+ "none";
+
+ if ( options.height === "auto" ) {
+ this.element.css( {
+ minHeight: minContentHeight,
+ maxHeight: maxContentHeight,
+ height: "auto"
+ } );
+ } else {
+ this.element.height( Math.max( 0, options.height - nonContentHeight ) );
+ }
+
+ if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
+ this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
+ }
+ },
+
+ _blockFrames: function() {
+ this.iframeBlocks = this.document.find( "iframe" ).map( function() {
+ var iframe = $( this );
+
+ return $( "<div>" )
+ .css( {
+ position: "absolute",
+ width: iframe.outerWidth(),
+ height: iframe.outerHeight()
+ } )
+ .appendTo( iframe.parent() )
+ .offset( iframe.offset() )[ 0 ];
+ } );
+ },
+
+ _unblockFrames: function() {
+ if ( this.iframeBlocks ) {
+ this.iframeBlocks.remove();
+ delete this.iframeBlocks;
+ }
+ },
+
+ _allowInteraction: function( event ) {
+ if ( $( event.target ).closest( ".ui-dialog" ).length ) {
+ return true;
+ }
+
+ // TODO: Remove hack when datepicker implements
+ // the .ui-front logic (#8989)
+ return !!$( event.target ).closest( ".ui-datepicker" ).length;
+ },
+
+ _createOverlay: function() {
+ if ( !this.options.modal ) {
+ return;
+ }
+
+ // We use a delay in case the overlay is created from an
+ // event that we're going to be cancelling (#2804)
+ var isOpening = true;
+ this._delay( function() {
+ isOpening = false;
+ } );
+
+ if ( !this.document.data( "ui-dialog-overlays" ) ) {
+
+ // Prevent use of anchors and inputs
+ // Using _on() for an event handler shared across many instances is
+ // safe because the dialogs stack and must be closed in reverse order
+ this._on( this.document, {
+ focusin: function( event ) {
+ if ( isOpening ) {
+ return;
+ }
+
+ if ( !this._allowInteraction( event ) ) {
+ event.preventDefault();
+ this._trackingInstances()[ 0 ]._focusTabbable();
+ }
+ }
+ } );
+ }
+
+ this.overlay = $( "<div>" )
+ .appendTo( this._appendTo() );
+
+ this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
+ this._on( this.overlay, {
+ mousedown: "_keepFocus"
+ } );
+ this.document.data( "ui-dialog-overlays",
+ ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
+ },
+
+ _destroyOverlay: function() {
+ if ( !this.options.modal ) {
+ return;
+ }
+
+ if ( this.overlay ) {
+ var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
+
+ if ( !overlays ) {
+ this._off( this.document, "focusin" );
+ this.document.removeData( "ui-dialog-overlays" );
+ } else {
+ this.document.data( "ui-dialog-overlays", overlays );
+ }
+
+ this.overlay.remove();
+ this.overlay = null;
+ }
+ }
+} );
+
+// DEPRECATED
+// TODO: switch return back to widget declaration at top of file when this is removed
+if ( $.uiBackCompat !== false ) {
+
+ // Backcompat for dialogClass option
+ $.widget( "ui.dialog", $.ui.dialog, {
+ options: {
+ dialogClass: ""
+ },
+ _createWrapper: function() {
+ this._super();
+ this.uiDialog.addClass( this.options.dialogClass );
+ },
+ _setOption: function( key, value ) {
+ if ( key === "dialogClass" ) {
+ this.uiDialog
+ .removeClass( this.options.dialogClass )
+ .addClass( value );
+ }
+ this._superApply( arguments );
+ }
+ } );
+}
+
+var widgetsDialog = $.ui.dialog;
+
+
+/*!
+ * jQuery UI Droppable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Droppable
+//>>group: Interactions
+//>>description: Enables drop targets for draggable elements.
+//>>docs: http://api.jqueryui.com/droppable/
+//>>demos: http://jqueryui.com/droppable/
+
+
+
+$.widget( "ui.droppable", {
+ version: "1.12.1",
+ widgetEventPrefix: "drop",
+ options: {
+ accept: "*",
+ addClasses: true,
+ greedy: false,
+ scope: "default",
+ tolerance: "intersect",
+
+ // Callbacks
+ activate: null,
+ deactivate: null,
+ drop: null,
+ out: null,
+ over: null
+ },
+ _create: function() {
+
+ var proportions,
+ o = this.options,
+ accept = o.accept;
+
+ this.isover = false;
+ this.isout = true;
+
+ this.accept = $.isFunction( accept ) ? accept : function( d ) {
+ return d.is( accept );
+ };
+
+ this.proportions = function( /* valueToWrite */ ) {
+ if ( arguments.length ) {
+
+ // Store the droppable's proportions
+ proportions = arguments[ 0 ];
+ } else {
+
+ // Retrieve or derive the droppable's proportions
+ return proportions ?
+ proportions :
+ proportions = {
+ width: this.element[ 0 ].offsetWidth,
+ height: this.element[ 0 ].offsetHeight
+ };
+ }
+ };
+
+ this._addToManager( o.scope );
+
+ o.addClasses && this._addClass( "ui-droppable" );
+
+ },
+
+ _addToManager: function( scope ) {
+
+ // Add the reference and positions to the manager
+ $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
+ $.ui.ddmanager.droppables[ scope ].push( this );
+ },
+
+ _splice: function( drop ) {
+ var i = 0;
+ for ( ; i < drop.length; i++ ) {
+ if ( drop[ i ] === this ) {
+ drop.splice( i, 1 );
+ }
+ }
+ },
+
+ _destroy: function() {
+ var drop = $.ui.ddmanager.droppables[ this.options.scope ];
+
+ this._splice( drop );
+ },
+
+ _setOption: function( key, value ) {
+
+ if ( key === "accept" ) {
+ this.accept = $.isFunction( value ) ? value : function( d ) {
+ return d.is( value );
+ };
+ } else if ( key === "scope" ) {
+ var drop = $.ui.ddmanager.droppables[ this.options.scope ];
+
+ this._splice( drop );
+ this._addToManager( value );
+ }
+
+ this._super( key, value );
+ },
+
+ _activate: function( event ) {
+ var draggable = $.ui.ddmanager.current;
+
+ this._addActiveClass();
+ if ( draggable ) {
+ this._trigger( "activate", event, this.ui( draggable ) );
+ }
+ },
+
+ _deactivate: function( event ) {
+ var draggable = $.ui.ddmanager.current;
+
+ this._removeActiveClass();
+ if ( draggable ) {
+ this._trigger( "deactivate", event, this.ui( draggable ) );
+ }
+ },
+
+ _over: function( event ) {
+
+ var draggable = $.ui.ddmanager.current;
+
+ // Bail if draggable and droppable are same element
+ if ( !draggable || ( draggable.currentItem ||
+ draggable.element )[ 0 ] === this.element[ 0 ] ) {
+ return;
+ }
+
+ if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
+ draggable.element ) ) ) {
+ this._addHoverClass();
+ this._trigger( "over", event, this.ui( draggable ) );
+ }
+
+ },
+
+ _out: function( event ) {
+
+ var draggable = $.ui.ddmanager.current;
+
+ // Bail if draggable and droppable are same element
+ if ( !draggable || ( draggable.currentItem ||
+ draggable.element )[ 0 ] === this.element[ 0 ] ) {
+ return;
+ }
+
+ if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
+ draggable.element ) ) ) {
+ this._removeHoverClass();
+ this._trigger( "out", event, this.ui( draggable ) );
+ }
+
+ },
+
+ _drop: function( event, custom ) {
+
+ var draggable = custom || $.ui.ddmanager.current,
+ childrenIntersection = false;
+
+ // Bail if draggable and droppable are same element
+ if ( !draggable || ( draggable.currentItem ||
+ draggable.element )[ 0 ] === this.element[ 0 ] ) {
+ return false;
+ }
+
+ this.element
+ .find( ":data(ui-droppable)" )
+ .not( ".ui-draggable-dragging" )
+ .each( function() {
+ var inst = $( this ).droppable( "instance" );
+ if (
+ inst.options.greedy &&
+ !inst.options.disabled &&
+ inst.options.scope === draggable.options.scope &&
+ inst.accept.call(
+ inst.element[ 0 ], ( draggable.currentItem || draggable.element )
+ ) &&
+ intersect(
+ draggable,
+ $.extend( inst, { offset: inst.element.offset() } ),
+ inst.options.tolerance, event
+ )
+ ) {
+ childrenIntersection = true;
+ return false; }
+ } );
+ if ( childrenIntersection ) {
+ return false;
+ }
+
+ if ( this.accept.call( this.element[ 0 ],
+ ( draggable.currentItem || draggable.element ) ) ) {
+ this._removeActiveClass();
+ this._removeHoverClass();
+
+ this._trigger( "drop", event, this.ui( draggable ) );
+ return this.element;
+ }
+
+ return false;
+
+ },
+
+ ui: function( c ) {
+ return {
+ draggable: ( c.currentItem || c.element ),
+ helper: c.helper,
+ position: c.position,
+ offset: c.positionAbs
+ };
+ },
+
+ // Extension points just to make backcompat sane and avoid duplicating logic
+ // TODO: Remove in 1.13 along with call to it below
+ _addHoverClass: function() {
+ this._addClass( "ui-droppable-hover" );
+ },
+
+ _removeHoverClass: function() {
+ this._removeClass( "ui-droppable-hover" );
+ },
+
+ _addActiveClass: function() {
+ this._addClass( "ui-droppable-active" );
+ },
+
+ _removeActiveClass: function() {
+ this._removeClass( "ui-droppable-active" );
+ }
+} );
+
+var intersect = $.ui.intersect = ( function() {
+ function isOverAxis( x, reference, size ) {
+ return ( x >= reference ) && ( x < ( reference + size ) );
+ }
+
+ return function( draggable, droppable, toleranceMode, event ) {
+
+ if ( !droppable.offset ) {
+ return false;
+ }
+
+ var x1 = ( draggable.positionAbs ||
+ draggable.position.absolute ).left + draggable.margins.left,
+ y1 = ( draggable.positionAbs ||
+ draggable.position.absolute ).top + draggable.margins.top,
+ x2 = x1 + draggable.helperProportions.width,
+ y2 = y1 + draggable.helperProportions.height,
+ l = droppable.offset.left,
+ t = droppable.offset.top,
+ r = l + droppable.proportions().width,
+ b = t + droppable.proportions().height;
+
+ switch ( toleranceMode ) {
+ case "fit":
+ return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
+ case "intersect":
+ return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
+ x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
+ t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
+ y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
+ case "pointer":
+ return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
+ isOverAxis( event.pageX, l, droppable.proportions().width );
+ case "touch":
+ return (
+ ( y1 >= t && y1 <= b ) || // Top edge touching
+ ( y2 >= t && y2 <= b ) || // Bottom edge touching
+ ( y1 < t && y2 > b ) // Surrounded vertically
+ ) && (
+ ( x1 >= l && x1 <= r ) || // Left edge touching
+ ( x2 >= l && x2 <= r ) || // Right edge touching
+ ( x1 < l && x2 > r ) // Surrounded horizontally
+ );
+ default:
+ return false;
+ }
+ };
+} )();
+
+/*
+ This manager tracks offsets of draggables and droppables
+*/
+$.ui.ddmanager = {
+ current: null,
+ droppables: { "default": [] },
+ prepareOffsets: function( t, event ) {
+
+ var i, j,
+ m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
+ type = event ? event.type : null, // workaround for #2317
+ list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
+
+ droppablesLoop: for ( i = 0; i < m.length; i++ ) {
+
+ // No disabled and non-accepted
+ if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
+ ( t.currentItem || t.element ) ) ) ) {
+ continue;
+ }
+
+ // Filter out elements in the current dragged item
+ for ( j = 0; j < list.length; j++ ) {
+ if ( list[ j ] === m[ i ].element[ 0 ] ) {
+ m[ i ].proportions().height = 0;
+ continue droppablesLoop;
+ }
+ }
+
+ m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
+ if ( !m[ i ].visible ) {
+ continue;
+ }
+
+ // Activate the droppable if used directly from draggables
+ if ( type === "mousedown" ) {
+ m[ i ]._activate.call( m[ i ], event );
+ }
+
+ m[ i ].offset = m[ i ].element.offset();
+ m[ i ].proportions( {
+ width: m[ i ].element[ 0 ].offsetWidth,
+ height: m[ i ].element[ 0 ].offsetHeight
+ } );
+
+ }
+
+ },
+ drop: function( draggable, event ) {
+
+ var dropped = false;
+
+ // Create a copy of the droppables in case the list changes during the drop (#9116)
+ $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
+
+ if ( !this.options ) {
+ return;
+ }
+ if ( !this.options.disabled && this.visible &&
+ intersect( draggable, this, this.options.tolerance, event ) ) {
+ dropped = this._drop.call( this, event ) || dropped;
+ }
+
+ if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
+ ( draggable.currentItem || draggable.element ) ) ) {
+ this.isout = true;
+ this.isover = false;
+ this._deactivate.call( this, event );
+ }
+
+ } );
+ return dropped;
+
+ },
+ dragStart: function( draggable, event ) {
+
+ // Listen for scrolling so that if the dragging causes scrolling the position of the
+ // droppables can be recalculated (see #5003)
+ draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
+ if ( !draggable.options.refreshPositions ) {
+ $.ui.ddmanager.prepareOffsets( draggable, event );
+ }
+ } );
+ },
+ drag: function( draggable, event ) {
+
+ // If you have a highly dynamic page, you might try this option. It renders positions
+ // every time you move the mouse.
+ if ( draggable.options.refreshPositions ) {
+ $.ui.ddmanager.prepareOffsets( draggable, event );
+ }
+
+ // Run through all droppables and check their positions based on specific tolerance options
+ $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
+
+ if ( this.options.disabled || this.greedyChild || !this.visible ) {
+ return;
+ }
+
+ var parentInstance, scope, parent,
+ intersects = intersect( draggable, this, this.options.tolerance, event ),
+ c = !intersects && this.isover ?
+ "isout" :
+ ( intersects && !this.isover ? "isover" : null );
+ if ( !c ) {
+ return;
+ }
+
+ if ( this.options.greedy ) {
+
+ // find droppable parents with same scope
+ scope = this.options.scope;
+ parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
+ return $( this ).droppable( "instance" ).options.scope === scope;
+ } );
+
+ if ( parent.length ) {
+ parentInstance = $( parent[ 0 ] ).droppable( "instance" );
+ parentInstance.greedyChild = ( c === "isover" );
+ }
+ }
+
+ // We just moved into a greedy child
+ if ( parentInstance && c === "isover" ) {
+ parentInstance.isover = false;
+ parentInstance.isout = true;
+ parentInstance._out.call( parentInstance, event );
+ }
+
+ this[ c ] = true;
+ this[ c === "isout" ? "isover" : "isout" ] = false;
+ this[ c === "isover" ? "_over" : "_out" ].call( this, event );
+
+ // We just moved out of a greedy child
+ if ( parentInstance && c === "isout" ) {
+ parentInstance.isout = false;
+ parentInstance.isover = true;
+ parentInstance._over.call( parentInstance, event );
+ }
+ } );
+
+ },
+ dragStop: function( draggable, event ) {
+ draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
+
+ // Call prepareOffsets one final time since IE does not fire return scroll events when
+ // overflow was caused by drag (see #5003)
+ if ( !draggable.options.refreshPositions ) {
+ $.ui.ddmanager.prepareOffsets( draggable, event );
+ }
+ }
+};
+
+// DEPRECATED
+// TODO: switch return back to widget declaration at top of file when this is removed
+if ( $.uiBackCompat !== false ) {
+
+ // Backcompat for activeClass and hoverClass options
+ $.widget( "ui.droppable", $.ui.droppable, {
+ options: {
+ hoverClass: false,
+ activeClass: false
+ },
+ _addActiveClass: function() {
+ this._super();
+ if ( this.options.activeClass ) {
+ this.element.addClass( this.options.activeClass );
+ }
+ },
+ _removeActiveClass: function() {
+ this._super();
+ if ( this.options.activeClass ) {
+ this.element.removeClass( this.options.activeClass );
+ }
+ },
+ _addHoverClass: function() {
+ this._super();
+ if ( this.options.hoverClass ) {
+ this.element.addClass( this.options.hoverClass );
+ }
+ },
+ _removeHoverClass: function() {
+ this._super();
+ if ( this.options.hoverClass ) {
+ this.element.removeClass( this.options.hoverClass );
+ }
+ }
+ } );
+}
+
+var widgetsDroppable = $.ui.droppable;
+
+
+/*!
+ * jQuery UI Progressbar 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Progressbar
+//>>group: Widgets
+// jscs:disable maximumLineLength
+//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
+// jscs:enable maximumLineLength
+//>>docs: http://api.jqueryui.com/progressbar/
+//>>demos: http://jqueryui.com/progressbar/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/progressbar.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+var widgetsProgressbar = $.widget( "ui.progressbar", {
+ version: "1.12.1",
+ options: {
+ classes: {
+ "ui-progressbar": "ui-corner-all",
+ "ui-progressbar-value": "ui-corner-left",
+ "ui-progressbar-complete": "ui-corner-right"
+ },
+ max: 100,
+ value: 0,
+
+ change: null,
+ complete: null
+ },
+
+ min: 0,
+
+ _create: function() {
+
+ // Constrain initial value
+ this.oldValue = this.options.value = this._constrainedValue();
+
+ this.element.attr( {
+
+ // Only set static values; aria-valuenow and aria-valuemax are
+ // set inside _refreshValue()
+ role: "progressbar",
+ "aria-valuemin": this.min
+ } );
+ this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
+
+ this.valueDiv = $( "<div>" ).appendTo( this.element );
+ this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
+ this._refreshValue();
+ },
+
+ _destroy: function() {
+ this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
+
+ this.valueDiv.remove();
+ },
+
+ value: function( newValue ) {
+ if ( newValue === undefined ) {
+ return this.options.value;
+ }
+
+ this.options.value = this._constrainedValue( newValue );
+ this._refreshValue();
+ },
+
+ _constrainedValue: function( newValue ) {
+ if ( newValue === undefined ) {
+ newValue = this.options.value;
+ }
+
+ this.indeterminate = newValue === false;
+
+ // Sanitize value
+ if ( typeof newValue !== "number" ) {
+ newValue = 0;
+ }
+
+ return this.indeterminate ? false :
+ Math.min( this.options.max, Math.max( this.min, newValue ) );
+ },
+
+ _setOptions: function( options ) {
+
+ // Ensure "value" option is set after other values (like max)
+ var value = options.value;
+ delete options.value;
+
+ this._super( options );
+
+ this.options.value = this._constrainedValue( value );
+ this._refreshValue();
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "max" ) {
+
+ // Don't allow a max less than min
+ value = Math.max( this.min, value );
+ }
+ this._super( key, value );
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", value );
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
+ _percentage: function() {
+ return this.indeterminate ?
+ 100 :
+ 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
+ },
+
+ _refreshValue: function() {
+ var value = this.options.value,
+ percentage = this._percentage();
+
+ this.valueDiv
+ .toggle( this.indeterminate || value > this.min )
+ .width( percentage.toFixed( 0 ) + "%" );
+
+ this
+ ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
+ value === this.options.max )
+ ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
+
+ if ( this.indeterminate ) {
+ this.element.removeAttr( "aria-valuenow" );
+ if ( !this.overlayDiv ) {
+ this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
+ this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
+ }
+ } else {
+ this.element.attr( {
+ "aria-valuemax": this.options.max,
+ "aria-valuenow": value
+ } );
+ if ( this.overlayDiv ) {
+ this.overlayDiv.remove();
+ this.overlayDiv = null;
+ }
+ }
+
+ if ( this.oldValue !== value ) {
+ this.oldValue = value;
+ this._trigger( "change" );
+ }
+ if ( value === this.options.max ) {
+ this._trigger( "complete" );
+ }
+ }
+} );
+
+
+/*!
+ * jQuery UI Selectable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Selectable
+//>>group: Interactions
+//>>description: Allows groups of elements to be selected with the mouse.
+//>>docs: http://api.jqueryui.com/selectable/
+//>>demos: http://jqueryui.com/selectable/
+//>>css.structure: ../../themes/base/selectable.css
+
+
+
+var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
+ version: "1.12.1",
+ options: {
+ appendTo: "body",
+ autoRefresh: true,
+ distance: 0,
+ filter: "*",
+ tolerance: "touch",
+
+ // Callbacks
+ selected: null,
+ selecting: null,
+ start: null,
+ stop: null,
+ unselected: null,
+ unselecting: null
+ },
+ _create: function() {
+ var that = this;
+
+ this._addClass( "ui-selectable" );
+
+ this.dragged = false;
+
+ // Cache selectee children based on filter
+ this.refresh = function() {
+ that.elementPos = $( that.element[ 0 ] ).offset();
+ that.selectees = $( that.options.filter, that.element[ 0 ] );
+ that._addClass( that.selectees, "ui-selectee" );
+ that.selectees.each( function() {
+ var $this = $( this ),
+ selecteeOffset = $this.offset(),
+ pos = {
+ left: selecteeOffset.left - that.elementPos.left,
+ top: selecteeOffset.top - that.elementPos.top
+ };
+ $.data( this, "selectable-item", {
+ element: this,
+ $element: $this,
+ left: pos.left,
+ top: pos.top,
+ right: pos.left + $this.outerWidth(),
+ bottom: pos.top + $this.outerHeight(),
+ startselected: false,
+ selected: $this.hasClass( "ui-selected" ),
+ selecting: $this.hasClass( "ui-selecting" ),
+ unselecting: $this.hasClass( "ui-unselecting" )
+ } );
+ } );
+ };
+ this.refresh();
+
+ this._mouseInit();
+
+ this.helper = $( "<div>" );
+ this._addClass( this.helper, "ui-selectable-helper" );
+ },
+
+ _destroy: function() {
+ this.selectees.removeData( "selectable-item" );
+ this._mouseDestroy();
+ },
+
+ _mouseStart: function( event ) {
+ var that = this,
+ options = this.options;
+
+ this.opos = [ event.pageX, event.pageY ];
+ this.elementPos = $( this.element[ 0 ] ).offset();
+
+ if ( this.options.disabled ) {
+ return;
+ }
+
+ this.selectees = $( options.filter, this.element[ 0 ] );
+
+ this._trigger( "start", event );
+
+ $( options.appendTo ).append( this.helper );
+
+ // position helper (lasso)
+ this.helper.css( {
+ "left": event.pageX,
+ "top": event.pageY,
+ "width": 0,
+ "height": 0
+ } );
+
+ if ( options.autoRefresh ) {
+ this.refresh();
+ }
+
+ this.selectees.filter( ".ui-selected" ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
+ selectee.startselected = true;
+ if ( !event.metaKey && !event.ctrlKey ) {
+ that._removeClass( selectee.$element, "ui-selected" );
+ selectee.selected = false;
+ that._addClass( selectee.$element, "ui-unselecting" );
+ selectee.unselecting = true;
+
+ // selectable UNSELECTING callback
+ that._trigger( "unselecting", event, {
+ unselecting: selectee.element
+ } );
+ }
+ } );
+
+ $( event.target ).parents().addBack().each( function() {
+ var doSelect,
+ selectee = $.data( this, "selectable-item" );
+ if ( selectee ) {
+ doSelect = ( !event.metaKey && !event.ctrlKey ) ||
+ !selectee.$element.hasClass( "ui-selected" );
+ that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
+ ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
+ selectee.unselecting = !doSelect;
+ selectee.selecting = doSelect;
+ selectee.selected = doSelect;
+
+ // selectable (UN)SELECTING callback
+ if ( doSelect ) {
+ that._trigger( "selecting", event, {
+ selecting: selectee.element
+ } );
+ } else {
+ that._trigger( "unselecting", event, {
+ unselecting: selectee.element
+ } );
+ }
+ return false;
+ }
+ } );
+
+ },
+
+ _mouseDrag: function( event ) {
+
+ this.dragged = true;
+
+ if ( this.options.disabled ) {
+ return;
+ }
+
+ var tmp,
+ that = this,
+ options = this.options,
+ x1 = this.opos[ 0 ],
+ y1 = this.opos[ 1 ],
+ x2 = event.pageX,
+ y2 = event.pageY;
+
+ if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
+ if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
+ this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
+
+ this.selectees.each( function() {
+ var selectee = $.data( this, "selectable-item" ),
+ hit = false,
+ offset = {};
+
+ //prevent helper from being selected if appendTo: selectable
+ if ( !selectee || selectee.element === that.element[ 0 ] ) {
+ return;
+ }
+
+ offset.left = selectee.left + that.elementPos.left;
+ offset.right = selectee.right + that.elementPos.left;
+ offset.top = selectee.top + that.elementPos.top;
+ offset.bottom = selectee.bottom + that.elementPos.top;
+
+ if ( options.tolerance === "touch" ) {
+ hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
+ offset.bottom < y1 ) );
+ } else if ( options.tolerance === "fit" ) {
+ hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
+ offset.bottom < y2 );
+ }
+
+ if ( hit ) {
+
+ // SELECT
+ if ( selectee.selected ) {
+ that._removeClass( selectee.$element, "ui-selected" );
+ selectee.selected = false;
+ }
+ if ( selectee.unselecting ) {
+ that._removeClass( selectee.$element, "ui-unselecting" );
+ selectee.unselecting = false;
+ }
+ if ( !selectee.selecting ) {
+ that._addClass( selectee.$element, "ui-selecting" );
+ selectee.selecting = true;
+
+ // selectable SELECTING callback
+ that._trigger( "selecting", event, {
+ selecting: selectee.element
+ } );
+ }
+ } else {
+
+ // UNSELECT
+ if ( selectee.selecting ) {
+ if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
+ that._removeClass( selectee.$element, "ui-selecting" );
+ selectee.selecting = false;
+ that._addClass( selectee.$element, "ui-selected" );
+ selectee.selected = true;
+ } else {
+ that._removeClass( selectee.$element, "ui-selecting" );
+ selectee.selecting = false;
+ if ( selectee.startselected ) {
+ that._addClass( selectee.$element, "ui-unselecting" );
+ selectee.unselecting = true;
+ }
+
+ // selectable UNSELECTING callback
+ that._trigger( "unselecting", event, {
+ unselecting: selectee.element
+ } );
+ }
+ }
+ if ( selectee.selected ) {
+ if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
+ that._removeClass( selectee.$element, "ui-selected" );
+ selectee.selected = false;
+
+ that._addClass( selectee.$element, "ui-unselecting" );
+ selectee.unselecting = true;
+
+ // selectable UNSELECTING callback
+ that._trigger( "unselecting", event, {
+ unselecting: selectee.element
+ } );
+ }
+ }
+ }
+ } );
+
+ return false;
+ },
+
+ _mouseStop: function( event ) {
+ var that = this;
+
+ this.dragged = false;
+
+ $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
+ that._removeClass( selectee.$element, "ui-unselecting" );
+ selectee.unselecting = false;
+ selectee.startselected = false;
+ that._trigger( "unselected", event, {
+ unselected: selectee.element
+ } );
+ } );
+ $( ".ui-selecting", this.element[ 0 ] ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
+ that._removeClass( selectee.$element, "ui-selecting" )
+ ._addClass( selectee.$element, "ui-selected" );
+ selectee.selecting = false;
+ selectee.selected = true;
+ selectee.startselected = true;
+ that._trigger( "selected", event, {
+ selected: selectee.element
+ } );
+ } );
+ this._trigger( "stop", event );
+
+ this.helper.remove();
+
+ return false;
+ }
+
+} );
+
+
+/*!
+ * jQuery UI Selectmenu 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Selectmenu
+//>>group: Widgets
+// jscs:disable maximumLineLength
+//>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
+// jscs:enable maximumLineLength
+//>>docs: http://api.jqueryui.com/selectmenu/
+//>>demos: http://jqueryui.com/selectmenu/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
+ version: "1.12.1",
+ defaultElement: "<select>",
+ options: {
+ appendTo: null,
+ classes: {
+ "ui-selectmenu-button-open": "ui-corner-top",
+ "ui-selectmenu-button-closed": "ui-corner-all"
+ },
+ disabled: null,
+ icons: {
+ button: "ui-icon-triangle-1-s"
+ },
+ position: {
+ my: "left top",
+ at: "left bottom",
+ collision: "none"
+ },
+ width: false,
+
+ // Callbacks
+ change: null,
+ close: null,
+ focus: null,
+ open: null,
+ select: null
+ },
+
+ _create: function() {
+ var selectmenuId = this.element.uniqueId().attr( "id" );
+ this.ids = {
+ element: selectmenuId,
+ button: selectmenuId + "-button",
+ menu: selectmenuId + "-menu"
+ };
+
+ this._drawButton();
+ this._drawMenu();
+ this._bindFormResetHandler();
+
+ this._rendered = false;
+ this.menuItems = $();
+ },
+
+ _drawButton: function() {
+ var icon,
+ that = this,
+ item = this._parseOption(
+ this.element.find( "option:selected" ),
+ this.element[ 0 ].selectedIndex
+ );
+
+ // Associate existing label with the new button
+ this.labels = this.element.labels().attr( "for", this.ids.button );
+ this._on( this.labels, {
+ click: function( event ) {
+ this.button.focus();
+ event.preventDefault();
+ }
+ } );
+
+ // Hide original select element
+ this.element.hide();
+
+ // Create button
+ this.button = $( "<span>", {
+ tabindex: this.options.disabled ? -1 : 0,
+ id: this.ids.button,
+ role: "combobox",
+ "aria-expanded": "false",
+ "aria-autocomplete": "list",
+ "aria-owns": this.ids.menu,
+ "aria-haspopup": "true",
+ title: this.element.attr( "title" )
+ } )
+ .insertAfter( this.element );
+
+ this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
+ "ui-button ui-widget" );
+
+ icon = $( "<span>" ).appendTo( this.button );
+ this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
+ this.buttonItem = this._renderButtonItem( item )
+ .appendTo( this.button );
+
+ if ( this.options.width !== false ) {
+ this._resizeButton();
+ }
+
+ this._on( this.button, this._buttonEvents );
+ this.button.one( "focusin", function() {
+
+ // Delay rendering the menu items until the button receives focus.
+ // The menu may have already been rendered via a programmatic open.
+ if ( !that._rendered ) {
+ that._refreshMenu();
+ }
+ } );
+ },
+
+ _drawMenu: function() {
+ var that = this;
+
+ // Create menu
+ this.menu = $( "<ul>", {
+ "aria-hidden": "true",
+ "aria-labelledby": this.ids.button,
+ id: this.ids.menu
+ } );
+
+ // Wrap menu
+ this.menuWrap = $( "<div>" ).append( this.menu );
+ this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
+ this.menuWrap.appendTo( this._appendTo() );
+
+ // Initialize menu widget
+ this.menuInstance = this.menu
+ .menu( {
+ classes: {
+ "ui-menu": "ui-corner-bottom"
+ },
+ role: "listbox",
+ select: function( event, ui ) {
+ event.preventDefault();
+
+ // Support: IE8
+ // If the item was selected via a click, the text selection
+ // will be destroyed in IE
+ that._setSelection();
+
+ that._select( ui.item.data( "ui-selectmenu-item" ), event );
+ },
+ focus: function( event, ui ) {
+ var item = ui.item.data( "ui-selectmenu-item" );
+
+ // Prevent inital focus from firing and check if its a newly focused item
+ if ( that.focusIndex != null && item.index !== that.focusIndex ) {
+ that._trigger( "focus", event, { item: item } );
+ if ( !that.isOpen ) {
+ that._select( item, event );
+ }
+ }
+ that.focusIndex = item.index;
+
+ that.button.attr( "aria-activedescendant",
+ that.menuItems.eq( item.index ).attr( "id" ) );
+ }
+ } )
+ .menu( "instance" );
+
+ // Don't close the menu on mouseleave
+ this.menuInstance._off( this.menu, "mouseleave" );
+
+ // Cancel the menu's collapseAll on document click
+ this.menuInstance._closeOnDocumentClick = function() {
+ return false;
+ };
+
+ // Selects often contain empty items, but never contain dividers
+ this.menuInstance._isDivider = function() {
+ return false;
+ };
+ },
+
+ refresh: function() {
+ this._refreshMenu();
+ this.buttonItem.replaceWith(
+ this.buttonItem = this._renderButtonItem(
+
+ // Fall back to an empty object in case there are no options
+ this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
+ )
+ );
+ if ( this.options.width === null ) {
+ this._resizeButton();
+ }
+ },
+
+ _refreshMenu: function() {
+ var item,
+ options = this.element.find( "option" );
+
+ this.menu.empty();
+
+ this._parseOptions( options );
+ this._renderMenu( this.menu, this.items );
+
+ this.menuInstance.refresh();
+ this.menuItems = this.menu.find( "li" )
+ .not( ".ui-selectmenu-optgroup" )
+ .find( ".ui-menu-item-wrapper" );
+
+ this._rendered = true;
+
+ if ( !options.length ) {
+ return;
+ }
+
+ item = this._getSelectedItem();
+
+ // Update the menu to have the correct item focused
+ this.menuInstance.focus( null, item );
+ this._setAria( item.data( "ui-selectmenu-item" ) );
+
+ // Set disabled state
+ this._setOption( "disabled", this.element.prop( "disabled" ) );
+ },
+
+ open: function( event ) {
+ if ( this.options.disabled ) {
+ return;
+ }
+
+ // If this is the first time the menu is being opened, render the items
+ if ( !this._rendered ) {
+ this._refreshMenu();
+ } else {
+
+ // Menu clears focus on close, reset focus to selected item
+ this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
+ this.menuInstance.focus( null, this._getSelectedItem() );
+ }
+
+ // If there are no options, don't open the menu
+ if ( !this.menuItems.length ) {
+ return;
+ }
+
+ this.isOpen = true;
+ this._toggleAttr();
+ this._resizeMenu();
+ this._position();
+
+ this._on( this.document, this._documentClick );
+
+ this._trigger( "open", event );
+ },
+
+ _position: function() {
+ this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
+ },
+
+ close: function( event ) {
+ if ( !this.isOpen ) {
+ return;
+ }
+
+ this.isOpen = false;
+ this._toggleAttr();
+
+ this.range = null;
+ this._off( this.document );
+
+ this._trigger( "close", event );
+ },
+
+ widget: function() {
+ return this.button;
+ },
+
+ menuWidget: function() {
+ return this.menu;
+ },
+
+ _renderButtonItem: function( item ) {
+ var buttonItem = $( "<span>" );
+
+ this._setText( buttonItem, item.label );
+ this._addClass( buttonItem, "ui-selectmenu-text" );
+
+ return buttonItem;
+ },
+
+ _renderMenu: function( ul, items ) {
+ var that = this,
+ currentOptgroup = "";
+
+ $.each( items, function( index, item ) {
+ var li;
+
+ if ( item.optgroup !== currentOptgroup ) {
+ li = $( "<li>", {
+ text: item.optgroup
+ } );
+ that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
+ ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
+ " ui-state-disabled" :
+ "" ) );
+
+ li.appendTo( ul );
+
+ currentOptgroup = item.optgroup;
+ }
+
+ that._renderItemData( ul, item );
+ } );
+ },
+
+ _renderItemData: function( ul, item ) {
+ return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
+ },
+
+ _renderItem: function( ul, item ) {
+ var li = $( "<li>" ),
+ wrapper = $( "<div>", {
+ title: item.element.attr( "title" )
+ } );
+
+ if ( item.disabled ) {
+ this._addClass( li, null, "ui-state-disabled" );
+ }
+ this._setText( wrapper, item.label );
+
+ return li.append( wrapper ).appendTo( ul );
+ },
+
+ _setText: function( element, value ) {
+ if ( value ) {
+ element.text( value );
+ } else {
+ element.html( " " );
+ }
+ },
+
+ _move: function( direction, event ) {
+ var item, next,
+ filter = ".ui-menu-item";
+
+ if ( this.isOpen ) {
+ item = this.menuItems.eq( this.focusIndex ).parent( "li" );
+ } else {
+ item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
+ filter += ":not(.ui-state-disabled)";
+ }
+
+ if ( direction === "first" || direction === "last" ) {
+ next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
+ } else {
+ next = item[ direction + "All" ]( filter ).eq( 0 );
+ }
+
+ if ( next.length ) {
+ this.menuInstance.focus( event, next );
+ }
+ },
+
+ _getSelectedItem: function() {
+ return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
+ },
+
+ _toggle: function( event ) {
+ this[ this.isOpen ? "close" : "open" ]( event );
+ },
+
+ _setSelection: function() {
+ var selection;
+
+ if ( !this.range ) {
+ return;
+ }
+
+ if ( window.getSelection ) {
+ selection = window.getSelection();
+ selection.removeAllRanges();
+ selection.addRange( this.range );
+
+ // Support: IE8
+ } else {
+ this.range.select();
+ }
+
+ // Support: IE
+ // Setting the text selection kills the button focus in IE, but
+ // restoring the focus doesn't kill the selection.
+ this.button.focus();
+ },
+
+ _documentClick: {
+ mousedown: function( event ) {
+ if ( !this.isOpen ) {
+ return;
+ }
+
+ if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
+ $.ui.escapeSelector( this.ids.button ) ).length ) {
+ this.close( event );
+ }
+ }
+ },
+
+ _buttonEvents: {
+
+ // Prevent text selection from being reset when interacting with the selectmenu (#10144)
+ mousedown: function() {
+ var selection;
+
+ if ( window.getSelection ) {
+ selection = window.getSelection();
+ if ( selection.rangeCount ) {
+ this.range = selection.getRangeAt( 0 );
+ }
+
+ // Support: IE8
+ } else {
+ this.range = document.selection.createRange();
+ }
+ },
+
+ click: function( event ) {
+ this._setSelection();
+ this._toggle( event );
+ },
+
+ keydown: function( event ) {
+ var preventDefault = true;
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.TAB:
+ case $.ui.keyCode.ESCAPE:
+ this.close( event );
+ preventDefault = false;
+ break;
+ case $.ui.keyCode.ENTER:
+ if ( this.isOpen ) {
+ this._selectFocusedItem( event );
+ }
+ break;
+ case $.ui.keyCode.UP:
+ if ( event.altKey ) {
+ this._toggle( event );
+ } else {
+ this._move( "prev", event );
+ }
+ break;
+ case $.ui.keyCode.DOWN:
+ if ( event.altKey ) {
+ this._toggle( event );
+ } else {
+ this._move( "next", event );
+ }
+ break;
+ case $.ui.keyCode.SPACE:
+ if ( this.isOpen ) {
+ this._selectFocusedItem( event );
+ } else {
+ this._toggle( event );
+ }
+ break;
+ case $.ui.keyCode.LEFT:
+ this._move( "prev", event );
+ break;
+ case $.ui.keyCode.RIGHT:
+ this._move( "next", event );
+ break;
+ case $.ui.keyCode.HOME:
+ case $.ui.keyCode.PAGE_UP:
+ this._move( "first", event );
+ break;
+ case $.ui.keyCode.END:
+ case $.ui.keyCode.PAGE_DOWN:
+ this._move( "last", event );
+ break;
+ default:
+ this.menu.trigger( event );
+ preventDefault = false;
+ }
+
+ if ( preventDefault ) {
+ event.preventDefault();
+ }
+ }
+ },
+
+ _selectFocusedItem: function( event ) {
+ var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
+ if ( !item.hasClass( "ui-state-disabled" ) ) {
+ this._select( item.data( "ui-selectmenu-item" ), event );
+ }
+ },
+
+ _select: function( item, event ) {
+ var oldIndex = this.element[ 0 ].selectedIndex;
+
+ // Change native select element
+ this.element[ 0 ].selectedIndex = item.index;
+ this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
+ this._setAria( item );
+ this._trigger( "select", event, { item: item } );
+
+ if ( item.index !== oldIndex ) {
+ this._trigger( "change", event, { item: item } );
+ }
+
+ this.close( event );
+ },
+
+ _setAria: function( item ) {
+ var id = this.menuItems.eq( item.index ).attr( "id" );
+
+ this.button.attr( {
+ "aria-labelledby": id,
+ "aria-activedescendant": id
+ } );
+ this.menu.attr( "aria-activedescendant", id );
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "icons" ) {
+ var icon = this.button.find( "span.ui-icon" );
+ this._removeClass( icon, null, this.options.icons.button )
+ ._addClass( icon, null, value.button );
+ }
+
+ this._super( key, value );
+
+ if ( key === "appendTo" ) {
+ this.menuWrap.appendTo( this._appendTo() );
+ }
+
+ if ( key === "width" ) {
+ this._resizeButton();
+ }
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.menuInstance.option( "disabled", value );
+ this.button.attr( "aria-disabled", value );
+ this._toggleClass( this.button, null, "ui-state-disabled", value );
+
+ this.element.prop( "disabled", value );
+ if ( value ) {
+ this.button.attr( "tabindex", -1 );
+ this.close();
+ } else {
+ this.button.attr( "tabindex", 0 );
+ }
+ },
+
+ _appendTo: function() {
+ var element = this.options.appendTo;
+
+ if ( element ) {
+ element = element.jquery || element.nodeType ?
+ $( element ) :
+ this.document.find( element ).eq( 0 );
+ }
+
+ if ( !element || !element[ 0 ] ) {
+ element = this.element.closest( ".ui-front, dialog" );
+ }
+
+ if ( !element.length ) {
+ element = this.document[ 0 ].body;
+ }
+
+ return element;
+ },
+
+ _toggleAttr: function() {
+ this.button.attr( "aria-expanded", this.isOpen );
+
+ // We can't use two _toggleClass() calls here, because we need to make sure
+ // we always remove classes first and add them second, otherwise if both classes have the
+ // same theme class, it will be removed after we add it.
+ this._removeClass( this.button, "ui-selectmenu-button-" +
+ ( this.isOpen ? "closed" : "open" ) )
+ ._addClass( this.button, "ui-selectmenu-button-" +
+ ( this.isOpen ? "open" : "closed" ) )
+ ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
+
+ this.menu.attr( "aria-hidden", !this.isOpen );
+ },
+
+ _resizeButton: function() {
+ var width = this.options.width;
+
+ // For `width: false`, just remove inline style and stop
+ if ( width === false ) {
+ this.button.css( "width", "" );
+ return;
+ }
+
+ // For `width: null`, match the width of the original element
+ if ( width === null ) {
+ width = this.element.show().outerWidth();
+ this.element.hide();
+ }
+
+ this.button.outerWidth( width );
+ },
+
+ _resizeMenu: function() {
+ this.menu.outerWidth( Math.max(
+ this.button.outerWidth(),
+
+ // Support: IE10
+ // IE10 wraps long text (possibly a rounding bug)
+ // so we add 1px to avoid the wrapping
+ this.menu.width( "" ).outerWidth() + 1
+ ) );
+ },
+
+ _getCreateOptions: function() {
+ var options = this._super();
+
+ options.disabled = this.element.prop( "disabled" );
+
+ return options;
+ },
+
+ _parseOptions: function( options ) {
+ var that = this,
+ data = [];
+ options.each( function( index, item ) {
+ data.push( that._parseOption( $( item ), index ) );
+ } );
+ this.items = data;
+ },
+
+ _parseOption: function( option, index ) {
+ var optgroup = option.parent( "optgroup" );
+
+ return {
+ element: option,
+ index: index,
+ value: option.val(),
+ label: option.text(),
+ optgroup: optgroup.attr( "label" ) || "",
+ disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
+ };
+ },
+
+ _destroy: function() {
+ this._unbindFormResetHandler();
+ this.menuWrap.remove();
+ this.button.remove();
+ this.element.show();
+ this.element.removeUniqueId();
+ this.labels.attr( "for", this.ids.element );
+ }
+} ] );
+
+
+/*!
+ * jQuery UI Slider 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Slider
+//>>group: Widgets
+//>>description: Displays a flexible slider with ranges and accessibility via keyboard.
+//>>docs: http://api.jqueryui.com/slider/
+//>>demos: http://jqueryui.com/slider/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/slider.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
+ version: "1.12.1",
+ widgetEventPrefix: "slide",
+
+ options: {
+ animate: false,
+ classes: {
+ "ui-slider": "ui-corner-all",
+ "ui-slider-handle": "ui-corner-all",
+
+ // Note: ui-widget-header isn't the most fittingly semantic framework class for this
+ // element, but worked best visually with a variety of themes
+ "ui-slider-range": "ui-corner-all ui-widget-header"
+ },
+ distance: 0,
+ max: 100,
+ min: 0,
+ orientation: "horizontal",
+ range: false,
+ step: 1,
+ value: 0,
+ values: null,
+
+ // Callbacks
+ change: null,
+ slide: null,
+ start: null,
+ stop: null
+ },
+
+ // Number of pages in a slider
+ // (how many times can you page up/down to go through the whole range)
+ numPages: 5,
+
+ _create: function() {
+ this._keySliding = false;
+ this._mouseSliding = false;
+ this._animateOff = true;
+ this._handleIndex = null;
+ this._detectOrientation();
+ this._mouseInit();
+ this._calculateNewMax();
+
+ this._addClass( "ui-slider ui-slider-" + this.orientation,
+ "ui-widget ui-widget-content" );
+
+ this._refresh();
+
+ this._animateOff = false;
+ },
+
+ _refresh: function() {
+ this._createRange();
+ this._createHandles();
+ this._setupEvents();
+ this._refreshValue();
+ },
+
+ _createHandles: function() {
+ var i, handleCount,
+ options = this.options,
+ existingHandles = this.element.find( ".ui-slider-handle" ),
+ handle = "<span tabindex='0'></span>",
+ handles = [];
+
+ handleCount = ( options.values && options.values.length ) || 1;
+
+ if ( existingHandles.length > handleCount ) {
+ existingHandles.slice( handleCount ).remove();
+ existingHandles = existingHandles.slice( 0, handleCount );
+ }
+
+ for ( i = existingHandles.length; i < handleCount; i++ ) {
+ handles.push( handle );
+ }
+
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
+
+ this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
+
+ this.handle = this.handles.eq( 0 );
+
+ this.handles.each( function( i ) {
+ $( this )
+ .data( "ui-slider-handle-index", i )
+ .attr( "tabIndex", 0 );
+ } );
+ },
+
+ _createRange: function() {
+ var options = this.options;
+
+ if ( options.range ) {
+ if ( options.range === true ) {
+ if ( !options.values ) {
+ options.values = [ this._valueMin(), this._valueMin() ];
+ } else if ( options.values.length && options.values.length !== 2 ) {
+ options.values = [ options.values[ 0 ], options.values[ 0 ] ];
+ } else if ( $.isArray( options.values ) ) {
+ options.values = options.values.slice( 0 );
+ }
+ }
+
+ if ( !this.range || !this.range.length ) {
+ this.range = $( "<div>" )
+ .appendTo( this.element );
+
+ this._addClass( this.range, "ui-slider-range" );
+ } else {
+ this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
+
+ // Handle range switching from true to min/max
+ this.range.css( {
+ "left": "",
+ "bottom": ""
+ } );
+ }
+ if ( options.range === "min" || options.range === "max" ) {
+ this._addClass( this.range, "ui-slider-range-" + options.range );
+ }
+ } else {
+ if ( this.range ) {
+ this.range.remove();
+ }
+ this.range = null;
+ }
+ },
+
+ _setupEvents: function() {
+ this._off( this.handles );
+ this._on( this.handles, this._handleEvents );
+ this._hoverable( this.handles );
+ this._focusable( this.handles );
+ },
+
+ _destroy: function() {
+ this.handles.remove();
+ if ( this.range ) {
+ this.range.remove();
+ }
+
+ this._mouseDestroy();
+ },
+
+ _mouseCapture: function( event ) {
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
+ that = this,
+ o = this.options;
+
+ if ( o.disabled ) {
+ return false;
+ }
+
+ this.elementSize = {
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight()
+ };
+ this.elementOffset = this.element.offset();
+
+ position = { x: event.pageX, y: event.pageY };
+ normValue = this._normValueFromMouse( position );
+ distance = this._valueMax() - this._valueMin() + 1;
+ this.handles.each( function( i ) {
+ var thisDistance = Math.abs( normValue - that.values( i ) );
+ if ( ( distance > thisDistance ) ||
+ ( distance === thisDistance &&
+ ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
+ distance = thisDistance;
+ closestHandle = $( this );
+ index = i;
+ }
+ } );
+
+ allowed = this._start( event, index );
+ if ( allowed === false ) {
+ return false;
+ }
+ this._mouseSliding = true;
+
+ this._handleIndex = index;
+
+ this._addClass( closestHandle, null, "ui-state-active" );
+ closestHandle.trigger( "focus" );
+
+ offset = closestHandle.offset();
+ mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
+ this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
+ left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
+ top: event.pageY - offset.top -
+ ( closestHandle.height() / 2 ) -
+ ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
+ ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
+ ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
+ };
+
+ if ( !this.handles.hasClass( "ui-state-hover" ) ) {
+ this._slide( event, index, normValue );
+ }
+ this._animateOff = true;
+ return true;
+ },
+
+ _mouseStart: function() {
+ return true;
+ },
+
+ _mouseDrag: function( event ) {
+ var position = { x: event.pageX, y: event.pageY },
+ normValue = this._normValueFromMouse( position );
+
+ this._slide( event, this._handleIndex, normValue );
+
+ return false;
+ },
+
+ _mouseStop: function( event ) {
+ this._removeClass( this.handles, null, "ui-state-active" );
+ this._mouseSliding = false;
+
+ this._stop( event, this._handleIndex );
+ this._change( event, this._handleIndex );
+
+ this._handleIndex = null;
+ this._clickOffset = null;
+ this._animateOff = false;
+
+ return false;
+ },
+
+ _detectOrientation: function() {
+ this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
+ },
+
+ _normValueFromMouse: function( position ) {
+ var pixelTotal,
+ pixelMouse,
+ percentMouse,
+ valueTotal,
+ valueMouse;
+
+ if ( this.orientation === "horizontal" ) {
+ pixelTotal = this.elementSize.width;
+ pixelMouse = position.x - this.elementOffset.left -
+ ( this._clickOffset ? this._clickOffset.left : 0 );
+ } else {
+ pixelTotal = this.elementSize.height;
+ pixelMouse = position.y - this.elementOffset.top -
+ ( this._clickOffset ? this._clickOffset.top : 0 );
+ }
+
+ percentMouse = ( pixelMouse / pixelTotal );
+ if ( percentMouse > 1 ) {
+ percentMouse = 1;
+ }
+ if ( percentMouse < 0 ) {
+ percentMouse = 0;
+ }
+ if ( this.orientation === "vertical" ) {
+ percentMouse = 1 - percentMouse;
+ }
+
+ valueTotal = this._valueMax() - this._valueMin();
+ valueMouse = this._valueMin() + percentMouse * valueTotal;
+
+ return this._trimAlignValue( valueMouse );
+ },
+
+ _uiHash: function( index, value, values ) {
+ var uiHash = {
+ handle: this.handles[ index ],
+ handleIndex: index,
+ value: value !== undefined ? value : this.value()
+ };
+
+ if ( this._hasMultipleValues() ) {
+ uiHash.value = value !== undefined ? value : this.values( index );
+ uiHash.values = values || this.values();
+ }
+
+ return uiHash;
+ },
+
+ _hasMultipleValues: function() {
+ return this.options.values && this.options.values.length;
+ },
+
+ _start: function( event, index ) {
+ return this._trigger( "start", event, this._uiHash( index ) );
+ },
+
+ _slide: function( event, index, newVal ) {
+ var allowed, otherVal,
+ currentValue = this.value(),
+ newValues = this.values();
+
+ if ( this._hasMultipleValues() ) {
+ otherVal = this.values( index ? 0 : 1 );
+ currentValue = this.values( index );
+
+ if ( this.options.values.length === 2 && this.options.range === true ) {
+ newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
+ }
+
+ newValues[ index ] = newVal;
+ }
+
+ if ( newVal === currentValue ) {
+ return;
+ }
+
+ allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
+
+ // A slide can be canceled by returning false from the slide callback
+ if ( allowed === false ) {
+ return;
+ }
+
+ if ( this._hasMultipleValues() ) {
+ this.values( index, newVal );
+ } else {
+ this.value( newVal );
+ }
+ },
+
+ _stop: function( event, index ) {
+ this._trigger( "stop", event, this._uiHash( index ) );
+ },
+
+ _change: function( event, index ) {
+ if ( !this._keySliding && !this._mouseSliding ) {
+
+ //store the last changed value index for reference when handles overlap
+ this._lastChangedValue = index;
+ this._trigger( "change", event, this._uiHash( index ) );
+ }
+ },
+
+ value: function( newValue ) {
+ if ( arguments.length ) {
+ this.options.value = this._trimAlignValue( newValue );
+ this._refreshValue();
+ this._change( null, 0 );
+ return;
+ }
+
+ return this._value();
+ },
+
+ values: function( index, newValue ) {
+ var vals,
+ newValues,
+ i;
+
+ if ( arguments.length > 1 ) {
+ this.options.values[ index ] = this._trimAlignValue( newValue );
+ this._refreshValue();
+ this._change( null, index );
+ return;
+ }
+
+ if ( arguments.length ) {
+ if ( $.isArray( arguments[ 0 ] ) ) {
+ vals = this.options.values;
+ newValues = arguments[ 0 ];
+ for ( i = 0; i < vals.length; i += 1 ) {
+ vals[ i ] = this._trimAlignValue( newValues[ i ] );
+ this._change( null, i );
+ }
+ this._refreshValue();
+ } else {
+ if ( this._hasMultipleValues() ) {
+ return this._values( index );
+ } else {
+ return this.value();
+ }
+ }
+ } else {
+ return this._values();
+ }
+ },
+
+ _setOption: function( key, value ) {
+ var i,
+ valsLength = 0;
+
+ if ( key === "range" && this.options.range === true ) {
+ if ( value === "min" ) {
+ this.options.value = this._values( 0 );
+ this.options.values = null;
+ } else if ( value === "max" ) {
+ this.options.value = this._values( this.options.values.length - 1 );
+ this.options.values = null;
+ }
+ }
+
+ if ( $.isArray( this.options.values ) ) {
+ valsLength = this.options.values.length;
+ }
+
+ this._super( key, value );
+
+ switch ( key ) {
+ case "orientation":
+ this._detectOrientation();
+ this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
+ ._addClass( "ui-slider-" + this.orientation );
+ this._refreshValue();
+ if ( this.options.range ) {
+ this._refreshRange( value );
+ }
+
+ // Reset positioning from previous orientation
+ this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
+ break;
+ case "value":
+ this._animateOff = true;
+ this._refreshValue();
+ this._change( null, 0 );
+ this._animateOff = false;
+ break;
+ case "values":
+ this._animateOff = true;
+ this._refreshValue();
+
+ // Start from the last handle to prevent unreachable handles (#9046)
+ for ( i = valsLength - 1; i >= 0; i-- ) {
+ this._change( null, i );
+ }
+ this._animateOff = false;
+ break;
+ case "step":
+ case "min":
+ case "max":
+ this._animateOff = true;
+ this._calculateNewMax();
+ this._refreshValue();
+ this._animateOff = false;
+ break;
+ case "range":
+ this._animateOff = true;
+ this._refresh();
+ this._animateOff = false;
+ break;
+ }
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
+ //internal value getter
+ // _value() returns value trimmed by min and max, aligned by step
+ _value: function() {
+ var val = this.options.value;
+ val = this._trimAlignValue( val );
+
+ return val;
+ },
+
+ //internal values getter
+ // _values() returns array of values trimmed by min and max, aligned by step
+ // _values( index ) returns single value trimmed by min and max, aligned by step
+ _values: function( index ) {
+ var val,
+ vals,
+ i;
+
+ if ( arguments.length ) {
+ val = this.options.values[ index ];
+ val = this._trimAlignValue( val );
+
+ return val;
+ } else if ( this._hasMultipleValues() ) {
+
+ // .slice() creates a copy of the array
+ // this copy gets trimmed by min and max and then returned
+ vals = this.options.values.slice();
+ for ( i = 0; i < vals.length; i += 1 ) {
+ vals[ i ] = this._trimAlignValue( vals[ i ] );
+ }
+
+ return vals;
+ } else {
+ return [];
+ }
+ },
+
+ // Returns the step-aligned value that val is closest to, between (inclusive) min and max
+ _trimAlignValue: function( val ) {
+ if ( val <= this._valueMin() ) {
+ return this._valueMin();
+ }
+ if ( val >= this._valueMax() ) {
+ return this._valueMax();
+ }
+ var step = ( this.options.step > 0 ) ? this.options.step : 1,
+ valModStep = ( val - this._valueMin() ) % step,
+ alignValue = val - valModStep;
+
+ if ( Math.abs( valModStep ) * 2 >= step ) {
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
+ }
+
+ // Since JavaScript has problems with large floats, round
+ // the final value to 5 digits after the decimal point (see #4124)
+ return parseFloat( alignValue.toFixed( 5 ) );
+ },
+
+ _calculateNewMax: function() {
+ var max = this.options.max,
+ min = this._valueMin(),
+ step = this.options.step,
+ aboveMin = Math.round( ( max - min ) / step ) * step;
+ max = aboveMin + min;
+ if ( max > this.options.max ) {
+
+ //If max is not divisible by step, rounding off may increase its value
+ max -= step;
+ }
+ this.max = parseFloat( max.toFixed( this._precision() ) );
+ },
+
+ _precision: function() {
+ var precision = this._precisionOf( this.options.step );
+ if ( this.options.min !== null ) {
+ precision = Math.max( precision, this._precisionOf( this.options.min ) );
+ }
+ return precision;
+ },
+
+ _precisionOf: function( num ) {
+ var str = num.toString(),
+ decimal = str.indexOf( "." );
+ return decimal === -1 ? 0 : str.length - decimal - 1;
+ },
+
+ _valueMin: function() {
+ return this.options.min;
+ },
+
+ _valueMax: function() {
+ return this.max;
+ },
+
+ _refreshRange: function( orientation ) {
+ if ( orientation === "vertical" ) {
+ this.range.css( { "width": "", "left": "" } );
+ }
+ if ( orientation === "horizontal" ) {
+ this.range.css( { "height": "", "bottom": "" } );
+ }
+ },
+
+ _refreshValue: function() {
+ var lastValPercent, valPercent, value, valueMin, valueMax,
+ oRange = this.options.range,
+ o = this.options,
+ that = this,
+ animate = ( !this._animateOff ) ? o.animate : false,
+ _set = {};
+
+ if ( this._hasMultipleValues() ) {
+ this.handles.each( function( i ) {
+ valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
+ that._valueMin() ) * 100;
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
+ if ( that.options.range === true ) {
+ if ( that.orientation === "horizontal" ) {
+ if ( i === 0 ) {
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ left: valPercent + "%"
+ }, o.animate );
+ }
+ if ( i === 1 ) {
+ that.range[ animate ? "animate" : "css" ]( {
+ width: ( valPercent - lastValPercent ) + "%"
+ }, {
+ queue: false,
+ duration: o.animate
+ } );
+ }
+ } else {
+ if ( i === 0 ) {
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ bottom: ( valPercent ) + "%"
+ }, o.animate );
+ }
+ if ( i === 1 ) {
+ that.range[ animate ? "animate" : "css" ]( {
+ height: ( valPercent - lastValPercent ) + "%"
+ }, {
+ queue: false,
+ duration: o.animate
+ } );
+ }
+ }
+ }
+ lastValPercent = valPercent;
+ } );
+ } else {
+ value = this.value();
+ valueMin = this._valueMin();
+ valueMax = this._valueMax();
+ valPercent = ( valueMax !== valueMin ) ?
+ ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
+ 0;
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
+
+ if ( oRange === "min" && this.orientation === "horizontal" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ width: valPercent + "%"
+ }, o.animate );
+ }
+ if ( oRange === "max" && this.orientation === "horizontal" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ width: ( 100 - valPercent ) + "%"
+ }, o.animate );
+ }
+ if ( oRange === "min" && this.orientation === "vertical" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ height: valPercent + "%"
+ }, o.animate );
+ }
+ if ( oRange === "max" && this.orientation === "vertical" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
+ height: ( 100 - valPercent ) + "%"
+ }, o.animate );
+ }
+ }
+ },
+
+ _handleEvents: {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ case $.ui.keyCode.END:
+ case $.ui.keyCode.PAGE_UP:
+ case $.ui.keyCode.PAGE_DOWN:
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ event.preventDefault();
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ this._addClass( $( event.target ), null, "ui-state-active" );
+ allowed = this._start( event, index );
+ if ( allowed === false ) {
+ return;
+ }
+ }
+ break;
+ }
+
+ step = this.options.step;
+ if ( this._hasMultipleValues() ) {
+ curVal = newVal = this.values( index );
+ } else {
+ curVal = newVal = this.value();
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ newVal = this._valueMin();
+ break;
+ case $.ui.keyCode.END:
+ newVal = this._valueMax();
+ break;
+ case $.ui.keyCode.PAGE_UP:
+ newVal = this._trimAlignValue(
+ curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
+ );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ newVal = this._trimAlignValue(
+ curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
+ break;
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ if ( curVal === this._valueMax() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal + step );
+ break;
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ if ( curVal === this._valueMin() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal - step );
+ break;
+ }
+
+ this._slide( event, index, newVal );
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
+
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ this._removeClass( $( event.target ), null, "ui-state-active" );
+ }
+ }
+ }
+} );
+
+
+/*!
+ * jQuery UI Sortable 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Sortable
+//>>group: Interactions
+//>>description: Enables items in a list to be sorted using the mouse.
+//>>docs: http://api.jqueryui.com/sortable/
+//>>demos: http://jqueryui.com/sortable/
+//>>css.structure: ../../themes/base/sortable.css
+
+
+
+var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
+ version: "1.12.1",
+ widgetEventPrefix: "sort",
+ ready: false,
+ options: {
+ appendTo: "parent",
+ axis: false,
+ connectWith: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ dropOnEmpty: true,
+ forcePlaceholderSize: false,
+ forceHelperSize: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ items: "> *",
+ opacity: false,
+ placeholder: false,
+ revert: false,
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ scope: "default",
+ tolerance: "intersect",
+ zIndex: 1000,
+
+ // Callbacks
+ activate: null,
+ beforeStop: null,
+ change: null,
+ deactivate: null,
+ out: null,
+ over: null,
+ receive: null,
+ remove: null,
+ sort: null,
+ start: null,
+ stop: null,
+ update: null
+ },
+
+ _isOverAxis: function( x, reference, size ) {
+ return ( x >= reference ) && ( x < ( reference + size ) );
+ },
+
+ _isFloating: function( item ) {
+ return ( /left|right/ ).test( item.css( "float" ) ) ||
+ ( /inline|table-cell/ ).test( item.css( "display" ) );
+ },
+
+ _create: function() {
+ this.containerCache = {};
+ this._addClass( "ui-sortable" );
+
+ //Get the items
+ this.refresh();
+
+ //Let's determine the parent's offset
+ this.offset = this.element.offset();
+
+ //Initialize mouse events for interaction
+ this._mouseInit();
+
+ this._setHandleClassName();
+
+ //We're ready to go
+ this.ready = true;
+
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+
+ if ( key === "handle" ) {
+ this._setHandleClassName();
+ }
+ },
+
+ _setHandleClassName: function() {
+ var that = this;
+ this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
+ $.each( this.items, function() {
+ that._addClass(
+ this.instance.options.handle ?
+ this.item.find( this.instance.options.handle ) :
+ this.item,
+ "ui-sortable-handle"
+ );
+ } );
+ },
+
+ _destroy: function() {
+ this._mouseDestroy();
+
+ for ( var i = this.items.length - 1; i >= 0; i-- ) {
+ this.items[ i ].item.removeData( this.widgetName + "-item" );
+ }
+
+ return this;
+ },
+
+ _mouseCapture: function( event, overrideHandle ) {
+ var currentItem = null,
+ validHandle = false,
+ that = this;
+
+ if ( this.reverting ) {
+ return false;
+ }
+
+ if ( this.options.disabled || this.options.type === "static" ) {
+ return false;
+ }
+
+ //We have to refresh the items data once first
+ this._refreshItems( event );
+
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items
+ $( event.target ).parents().each( function() {
+ if ( $.data( this, that.widgetName + "-item" ) === that ) {
+ currentItem = $( this );
+ return false;
+ }
+ } );
+ if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
+ currentItem = $( event.target );
+ }
+
+ if ( !currentItem ) {
+ return false;
+ }
+ if ( this.options.handle && !overrideHandle ) {
+ $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
+ if ( this === event.target ) {
+ validHandle = true;
+ }
+ } );
+ if ( !validHandle ) {
+ return false;
+ }
+ }
+
+ this.currentItem = currentItem;
+ this._removeCurrentsFromItems();
+ return true;
+
+ },
+
+ _mouseStart: function( event, overrideHandle, noActivation ) {
+
+ var i, body,
+ o = this.options;
+
+ this.currentContainer = this;
+
+ //We only need to call refreshPositions, because the refreshItems call has been moved to
+ // mouseCapture
+ this.refreshPositions();
+
+ //Create and append the visible helper
+ this.helper = this._createHelper( event );
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Get the next scrolling parent
+ this.scrollParent = this.helper.scrollParent();
+
+ //The element's absolute position on the page minus margins
+ this.offset = this.currentItem.offset();
+ this.offset = {
+ top: this.offset.top - this.margins.top,
+ left: this.offset.left - this.margins.left
+ };
+
+ $.extend( this.offset, {
+ click: { //Where the click happened, relative to the element
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ },
+ parent: this._getParentOffset(),
+
+ // This is a relative to absolute position minus the actual position calculation -
+ // only used for relative positioned helper
+ relative: this._getRelativeOffset()
+ } );
+
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css( "position", "absolute" );
+ this.cssPosition = this.helper.css( "position" );
+
+ //Generate the original position
+ this.originalPosition = this._generatePosition( event );
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
+
+ //Cache the former DOM position
+ this.domPosition = {
+ prev: this.currentItem.prev()[ 0 ],
+ parent: this.currentItem.parent()[ 0 ]
+ };
+
+ // If the helper is not the original, hide the original so it's not playing any role during
+ // the drag, won't cause anything bad this way
+ if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
+ this.currentItem.hide();
+ }
+
+ //Create the placeholder
+ this._createPlaceholder();
+
+ //Set a containment if given in the options
+ if ( o.containment ) {
+ this._setContainment();
+ }
+
+ if ( o.cursor && o.cursor !== "auto" ) { // cursor option
+ body = this.document.find( "body" );
+
+ // Support: IE
+ this.storedCursor = body.css( "cursor" );
+ body.css( "cursor", o.cursor );
+
+ this.storedStylesheet =
+ $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
+ }
+
+ if ( o.opacity ) { // opacity option
+ if ( this.helper.css( "opacity" ) ) {
+ this._storedOpacity = this.helper.css( "opacity" );
+ }
+ this.helper.css( "opacity", o.opacity );
+ }
+
+ if ( o.zIndex ) { // zIndex option
+ if ( this.helper.css( "zIndex" ) ) {
+ this._storedZIndex = this.helper.css( "zIndex" );
+ }
+ this.helper.css( "zIndex", o.zIndex );
+ }
+
+ //Prepare scrolling
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ this.scrollParent[ 0 ].tagName !== "HTML" ) {
+ this.overflowOffset = this.scrollParent.offset();
+ }
+
+ //Call callbacks
+ this._trigger( "start", event, this._uiHash() );
+
+ //Recache the helper size
+ if ( !this._preserveHelperProportions ) {
+ this._cacheHelperProportions();
+ }
+
+ //Post "activate" events to possible containers
+ if ( !noActivation ) {
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+ this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
+ }
+ }
+
+ //Prepare possible droppables
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.current = this;
+ }
+
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
+ }
+
+ this.dragging = true;
+
+ this._addClass( this.helper, "ui-sortable-helper" );
+
+ // Execute the drag once - this causes the helper not to be visiblebefore getting its
+ // correct position
+ this._mouseDrag( event );
+ return true;
+
+ },
+
+ _mouseDrag: function( event ) {
+ var i, item, itemElement, intersection,
+ o = this.options,
+ scrolled = false;
+
+ //Compute the helpers position
+ this.position = this._generatePosition( event );
+ this.positionAbs = this._convertPositionTo( "absolute" );
+
+ if ( !this.lastPositionAbs ) {
+ this.lastPositionAbs = this.positionAbs;
+ }
+
+ //Do scrolling
+ if ( this.options.scroll ) {
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ this.scrollParent[ 0 ].tagName !== "HTML" ) {
+
+ if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
+ event.pageY < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollTop =
+ scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
+ } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollTop =
+ scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
+ }
+
+ if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
+ event.pageX < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollLeft = scrolled =
+ this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
+ } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollLeft = scrolled =
+ this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
+ }
+
+ } else {
+
+ if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
+ scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
+ } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
+ o.scrollSensitivity ) {
+ scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
+ }
+
+ if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
+ scrolled = this.document.scrollLeft(
+ this.document.scrollLeft() - o.scrollSpeed
+ );
+ } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
+ o.scrollSensitivity ) {
+ scrolled = this.document.scrollLeft(
+ this.document.scrollLeft() + o.scrollSpeed
+ );
+ }
+
+ }
+
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
+ }
+ }
+
+ //Regenerate the absolute position used for position checks
+ this.positionAbs = this._convertPositionTo( "absolute" );
+
+ //Set the helper position
+ if ( !this.options.axis || this.options.axis !== "y" ) {
+ this.helper[ 0 ].style.left = this.position.left + "px";
+ }
+ if ( !this.options.axis || this.options.axis !== "x" ) {
+ this.helper[ 0 ].style.top = this.position.top + "px";
+ }
+
+ //Rearrange
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
+
+ //Cache variables and intersection, continue if no intersection
+ item = this.items[ i ];
+ itemElement = item.item[ 0 ];
+ intersection = this._intersectsWithPointer( item );
+ if ( !intersection ) {
+ continue;
+ }
+
+ // Only put the placeholder inside the current Container, skip all
+ // items from other containers. This works because when moving
+ // an item from one container to another the
+ // currentContainer is switched before the placeholder is moved.
+ //
+ // Without this, moving items in "sub-sortables" can cause
+ // the placeholder to jitter between the outer and inner container.
+ if ( item.instance !== this.currentContainer ) {
+ continue;
+ }
+
+ // Cannot intersect with itself
+ // no useless actions that have been done before
+ // no action if the item moved is the parent of the item checked
+ if ( itemElement !== this.currentItem[ 0 ] &&
+ this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
+ !$.contains( this.placeholder[ 0 ], itemElement ) &&
+ ( this.options.type === "semi-dynamic" ?
+ !$.contains( this.element[ 0 ], itemElement ) :
+ true
+ )
+ ) {
+
+ this.direction = intersection === 1 ? "down" : "up";
+
+ if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
+ this._rearrange( event, item );
+ } else {
+ break;
+ }
+
+ this._trigger( "change", event, this._uiHash() );
+ break;
+ }
+ }
+
+ //Post events to containers
+ this._contactContainers( event );
+
+ //Interconnect with droppables
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.drag( this, event );
+ }
+
+ //Call callbacks
+ this._trigger( "sort", event, this._uiHash() );
+
+ this.lastPositionAbs = this.positionAbs;
+ return false;
+
+ },
+
+ _mouseStop: function( event, noPropagation ) {
+
+ if ( !event ) {
+ return;
+ }
+
+ //If we are using droppables, inform the manager about the drop
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
+ $.ui.ddmanager.drop( this, event );
+ }
+
+ if ( this.options.revert ) {
+ var that = this,
+ cur = this.placeholder.offset(),
+ axis = this.options.axis,
+ animation = {};
+
+ if ( !axis || axis === "x" ) {
+ animation.left = cur.left - this.offset.parent.left - this.margins.left +
+ ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
+ 0 :
+ this.offsetParent[ 0 ].scrollLeft
+ );
+ }
+ if ( !axis || axis === "y" ) {
+ animation.top = cur.top - this.offset.parent.top - this.margins.top +
+ ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
+ 0 :
+ this.offsetParent[ 0 ].scrollTop
+ );
+ }
+ this.reverting = true;
+ $( this.helper ).animate(
+ animation,
+ parseInt( this.options.revert, 10 ) || 500,
+ function() {
+ that._clear( event );
+ }
+ );
+ } else {
+ this._clear( event, noPropagation );
+ }
+
+ return false;
+
+ },
+
+ cancel: function() {
+
+ if ( this.dragging ) {
+
+ this._mouseUp( new $.Event( "mouseup", { target: null } ) );
+
+ if ( this.options.helper === "original" ) {
+ this.currentItem.css( this._storedCSS );
+ this._removeClass( this.currentItem, "ui-sortable-helper" );
+ } else {
+ this.currentItem.show();
+ }
+
+ //Post deactivating events to containers
+ for ( var i = this.containers.length - 1; i >= 0; i-- ) {
+ this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
+ if ( this.containers[ i ].containerCache.over ) {
+ this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
+ this.containers[ i ].containerCache.over = 0;
+ }
+ }
+
+ }
+
+ if ( this.placeholder ) {
+
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
+ // it unbinds ALL events from the original node!
+ if ( this.placeholder[ 0 ].parentNode ) {
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
+ }
+ if ( this.options.helper !== "original" && this.helper &&
+ this.helper[ 0 ].parentNode ) {
+ this.helper.remove();
+ }
+
+ $.extend( this, {
+ helper: null,
+ dragging: false,
+ reverting: false,
+ _noFinalSort: null
+ } );
+
+ if ( this.domPosition.prev ) {
+ $( this.domPosition.prev ).after( this.currentItem );
+ } else {
+ $( this.domPosition.parent ).prepend( this.currentItem );
+ }
+ }
+
+ return this;
+
+ },
+
+ serialize: function( o ) {
+
+ var items = this._getItemsAsjQuery( o && o.connected ),
+ str = [];
+ o = o || {};
+
+ $( items ).each( function() {
+ var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
+ .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
+ if ( res ) {
+ str.push(
+ ( o.key || res[ 1 ] + "[]" ) +
+ "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
+ }
+ } );
+
+ if ( !str.length && o.key ) {
+ str.push( o.key + "=" );
+ }
+
+ return str.join( "&" );
+
+ },
+
+ toArray: function( o ) {
+
+ var items = this._getItemsAsjQuery( o && o.connected ),
+ ret = [];
+
+ o = o || {};
+
+ items.each( function() {
+ ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
+ } );
+ return ret;
+
+ },
+
+ /* Be careful with the following core functions */
+ _intersectsWith: function( item ) {
+
+ var x1 = this.positionAbs.left,
+ x2 = x1 + this.helperProportions.width,
+ y1 = this.positionAbs.top,
+ y2 = y1 + this.helperProportions.height,
+ l = item.left,
+ r = l + item.width,
+ t = item.top,
+ b = t + item.height,
+ dyClick = this.offset.click.top,
+ dxClick = this.offset.click.left,
+ isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
+ ( y1 + dyClick ) < b ),
+ isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
+ ( x1 + dxClick ) < r ),
+ isOverElement = isOverElementHeight && isOverElementWidth;
+
+ if ( this.options.tolerance === "pointer" ||
+ this.options.forcePointerForContainers ||
+ ( this.options.tolerance !== "pointer" &&
+ this.helperProportions[ this.floating ? "width" : "height" ] >
+ item[ this.floating ? "width" : "height" ] )
+ ) {
+ return isOverElement;
+ } else {
+
+ return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
+ x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
+ t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
+ y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
+
+ }
+ },
+
+ _intersectsWithPointer: function( item ) {
+ var verticalDirection, horizontalDirection,
+ isOverElementHeight = ( this.options.axis === "x" ) ||
+ this._isOverAxis(
+ this.positionAbs.top + this.offset.click.top, item.top, item.height ),
+ isOverElementWidth = ( this.options.axis === "y" ) ||
+ this._isOverAxis(
+ this.positionAbs.left + this.offset.click.left, item.left, item.width ),
+ isOverElement = isOverElementHeight && isOverElementWidth;
+
+ if ( !isOverElement ) {
+ return false;
+ }
+
+ verticalDirection = this._getDragVerticalDirection();
+ horizontalDirection = this._getDragHorizontalDirection();
+
+ return this.floating ?
+ ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
+ : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
+
+ },
+
+ _intersectsWithSides: function( item ) {
+
+ var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
+ this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
+ isOverRightHalf = this._isOverAxis( this.positionAbs.left +
+ this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
+ verticalDirection = this._getDragVerticalDirection(),
+ horizontalDirection = this._getDragHorizontalDirection();
+
+ if ( this.floating && horizontalDirection ) {
+ return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
+ ( horizontalDirection === "left" && !isOverRightHalf ) );
+ } else {
+ return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
+ ( verticalDirection === "up" && !isOverBottomHalf ) );
+ }
+
+ },
+
+ _getDragVerticalDirection: function() {
+ var delta = this.positionAbs.top - this.lastPositionAbs.top;
+ return delta !== 0 && ( delta > 0 ? "down" : "up" );
+ },
+
+ _getDragHorizontalDirection: function() {
+ var delta = this.positionAbs.left - this.lastPositionAbs.left;
+ return delta !== 0 && ( delta > 0 ? "right" : "left" );
+ },
+
+ refresh: function( event ) {
+ this._refreshItems( event );
+ this._setHandleClassName();
+ this.refreshPositions();
+ return this;
+ },
+
+ _connectWith: function() {
+ var options = this.options;
+ return options.connectWith.constructor === String ?
+ [ options.connectWith ] :
+ options.connectWith;
+ },
+
+ _getItemsAsjQuery: function( connected ) {
+
+ var i, j, cur, inst,
+ items = [],
+ queries = [],
+ connectWith = this._connectWith();
+
+ if ( connectWith && connected ) {
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
+ cur = $( connectWith[ i ], this.document[ 0 ] );
+ for ( j = cur.length - 1; j >= 0; j-- ) {
+ inst = $.data( cur[ j ], this.widgetFullName );
+ if ( inst && inst !== this && !inst.options.disabled ) {
+ queries.push( [ $.isFunction( inst.options.items ) ?
+ inst.options.items.call( inst.element ) :
+ $( inst.options.items, inst.element )
+ .not( ".ui-sortable-helper" )
+ .not( ".ui-sortable-placeholder" ), inst ] );
+ }
+ }
+ }
+ }
+
+ queries.push( [ $.isFunction( this.options.items ) ?
+ this.options.items
+ .call( this.element, null, { options: this.options, item: this.currentItem } ) :
+ $( this.options.items, this.element )
+ .not( ".ui-sortable-helper" )
+ .not( ".ui-sortable-placeholder" ), this ] );
+
+ function addItems() {
+ items.push( this );
+ }
+ for ( i = queries.length - 1; i >= 0; i-- ) {
+ queries[ i ][ 0 ].each( addItems );
+ }
+
+ return $( items );
+
+ },
+
+ _removeCurrentsFromItems: function() {
+
+ var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
+
+ this.items = $.grep( this.items, function( item ) {
+ for ( var j = 0; j < list.length; j++ ) {
+ if ( list[ j ] === item.item[ 0 ] ) {
+ return false;
+ }
+ }
+ return true;
+ } );
+
+ },
+
+ _refreshItems: function( event ) {
+
+ this.items = [];
+ this.containers = [ this ];
+
+ var i, j, cur, inst, targetData, _queries, item, queriesLength,
+ items = this.items,
+ queries = [ [ $.isFunction( this.options.items ) ?
+ this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
+ $( this.options.items, this.element ), this ] ],
+ connectWith = this._connectWith();
+
+ //Shouldn't be run the first time through due to massive slow-down
+ if ( connectWith && this.ready ) {
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
+ cur = $( connectWith[ i ], this.document[ 0 ] );
+ for ( j = cur.length - 1; j >= 0; j-- ) {
+ inst = $.data( cur[ j ], this.widgetFullName );
+ if ( inst && inst !== this && !inst.options.disabled ) {
+ queries.push( [ $.isFunction( inst.options.items ) ?
+ inst.options.items
+ .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
+ $( inst.options.items, inst.element ), inst ] );
+ this.containers.push( inst );
+ }
+ }
+ }
+ }
+
+ for ( i = queries.length - 1; i >= 0; i-- ) {
+ targetData = queries[ i ][ 1 ];
+ _queries = queries[ i ][ 0 ];
+
+ for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
+ item = $( _queries[ j ] );
+
+ // Data for target checking (mouse manager)
+ item.data( this.widgetName + "-item", targetData );
+
+ items.push( {
+ item: item,
+ instance: targetData,
+ width: 0, height: 0,
+ left: 0, top: 0
+ } );
+ }
+ }
+
+ },
+
+ refreshPositions: function( fast ) {
+
+ // Determine whether items are being displayed horizontally
+ this.floating = this.items.length ?
+ this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
+ false;
+
+ //This has to be redone because due to the item being moved out/into the offsetParent,
+ // the offsetParent's position will change
+ if ( this.offsetParent && this.helper ) {
+ this.offset.parent = this._getParentOffset();
+ }
+
+ var i, item, t, p;
+
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
+ item = this.items[ i ];
+
+ //We ignore calculating positions of all connected containers when we're not over them
+ if ( item.instance !== this.currentContainer && this.currentContainer &&
+ item.item[ 0 ] !== this.currentItem[ 0 ] ) {
+ continue;
+ }
+
+ t = this.options.toleranceElement ?
+ $( this.options.toleranceElement, item.item ) :
+ item.item;
+
+ if ( !fast ) {
+ item.width = t.outerWidth();
+ item.height = t.outerHeight();
+ }
+
+ p = t.offset();
+ item.left = p.left;
+ item.top = p.top;
+ }
+
+ if ( this.options.custom && this.options.custom.refreshContainers ) {
+ this.options.custom.refreshContainers.call( this );
+ } else {
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+ p = this.containers[ i ].element.offset();
+ this.containers[ i ].containerCache.left = p.left;
+ this.containers[ i ].containerCache.top = p.top;
+ this.containers[ i ].containerCache.width =
+ this.containers[ i ].element.outerWidth();
+ this.containers[ i ].containerCache.height =
+ this.containers[ i ].element.outerHeight();
+ }
+ }
+
+ return this;
+ },
+
+ _createPlaceholder: function( that ) {
+ that = that || this;
+ var className,
+ o = that.options;
+
+ if ( !o.placeholder || o.placeholder.constructor === String ) {
+ className = o.placeholder;
+ o.placeholder = {
+ element: function() {
+
+ var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
+ element = $( "<" + nodeName + ">", that.document[ 0 ] );
+
+ that._addClass( element, "ui-sortable-placeholder",
+ className || that.currentItem[ 0 ].className )
+ ._removeClass( element, "ui-sortable-helper" );
+
+ if ( nodeName === "tbody" ) {
+ that._createTrPlaceholder(
+ that.currentItem.find( "tr" ).eq( 0 ),
+ $( "<tr>", that.document[ 0 ] ).appendTo( element )
+ );
+ } else if ( nodeName === "tr" ) {
+ that._createTrPlaceholder( that.currentItem, element );
+ } else if ( nodeName === "img" ) {
+ element.attr( "src", that.currentItem.attr( "src" ) );
+ }
+
+ if ( !className ) {
+ element.css( "visibility", "hidden" );
+ }
+
+ return element;
+ },
+ update: function( container, p ) {
+
+ // 1. If a className is set as 'placeholder option, we don't force sizes -
+ // the class is responsible for that
+ // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
+ // class name is specified
+ if ( className && !o.forcePlaceholderSize ) {
+ return;
+ }
+
+ //If the element doesn't have a actual height by itself (without styles coming
+ // from a stylesheet), it receives the inline height from the dragged item
+ if ( !p.height() ) {
+ p.height(
+ that.currentItem.innerHeight() -
+ parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
+ parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
+ }
+ if ( !p.width() ) {
+ p.width(
+ that.currentItem.innerWidth() -
+ parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
+ parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
+ }
+ }
+ };
+ }
+
+ //Create the placeholder
+ that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
+
+ //Append it after the actual current item
+ that.currentItem.after( that.placeholder );
+
+ //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
+ o.placeholder.update( that, that.placeholder );
+
+ },
+
+ _createTrPlaceholder: function( sourceTr, targetTr ) {
+ var that = this;
+
+ sourceTr.children().each( function() {
+ $( "<td> </td>", that.document[ 0 ] )
+ .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
+ .appendTo( targetTr );
+ } );
+ },
+
+ _contactContainers: function( event ) {
+ var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
+ floating, axis,
+ innermostContainer = null,
+ innermostIndex = null;
+
+ // Get innermost container that intersects with item
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+
+ // Never consider a container that's located within the item itself
+ if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
+ continue;
+ }
+
+ if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
+
+ // If we've already found a container and it's more "inner" than this, then continue
+ if ( innermostContainer &&
+ $.contains(
+ this.containers[ i ].element[ 0 ],
+ innermostContainer.element[ 0 ] ) ) {
+ continue;
+ }
+
+ innermostContainer = this.containers[ i ];
+ innermostIndex = i;
+
+ } else {
+
+ // container doesn't intersect. trigger "out" event if necessary
+ if ( this.containers[ i ].containerCache.over ) {
+ this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
+ this.containers[ i ].containerCache.over = 0;
+ }
+ }
+
+ }
+
+ // If no intersecting containers found, return
+ if ( !innermostContainer ) {
+ return;
+ }
+
+ // Move the item into the container if it's not there already
+ if ( this.containers.length === 1 ) {
+ if ( !this.containers[ innermostIndex ].containerCache.over ) {
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
+ this.containers[ innermostIndex ].containerCache.over = 1;
+ }
+ } else {
+
+ // When entering a new container, we will find the item with the least distance and
+ // append our item near it
+ dist = 10000;
+ itemWithLeastDistance = null;
+ floating = innermostContainer.floating || this._isFloating( this.currentItem );
+ posProperty = floating ? "left" : "top";
+ sizeProperty = floating ? "width" : "height";
+ axis = floating ? "pageX" : "pageY";
+
+ for ( j = this.items.length - 1; j >= 0; j-- ) {
+ if ( !$.contains(
+ this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
+ ) {
+ continue;
+ }
+ if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
+ continue;
+ }
+
+ cur = this.items[ j ].item.offset()[ posProperty ];
+ nearBottom = false;
+ if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
+ nearBottom = true;
+ }
+
+ if ( Math.abs( event[ axis ] - cur ) < dist ) {
+ dist = Math.abs( event[ axis ] - cur );
+ itemWithLeastDistance = this.items[ j ];
+ this.direction = nearBottom ? "up" : "down";
+ }
+ }
+
+ //Check if dropOnEmpty is enabled
+ if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
+ return;
+ }
+
+ if ( this.currentContainer === this.containers[ innermostIndex ] ) {
+ if ( !this.currentContainer.containerCache.over ) {
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
+ this.currentContainer.containerCache.over = 1;
+ }
+ return;
+ }
+
+ itemWithLeastDistance ?
+ this._rearrange( event, itemWithLeastDistance, null, true ) :
+ this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
+ this._trigger( "change", event, this._uiHash() );
+ this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
+ this.currentContainer = this.containers[ innermostIndex ];
+
+ //Update the placeholder
+ this.options.placeholder.update( this.currentContainer, this.placeholder );
+
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
+ this.containers[ innermostIndex ].containerCache.over = 1;
+ }
+
+ },
+
+ _createHelper: function( event ) {
+
+ var o = this.options,
+ helper = $.isFunction( o.helper ) ?
+ $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
+ ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
+
+ //Add the helper to the DOM if that didn't happen already
+ if ( !helper.parents( "body" ).length ) {
+ $( o.appendTo !== "parent" ?
+ o.appendTo :
+ this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
+ }
+
+ if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
+ this._storedCSS = {
+ width: this.currentItem[ 0 ].style.width,
+ height: this.currentItem[ 0 ].style.height,
+ position: this.currentItem.css( "position" ),
+ top: this.currentItem.css( "top" ),
+ left: this.currentItem.css( "left" )
+ };
+ }
+
+ if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
+ helper.width( this.currentItem.width() );
+ }
+ if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
+ helper.height( this.currentItem.height() );
+ }
+
+ return helper;
+
+ },
+
+ _adjustOffsetFromHelper: function( obj ) {
+ if ( typeof obj === "string" ) {
+ obj = obj.split( " " );
+ }
+ if ( $.isArray( obj ) ) {
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
+ }
+ if ( "left" in obj ) {
+ this.offset.click.left = obj.left + this.margins.left;
+ }
+ if ( "right" in obj ) {
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ }
+ if ( "top" in obj ) {
+ this.offset.click.top = obj.top + this.margins.top;
+ }
+ if ( "bottom" in obj ) {
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ }
+ },
+
+ _getParentOffset: function() {
+
+ //Get the offsetParent and cache its position
+ this.offsetParent = this.helper.offsetParent();
+ var po = this.offsetParent.offset();
+
+ // This is a special case where we need to modify a offset calculated on start, since the
+ // following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the
+ // next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
+ // the document, which means that the scroll is included in the initial calculation of the
+ // offset of the parent, and never recalculated upon drag
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ // This needs to be actually done for all browsers, since pageX/pageY includes this
+ // information with an ugly IE fix
+ if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
+ ( this.offsetParent[ 0 ].tagName &&
+ this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
+ po = { top: 0, left: 0 };
+ }
+
+ return {
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+
+ if ( this.cssPosition === "relative" ) {
+ var p = this.currentItem.position();
+ return {
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
+ this.scrollParent.scrollTop(),
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
+ this.scrollParent.scrollLeft()
+ };
+ } else {
+ return { top: 0, left: 0 };
+ }
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
+ top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var ce, co, over,
+ o = this.options;
+ if ( o.containment === "parent" ) {
+ o.containment = this.helper[ 0 ].parentNode;
+ }
+ if ( o.containment === "document" || o.containment === "window" ) {
+ this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ o.containment === "document" ?
+ this.document.width() :
+ this.window.width() - this.helperProportions.width - this.margins.left,
+ ( o.containment === "document" ?
+ ( this.document.height() || document.body.parentNode.scrollHeight ) :
+ this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
+ ) - this.helperProportions.height - this.margins.top
+ ];
+ }
+
+ if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
+ ce = $( o.containment )[ 0 ];
+ co = $( o.containment ).offset();
+ over = ( $( ce ).css( "overflow" ) !== "hidden" );
+
+ this.containment = [
+ co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
+ ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
+ co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
+ ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
+ co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
+ ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
+ ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
+ this.helperProportions.width - this.margins.left,
+ co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
+ ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
+ ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
+ this.helperProportions.height - this.margins.top
+ ];
+ }
+
+ },
+
+ _convertPositionTo: function( d, pos ) {
+
+ if ( !pos ) {
+ pos = this.position;
+ }
+ var mod = d === "absolute" ? 1 : -1,
+ scroll = this.cssPosition === "absolute" &&
+ !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
+ this.offsetParent :
+ this.scrollParent,
+ scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
+
+ return {
+ top: (
+
+ // The absolute mouse position
+ pos.top +
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.top * mod +
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.top * mod -
+ ( ( this.cssPosition === "fixed" ?
+ -this.scrollParent.scrollTop() :
+ ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
+ ),
+ left: (
+
+ // The absolute mouse position
+ pos.left +
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.left * mod +
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.left * mod -
+ ( ( this.cssPosition === "fixed" ?
+ -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
+ scroll.scrollLeft() ) * mod )
+ )
+ };
+
+ },
+
+ _generatePosition: function( event ) {
+
+ var top, left,
+ o = this.options,
+ pageX = event.pageX,
+ pageY = event.pageY,
+ scroll = this.cssPosition === "absolute" &&
+ !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
+ this.offsetParent :
+ this.scrollParent,
+ scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
+
+ // This is another very weird special case that only happens for relative elements:
+ // 1. If the css position is relative
+ // 2. and the scroll parent is the document or similar to the offset parent
+ // we have to refresh the relative offset during the scroll so there are no jumps
+ if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
+ this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
+ this.offset.relative = this._getRelativeOffset();
+ }
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
+
+ if ( this.containment ) {
+ if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
+ pageX = this.containment[ 0 ] + this.offset.click.left;
+ }
+ if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
+ pageY = this.containment[ 1 ] + this.offset.click.top;
+ }
+ if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
+ pageX = this.containment[ 2 ] + this.offset.click.left;
+ }
+ if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
+ pageY = this.containment[ 3 ] + this.offset.click.top;
+ }
+ }
+
+ if ( o.grid ) {
+ top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
+ o.grid[ 1 ] ) * o.grid[ 1 ];
+ pageY = this.containment ?
+ ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
+ top - this.offset.click.top <= this.containment[ 3 ] ) ?
+ top :
+ ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
+ top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
+ top;
+
+ left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
+ o.grid[ 0 ] ) * o.grid[ 0 ];
+ pageX = this.containment ?
+ ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
+ left - this.offset.click.left <= this.containment[ 2 ] ) ?
+ left :
+ ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
+ left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
+ left;
+ }
+
+ }
+
+ return {
+ top: (
+
+ // The absolute mouse position
+ pageY -
+
+ // Click offset (relative to the element)
+ this.offset.click.top -
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.top -
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.top +
+ ( ( this.cssPosition === "fixed" ?
+ -this.scrollParent.scrollTop() :
+ ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
+ ),
+ left: (
+
+ // The absolute mouse position
+ pageX -
+
+ // Click offset (relative to the element)
+ this.offset.click.left -
+
+ // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.relative.left -
+
+ // The offsetParent's offset without borders (offset + border)
+ this.offset.parent.left +
+ ( ( this.cssPosition === "fixed" ?
+ -this.scrollParent.scrollLeft() :
+ scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
+ )
+ };
+
+ },
+
+ _rearrange: function( event, i, a, hardRefresh ) {
+
+ a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
+ i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
+ ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
+
+ //Various things done here to improve the performance:
+ // 1. we create a setTimeout, that calls refreshPositions
+ // 2. on the instance, we have a counter variable, that get's higher after every append
+ // 3. on the local scope, we copy the counter variable, and check in the timeout,
+ // if it's still the same
+ // 4. this lets only the last addition to the timeout stack through
+ this.counter = this.counter ? ++this.counter : 1;
+ var counter = this.counter;
+
+ this._delay( function() {
+ if ( counter === this.counter ) {
+
+ //Precompute after each DOM insertion, NOT on mousemove
+ this.refreshPositions( !hardRefresh );
+ }
+ } );
+
+ },
+
+ _clear: function( event, noPropagation ) {
+
+ this.reverting = false;
+
+ // We delay all events that have to be triggered to after the point where the placeholder
+ // has been removed and everything else normalized again
+ var i,
+ delayedTriggers = [];
+
+ // We first have to update the dom position of the actual currentItem
+ // Note: don't do it if the current item is already removed (by a user), or it gets
+ // reappended (see #4088)
+ if ( !this._noFinalSort && this.currentItem.parent().length ) {
+ this.placeholder.before( this.currentItem );
+ }
+ this._noFinalSort = null;
+
+ if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
+ for ( i in this._storedCSS ) {
+ if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
+ this._storedCSS[ i ] = "";
+ }
+ }
+ this.currentItem.css( this._storedCSS );
+ this._removeClass( this.currentItem, "ui-sortable-helper" );
+ } else {
+ this.currentItem.show();
+ }
+
+ if ( this.fromOutside && !noPropagation ) {
+ delayedTriggers.push( function( event ) {
+ this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
+ } );
+ }
+ if ( ( this.fromOutside ||
+ this.domPosition.prev !==
+ this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
+ this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
+
+ // Trigger update callback if the DOM position has changed
+ delayedTriggers.push( function( event ) {
+ this._trigger( "update", event, this._uiHash() );
+ } );
+ }
+
+ // Check if the items Container has Changed and trigger appropriate
+ // events.
+ if ( this !== this.currentContainer ) {
+ if ( !noPropagation ) {
+ delayedTriggers.push( function( event ) {
+ this._trigger( "remove", event, this._uiHash() );
+ } );
+ delayedTriggers.push( ( function( c ) {
+ return function( event ) {
+ c._trigger( "receive", event, this._uiHash( this ) );
+ };
+ } ).call( this, this.currentContainer ) );
+ delayedTriggers.push( ( function( c ) {
+ return function( event ) {
+ c._trigger( "update", event, this._uiHash( this ) );
+ };
+ } ).call( this, this.currentContainer ) );
+ }
+ }
+
+ //Post events to containers
+ function delayEvent( type, instance, container ) {
+ return function( event ) {
+ container._trigger( type, event, instance._uiHash( instance ) );
+ };
+ }
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+ if ( !noPropagation ) {
+ delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
+ }
+ if ( this.containers[ i ].containerCache.over ) {
+ delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
+ this.containers[ i ].containerCache.over = 0;
+ }
+ }
+
+ //Do what was originally in plugins
+ if ( this.storedCursor ) {
+ this.document.find( "body" ).css( "cursor", this.storedCursor );
+ this.storedStylesheet.remove();
+ }
+ if ( this._storedOpacity ) {
+ this.helper.css( "opacity", this._storedOpacity );
+ }
+ if ( this._storedZIndex ) {
+ this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
+ }
+
+ this.dragging = false;
+
+ if ( !noPropagation ) {
+ this._trigger( "beforeStop", event, this._uiHash() );
+ }
+
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
+ // it unbinds ALL events from the original node!
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
+
+ if ( !this.cancelHelperRemoval ) {
+ if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
+ this.helper.remove();
+ }
+ this.helper = null;
+ }
+
+ if ( !noPropagation ) {
+ for ( i = 0; i < delayedTriggers.length; i++ ) {
+
+ // Trigger all delayed events
+ delayedTriggers[ i ].call( this, event );
+ }
+ this._trigger( "stop", event, this._uiHash() );
+ }
+
+ this.fromOutside = false;
+ return !this.cancelHelperRemoval;
+
+ },
+
+ _trigger: function() {
+ if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
+ this.cancel();
+ }
+ },
+
+ _uiHash: function( _inst ) {
+ var inst = _inst || this;
+ return {
+ helper: inst.helper,
+ placeholder: inst.placeholder || $( [] ),
+ position: inst.position,
+ originalPosition: inst.originalPosition,
+ offset: inst.positionAbs,
+ item: inst.currentItem,
+ sender: _inst ? _inst.element : null
+ };
+ }
+
+} );
+
+
+/*!
+ * jQuery UI Spinner 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Spinner
+//>>group: Widgets
+//>>description: Displays buttons to easily input numbers via the keyboard or mouse.
+//>>docs: http://api.jqueryui.com/spinner/
+//>>demos: http://jqueryui.com/spinner/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/spinner.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+function spinnerModifer( fn ) {
+ return function() {
+ var previous = this.element.val();
+ fn.apply( this, arguments );
+ this._refresh();
+ if ( previous !== this.element.val() ) {
+ this._trigger( "change" );
+ }
+ };
+}
+
+$.widget( "ui.spinner", {
+ version: "1.12.1",
+ defaultElement: "<input>",
+ widgetEventPrefix: "spin",
+ options: {
+ classes: {
+ "ui-spinner": "ui-corner-all",
+ "ui-spinner-down": "ui-corner-br",
+ "ui-spinner-up": "ui-corner-tr"
+ },
+ culture: null,
+ icons: {
+ down: "ui-icon-triangle-1-s",
+ up: "ui-icon-triangle-1-n"
+ },
+ incremental: true,
+ max: null,
+ min: null,
+ numberFormat: null,
+ page: 10,
+ step: 1,
+
+ change: null,
+ spin: null,
+ start: null,
+ stop: null
+ },
+
+ _create: function() {
+
+ // handle string values that need to be parsed
+ this._setOption( "max", this.options.max );
+ this._setOption( "min", this.options.min );
+ this._setOption( "step", this.options.step );
+
+ // Only format if there is a value, prevents the field from being marked
+ // as invalid in Firefox, see #9573.
+ if ( this.value() !== "" ) {
+
+ // Format the value, but don't constrain.
+ this._value( this.element.val(), true );
+ }
+
+ this._draw();
+ this._on( this._events );
+ this._refresh();
+
+ // Turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ } );
+ },
+
+ _getCreateOptions: function() {
+ var options = this._super();
+ var element = this.element;
+
+ $.each( [ "min", "max", "step" ], function( i, option ) {
+ var value = element.attr( option );
+ if ( value != null && value.length ) {
+ options[ option ] = value;
+ }
+ } );
+
+ return options;
+ },
+
+ _events: {
+ keydown: function( event ) {
+ if ( this._start( event ) && this._keydown( event ) ) {
+ event.preventDefault();
+ }
+ },
+ keyup: "_stop",
+ focus: function() {
+ this.previous = this.element.val();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
+ this._stop();
+ this._refresh();
+ if ( this.previous !== this.element.val() ) {
+ this._trigger( "change", event );
+ }
+ },
+ mousewheel: function( event, delta ) {
+ if ( !delta ) {
+ return;
+ }
+ if ( !this.spinning && !this._start( event ) ) {
+ return false;
+ }
+
+ this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
+ clearTimeout( this.mousewheelTimer );
+ this.mousewheelTimer = this._delay( function() {
+ if ( this.spinning ) {
+ this._stop( event );
+ }
+ }, 100 );
+ event.preventDefault();
+ },
+ "mousedown .ui-spinner-button": function( event ) {
+ var previous;
+
+ // We never want the buttons to have focus; whenever the user is
+ // interacting with the spinner, the focus should be on the input.
+ // If the input is focused then this.previous is properly set from
+ // when the input first received focus. If the input is not focused
+ // then we need to set this.previous based on the value before spinning.
+ previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
+ this.previous : this.element.val();
+ function checkFocus() {
+ var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
+ if ( !isActive ) {
+ this.element.trigger( "focus" );
+ this.previous = previous;
+
+ // support: IE
+ // IE sets focus asynchronously, so we need to check if focus
+ // moved off of the input because the user clicked on the button.
+ this._delay( function() {
+ this.previous = previous;
+ } );
+ }
+ }
+
+ // Ensure focus is on (or stays on) the text field
+ event.preventDefault();
+ checkFocus.call( this );
+
+ // Support: IE
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ // and check (again) if focus moved off of the input.
+ this.cancelBlur = true;
+ this._delay( function() {
+ delete this.cancelBlur;
+ checkFocus.call( this );
+ } );
+
+ if ( this._start( event ) === false ) {
+ return;
+ }
+
+ this._repeat( null, $( event.currentTarget )
+ .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+ "mouseup .ui-spinner-button": "_stop",
+ "mouseenter .ui-spinner-button": function( event ) {
+
+ // button will add ui-state-active if mouse was down while mouseleave and kept down
+ if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
+ return;
+ }
+
+ if ( this._start( event ) === false ) {
+ return false;
+ }
+ this._repeat( null, $( event.currentTarget )
+ .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+
+ // TODO: do we really want to consider this a stop?
+ // shouldn't we just stop the repeater and wait until mouseup before
+ // we trigger the stop event?
+ "mouseleave .ui-spinner-button": "_stop"
+ },
+
+ // Support mobile enhanced option and make backcompat more sane
+ _enhance: function() {
+ this.uiSpinner = this.element
+ .attr( "autocomplete", "off" )
+ .wrap( "<span>" )
+ .parent()
+
+ // Add buttons
+ .append(
+ "<a></a><a></a>"
+ );
+ },
+
+ _draw: function() {
+ this._enhance();
+
+ this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
+ this._addClass( "ui-spinner-input" );
+
+ this.element.attr( "role", "spinbutton" );
+
+ // Button bindings
+ this.buttons = this.uiSpinner.children( "a" )
+ .attr( "tabIndex", -1 )
+ .attr( "aria-hidden", true )
+ .button( {
+ classes: {
+ "ui-button": ""
+ }
+ } );
+
+ // TODO: Right now button does not support classes this is already updated in button PR
+ this._removeClass( this.buttons, "ui-corner-all" );
+
+ this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
+ this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
+ this.buttons.first().button( {
+ "icon": this.options.icons.up,
+ "showLabel": false
+ } );
+ this.buttons.last().button( {
+ "icon": this.options.icons.down,
+ "showLabel": false
+ } );
+
+ // IE 6 doesn't understand height: 50% for the buttons
+ // unless the wrapper has an explicit height
+ if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
+ this.uiSpinner.height() > 0 ) {
+ this.uiSpinner.height( this.uiSpinner.height() );
+ }
+ },
+
+ _keydown: function( event ) {
+ var options = this.options,
+ keyCode = $.ui.keyCode;
+
+ switch ( event.keyCode ) {
+ case keyCode.UP:
+ this._repeat( null, 1, event );
+ return true;
+ case keyCode.DOWN:
+ this._repeat( null, -1, event );
+ return true;
+ case keyCode.PAGE_UP:
+ this._repeat( null, options.page, event );
+ return true;
+ case keyCode.PAGE_DOWN:
+ this._repeat( null, -options.page, event );
+ return true;
+ }
+
+ return false;
+ },
+
+ _start: function( event ) {
+ if ( !this.spinning && this._trigger( "start", event ) === false ) {
+ return false;
+ }
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+ this.spinning = true;
+ return true;
+ },
+
+ _repeat: function( i, steps, event ) {
+ i = i || 500;
+
+ clearTimeout( this.timer );
+ this.timer = this._delay( function() {
+ this._repeat( 40, steps, event );
+ }, i );
+
+ this._spin( steps * this.options.step, event );
+ },
+
+ _spin: function( step, event ) {
+ var value = this.value() || 0;
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+
+ value = this._adjustValue( value + step * this._increment( this.counter ) );
+
+ if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
+ this._value( value );
+ this.counter++;
+ }
+ },
+
+ _increment: function( i ) {
+ var incremental = this.options.incremental;
+
+ if ( incremental ) {
+ return $.isFunction( incremental ) ?
+ incremental( i ) :
+ Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
+ }
+
+ return 1;
+ },
+
+ _precision: function() {
+ var precision = this._precisionOf( this.options.step );
+ if ( this.options.min !== null ) {
+ precision = Math.max( precision, this._precisionOf( this.options.min ) );
+ }
+ return precision;
+ },
+
+ _precisionOf: function( num ) {
+ var str = num.toString(),
+ decimal = str.indexOf( "." );
+ return decimal === -1 ? 0 : str.length - decimal - 1;
+ },
+
+ _adjustValue: function( value ) {
+ var base, aboveMin,
+ options = this.options;
+
+ // Make sure we're at a valid step
+ // - find out where we are relative to the base (min or 0)
+ base = options.min !== null ? options.min : 0;
+ aboveMin = value - base;
+
+ // - round to the nearest step
+ aboveMin = Math.round( aboveMin / options.step ) * options.step;
+
+ // - rounding is based on 0, so adjust back to our base
+ value = base + aboveMin;
+
+ // Fix precision from bad JS floating point math
+ value = parseFloat( value.toFixed( this._precision() ) );
+
+ // Clamp the value
+ if ( options.max !== null && value > options.max ) {
+ return options.max;
+ }
+ if ( options.min !== null && value < options.min ) {
+ return options.min;
+ }
+
+ return value;
+ },
+
+ _stop: function( event ) {
+ if ( !this.spinning ) {
+ return;
+ }
+
+ clearTimeout( this.timer );
+ clearTimeout( this.mousewheelTimer );
+ this.counter = 0;
+ this.spinning = false;
+ this._trigger( "stop", event );
+ },
+
+ _setOption: function( key, value ) {
+ var prevValue, first, last;
+
+ if ( key === "culture" || key === "numberFormat" ) {
+ prevValue = this._parse( this.element.val() );
+ this.options[ key ] = value;
+ this.element.val( this._format( prevValue ) );
+ return;
+ }
+
+ if ( key === "max" || key === "min" || key === "step" ) {
+ if ( typeof value === "string" ) {
+ value = this._parse( value );
+ }
+ }
+ if ( key === "icons" ) {
+ first = this.buttons.first().find( ".ui-icon" );
+ this._removeClass( first, null, this.options.icons.up );
+ this._addClass( first, null, value.up );
+ last = this.buttons.last().find( ".ui-icon" );
+ this._removeClass( last, null, this.options.icons.down );
+ this._addClass( last, null, value.down );
+ }
+
+ this._super( key, value );
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
+ this.element.prop( "disabled", !!value );
+ this.buttons.button( value ? "disable" : "enable" );
+ },
+
+ _setOptions: spinnerModifer( function( options ) {
+ this._super( options );
+ } ),
+
+ _parse: function( val ) {
+ if ( typeof val === "string" && val !== "" ) {
+ val = window.Globalize && this.options.numberFormat ?
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
+ }
+ return val === "" || isNaN( val ) ? null : val;
+ },
+
+ _format: function( value ) {
+ if ( value === "" ) {
+ return "";
+ }
+ return window.Globalize && this.options.numberFormat ?
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
+ value;
+ },
+
+ _refresh: function() {
+ this.element.attr( {
+ "aria-valuemin": this.options.min,
+ "aria-valuemax": this.options.max,
+
+ // TODO: what should we do with values that can't be parsed?
+ "aria-valuenow": this._parse( this.element.val() )
+ } );
+ },
+
+ isValid: function() {
+ var value = this.value();
+
+ // Null is invalid
+ if ( value === null ) {
+ return false;
+ }
+
+ // If value gets adjusted, it's invalid
+ return value === this._adjustValue( value );
+ },
+
+ // Update the value without triggering change
+ _value: function( value, allowAny ) {
+ var parsed;
+ if ( value !== "" ) {
+ parsed = this._parse( value );
+ if ( parsed !== null ) {
+ if ( !allowAny ) {
+ parsed = this._adjustValue( parsed );
+ }
+ value = this._format( parsed );
+ }
+ }
+ this.element.val( value );
+ this._refresh();
+ },
+
+ _destroy: function() {
+ this.element
+ .prop( "disabled", false )
+ .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
+
+ this.uiSpinner.replaceWith( this.element );
+ },
+
+ stepUp: spinnerModifer( function( steps ) {
+ this._stepUp( steps );
+ } ),
+ _stepUp: function( steps ) {
+ if ( this._start() ) {
+ this._spin( ( steps || 1 ) * this.options.step );
+ this._stop();
+ }
+ },
+
+ stepDown: spinnerModifer( function( steps ) {
+ this._stepDown( steps );
+ } ),
+ _stepDown: function( steps ) {
+ if ( this._start() ) {
+ this._spin( ( steps || 1 ) * -this.options.step );
+ this._stop();
+ }
+ },
+
+ pageUp: spinnerModifer( function( pages ) {
+ this._stepUp( ( pages || 1 ) * this.options.page );
+ } ),
+
+ pageDown: spinnerModifer( function( pages ) {
+ this._stepDown( ( pages || 1 ) * this.options.page );
+ } ),
+
+ value: function( newVal ) {
+ if ( !arguments.length ) {
+ return this._parse( this.element.val() );
+ }
+ spinnerModifer( this._value ).call( this, newVal );
+ },
+
+ widget: function() {
+ return this.uiSpinner;
+ }
+} );
+
+// DEPRECATED
+// TODO: switch return back to widget declaration at top of file when this is removed
+if ( $.uiBackCompat !== false ) {
+
+ // Backcompat for spinner html extension points
+ $.widget( "ui.spinner", $.ui.spinner, {
+ _enhance: function() {
+ this.uiSpinner = this.element
+ .attr( "autocomplete", "off" )
+ .wrap( this._uiSpinnerHtml() )
+ .parent()
+
+ // Add buttons
+ .append( this._buttonHtml() );
+ },
+ _uiSpinnerHtml: function() {
+ return "<span>";
+ },
+
+ _buttonHtml: function() {
+ return "<a></a><a></a>";
+ }
+ } );
+}
+
+var widgetsSpinner = $.ui.spinner;
+
+
+/*!
+ * jQuery UI Tabs 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Tabs
+//>>group: Widgets
+//>>description: Transforms a set of container elements into a tab structure.
+//>>docs: http://api.jqueryui.com/tabs/
+//>>demos: http://jqueryui.com/tabs/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/tabs.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.tabs", {
+ version: "1.12.1",
+ delay: 300,
+ options: {
+ active: null,
+ classes: {
+ "ui-tabs": "ui-corner-all",
+ "ui-tabs-nav": "ui-corner-all",
+ "ui-tabs-panel": "ui-corner-bottom",
+ "ui-tabs-tab": "ui-corner-top"
+ },
+ collapsible: false,
+ event: "click",
+ heightStyle: "content",
+ hide: null,
+ show: null,
+
+ // Callbacks
+ activate: null,
+ beforeActivate: null,
+ beforeLoad: null,
+ load: null
+ },
+
+ _isLocal: ( function() {
+ var rhash = /#.*$/;
+
+ return function( anchor ) {
+ var anchorUrl, locationUrl;
+
+ anchorUrl = anchor.href.replace( rhash, "" );
+ locationUrl = location.href.replace( rhash, "" );
+
+ // Decoding may throw an error if the URL isn't UTF-8 (#9518)
+ try {
+ anchorUrl = decodeURIComponent( anchorUrl );
+ } catch ( error ) {}
+ try {
+ locationUrl = decodeURIComponent( locationUrl );
+ } catch ( error ) {}
+
+ return anchor.hash.length > 1 && anchorUrl === locationUrl;
+ };
+ } )(),
+
+ _create: function() {
+ var that = this,
+ options = this.options;
+
+ this.running = false;
+
+ this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
+ this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
+
+ this._processTabs();
+ options.active = this._initialActive();
+
+ // Take disabling tabs via class attribute from HTML
+ // into account and update option properly.
+ if ( $.isArray( options.disabled ) ) {
+ options.disabled = $.unique( options.disabled.concat(
+ $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
+ return that.tabs.index( li );
+ } )
+ ) ).sort();
+ }
+
+ // Check for length avoids error when initializing empty list
+ if ( this.options.active !== false && this.anchors.length ) {
+ this.active = this._findActive( options.active );
+ } else {
+ this.active = $();
+ }
+
+ this._refresh();
+
+ if ( this.active.length ) {
+ this.load( options.active );
+ }
+ },
+
+ _initialActive: function() {
+ var active = this.options.active,
+ collapsible = this.options.collapsible,
+ locationHash = location.hash.substring( 1 );
+
+ if ( active === null ) {
+
+ // check the fragment identifier in the URL
+ if ( locationHash ) {
+ this.tabs.each( function( i, tab ) {
+ if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
+ active = i;
+ return false;
+ }
+ } );
+ }
+
+ // Check for a tab marked active via a class
+ if ( active === null ) {
+ active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
+ }
+
+ // No active tab, set to false
+ if ( active === null || active === -1 ) {
+ active = this.tabs.length ? 0 : false;
+ }
+ }
+
+ // Handle numbers: negative, out of range
+ if ( active !== false ) {
+ active = this.tabs.index( this.tabs.eq( active ) );
+ if ( active === -1 ) {
+ active = collapsible ? false : 0;
+ }
+ }
+
+ // Don't allow collapsible: false and active: false
+ if ( !collapsible && active === false && this.anchors.length ) {
+ active = 0;
+ }
+
+ return active;
+ },
+
+ _getCreateEventData: function() {
+ return {
+ tab: this.active,
+ panel: !this.active.length ? $() : this._getPanelForTab( this.active )
+ };
+ },
+
+ _tabKeydown: function( event ) {
+ var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
+ selectedIndex = this.tabs.index( focusedTab ),
+ goingForward = true;
+
+ if ( this._handlePageNav( event ) ) {
+ return;
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.RIGHT:
+ case $.ui.keyCode.DOWN:
+ selectedIndex++;
+ break;
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.LEFT:
+ goingForward = false;
+ selectedIndex--;
+ break;
+ case $.ui.keyCode.END:
+ selectedIndex = this.anchors.length - 1;
+ break;
+ case $.ui.keyCode.HOME:
+ selectedIndex = 0;
+ break;
+ case $.ui.keyCode.SPACE:
+
+ // Activate only, no collapsing
+ event.preventDefault();
+ clearTimeout( this.activating );
+ this._activate( selectedIndex );
+ return;
+ case $.ui.keyCode.ENTER:
+
+ // Toggle (cancel delayed activation, allow collapsing)
+ event.preventDefault();
+ clearTimeout( this.activating );
+
+ // Determine if we should collapse or activate
+ this._activate( selectedIndex === this.options.active ? false : selectedIndex );
+ return;
+ default:
+ return;
+ }
+
+ // Focus the appropriate tab, based on which key was pressed
+ event.preventDefault();
+ clearTimeout( this.activating );
+ selectedIndex = this._focusNextTab( selectedIndex, goingForward );
+
+ // Navigating with control/command key will prevent automatic activation
+ if ( !event.ctrlKey && !event.metaKey ) {
+
+ // Update aria-selected immediately so that AT think the tab is already selected.
+ // Otherwise AT may confuse the user by stating that they need to activate the tab,
+ // but the tab will already be activated by the time the announcement finishes.
+ focusedTab.attr( "aria-selected", "false" );
+ this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
+
+ this.activating = this._delay( function() {
+ this.option( "active", selectedIndex );
+ }, this.delay );
+ }
+ },
+
+ _panelKeydown: function( event ) {
+ if ( this._handlePageNav( event ) ) {
+ return;
+ }
+
+ // Ctrl+up moves focus to the current tab
+ if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
+ event.preventDefault();
+ this.active.trigger( "focus" );
+ }
+ },
+
+ // Alt+page up/down moves focus to the previous/next tab (and activates)
+ _handlePageNav: function( event ) {
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
+ this._activate( this._focusNextTab( this.options.active - 1, false ) );
+ return true;
+ }
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
+ this._activate( this._focusNextTab( this.options.active + 1, true ) );
+ return true;
+ }
+ },
+
+ _findNextTab: function( index, goingForward ) {
+ var lastTabIndex = this.tabs.length - 1;
+
+ function constrain() {
+ if ( index > lastTabIndex ) {
+ index = 0;
+ }
+ if ( index < 0 ) {
+ index = lastTabIndex;
+ }
+ return index;
+ }
+
+ while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
+ index = goingForward ? index + 1 : index - 1;
+ }
+
+ return index;
+ },
+
+ _focusNextTab: function( index, goingForward ) {
+ index = this._findNextTab( index, goingForward );
+ this.tabs.eq( index ).trigger( "focus" );
+ return index;
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "active" ) {
+
+ // _activate() will handle invalid values and update this.options
+ this._activate( value );
+ return;
+ }
+
+ this._super( key, value );
+
+ if ( key === "collapsible" ) {
+ this._toggleClass( "ui-tabs-collapsible", null, value );
+
+ // Setting collapsible: false while collapsed; open first panel
+ if ( !value && this.options.active === false ) {
+ this._activate( 0 );
+ }
+ }
+
+ if ( key === "event" ) {
+ this._setupEvents( value );
+ }
+
+ if ( key === "heightStyle" ) {
+ this._setupHeightStyle( value );
+ }
+ },
+
+ _sanitizeSelector: function( hash ) {
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
+ },
+
+ refresh: function() {
+ var options = this.options,
+ lis = this.tablist.children( ":has(a[href])" );
+
+ // Get disabled tabs from class attribute from HTML
+ // this will get converted to a boolean if needed in _refresh()
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
+ return lis.index( tab );
+ } );
+
+ this._processTabs();
+
+ // Was collapsed or no tabs
+ if ( options.active === false || !this.anchors.length ) {
+ options.active = false;
+ this.active = $();
+
+ // was active, but active tab is gone
+ } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
+
+ // all remaining tabs are disabled
+ if ( this.tabs.length === options.disabled.length ) {
+ options.active = false;
+ this.active = $();
+
+ // activate previous tab
+ } else {
+ this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
+ }
+
+ // was active, active tab still exists
+ } else {
+
+ // make sure active index is correct
+ options.active = this.tabs.index( this.active );
+ }
+
+ this._refresh();
+ },
+
+ _refresh: function() {
+ this._setOptionDisabled( this.options.disabled );
+ this._setupEvents( this.options.event );
+ this._setupHeightStyle( this.options.heightStyle );
+
+ this.tabs.not( this.active ).attr( {
+ "aria-selected": "false",
+ "aria-expanded": "false",
+ tabIndex: -1
+ } );
+ this.panels.not( this._getPanelForTab( this.active ) )
+ .hide()
+ .attr( {
+ "aria-hidden": "true"
+ } );
+
+ // Make sure one tab is in the tab order
+ if ( !this.active.length ) {
+ this.tabs.eq( 0 ).attr( "tabIndex", 0 );
+ } else {
+ this.active
+ .attr( {
+ "aria-selected": "true",
+ "aria-expanded": "true",
+ tabIndex: 0
+ } );
+ this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
+ this._getPanelForTab( this.active )
+ .show()
+ .attr( {
+ "aria-hidden": "false"
+ } );
+ }
+ },
+
+ _processTabs: function() {
+ var that = this,
+ prevTabs = this.tabs,
+ prevAnchors = this.anchors,
+ prevPanels = this.panels;
+
+ this.tablist = this._getList().attr( "role", "tablist" );
+ this._addClass( this.tablist, "ui-tabs-nav",
+ "ui-helper-reset ui-helper-clearfix ui-widget-header" );
+
+ // Prevent users from focusing disabled tabs via click
+ this.tablist
+ .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
+ if ( $( this ).is( ".ui-state-disabled" ) ) {
+ event.preventDefault();
+ }
+ } )
+
+ // Support: IE <9
+ // Preventing the default action in mousedown doesn't prevent IE
+ // from focusing the element, so if the anchor gets focused, blur.
+ // We don't have to worry about focusing the previously focused
+ // element since clicking on a non-focusable element should focus
+ // the body anyway.
+ .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
+ if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
+ this.blur();
+ }
+ } );
+
+ this.tabs = this.tablist.find( "> li:has(a[href])" )
+ .attr( {
+ role: "tab",
+ tabIndex: -1
+ } );
+ this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
+
+ this.anchors = this.tabs.map( function() {
+ return $( "a", this )[ 0 ];
+ } )
+ .attr( {
+ role: "presentation",
+ tabIndex: -1
+ } );
+ this._addClass( this.anchors, "ui-tabs-anchor" );
+
+ this.panels = $();
+
+ this.anchors.each( function( i, anchor ) {
+ var selector, panel, panelId,
+ anchorId = $( anchor ).uniqueId().attr( "id" ),
+ tab = $( anchor ).closest( "li" ),
+ originalAriaControls = tab.attr( "aria-controls" );
+
+ // Inline tab
+ if ( that._isLocal( anchor ) ) {
+ selector = anchor.hash;
+ panelId = selector.substring( 1 );
+ panel = that.element.find( that._sanitizeSelector( selector ) );
+
+ // remote tab
+ } else {
+
+ // If the tab doesn't already have aria-controls,
+ // generate an id by using a throw-away element
+ panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
+ selector = "#" + panelId;
+ panel = that.element.find( selector );
+ if ( !panel.length ) {
+ panel = that._createPanel( panelId );
+ panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
+ }
+ panel.attr( "aria-live", "polite" );
+ }
+
+ if ( panel.length ) {
+ that.panels = that.panels.add( panel );
+ }
+ if ( originalAriaControls ) {
+ tab.data( "ui-tabs-aria-controls", originalAriaControls );
+ }
+ tab.attr( {
+ "aria-controls": panelId,
+ "aria-labelledby": anchorId
+ } );
+ panel.attr( "aria-labelledby", anchorId );
+ } );
+
+ this.panels.attr( "role", "tabpanel" );
+ this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
+
+ // Avoid memory leaks (#10056)
+ if ( prevTabs ) {
+ this._off( prevTabs.not( this.tabs ) );
+ this._off( prevAnchors.not( this.anchors ) );
+ this._off( prevPanels.not( this.panels ) );
+ }
+ },
+
+ // Allow overriding how to find the list for rare usage scenarios (#7715)
+ _getList: function() {
+ return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
+ },
+
+ _createPanel: function( id ) {
+ return $( "<div>" )
+ .attr( "id", id )
+ .data( "ui-tabs-destroy", true );
+ },
+
+ _setOptionDisabled: function( disabled ) {
+ var currentItem, li, i;
+
+ if ( $.isArray( disabled ) ) {
+ if ( !disabled.length ) {
+ disabled = false;
+ } else if ( disabled.length === this.anchors.length ) {
+ disabled = true;
+ }
+ }
+
+ // Disable tabs
+ for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
+ currentItem = $( li );
+ if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
+ currentItem.attr( "aria-disabled", "true" );
+ this._addClass( currentItem, null, "ui-state-disabled" );
+ } else {
+ currentItem.removeAttr( "aria-disabled" );
+ this._removeClass( currentItem, null, "ui-state-disabled" );
+ }
+ }
+
+ this.options.disabled = disabled;
+
+ this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
+ disabled === true );
+ },
+
+ _setupEvents: function( event ) {
+ var events = {};
+ if ( event ) {
+ $.each( event.split( " " ), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ } );
+ }
+
+ this._off( this.anchors.add( this.tabs ).add( this.panels ) );
+
+ // Always prevent the default action, even when disabled
+ this._on( true, this.anchors, {
+ click: function( event ) {
+ event.preventDefault();
+ }
+ } );
+ this._on( this.anchors, events );
+ this._on( this.tabs, { keydown: "_tabKeydown" } );
+ this._on( this.panels, { keydown: "_panelKeydown" } );
+
+ this._focusable( this.tabs );
+ this._hoverable( this.tabs );
+ },
+
+ _setupHeightStyle: function( heightStyle ) {
+ var maxHeight,
+ parent = this.element.parent();
+
+ if ( heightStyle === "fill" ) {
+ maxHeight = parent.height();
+ maxHeight -= this.element.outerHeight() - this.element.height();
+
+ this.element.siblings( ":visible" ).each( function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ } );
+
+ this.element.children().not( this.panels ).each( function() {
+ maxHeight -= $( this ).outerHeight( true );
+ } );
+
+ this.panels.each( function() {
+ $( this ).height( Math.max( 0, maxHeight -
+ $( this ).innerHeight() + $( this ).height() ) );
+ } )
+ .css( "overflow", "auto" );
+ } else if ( heightStyle === "auto" ) {
+ maxHeight = 0;
+ this.panels.each( function() {
+ maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
+ } ).height( maxHeight );
+ }
+ },
+
+ _eventHandler: function( event ) {
+ var options = this.options,
+ active = this.active,
+ anchor = $( event.currentTarget ),
+ tab = anchor.closest( "li" ),
+ clickedIsActive = tab[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : this._getPanelForTab( tab ),
+ toHide = !active.length ? $() : this._getPanelForTab( active ),
+ eventData = {
+ oldTab: active,
+ oldPanel: toHide,
+ newTab: collapsing ? $() : tab,
+ newPanel: toShow
+ };
+
+ event.preventDefault();
+
+ if ( tab.hasClass( "ui-state-disabled" ) ||
+
+ // tab is already loading
+ tab.hasClass( "ui-tabs-loading" ) ||
+
+ // can't switch durning an animation
+ this.running ||
+
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+ return;
+ }
+
+ options.active = collapsing ? false : this.tabs.index( tab );
+
+ this.active = clickedIsActive ? $() : tab;
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+
+ if ( !toHide.length && !toShow.length ) {
+ $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
+ }
+
+ if ( toShow.length ) {
+ this.load( this.tabs.index( tab ), event );
+ }
+ this._toggle( event, eventData );
+ },
+
+ // Handles show/hide for selecting tabs
+ _toggle: function( event, eventData ) {
+ var that = this,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel;
+
+ this.running = true;
+
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
+ }
+
+ function show() {
+ that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
+
+ if ( toShow.length && that.options.show ) {
+ that._show( toShow, that.options.show, complete );
+ } else {
+ toShow.show();
+ complete();
+ }
+ }
+
+ // Start out by hiding, then showing, then completing
+ if ( toHide.length && this.options.hide ) {
+ this._hide( toHide, this.options.hide, function() {
+ that._removeClass( eventData.oldTab.closest( "li" ),
+ "ui-tabs-active", "ui-state-active" );
+ show();
+ } );
+ } else {
+ this._removeClass( eventData.oldTab.closest( "li" ),
+ "ui-tabs-active", "ui-state-active" );
+ toHide.hide();
+ show();
+ }
+
+ toHide.attr( "aria-hidden", "true" );
+ eventData.oldTab.attr( {
+ "aria-selected": "false",
+ "aria-expanded": "false"
+ } );
+
+ // If we're switching tabs, remove the old tab from the tab order.
+ // If we're opening from collapsed state, remove the previous tab from the tab order.
+ // If we're collapsing, then keep the collapsing tab in the tab order.
+ if ( toShow.length && toHide.length ) {
+ eventData.oldTab.attr( "tabIndex", -1 );
+ } else if ( toShow.length ) {
+ this.tabs.filter( function() {
+ return $( this ).attr( "tabIndex" ) === 0;
+ } )
+ .attr( "tabIndex", -1 );
+ }
+
+ toShow.attr( "aria-hidden", "false" );
+ eventData.newTab.attr( {
+ "aria-selected": "true",
+ "aria-expanded": "true",
+ tabIndex: 0
+ } );
+ },
+
+ _activate: function( index ) {
+ var anchor,
+ active = this._findActive( index );
+
+ // Trying to activate the already active panel
+ if ( active[ 0 ] === this.active[ 0 ] ) {
+ return;
+ }
+
+ // Trying to collapse, simulate a click on the current active header
+ if ( !active.length ) {
+ active = this.active;
+ }
+
+ anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
+ this._eventHandler( {
+ target: anchor,
+ currentTarget: anchor,
+ preventDefault: $.noop
+ } );
+ },
+
+ _findActive: function( index ) {
+ return index === false ? $() : this.tabs.eq( index );
+ },
+
+ _getIndex: function( index ) {
+
+ // meta-function to give users option to provide a href string instead of a numerical index.
+ if ( typeof index === "string" ) {
+ index = this.anchors.index( this.anchors.filter( "[href$='" +
+ $.ui.escapeSelector( index ) + "']" ) );
+ }
+
+ return index;
+ },
+
+ _destroy: function() {
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+
+ this.tablist
+ .removeAttr( "role" )
+ .off( this.eventNamespace );
+
+ this.anchors
+ .removeAttr( "role tabIndex" )
+ .removeUniqueId();
+
+ this.tabs.add( this.panels ).each( function() {
+ if ( $.data( this, "ui-tabs-destroy" ) ) {
+ $( this ).remove();
+ } else {
+ $( this ).removeAttr( "role tabIndex " +
+ "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
+ }
+ } );
+
+ this.tabs.each( function() {
+ var li = $( this ),
+ prev = li.data( "ui-tabs-aria-controls" );
+ if ( prev ) {
+ li
+ .attr( "aria-controls", prev )
+ .removeData( "ui-tabs-aria-controls" );
+ } else {
+ li.removeAttr( "aria-controls" );
+ }
+ } );
+
+ this.panels.show();
+
+ if ( this.options.heightStyle !== "content" ) {
+ this.panels.css( "height", "" );
+ }
+ },
+
+ enable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === false ) {
+ return;
+ }
+
+ if ( index === undefined ) {
+ disabled = false;
+ } else {
+ index = this._getIndex( index );
+ if ( $.isArray( disabled ) ) {
+ disabled = $.map( disabled, function( num ) {
+ return num !== index ? num : null;
+ } );
+ } else {
+ disabled = $.map( this.tabs, function( li, num ) {
+ return num !== index ? num : null;
+ } );
+ }
+ }
+ this._setOptionDisabled( disabled );
+ },
+
+ disable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === true ) {
+ return;
+ }
+
+ if ( index === undefined ) {
+ disabled = true;
+ } else {
+ index = this._getIndex( index );
+ if ( $.inArray( index, disabled ) !== -1 ) {
+ return;
+ }
+ if ( $.isArray( disabled ) ) {
+ disabled = $.merge( [ index ], disabled ).sort();
+ } else {
+ disabled = [ index ];
+ }
+ }
+ this._setOptionDisabled( disabled );
+ },
+
+ load: function( index, event ) {
+ index = this._getIndex( index );
+ var that = this,
+ tab = this.tabs.eq( index ),
+ anchor = tab.find( ".ui-tabs-anchor" ),
+ panel = this._getPanelForTab( tab ),
+ eventData = {
+ tab: tab,
+ panel: panel
+ },
+ complete = function( jqXHR, status ) {
+ if ( status === "abort" ) {
+ that.panels.stop( false, true );
+ }
+
+ that._removeClass( tab, "ui-tabs-loading" );
+ panel.removeAttr( "aria-busy" );
+
+ if ( jqXHR === that.xhr ) {
+ delete that.xhr;
+ }
+ };
+
+ // Not remote
+ if ( this._isLocal( anchor[ 0 ] ) ) {
+ return;
+ }
+
+ this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
+
+ // Support: jQuery <1.8
+ // jQuery <1.8 returns false if the request is canceled in beforeSend,
+ // but as of 1.8, $.ajax() always returns a jqXHR object.
+ if ( this.xhr && this.xhr.statusText !== "canceled" ) {
+ this._addClass( tab, "ui-tabs-loading" );
+ panel.attr( "aria-busy", "true" );
+
+ this.xhr
+ .done( function( response, status, jqXHR ) {
+
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout( function() {
+ panel.html( response );
+ that._trigger( "load", event, eventData );
+
+ complete( jqXHR, status );
+ }, 1 );
+ } )
+ .fail( function( jqXHR, status ) {
+
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout( function() {
+ complete( jqXHR, status );
+ }, 1 );
+ } );
+ }
+ },
+
+ _ajaxSettings: function( anchor, event, eventData ) {
+ var that = this;
+ return {
+
+ // Support: IE <11 only
+ // Strip any hash that exists to prevent errors with the Ajax request
+ url: anchor.attr( "href" ).replace( /#.*$/, "" ),
+ beforeSend: function( jqXHR, settings ) {
+ return that._trigger( "beforeLoad", event,
+ $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
+ }
+ };
+ },
+
+ _getPanelForTab: function( tab ) {
+ var id = $( tab ).attr( "aria-controls" );
+ return this.element.find( this._sanitizeSelector( "#" + id ) );
+ }
+} );
+
+// DEPRECATED
+// TODO: Switch return back to widget declaration at top of file when this is removed
+if ( $.uiBackCompat !== false ) {
+
+ // Backcompat for ui-tab class (now ui-tabs-tab)
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _processTabs: function() {
+ this._superApply( arguments );
+ this._addClass( this.tabs, "ui-tab" );
+ }
+ } );
+}
+
+var widgetsTabs = $.ui.tabs;
+
+
+/*!
+ * jQuery UI Tooltip 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Tooltip
+//>>group: Widgets
+//>>description: Shows additional information for any element on hover or focus.
+//>>docs: http://api.jqueryui.com/tooltip/
+//>>demos: http://jqueryui.com/tooltip/
+//>>css.structure: ../../themes/base/core.css
+//>>css.structure: ../../themes/base/tooltip.css
+//>>css.theme: ../../themes/base/theme.css
+
+
+
+$.widget( "ui.tooltip", {
+ version: "1.12.1",
+ options: {
+ classes: {
+ "ui-tooltip": "ui-corner-all ui-widget-shadow"
+ },
+ content: function() {
+
+ // support: IE<9, Opera in jQuery <1.7
+ // .text() can't accept undefined, so coerce to a string
+ var title = $( this ).attr( "title" ) || "";
+
+ // Escape title, since we're going from an attribute to raw HTML
+ return $( "<a>" ).text( title ).html();
+ },
+ hide: true,
+
+ // Disabled elements have inconsistent behavior across browsers (#8661)
+ items: "[title]:not([disabled])",
+ position: {
+ my: "left top+15",
+ at: "left bottom",
+ collision: "flipfit flip"
+ },
+ show: true,
+ track: false,
+
+ // Callbacks
+ close: null,
+ open: null
+ },
+
+ _addDescribedBy: function( elem, id ) {
+ var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
+ describedby.push( id );
+ elem
+ .data( "ui-tooltip-id", id )
+ .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
+ },
+
+ _removeDescribedBy: function( elem ) {
+ var id = elem.data( "ui-tooltip-id" ),
+ describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
+ index = $.inArray( id, describedby );
+
+ if ( index !== -1 ) {
+ describedby.splice( index, 1 );
+ }
+
+ elem.removeData( "ui-tooltip-id" );
+ describedby = $.trim( describedby.join( " " ) );
+ if ( describedby ) {
+ elem.attr( "aria-describedby", describedby );
+ } else {
+ elem.removeAttr( "aria-describedby" );
+ }
+ },
+
+ _create: function() {
+ this._on( {
+ mouseover: "open",
+ focusin: "open"
+ } );
+
+ // IDs of generated tooltips, needed for destroy
+ this.tooltips = {};
+
+ // IDs of parent tooltips where we removed the title attribute
+ this.parents = {};
+
+ // Append the aria-live region so tooltips announce correctly
+ this.liveRegion = $( "<div>" )
+ .attr( {
+ role: "log",
+ "aria-live": "assertive",
+ "aria-relevant": "additions"
+ } )
+ .appendTo( this.document[ 0 ].body );
+ this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
+
+ this.disabledTitles = $( [] );
+ },
+
+ _setOption: function( key, value ) {
+ var that = this;
+
+ this._super( key, value );
+
+ if ( key === "content" ) {
+ $.each( this.tooltips, function( id, tooltipData ) {
+ that._updateContent( tooltipData.element );
+ } );
+ }
+ },
+
+ _setOptionDisabled: function( value ) {
+ this[ value ? "_disable" : "_enable" ]();
+ },
+
+ _disable: function() {
+ var that = this;
+
+ // Close open tooltips
+ $.each( this.tooltips, function( id, tooltipData ) {
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = tooltipData.element[ 0 ];
+ that.close( event, true );
+ } );
+
+ // Remove title attributes to prevent native tooltips
+ this.disabledTitles = this.disabledTitles.add(
+ this.element.find( this.options.items ).addBack()
+ .filter( function() {
+ var element = $( this );
+ if ( element.is( "[title]" ) ) {
+ return element
+ .data( "ui-tooltip-title", element.attr( "title" ) )
+ .removeAttr( "title" );
+ }
+ } )
+ );
+ },
+
+ _enable: function() {
+
+ // restore title attributes
+ this.disabledTitles.each( function() {
+ var element = $( this );
+ if ( element.data( "ui-tooltip-title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ }
+ } );
+ this.disabledTitles = $( [] );
+ },
+
+ open: function( event ) {
+ var that = this,
+ target = $( event ? event.target : this.element )
+
+ // we need closest here due to mouseover bubbling,
+ // but always pointing at the same event target
+ .closest( this.options.items );
+
+ // No element to show a tooltip for or the tooltip is already open
+ if ( !target.length || target.data( "ui-tooltip-id" ) ) {
+ return;
+ }
+
+ if ( target.attr( "title" ) ) {
+ target.data( "ui-tooltip-title", target.attr( "title" ) );
+ }
+
+ target.data( "ui-tooltip-open", true );
+
+ // Kill parent tooltips, custom or native, for hover
+ if ( event && event.type === "mouseover" ) {
+ target.parents().each( function() {
+ var parent = $( this ),
+ blurEvent;
+ if ( parent.data( "ui-tooltip-open" ) ) {
+ blurEvent = $.Event( "blur" );
+ blurEvent.target = blurEvent.currentTarget = this;
+ that.close( blurEvent, true );
+ }
+ if ( parent.attr( "title" ) ) {
+ parent.uniqueId();
+ that.parents[ this.id ] = {
+ element: this,
+ title: parent.attr( "title" )
+ };
+ parent.attr( "title", "" );
+ }
+ } );
+ }
+
+ this._registerCloseHandlers( event, target );
+ this._updateContent( target, event );
+ },
+
+ _updateContent: function( target, event ) {
+ var content,
+ contentOption = this.options.content,
+ that = this,
+ eventType = event ? event.type : null;
+
+ if ( typeof contentOption === "string" || contentOption.nodeType ||
+ contentOption.jquery ) {
+ return this._open( event, target, contentOption );
+ }
+
+ content = contentOption.call( target[ 0 ], function( response ) {
+
+ // IE may instantly serve a cached response for ajax requests
+ // delay this call to _open so the other call to _open runs first
+ that._delay( function() {
+
+ // Ignore async response if tooltip was closed already
+ if ( !target.data( "ui-tooltip-open" ) ) {
+ return;
+ }
+
+ // JQuery creates a special event for focusin when it doesn't
+ // exist natively. To improve performance, the native event
+ // object is reused and the type is changed. Therefore, we can't
+ // rely on the type being correct after the event finished
+ // bubbling, so we set it back to the previous value. (#8740)
+ if ( event ) {
+ event.type = eventType;
+ }
+ this._open( event, target, response );
+ } );
+ } );
+ if ( content ) {
+ this._open( event, target, content );
+ }
+ },
+
+ _open: function( event, target, content ) {
+ var tooltipData, tooltip, delayedShow, a11yContent,
+ positionOption = $.extend( {}, this.options.position );
+
+ if ( !content ) {
+ return;
+ }
+
+ // Content can be updated multiple times. If the tooltip already
+ // exists, then just update the content and bail.
+ tooltipData = this._find( target );
+ if ( tooltipData ) {
+ tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
+ return;
+ }
+
+ // If we have a title, clear it to prevent the native tooltip
+ // we have to check first to avoid defining a title if none exists
+ // (we don't want to cause an element to start matching [title])
+ //
+ // We use removeAttr only for key events, to allow IE to export the correct
+ // accessible attributes. For mouse events, set to empty string to avoid
+ // native tooltip showing up (happens only when removing inside mouseover).
+ if ( target.is( "[title]" ) ) {
+ if ( event && event.type === "mouseover" ) {
+ target.attr( "title", "" );
+ } else {
+ target.removeAttr( "title" );
+ }
+ }
+
+ tooltipData = this._tooltip( target );
+ tooltip = tooltipData.tooltip;
+ this._addDescribedBy( target, tooltip.attr( "id" ) );
+ tooltip.find( ".ui-tooltip-content" ).html( content );
+
+ // Support: Voiceover on OS X, JAWS on IE <= 9
+ // JAWS announces deletions even when aria-relevant="additions"
+ // Voiceover will sometimes re-read the entire log region's contents from the beginning
+ this.liveRegion.children().hide();
+ a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
+ a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
+ a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
+ a11yContent.appendTo( this.liveRegion );
+
+ function position( event ) {
+ positionOption.of = event;
+ if ( tooltip.is( ":hidden" ) ) {
+ return;
+ }
+ tooltip.position( positionOption );
+ }
+ if ( this.options.track && event && /^mouse/.test( event.type ) ) {
+ this._on( this.document, {
+ mousemove: position
+ } );
+
+ // trigger once to override element-relative positioning
+ position( event );
+ } else {
+ tooltip.position( $.extend( {
+ of: target
+ }, this.options.position ) );
+ }
+
+ tooltip.hide();
+
+ this._show( tooltip, this.options.show );
+
+ // Handle tracking tooltips that are shown with a delay (#8644). As soon
+ // as the tooltip is visible, position the tooltip using the most recent
+ // event.
+ // Adds the check to add the timers only when both delay and track options are set (#14682)
+ if ( this.options.track && this.options.show && this.options.show.delay ) {
+ delayedShow = this.delayedShow = setInterval( function() {
+ if ( tooltip.is( ":visible" ) ) {
+ position( positionOption.of );
+ clearInterval( delayedShow );
+ }
+ }, $.fx.interval );
+ }
+
+ this._trigger( "open", event, { tooltip: tooltip } );
+ },
+
+ _registerCloseHandlers: function( event, target ) {
+ var events = {
+ keyup: function( event ) {
+ if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
+ var fakeEvent = $.Event( event );
+ fakeEvent.currentTarget = target[ 0 ];
+ this.close( fakeEvent, true );
+ }
+ }
+ };
+
+ // Only bind remove handler for delegated targets. Non-delegated
+ // tooltips will handle this in destroy.
+ if ( target[ 0 ] !== this.element[ 0 ] ) {
+ events.remove = function() {
+ this._removeTooltip( this._find( target ).tooltip );
+ };
+ }
+
+ if ( !event || event.type === "mouseover" ) {
+ events.mouseleave = "close";
+ }
+ if ( !event || event.type === "focusin" ) {
+ events.focusout = "close";
+ }
+ this._on( true, target, events );
+ },
+
+ close: function( event ) {
+ var tooltip,
+ that = this,
+ target = $( event ? event.currentTarget : this.element ),
+ tooltipData = this._find( target );
+
+ // The tooltip may already be closed
+ if ( !tooltipData ) {
+
+ // We set ui-tooltip-open immediately upon open (in open()), but only set the
+ // additional data once there's actually content to show (in _open()). So even if the
+ // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
+ // the period between open() and _open().
+ target.removeData( "ui-tooltip-open" );
+ return;
+ }
+
+ tooltip = tooltipData.tooltip;
+
+ // Disabling closes the tooltip, so we need to track when we're closing
+ // to avoid an infinite loop in case the tooltip becomes disabled on close
+ if ( tooltipData.closing ) {
+ return;
+ }
+
+ // Clear the interval for delayed tracking tooltips
+ clearInterval( this.delayedShow );
+
+ // Only set title if we had one before (see comment in _open())
+ // If the title attribute has changed since open(), don't restore
+ if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
+ target.attr( "title", target.data( "ui-tooltip-title" ) );
+ }
+
+ this._removeDescribedBy( target );
+
+ tooltipData.hiding = true;
+ tooltip.stop( true );
+ this._hide( tooltip, this.options.hide, function() {
+ that._removeTooltip( $( this ) );
+ } );
+
+ target.removeData( "ui-tooltip-open" );
+ this._off( target, "mouseleave focusout keyup" );
+
+ // Remove 'remove' binding only on delegated targets
+ if ( target[ 0 ] !== this.element[ 0 ] ) {
+ this._off( target, "remove" );
+ }
+ this._off( this.document, "mousemove" );
+
+ if ( event && event.type === "mouseleave" ) {
+ $.each( this.parents, function( id, parent ) {
+ $( parent.element ).attr( "title", parent.title );
+ delete that.parents[ id ];
+ } );
+ }
+
+ tooltipData.closing = true;
+ this._trigger( "close", event, { tooltip: tooltip } );
+ if ( !tooltipData.hiding ) {
+ tooltipData.closing = false;
+ }
+ },
+
+ _tooltip: function( element ) {
+ var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
+ content = $( "<div>" ).appendTo( tooltip ),
+ id = tooltip.uniqueId().attr( "id" );
+
+ this._addClass( content, "ui-tooltip-content" );
+ this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
+
+ tooltip.appendTo( this._appendTo( element ) );
+
+ return this.tooltips[ id ] = {
+ element: element,
+ tooltip: tooltip
+ };
+ },
+
+ _find: function( target ) {
+ var id = target.data( "ui-tooltip-id" );
+ return id ? this.tooltips[ id ] : null;
+ },
+
+ _removeTooltip: function( tooltip ) {
+ tooltip.remove();
+ delete this.tooltips[ tooltip.attr( "id" ) ];
+ },
+
+ _appendTo: function( target ) {
+ var element = target.closest( ".ui-front, dialog" );
+
+ if ( !element.length ) {
+ element = this.document[ 0 ].body;
+ }
+
+ return element;
+ },
+
+ _destroy: function() {
+ var that = this;
+
+ // Close open tooltips
+ $.each( this.tooltips, function( id, tooltipData ) {
+
+ // Delegate to close method to handle common cleanup
+ var event = $.Event( "blur" ),
+ element = tooltipData.element;
+ event.target = event.currentTarget = element[ 0 ];
+ that.close( event, true );
+
+ // Remove immediately; destroying an open tooltip doesn't use the
+ // hide animation
+ $( "#" + id ).remove();
+
+ // Restore the title
+ if ( element.data( "ui-tooltip-title" ) ) {
+
+ // If the title attribute has changed since open(), don't restore
+ if ( !element.attr( "title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ }
+ element.removeData( "ui-tooltip-title" );
+ }
+ } );
+ this.liveRegion.remove();
+ }
+} );
+
+// DEPRECATED
+// TODO: Switch return back to widget declaration at top of file when this is removed
+if ( $.uiBackCompat !== false ) {
+
+ // Backcompat for tooltipClass option
+ $.widget( "ui.tooltip", $.ui.tooltip, {
+ options: {
+ tooltipClass: null
+ },
+ _tooltip: function() {
+ var tooltipData = this._superApply( arguments );
+ if ( this.options.tooltipClass ) {
+ tooltipData.tooltip.addClass( this.options.tooltipClass );
+ }
+ return tooltipData;
+ }
+ } );
+}
+
+var widgetsTooltip = $.ui.tooltip;
+
+
+
+
+}));
\ No newline at end of file
--- /dev/null
+++ b/js/jqueryui/tabs.html
@@ -1,0 +1,39 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>jQuery UI Tabs - Default functionality</title>
+ <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
+ <link rel="stylesheet" href="/resources/demos/style.css">
+ <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
+ <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
+ <script>
+ $( function() {
+ $( "#tabs" ).tabs();
+ } );
+ </script>
+</head>
+<body>
+
+<div id="tabs">
+ <ul>
+ <li><a href="#tabs-1">Nunc tincidunt</a></li>
+ <li><a href="#tabs-2">Proin dolor</a></li>
+ <li><a href="#tabs-3">Aenean lacinia</a></li>
+ </ul>
+ <div id="tabs-1">
+ <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
+ </div>
+ <div id="tabs-2">
+ <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
+ </div>
+ <div id="tabs-3">
+ <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
+ <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
+ </div>
+</div>
+
+
+</body>
+</html>
--- /dev/null
+++ b/js/jqueryui/tabs.js
@@ -1,0 +1,3 @@
+$( function() {
+ $( "#tabs" ).tabs();
+} );
--- /dev/null
+++ b/js/js.go
@@ -1,0 +1,247 @@
+package js
+
+import (
+ "9fans.net/go/plan9"
+ "9fans.net/go/plan9/client"
+ "bufio"
+ "bytes"
+ "context"
+ "fmt"
+ "golang.org/x/net/html"
+ "io"
+ "github.com/psilva261/opossum"
+ "github.com/psilva261/opossum/logger"
+ "github.com/psilva261/opossum/nodes"
+ "os"
+ "os/exec"
+ "os/user"
+ "strings"
+ "time"
+)
+
+var DebugDumpJS *bool
+var log *logger.Logger
+var timeout = 60*time.Second
+
+func SetLogger(l *logger.Logger) {
+ log = l
+}
+
+type ReadWriteCloser struct {
+ io.Reader
+ io.Writer
+ io.Closer
+}
+
+var (
+ fetcher opossum.Fetcher
+ nt *nodes.Node
+
+ fsys *client.Fsys
+ cancel context.CancelFunc
+)
+
+func NewJS(html string, fetcher opossum.Fetcher, nn *nodes.Node) {
+ nt = nn
+ return
+}
+
+func call(fn, cmd string, args... string) (resp string, err error) {
+ fid, err := fsys.Open(fn, plan9.ORDWR)
+ if err != nil {
+ return
+ }
+ defer fid.Close()
+ fid.Write([]byte(cmd+"\n"))
+ for _, arg := range args {
+ fid.Write([]byte(arg+"\n"))
+ }
+ r := bufio.NewReader(fid)
+ b := bytes.NewBuffer([]byte{})
+ _, err = io.Copy(b, r)
+ if err != nil && !strings.Contains(err.Error(), io.ErrClosedPipe.Error()) {
+ return "", fmt.Errorf("unexpected error: %v", err)
+ }
+ return b.String(), nil
+}
+
+// Start with pre-defined scripts
+func Start(scripts ...string) (resHtm string, changed bool, err error) {
+ args := make([]string, 0, len(scripts)+2)
+ args = append(args, "-s", "opossum")
+ log.Infof("Start gojafs")
+
+ var ctx context.Context
+ ctx, cancel = context.WithCancel(context.Background())
+ cmd := exec.CommandContext(ctx, "gojafs", args...)
+ cmd.Stderr = os.Stderr
+ stdin, err := cmd.StdinPipe()
+ if err != nil {
+ return "", false, fmt.Errorf("stdin pipe: %w", err)
+ }
+ stdout, err := cmd.StdoutPipe()
+ if err != nil {
+ return "", false, fmt.Errorf("stdout pipe: %w", err)
+ }
+ rwc := &ReadWriteCloser{
+ Reader: stdout,
+ Writer: stdin,
+ Closer: stdin,
+ }
+
+ log.Infof("cmd.Start...")
+ if err = cmd.Start(); err != nil {
+ return "", false, fmt.Errorf("start: %w", err)
+ }
+ // Prevent Zombie processes after stopping
+ go cmd.Wait()
+
+ conn, err := client.NewConn(rwc)
+ if err != nil {
+ return "", false, fmt.Errorf("new conn: %w", err)
+ }
+ log.Infof("cmd.Connected...")
+ u, err := user.Current()
+ if err != nil {
+ return
+ }
+ un := u.Username
+ fsys, err = conn.Attach(nil, un, "")
+ if err != nil {
+ return
+ }
+ log.Infof("cmd.Attached...")
+
+ resp, err := call("ctl", "start")
+ if err != nil {
+ return "", false, fmt.Errorf("%v", err)
+ }
+
+ if resp != "" {
+ resHtm = resp
+ changed = true
+ }
+
+ return
+}
+
+func Stop() {
+ log.Infof("Stop devjs")
+ if cancel != nil {
+ cancel()
+ }
+}
+
+func printCode(code string, maxWidth int) {
+ if maxWidth > len(code) {
+ maxWidth = len(code)
+ }
+ log.Infof("js code: %v", code[:maxWidth])
+}
+
+// TriggerClick, and return the result html
+// ...then HTML5 parse it, diff the node tree
+// (probably faster and cleaner than anything else)
+func TriggerClick(selector string) (newHTML string, ok bool, err error) {
+ newHTML, err = call("ctl", "click", selector)
+ ok = newHTML != "" && err == nil
+ return
+}
+
+func Srcs(doc *nodes.Node) (srcs []string) {
+ srcs = make([]string, 0, 3)
+
+ iterateJsElements(doc, func(src, inlineCode string) {
+ if src = strings.TrimSpace(src); src != "" && !blocked(src) {
+ srcs = append(srcs, src)
+ }
+ })
+
+ return
+}
+
+func blocked(src string) bool {
+ for _, s := range []string{
+ "adsense",
+ "adsystem",
+ "adservice",
+ "googletagservice",
+ "googletagmanager",
+ "script.ioam.de",
+ "googlesyndication",
+ "adserver",
+ "nativeads",
+ "prebid",
+ ".ads.",
+ "google-analytics.com",
+ } {
+ if strings.Contains(src, s) {
+ return true
+ }
+ }
+ return false
+}
+
+func Scripts(doc *nodes.Node, downloads map[string]string) (codes []string) {
+ codes = make([]string, 0, 3)
+
+ iterateJsElements(doc, func(src, inlineCode string) {
+ if strings.TrimSpace(inlineCode) != "" {
+ log.Infof("JS.Scripts: inline code:")
+ printCode(inlineCode, 20)
+ codes = append(codes, inlineCode)
+ } else if c, ok := downloads[src]; ok {
+ log.Infof("JS.Scripts: referenced code (%v)", src)
+ codes = append(codes, c)
+ }
+ })
+
+ return
+}
+
+func iterateJsElements(doc *nodes.Node, fn func(src string, inlineCode string)) {
+ var f func(n *nodes.Node)
+ f = func(n *nodes.Node) {
+ if n.Type() == html.ElementNode && n.Data() == "script" {
+ isJS := true
+ src := ""
+
+ for _, a := range n.Attrs {
+ switch strings.ToLower(a.Key) {
+ case "type":
+ t, err := opossum.NewContentType(a.Val, nil)
+ if err != nil {
+ log.Printf("t: %v", err)
+ }
+ if a.Val == "" || t.IsJS() {
+ isJS = true
+ } else {
+ isJS = false
+ }
+ case "src":
+ src = a.Val
+ }
+ }
+
+ if isJS {
+ fn(src, n.ContentString(true))
+ }
+ }
+ for _, c := range n.Children {
+ f(c)
+ }
+ }
+
+ f(doc)
+
+ return
+}
+
+// AJAX:
+// https://stackoverflow.com/questions/7086858/loading-ajax-app-with-jsdom
+
+// Babel on Goja:
+// https://github.com/dop251/goja/issues/5#issuecomment-259996573
+
+// Goja supports ES5.1 which is essentially JS assembly:
+// https://github.com/dop251/goja/issues/76#issuecomment-399253779
--- /dev/null
+++ b/js/js_test.go
@@ -1,0 +1,69 @@
+package js
+
+import (
+ "io/ioutil"
+ "github.com/psilva261/opossum/browser/fs"
+ "github.com/psilva261/opossum/logger"
+ "github.com/psilva261/opossum/nodes"
+ "github.com/psilva261/opossum/style"
+ "golang.org/x/net/html"
+ "strings"
+ "testing"
+)
+
+const simpleHTML = `
+<html>
+<body>
+<h1 id="title">Hello</h1>
+</body>
+</html>
+`
+
+func init() {
+ f := false
+ t := true
+ DebugDumpJS = &t
+ logger.Quiet = &f
+ logger.Init()
+ log = &logger.Logger{Debug: true}
+ fs.SetLogger(log)
+ go fs.Srv9p()
+}
+
+func TestJQueryHide(t *testing.T) {
+ buf, err := ioutil.ReadFile("jquery-3.5.1.js")
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ script := `
+ $(document).ready(function() {
+ $('h1').hide();
+ });
+ `
+
+ r := strings.NewReader(simpleHTML)
+ doc, err := html.Parse(r)
+ if err != nil { t.Fatalf(err.Error()) }
+ nt := nodes.NewNodeTree(doc, style.Map{}, make(map[*html.Node]style.Map), nil)
+ fs.DOM = nt
+ fs.Update(simpleHTML, nil, []string{string(buf), script})
+
+ NewJS(simpleHTML, nil, nil)
+ resHtm, changed, err := Start(string(buf), script)
+ if !changed {
+ t.Fatalf("changed=%v", changed)
+ }
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("resHtm=%v", resHtm)
+
+ r = strings.NewReader(resHtm)
+ doc, err = html.Parse(r)
+ if err != nil { t.Fatalf(err.Error()) }
+ nt = nodes.NewNodeTree(doc, style.Map{}, make(map[*html.Node]style.Map), nil)
+ if v := nt.Find("h1").Css("display"); v != "none" {
+ t.Fatalf("%v", v)
+ }
+ Stop()
+}