trebuild documentation - sphere - GPU-based 3D discrete element method algorith… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 54bb1feed1f0e59ee7a81ca5693d21c44b343b67 | |
parent 1e6f5ae916b9d9664d7db00e9975753606971b21 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 7 Sep 2017 13:09:04 -0700 | |
rebuild documentation | |
Diffstat: | |
M doc/html/.buildinfo | 4 ++-- | |
M doc/html/_sources/index.txt | 4 ++-- | |
M doc/html/_sources/introduction.txt | 35 +++++++++++++++++------------… | |
M doc/html/_static/basic.css | 99 ++++++++++++++++++++++++++---… | |
M doc/html/_static/comment-bright.png | 0 | |
M doc/html/_static/comment-close.png | 0 | |
M doc/html/_static/comment.png | 0 | |
M doc/html/_static/default.css | 258 +----------------------------… | |
M doc/html/_static/doctools.js | 73 ++++++++++++++++++++++++-----… | |
M doc/html/_static/down-pressed.png | 0 | |
M doc/html/_static/down.png | 0 | |
M doc/html/_static/file.png | 0 | |
M doc/html/_static/jquery.js | 15523 ++++++++++++++++-------------… | |
M doc/html/_static/minus.png | 0 | |
M doc/html/_static/plus.png | 0 | |
M doc/html/_static/pygments.css | 7 +++++++ | |
M doc/html/_static/searchtools.js | 466 +++++++++++++++++++++--------… | |
M doc/html/_static/sidebar.js | 15 ++++++++++++--- | |
M doc/html/_static/underscore.js | 1452 +++++++++++++++++++----------… | |
M doc/html/_static/up-pressed.png | 0 | |
M doc/html/_static/up.png | 0 | |
M doc/html/_static/websupport.js | 32 ++++++++++++++++-------------… | |
M doc/html/cfd.html | 240 +++++++++++++++--------------… | |
M doc/html/dem.html | 140 +++++++++++++++--------------… | |
M doc/html/genindex.html | 322 +++++++++++++++++++++++++++--… | |
M doc/html/index.html | 85 ++++++++++++++++-------------… | |
M doc/html/introduction.html | 196 +++++++++++++++++------------… | |
M doc/html/objects.inv | 0 | |
M doc/html/py-modindex.html | 44 ++++++++++++++---------------… | |
M doc/html/python_api.html | 1619 +++++++++++++++++++++++++----… | |
M doc/html/search.html | 31 +++++++++++++++--------------… | |
M doc/html/searchindex.js | 4 ++-- | |
M doc/html/sphere_internals.html | 268 +++++++----------------------… | |
M doc/pdf/sphere.pdf | 0 | |
M doc/sphinx/index.rst | 4 ++-- | |
M doc/sphinx/introduction.rst | 35 +++++++++++++++++------------… | |
36 files changed, 11615 insertions(+), 9341 deletions(-) | |
--- | |
diff --git a/doc/html/.buildinfo b/doc/html/.buildinfo | |
t@@ -1,4 +1,4 @@ | |
# Sphinx build info version 1 | |
# This file hashes the configuration used when building these files. When it i… | |
-config: 572cfe56c7acc603f39739a18d514093 | |
-tags: fbb0d17656682115ca4d033fb2f83ba1 | |
+config: fe70a33065653dc9f13fbefebe7ac2f6 | |
+tags: 645f666f9bcd5a90fca523b33c5a78b7 | |
diff --git a/doc/html/_sources/index.txt b/doc/html/_sources/index.txt | |
t@@ -14,7 +14,7 @@ supervision of David Lundbek Egholm and Jan A. Piotrowski, a… | |
of Geoscience, Aarhus University, Denmark. The author welcomes interested third | |
party developers. This document is a work in progress. | |
-Contact: Anders Damsgaard, `<http://cs.au.dk/~adc>`_, | |
+Contact: Anders Damsgaard, `<https://adamsgaard.dk>`_, | |
`<[email protected]>`_ | |
t@@ -27,7 +27,7 @@ Contents | |
dem | |
cfd | |
python_api | |
- .. sphere_internals | |
+ sphere_internals | |
diff --git a/doc/html/_sources/introduction.txt b/doc/html/_sources/introductio… | |
t@@ -1,5 +1,5 @@ | |
-Introduction | |
-============ | |
+Introduction and Installation | |
+============================= | |
The ``sphere``-software is used for three-dimensional discrete element method | |
(DEM) particle simulations. The source code is written in C++, CUDA C and | |
t@@ -37,11 +37,11 @@ The build requirements are: | |
* `CMake <http://www.cmake.org>`_, version 2.8 or newer | |
* The `GNU Compiler Collection <http://gcc.gnu.org/>`_ (GCC) | |
* The `Nvidia CUDA toolkit <https://developer.nvidia.com/cuda-downloads>`_, | |
- version 5.0 or newer | |
+ version 8.0 or newer | |
In Debian GNU/Linux, these dependencies can be installed by running:: | |
- $ sudo apt-get install build-essential cmake nvidia-cuda-toolkit | |
+ $ sudo apt-get install build-essential cmake nvidia-cuda-toolkit clang-3.8 | |
Unfortunately, the Nvidia Toolkit is shipped under a non-free license. In order | |
to install it in Debian GNU/Linux, add ``non-free`` archives to your | |
t@@ -50,7 +50,7 @@ to install it in Debian GNU/Linux, add ``non-free`` archives… | |
The runtime requirements are: | |
* A `CUDA-enabled GPU <http://www.nvidia.com/object/cuda_gpus.html>`_ with | |
- compute capability 1.1 or greater. | |
+ compute capability 2.0 or greater. | |
* A Nvidia CUDA-enabled GPU and device driver | |
Optional tools, required for simulation setup and data processing: | |
t@@ -113,11 +113,6 @@ Building ``sphere`` | |
``sphere`` is built using ``cmake``, the platform-specific C/C++ compilers, | |
and ``nvcc`` from the Nvidia CUDA toolkit. | |
-If you plan to run ``sphere`` on a Kepler GPU, execute the following commands | |
-from the root directory:: | |
- | |
- $ cmake . && make | |
- | |
If you instead plan to execute it on a Fermi GPU, change ``set(GPU_GENERATION | |
1)`` to ``set(GPU_GENERATION 0`` in ``CMakeLists.txt``. | |
t@@ -132,19 +127,27 @@ sample subdirectory ``common/inc/helper_math.h`` into th… | |
directory, and run ``cmake`` and ``make`` again. Due to license restrictions, | |
sphere cannot be distributed with this file. | |
+If you plan to run ``sphere`` on a Kepler GPU, execute the following commands | |
+from the root directory:: | |
+ | |
+ $ cmake . && make | |
+ | |
+NOTE: If your system does not have a GCC compiler (e.g. GCC-5 for CUDA 8) | |
+compatible with the installed CUDA version, try using ``clang-3.8`` instead:: | |
+ | |
+ $ export CC=$(which clang-3.8) && export CXX=$(which clang++-3.8) && cmake . … | |
+ | |
After a successfull installation, the ``sphere`` executable will be located | |
in the root folder. To make sure that all components are working correctly, | |
execute:: | |
$ make test | |
-All instructions required for building ``sphere`` are provided in a number of | |
-``Makefile``'s. To generate the main ``sphere`` command-line executable, go to | |
-the root directory, and invoke CMake and GNU Make:: | |
- | |
- $ cmake . && make | |
+Disclaimer: On some systems the Navier-Stokes related tests will fail. If you | |
+do encounter these problems, but do not plan on using the Navier Stokes solver | |
+for fluid dynamics, carry on. | |
-If successfull, the Makefiles will create the required data folders, object | |
+If successful the Makefiles will create the required data folders, object | |
files, as well as the ``sphere`` executable in the root folder. Issue the | |
following commands to check the executable:: | |
diff --git a/doc/html/_static/basic.css b/doc/html/_static/basic.css | |
t@@ -4,7 +4,7 @@ | |
* | |
* Sphinx stylesheet -- basic theme. | |
* | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | |
* :license: BSD, see LICENSE for details. | |
* | |
*/ | |
t@@ -52,6 +52,8 @@ div.sphinxsidebar { | |
width: 230px; | |
margin-left: -100%; | |
font-size: 90%; | |
+ word-wrap: break-word; | |
+ overflow-wrap : break-word; | |
} | |
div.sphinxsidebar ul { | |
t@@ -83,12 +85,9 @@ div.sphinxsidebar #searchbox input[type="text"] { | |
width: 170px; | |
} | |
-div.sphinxsidebar #searchbox input[type="submit"] { | |
- width: 30px; | |
-} | |
- | |
img { | |
border: 0; | |
+ max-width: 100%; | |
} | |
/* -- search page ----------------------------------------------------------- … | |
t@@ -186,6 +185,13 @@ div.genindex-jumpbox { | |
/* -- general body styles --------------------------------------------------- … | |
+div.body p, div.body dd, div.body li, div.body blockquote { | |
+ -moz-hyphens: auto; | |
+ -ms-hyphens: auto; | |
+ -webkit-hyphens: auto; | |
+ hyphens: auto; | |
+} | |
+ | |
a.headerlink { | |
visibility: hidden; | |
} | |
t@@ -196,7 +202,10 @@ h3:hover > a.headerlink, | |
h4:hover > a.headerlink, | |
h5:hover > a.headerlink, | |
h6:hover > a.headerlink, | |
-dt:hover > a.headerlink { | |
+dt:hover > a.headerlink, | |
+caption:hover > a.headerlink, | |
+p.caption:hover > a.headerlink, | |
+div.code-block-caption:hover > a.headerlink { | |
visibility: visible; | |
} | |
t@@ -313,6 +322,13 @@ table.docutils { | |
border-collapse: collapse; | |
} | |
+table caption span.caption-number { | |
+ font-style: italic; | |
+} | |
+ | |
+table caption span.caption-text { | |
+} | |
+ | |
table.docutils td, table.docutils th { | |
padding: 1px 8px 1px 5px; | |
border-top: 0; | |
t@@ -343,6 +359,25 @@ table.citation td { | |
border-bottom: none; | |
} | |
+/* -- figures --------------------------------------------------------------- … | |
+ | |
+div.figure { | |
+ margin: 0.5em; | |
+ padding: 0.5em; | |
+} | |
+ | |
+div.figure p.caption { | |
+ padding: 0.3em; | |
+} | |
+ | |
+div.figure p.caption span.caption-number { | |
+ font-style: italic; | |
+} | |
+ | |
+div.figure p.caption span.caption-text { | |
+} | |
+ | |
+ | |
/* -- other body styles ----------------------------------------------------- … | |
ol.arabic { | |
t@@ -401,14 +436,14 @@ dl.glossary dt { | |
margin: 0; | |
} | |
-.refcount { | |
- color: #060; | |
-} | |
- | |
.optional { | |
font-size: 1.3em; | |
} | |
+.sig-paren { | |
+ font-size: larger; | |
+} | |
+ | |
.versionmodified { | |
font-style: italic; | |
} | |
t@@ -459,6 +494,13 @@ pre { | |
overflow-y: hidden; /* fixes display issues on Chrome browsers */ | |
} | |
+span.pre { | |
+ -moz-hyphens: none; | |
+ -ms-hyphens: none; | |
+ -webkit-hyphens: none; | |
+ hyphens: none; | |
+} | |
+ | |
td.linenos pre { | |
padding: 5px 0px; | |
border: 0; | |
t@@ -474,22 +516,51 @@ table.highlighttable td { | |
padding: 0 0.5em 0 0.5em; | |
} | |
-tt.descname { | |
+div.code-block-caption { | |
+ padding: 2px 5px; | |
+ font-size: small; | |
+} | |
+ | |
+div.code-block-caption code { | |
+ background-color: transparent; | |
+} | |
+ | |
+div.code-block-caption + div > div.highlight > pre { | |
+ margin-top: 0; | |
+} | |
+ | |
+div.code-block-caption span.caption-number { | |
+ padding: 0.1em 0.3em; | |
+ font-style: italic; | |
+} | |
+ | |
+div.code-block-caption span.caption-text { | |
+} | |
+ | |
+div.literal-block-wrapper { | |
+ padding: 1em 1em 0; | |
+} | |
+ | |
+div.literal-block-wrapper div.highlight { | |
+ margin: 0; | |
+} | |
+ | |
+code.descname { | |
background-color: transparent; | |
font-weight: bold; | |
font-size: 1.2em; | |
} | |
-tt.descclassname { | |
+code.descclassname { | |
background-color: transparent; | |
} | |
-tt.xref, a tt { | |
+code.xref, a code { | |
background-color: transparent; | |
font-weight: bold; | |
} | |
-h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { | |
+h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { | |
background-color: transparent; | |
} | |
diff --git a/doc/html/_static/comment-bright.png b/doc/html/_static/comment-bri… | |
Binary files differ. | |
diff --git a/doc/html/_static/comment-close.png b/doc/html/_static/comment-clos… | |
Binary files differ. | |
diff --git a/doc/html/_static/comment.png b/doc/html/_static/comment.png | |
Binary files differ. | |
diff --git a/doc/html/_static/default.css b/doc/html/_static/default.css | |
t@@ -1,256 +1 @@ | |
-/* | |
- * default.css_t | |
- * ~~~~~~~~~~~~~ | |
- * | |
- * Sphinx stylesheet -- default theme. | |
- * | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
- * :license: BSD, see LICENSE for details. | |
- * | |
- */ | |
- | |
-@import url("basic.css"); | |
- | |
-/* -- page layout ----------------------------------------------------------- … | |
- | |
-body { | |
- font-family: sans-serif; | |
- font-size: 100%; | |
- background-color: #11303d; | |
- color: #000; | |
- margin: 0; | |
- padding: 0; | |
-} | |
- | |
-div.document { | |
- background-color: #1c4e63; | |
-} | |
- | |
-div.documentwrapper { | |
- float: left; | |
- width: 100%; | |
-} | |
- | |
-div.bodywrapper { | |
- margin: 0 0 0 230px; | |
-} | |
- | |
-div.body { | |
- background-color: #ffffff; | |
- color: #000000; | |
- padding: 0 20px 30px 20px; | |
-} | |
- | |
-div.footer { | |
- color: #ffffff; | |
- width: 100%; | |
- padding: 9px 0 9px 0; | |
- text-align: center; | |
- font-size: 75%; | |
-} | |
- | |
-div.footer a { | |
- color: #ffffff; | |
- text-decoration: underline; | |
-} | |
- | |
-div.related { | |
- background-color: #133f52; | |
- line-height: 30px; | |
- color: #ffffff; | |
-} | |
- | |
-div.related a { | |
- color: #ffffff; | |
-} | |
- | |
-div.sphinxsidebar { | |
-} | |
- | |
-div.sphinxsidebar h3 { | |
- font-family: 'Trebuchet MS', sans-serif; | |
- color: #ffffff; | |
- font-size: 1.4em; | |
- font-weight: normal; | |
- margin: 0; | |
- padding: 0; | |
-} | |
- | |
-div.sphinxsidebar h3 a { | |
- color: #ffffff; | |
-} | |
- | |
-div.sphinxsidebar h4 { | |
- font-family: 'Trebuchet MS', sans-serif; | |
- color: #ffffff; | |
- font-size: 1.3em; | |
- font-weight: normal; | |
- margin: 5px 0 0 0; | |
- padding: 0; | |
-} | |
- | |
-div.sphinxsidebar p { | |
- color: #ffffff; | |
-} | |
- | |
-div.sphinxsidebar p.topless { | |
- margin: 5px 10px 10px 10px; | |
-} | |
- | |
-div.sphinxsidebar ul { | |
- margin: 10px; | |
- padding: 0; | |
- color: #ffffff; | |
-} | |
- | |
-div.sphinxsidebar a { | |
- color: #98dbcc; | |
-} | |
- | |
-div.sphinxsidebar input { | |
- border: 1px solid #98dbcc; | |
- font-family: sans-serif; | |
- font-size: 1em; | |
-} | |
- | |
- | |
- | |
-/* -- hyperlink styles ------------------------------------------------------ … | |
- | |
-a { | |
- color: #355f7c; | |
- text-decoration: none; | |
-} | |
- | |
-a:visited { | |
- color: #355f7c; | |
- text-decoration: none; | |
-} | |
- | |
-a:hover { | |
- text-decoration: underline; | |
-} | |
- | |
- | |
- | |
-/* -- body styles ----------------------------------------------------------- … | |
- | |
-div.body h1, | |
-div.body h2, | |
-div.body h3, | |
-div.body h4, | |
-div.body h5, | |
-div.body h6 { | |
- font-family: 'Trebuchet MS', sans-serif; | |
- background-color: #f2f2f2; | |
- font-weight: normal; | |
- color: #20435c; | |
- border-bottom: 1px solid #ccc; | |
- margin: 20px -20px 10px -20px; | |
- padding: 3px 0 3px 10px; | |
-} | |
- | |
-div.body h1 { margin-top: 0; font-size: 200%; } | |
-div.body h2 { font-size: 160%; } | |
-div.body h3 { font-size: 140%; } | |
-div.body h4 { font-size: 120%; } | |
-div.body h5 { font-size: 110%; } | |
-div.body h6 { font-size: 100%; } | |
- | |
-a.headerlink { | |
- color: #c60f0f; | |
- font-size: 0.8em; | |
- padding: 0 4px 0 4px; | |
- text-decoration: none; | |
-} | |
- | |
-a.headerlink:hover { | |
- background-color: #c60f0f; | |
- color: white; | |
-} | |
- | |
-div.body p, div.body dd, div.body li { | |
- text-align: justify; | |
- line-height: 130%; | |
-} | |
- | |
-div.admonition p.admonition-title + p { | |
- display: inline; | |
-} | |
- | |
-div.admonition p { | |
- margin-bottom: 5px; | |
-} | |
- | |
-div.admonition pre { | |
- margin-bottom: 5px; | |
-} | |
- | |
-div.admonition ul, div.admonition ol { | |
- margin-bottom: 5px; | |
-} | |
- | |
-div.note { | |
- background-color: #eee; | |
- border: 1px solid #ccc; | |
-} | |
- | |
-div.seealso { | |
- background-color: #ffc; | |
- border: 1px solid #ff6; | |
-} | |
- | |
-div.topic { | |
- background-color: #eee; | |
-} | |
- | |
-div.warning { | |
- background-color: #ffe4e4; | |
- border: 1px solid #f66; | |
-} | |
- | |
-p.admonition-title { | |
- display: inline; | |
-} | |
- | |
-p.admonition-title:after { | |
- content: ":"; | |
-} | |
- | |
-pre { | |
- padding: 5px; | |
- background-color: #eeffcc; | |
- color: #333333; | |
- line-height: 120%; | |
- border: 1px solid #ac9; | |
- border-left: none; | |
- border-right: none; | |
-} | |
- | |
-tt { | |
- background-color: #ecf0f3; | |
- padding: 0 1px 0 1px; | |
- font-size: 0.95em; | |
-} | |
- | |
-th { | |
- background-color: #ede; | |
-} | |
- | |
-.warning tt { | |
- background: #efc2c2; | |
-} | |
- | |
-.note tt { | |
- background: #d6d6d6; | |
-} | |
- | |
-.viewcode-back { | |
- font-family: sans-serif; | |
-} | |
- | |
-div.viewcode-block:target { | |
- background-color: #f4debf; | |
- border-top: 1px solid #ac9; | |
- border-bottom: 1px solid #ac9; | |
-} | |
-\ No newline at end of file | |
+@import url("classic.css"); | |
diff --git a/doc/html/_static/doctools.js b/doc/html/_static/doctools.js | |
t@@ -4,7 +4,7 @@ | |
* | |
* Sphinx JavaScript utilities for all documentation. | |
* | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | |
* :license: BSD, see LICENSE for details. | |
* | |
*/ | |
t@@ -32,7 +32,7 @@ if (!window.console || !console.firebug) { | |
*/ | |
jQuery.urldecode = function(x) { | |
return decodeURIComponent(x).replace(/\+/g, ' '); | |
-} | |
+}; | |
/** | |
* small helper function to urlencode strings | |
t@@ -62,18 +62,6 @@ jQuery.getQueryParameters = function(s) { | |
}; | |
/** | |
- * small function to check if an array contains | |
- * a given item. | |
- */ | |
-jQuery.contains = function(arr, item) { | |
- for (var i = 0; i < arr.length; i++) { | |
- if (arr[i] == item) | |
- return true; | |
- } | |
- return false; | |
-}; | |
- | |
-/** | |
* highlight a given string on a jquery object by wrapping it in | |
* span elements with the given class name. | |
*/ | |
t@@ -103,6 +91,30 @@ jQuery.fn.highlightText = function(text, className) { | |
}); | |
}; | |
+/* | |
+ * backward compatibility for jQuery.browser | |
+ * This will be supported until firefox bug is fixed. | |
+ */ | |
+if (!jQuery.browser) { | |
+ 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" | |
+ }; | |
+ }; | |
+ jQuery.browser = {}; | |
+ jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; | |
+} | |
+ | |
/** | |
* Small JavaScript module for the documentation. | |
*/ | |
t@@ -112,6 +124,7 @@ var Documentation = { | |
this.fixFirefoxAnchorBug(); | |
this.highlightSearchWords(); | |
this.initIndexTable(); | |
+ | |
}, | |
/** | |
t@@ -164,9 +177,10 @@ var Documentation = { | |
/** | |
* workaround a firefox stupidity | |
+ * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 | |
*/ | |
fixFirefoxAnchorBug : function() { | |
- if (document.location.hash && $.browser.mozilla) | |
+ if (document.location.hash) | |
window.setTimeout(function() { | |
document.location.href += ''; | |
}, 10); | |
t@@ -180,6 +194,9 @@ var Documentation = { | |
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; | |
if (terms.length) { | |
var body = $('div.body'); | |
+ if (!body.length) { | |
+ body = $('body'); | |
+ } | |
window.setTimeout(function() { | |
$.each(terms, function() { | |
body.highlightText(this.toLowerCase(), 'highlighted'); | |
t@@ -236,6 +253,29 @@ var Documentation = { | |
}); | |
var url = parts.join('/'); | |
return path.substring(url.lastIndexOf('/') + 1, path.length - 1); | |
+ }, | |
+ | |
+ initOnKeyListeners: function() { | |
+ $(document).keyup(function(event) { | |
+ var activeElementType = document.activeElement.tagName; | |
+ // don't navigate when in search box or textarea | |
+ if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' &&… | |
+ switch (event.keyCode) { | |
+ case 37: // left | |
+ var prevHref = $('link[rel="prev"]').prop('href'); | |
+ if (prevHref) { | |
+ window.location.href = prevHref; | |
+ return false; | |
+ } | |
+ case 39: // right | |
+ var nextHref = $('link[rel="next"]').prop('href'); | |
+ if (nextHref) { | |
+ window.location.href = nextHref; | |
+ return false; | |
+ } | |
+ } | |
+ } | |
+ }); | |
} | |
}; | |
t@@ -244,4 +284,4 @@ _ = Documentation.gettext; | |
$(document).ready(function() { | |
Documentation.init(); | |
-}); | |
+}); | |
+\ No newline at end of file | |
diff --git a/doc/html/_static/down-pressed.png b/doc/html/_static/down-pressed.… | |
Binary files differ. | |
diff --git a/doc/html/_static/down.png b/doc/html/_static/down.png | |
Binary files differ. | |
diff --git a/doc/html/_static/file.png b/doc/html/_static/file.png | |
Binary files differ. | |
diff --git a/doc/html/_static/jquery.js b/doc/html/_static/jquery.js | |
t@@ -1,291 +1,170 @@ | |
/*! | |
- * jQuery JavaScript Library v1.7.2 | |
- * http://jquery.com/ | |
- * | |
- * Copyright 2011, John Resig | |
- * Dual licensed under the MIT or GPL Version 2 licenses. | |
- * http://jquery.org/license | |
+ * jQuery JavaScript Library v3.1.1 | |
+ * https://jquery.com/ | |
* | |
* Includes Sizzle.js | |
- * http://sizzlejs.com/ | |
- * Copyright 2011, The Dojo Foundation | |
- * Released under the MIT, BSD, and GPL Licenses. | |
+ * https://sizzlejs.com/ | |
* | |
- * Date: Fri Jul 5 14:07:58 UTC 2013 | |
+ * Copyright jQuery Foundation and other contributors | |
+ * Released under the MIT license | |
+ * https://jquery.org/license | |
+ * | |
+ * Date: 2016-12-11T15:18Z | |
*/ | |
-(function( window, undefined ) { | |
- | |
-// Use the correct document accordingly with window argument (sandbox) | |
-var document = window.document, | |
- navigator = window.navigator, | |
- location = window.location; | |
-var jQuery = (function() { | |
- | |
-// Define a local copy of jQuery | |
-var jQuery = function( selector, context ) { | |
- // The jQuery object is actually just the init constructor 'en… | |
- return new jQuery.fn.init( selector, context, rootjQuery ); | |
- }, | |
- | |
- // Map over jQuery in case of overwrite | |
- _jQuery = window.jQuery, | |
- | |
- // Map over the $ in case of overwrite | |
- _$ = window.$, | |
- | |
- // A central reference to the root jQuery(document) | |
- rootjQuery, | |
- | |
- // A simple way to check for HTML strings or ID strings | |
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) | |
- quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, | |
- | |
- // Check if a string has a non-whitespace character in it | |
- rnotwhite = /\S/, | |
- | |
- // Used for trimming whitespace | |
- trimLeft = /^\s+/, | |
- trimRight = /\s+$/, | |
- | |
- // Match a standalone tag | |
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, | |
- | |
- // JSON RegExp | |
- rvalidchars = /^[\],:{}\s]*$/, | |
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, | |
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+… | |
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, | |
- | |
- // Useragent RegExp | |
- rwebkit = /(webkit)[ \/]([\w.]+)/, | |
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, | |
- rmsie = /(msie) ([\w.]+)/, | |
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, | |
+( function( global, factory ) { | |
+ | |
+ "use strict"; | |
+ | |
+ if ( typeof module === "object" && typeof module.exports === "object" … | |
+ | |
+ // For CommonJS and CommonJS-like environments where a proper … | |
+ // is present, execute the factory and get jQuery. | |
+ // For environments that do not have a `window` with a `docume… | |
+ // (such as Node.js), expose a factory as module.exports. | |
+ // This accentuates the need for the creation of a real `windo… | |
+ // 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 wi… | |
+ } | |
+ return factory( w ); | |
+ }; | |
+ } else { | |
+ factory( global ); | |
+ } | |
- // Matches dashed string for camelizing | |
- rdashAlpha = /-([a-z]|[0-9])/ig, | |
- rmsPrefix = /^-ms-/, | |
+// Pass this if window is not defined yet | |
+} )( typeof window !== "undefined" ? window : this, function( window, noGlobal… | |
- // Used by jQuery.camelCase as callback to replace() | |
- fcamelCase = function( all, letter ) { | |
- return ( letter + "" ).toUpperCase(); | |
- }, | |
+// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - … | |
+// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict m… | |
+// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict m… | |
+// enough that all such attempts are guarded in a try block. | |
- // Keep a UserAgent string for use with jQuery.browser | |
- userAgent = navigator.userAgent, | |
- // For matching the engine and version of the browser | |
- browserMatch, | |
+var arr = []; | |
- // The deferred used on DOM ready | |
- readyList, | |
+var document = window.document; | |
- // The ready event handler | |
- DOMContentLoaded, | |
+var getProto = Object.getPrototypeOf; | |
- // Save a reference to some core methods | |
- toString = Object.prototype.toString, | |
- hasOwn = Object.prototype.hasOwnProperty, | |
- push = Array.prototype.push, | |
- slice = Array.prototype.slice, | |
- trim = String.prototype.trim, | |
- indexOf = Array.prototype.indexOf, | |
+var slice = arr.slice; | |
- // [[Class]] -> type pairs | |
- class2type = {}; | |
+var concat = arr.concat; | |
-jQuery.fn = jQuery.prototype = { | |
- constructor: jQuery, | |
- init: function( selector, context, rootjQuery ) { | |
- var match, elem, ret, doc; | |
+var push = arr.push; | |
- // Handle $(""), $(null), or $(undefined) | |
- if ( !selector ) { | |
- return this; | |
- } | |
+var indexOf = arr.indexOf; | |
- // Handle $(DOMElement) | |
- if ( selector.nodeType ) { | |
- this.context = this[0] = selector; | |
- this.length = 1; | |
- return this; | |
- } | |
+var class2type = {}; | |
- // The body element only exists once, optimize finding it | |
- if ( selector === "body" && !context && document.body ) { | |
- this.context = document; | |
- this[0] = document.body; | |
- this.selector = selector; | |
- this.length = 1; | |
- return this; | |
- } | |
+var toString = class2type.toString; | |
- // Handle HTML strings | |
- if ( typeof selector === "string" ) { | |
- // Are we dealing with HTML string or an ID? | |
- if ( selector.charAt(0) === "<" && selector.charAt( se… | |
- // Assume that strings that start and end with… | |
- match = [ null, selector, null ]; | |
+var hasOwn = class2type.hasOwnProperty; | |
- } else { | |
- match = quickExpr.exec( selector ); | |
- } | |
+var fnToString = hasOwn.toString; | |
- // Verify a match, and that no context was specified f… | |
- if ( match && (match[1] || !context) ) { | |
+var ObjectFunctionString = fnToString.call( Object ); | |
- // HANDLE: $(html) -> $(array) | |
- if ( match[1] ) { | |
- context = context instanceof jQuery ? … | |
- doc = ( context ? context.ownerDocumen… | |
+var support = {}; | |
- // If a single string is passed in and… | |
- // just do a createElement and skip th… | |
- ret = rsingleTag.exec( selector ); | |
- if ( ret ) { | |
- if ( jQuery.isPlainObject( con… | |
- selector = [ document.… | |
- jQuery.fn.attr.call( s… | |
- } else { | |
- selector = [ doc.creat… | |
- } | |
+ function DOMEval( code, doc ) { | |
+ doc = doc || document; | |
- } else { | |
- ret = jQuery.buildFragment( [ … | |
- selector = ( ret.cacheable ? j… | |
- } | |
+ var script = doc.createElement( "script" ); | |
- return jQuery.merge( this, selector ); | |
+ script.text = code; | |
+ doc.head.appendChild( script ).parentNode.removeChild( script … | |
+ } | |
+/* global Symbol */ | |
+// Defining this global in .eslintrc.json would create a danger of using the g… | |
+// unguarded in another place, it seems safer to define global only for this m… | |
- // HANDLE: $("#id") | |
- } else { | |
- elem = document.getElementById( match[… | |
- | |
- // Check parentNode to catch when Blac… | |
- // nodes that are no longer in the doc… | |
- if ( elem && elem.parentNode ) { | |
- // Handle the case where IE an… | |
- // by name instead of ID | |
- if ( elem.id !== match[2] ) { | |
- return rootjQuery.find… | |
- } | |
- // Otherwise, we inject the el… | |
- this.length = 1; | |
- this[0] = elem; | |
- } | |
- this.context = document; | |
- this.selector = selector; | |
- return this; | |
- } | |
+var | |
+ version = "3.1.1", | |
- // HANDLE: $(expr, $(...)) | |
- } else if ( !context || context.jquery ) { | |
- return ( context || rootjQuery ).find( selecto… | |
+ // Define a local copy of jQuery | |
+ jQuery = function( selector, context ) { | |
- // HANDLE: $(expr, context) | |
- // (which is just equivalent to: $(context).find(expr) | |
- } else { | |
- return this.constructor( context ).find( selec… | |
- } | |
+ // The jQuery object is actually just the init constructor 'en… | |
+ // Need init if jQuery is called (just allow error to be throw… | |
+ return new jQuery.fn.init( selector, context ); | |
+ }, | |
- // HANDLE: $(function) | |
- // Shortcut for document ready | |
- } else if ( jQuery.isFunction( selector ) ) { | |
- return rootjQuery.ready( selector ); | |
- } | |
+ // Support: Android <=4.0 only | |
+ // Make sure we trim BOM and NBSP | |
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, | |
- if ( selector.selector !== undefined ) { | |
- this.selector = selector.selector; | |
- this.context = selector.context; | |
- } | |
+ // Matches dashed string for camelizing | |
+ rmsPrefix = /^-ms-/, | |
+ rdashAlpha = /-([a-z])/g, | |
- return jQuery.makeArray( selector, this ); | |
- }, | |
+ // Used by jQuery.camelCase as callback to replace() | |
+ fcamelCase = function( all, letter ) { | |
+ return letter.toUpperCase(); | |
+ }; | |
- // Start with an empty selector | |
- selector: "", | |
+jQuery.fn = jQuery.prototype = { | |
// The current version of jQuery being used | |
- jquery: "1.7.2", | |
+ jquery: version, | |
+ | |
+ constructor: jQuery, | |
// 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 slice.call( this, 0 ); | |
+ 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 a 'clean' array | |
- this.toArray() : | |
+ // Return all the elements in a clean array | |
+ if ( num == null ) { | |
+ return slice.call( this ); | |
+ } | |
- // Return just the object | |
- ( num < 0 ? this[ this.length + num ] : this[ num ] ); | |
+ // 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, name, selector ) { | |
- // Build a new jQuery matched element set | |
- var ret = this.constructor(); | |
- | |
- if ( jQuery.isArray( elems ) ) { | |
- push.apply( ret, elems ); | |
+ pushStack: function( elems ) { | |
- } else { | |
- jQuery.merge( ret, 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; | |
- | |
- if ( name === "find" ) { | |
- ret.selector = this.selector + ( this.selector ? " " :… | |
- } else if ( name ) { | |
- ret.selector = this.selector + "." + name + "(" + sele… | |
- } | |
- | |
// 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 ); | |
+ each: function( callback ) { | |
+ return jQuery.each( this, callback ); | |
}, | |
- ready: function( fn ) { | |
- // Attach the listeners | |
- jQuery.bindReady(); | |
- | |
- // Add the callback | |
- readyList.add( fn ); | |
- | |
- return this; | |
+ map: function( callback ) { | |
+ return this.pushStack( jQuery.map( this, function( elem, i ) { | |
+ return callback.call( elem, i, elem ); | |
+ } ) ); | |
}, | |
- eq: function( i ) { | |
- i = +i; | |
- return i === -1 ? | |
- this.slice( i ) : | |
- this.slice( i, i + 1 ); | |
+ slice: function() { | |
+ return this.pushStack( slice.apply( this, arguments ) ); | |
}, | |
first: function() { | |
t@@ -296,34 +175,26 @@ jQuery.fn = jQuery.prototype = { | |
return this.eq( -1 ); | |
}, | |
- slice: function() { | |
- return this.pushStack( slice.apply( this, arguments ), | |
- "slice", slice.call(arguments).join(",") ); | |
- }, | |
- | |
- map: function( callback ) { | |
- return this.pushStack( jQuery.map(this, function( elem, i ) { | |
- return callback.call( elem, i, elem ); | |
- })); | |
+ 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(null); | |
+ return this.prevObject || this.constructor(); | |
}, | |
// For internal use only. | |
// Behaves like an Array's method, not like a jQuery method. | |
push: push, | |
- sort: [].sort, | |
- splice: [].splice | |
+ sort: arr.sort, | |
+ splice: arr.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] || {}, | |
+ target = arguments[ 0 ] || {}, | |
i = 1, | |
length = arguments.length, | |
deep = false; | |
t@@ -331,25 +202,28 @@ jQuery.extend = jQuery.fn.extend = function() { | |
// Handle a deep copy situation | |
if ( typeof target === "boolean" ) { | |
deep = target; | |
- target = arguments[1] || {}; | |
- // skip the boolean and the target | |
- i = 2; | |
+ | |
+ // Skip the boolean and the target | |
+ target = arguments[ i ] || {}; | |
+ i++; | |
} | |
// Handle case when target is a string or something (possible in deep … | |
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) { | |
+ if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { | |
target = {}; | |
} | |
- // extend jQuery itself if only one argument is passed | |
- if ( length === i ) { | |
+ // Extend jQuery itself if only one argument is passed | |
+ if ( i === length ) { | |
target = this; | |
- --i; | |
+ i--; | |
} | |
for ( ; i < length; i++ ) { | |
+ | |
// Only deal with non-null/undefined values | |
- if ( (options = arguments[ i ]) != null ) { | |
+ if ( ( options = arguments[ i ] ) != null ) { | |
+ | |
// Extend the base object | |
for ( name in options ) { | |
src = target[ name ]; | |
t@@ -361,13 +235,15 @@ jQuery.extend = jQuery.fn.extend = function() { | |
} | |
// Recurse if we're merging plain objects or a… | |
- if ( deep && copy && ( jQuery.isPlainObject(co… | |
+ if ( deep && copy && ( jQuery.isPlainObject( c… | |
+ ( copyIsArray = jQuery.isArray( copy )… | |
+ | |
if ( copyIsArray ) { | |
copyIsArray = false; | |
- clone = src && jQuery.isArray(… | |
+ clone = src && jQuery.isArray(… | |
} else { | |
- clone = src && jQuery.isPlainO… | |
+ clone = src && jQuery.isPlainO… | |
} | |
// Never move original objects, clone … | |
t@@ -385,357 +261,163 @@ jQuery.extend = jQuery.fn.extend = function() { | |
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 ) { | |
- // Either a released hold or an DOMready/load event and not ye… | |
- if ( (wait === true && !--jQuery.readyWait) || (wait !== true … | |
- // Make sure body exists, at least, in case IE gets a … | |
- if ( !document.body ) { | |
- return setTimeout( jQuery.ready, 1 ); | |
- } | |
- | |
- // Remember that the DOM is ready | |
- jQuery.isReady = true; | |
+jQuery.extend( { | |
- // If a normal DOM Ready event fired, decrement, and w… | |
- if ( wait !== true && --jQuery.readyWait > 0 ) { | |
- return; | |
- } | |
+ // Unique for each copy of jQuery on the page | |
+ expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), | |
- // If there are functions bound, to execute | |
- readyList.fireWith( document, [ jQuery ] ); | |
+ // Assume jQuery is ready without the ready module | |
+ isReady: true, | |
- // Trigger any bound ready events | |
- if ( jQuery.fn.trigger ) { | |
- jQuery( document ).trigger( "ready" ).off( "re… | |
- } | |
- } | |
+ error: function( msg ) { | |
+ throw new Error( msg ); | |
}, | |
- bindReady: function() { | |
- if ( readyList ) { | |
- return; | |
- } | |
- | |
- readyList = jQuery.Callbacks( "once memory" ); | |
- | |
- // Catch cases where $(document).ready() is called after the | |
- // browser event has already occurred. | |
- if ( document.readyState === "complete" ) { | |
- // Handle it asynchronously to allow scripts the oppor… | |
- return setTimeout( jQuery.ready, 1 ); | |
- } | |
- | |
- // Mozilla, Opera and webkit nightlies currently support this … | |
- if ( document.addEventListener ) { | |
- // Use the handy event callback | |
- document.addEventListener( "DOMContentLoaded", DOMCont… | |
- | |
- // A fallback to window.onload, that will always work | |
- window.addEventListener( "load", jQuery.ready, false ); | |
- | |
- // If IE event model is used | |
- } else if ( document.attachEvent ) { | |
- // ensure firing before onload, | |
- // maybe late but safe also for iframes | |
- document.attachEvent( "onreadystatechange", DOMContent… | |
- | |
- // 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 toplevel = false; | |
- | |
- try { | |
- toplevel = window.frameElement == null; | |
- } catch(e) {} | |
- | |
- if ( document.documentElement.doScroll && toplevel ) { | |
- doScrollCheck(); | |
- } | |
- } | |
- }, | |
+ 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"; | |
+ return jQuery.type( obj ) === "function"; | |
}, | |
- isArray: Array.isArray || function( obj ) { | |
- return jQuery.type(obj) === "array"; | |
- }, | |
+ isArray: Array.isArray, | |
isWindow: function( obj ) { | |
- return obj != null && obj == obj.window; | |
+ return obj != null && obj === obj.window; | |
}, | |
isNumeric: function( obj ) { | |
- return !isNaN( parseFloat(obj) ) && isFinite( obj ); | |
- }, | |
- type: function( obj ) { | |
- return obj == null ? | |
- String( obj ) : | |
- class2type[ toString.call(obj) ] || "object"; | |
+ // 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, partic… | |
+ // subtraction forces infinities to NaN | |
+ !isNaN( obj - parseFloat( obj ) ); | |
}, | |
isPlainObject: function( obj ) { | |
- // Must be an Object. | |
- // Because of IE, we also have to check the presence of the co… | |
- // Make sure that DOM nodes and window objects don't pass thro… | |
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || … | |
- return false; | |
- } | |
+ var proto, Ctor; | |
- try { | |
- // Not own constructor property must be Object | |
- if ( obj.constructor && | |
- !hasOwn.call(obj, "constructor") && | |
- !hasOwn.call(obj.constructor.prototype, "isPro… | |
- return false; | |
- } | |
- } catch ( e ) { | |
- // IE8,9 Will throw exceptions on certain host objects… | |
+ // Detect obvious negatives | |
+ // Use toString instead of jQuery.type to catch host objects | |
+ if ( !obj || toString.call( obj ) !== "[object Object]" ) { | |
return false; | |
} | |
- // Own properties are enumerated firstly, so to speed up, | |
- // if last one is own, then all properties are own. | |
+ proto = getProto( obj ); | |
- var key; | |
- for ( key in obj ) {} | |
+ // Objects with no prototype (e.g., `Object.create( null )`) a… | |
+ if ( !proto ) { | |
+ return true; | |
+ } | |
- return key === undefined || hasOwn.call( obj, key ); | |
+ // Objects with prototype are plain iff they were constructed … | |
+ Ctor = hasOwn.call( proto, "constructor" ) && proto.constructo… | |
+ return typeof Ctor === "function" && fnToString.call( Ctor ) =… | |
}, | |
isEmptyObject: function( obj ) { | |
- for ( var name in obj ) { | |
+ | |
+ /* eslint-disable no-unused-vars */ | |
+ // See https://github.com/eslint/eslint/issues/6125 | |
+ var name; | |
+ | |
+ for ( name in obj ) { | |
return false; | |
} | |
return true; | |
}, | |
- error: function( msg ) { | |
- throw new Error( msg ); | |
- }, | |
- | |
- parseJSON: function( data ) { | |
- if ( typeof data !== "string" || !data ) { | |
- return null; | |
- } | |
- | |
- // Make sure leading/trailing whitespace is removed (IE can't … | |
- 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 ) )(); | |
- | |
+ type: function( obj ) { | |
+ if ( obj == null ) { | |
+ return obj + ""; | |
} | |
- jQuery.error( "Invalid JSON: " + data ); | |
- }, | |
- // Cross-browser xml parsing | |
- parseXML: function( data ) { | |
- if ( typeof data !== "string" || !data ) { | |
- return null; | |
- } | |
- var xml, tmp; | |
- 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(… | |
- jQuery.error( "Invalid XML: " + data ); | |
- } | |
- return xml; | |
+ // Support: Android <=2.3 only (functionish RegExp) | |
+ return typeof obj === "object" || typeof obj === "function" ? | |
+ class2type[ toString.call( obj ) ] || "object" : | |
+ typeof obj; | |
}, | |
- 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-javas… | |
- globalEval: function( data ) { | |
- if ( data && rnotwhite.test( data ) ) { | |
- // We use execScript on Internet Explorer | |
- // We use an anonymous function so that context is win… | |
- // rather than jQuery in Firefox | |
- ( window.execScript || function( data ) { | |
- window[ "eval" ].call( window, data ); | |
- } )( data ); | |
- } | |
+ globalEval: function( code ) { | |
+ DOMEval( code ); | |
}, | |
// Convert dashed to camelCase; used by the css and data modules | |
+ // Support: IE <=9 - 11, Edge 12 - 13 | |
// Microsoft forgot to hump their vendor prefix (#9572) | |
camelCase: function( string ) { | |
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha,… | |
}, | |
nodeName: function( elem, name ) { | |
- return elem.nodeName && elem.nodeName.toUpperCase() === name.t… | |
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.t… | |
}, | |
- // args is for internal usage only | |
- each: function( object, callback, args ) { | |
- var name, i = 0, | |
- length = object.length, | |
- isObj = length === undefined || jQuery.isFunction( obj… | |
+ each: function( obj, callback ) { | |
+ var length, i = 0; | |
- if ( args ) { | |
- if ( isObj ) { | |
- for ( name in object ) { | |
- if ( callback.apply( object[ name ], a… | |
- break; | |
- } | |
- } | |
- } else { | |
- for ( ; i < length; ) { | |
- if ( callback.apply( object[ i++ ], ar… | |
- break; | |
- } | |
+ if ( isArrayLike( obj ) ) { | |
+ length = obj.length; | |
+ for ( ; i < length; i++ ) { | |
+ if ( callback.call( obj[ i ], i, obj[ i ] ) ==… | |
+ break; | |
} | |
} | |
- | |
- // A special, fast, case for the most common use of each | |
} else { | |
- if ( isObj ) { | |
- for ( name in object ) { | |
- if ( callback.call( object[ name ], na… | |
- break; | |
- } | |
- } | |
- } else { | |
- for ( ; i < length; ) { | |
- if ( callback.call( object[ i ], i, ob… | |
- break; | |
- } | |
+ for ( i in obj ) { | |
+ if ( callback.call( obj[ i ], i, obj[ i ] ) ==… | |
+ break; | |
} | |
} | |
} | |
- return object; | |
+ return obj; | |
}, | |
- // Use native String.trim function wherever possible | |
- trim: trim ? | |
- function( text ) { | |
- return text == null ? | |
- "" : | |
- trim.call( text ); | |
- } : | |
- | |
- // Otherwise use our own trimming functionality | |
- function( text ) { | |
- return text == null ? | |
- "" : | |
- text.toString().replace( trimLeft, "" ).replac… | |
- }, | |
+ // Support: Android <=4.0 only | |
+ trim: function( text ) { | |
+ return text == null ? | |
+ "" : | |
+ ( text + "" ).replace( rtrim, "" ); | |
+ }, | |
// results is for internal usage only | |
- makeArray: function( array, results ) { | |
+ makeArray: function( arr, results ) { | |
var ret = results || []; | |
- if ( array != null ) { | |
- // The window, strings (and functions) also have 'leng… | |
- // Tweaked logic slightly to handle Blackberry 4.7 Reg… | |
- var type = jQuery.type( array ); | |
- | |
- if ( array.length == null || type === "string" || type… | |
- push.call( ret, array ); | |
+ if ( arr != null ) { | |
+ if ( isArrayLike( Object( arr ) ) ) { | |
+ jQuery.merge( ret, | |
+ typeof arr === "string" ? | |
+ [ arr ] : arr | |
+ ); | |
} else { | |
- jQuery.merge( ret, array ); | |
+ push.call( ret, arr ); | |
} | |
} | |
return ret; | |
}, | |
- inArray: function( elem, array, i ) { | |
- var len; | |
- | |
- if ( array ) { | |
- if ( indexOf ) { | |
- return indexOf.call( array, elem, i ); | |
- } | |
- | |
- len = array.length; | |
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; | |
- | |
- for ( ; i < len; i++ ) { | |
- // Skip accessing in sparse arrays | |
- if ( i in array && array[ i ] === elem ) { | |
- return i; | |
- } | |
- } | |
- } | |
- | |
- return -1; | |
+ 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 i = first.length, | |
- j = 0; | |
- | |
- if ( typeof second.length === "number" ) { | |
- for ( var l = second.length; j < l; j++ ) { | |
- first[ i++ ] = second[ j ]; | |
- } | |
+ var len = +second.length, | |
+ j = 0, | |
+ i = first.length; | |
- } else { | |
- while ( second[j] !== undefined ) { | |
- first[ i++ ] = second[ j++ ]; | |
- } | |
+ for ( ; j < len; j++ ) { | |
+ first[ i++ ] = second[ j ]; | |
} | |
first.length = i; | |
t@@ -743,53 +425,55 @@ jQuery.extend({ | |
return first; | |
}, | |
- grep: function( elems, callback, inv ) { | |
- var ret = [], retVal; | |
- inv = !!inv; | |
+ 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 ( var i = 0, length = elems.length; i < length; i++ ) { | |
- retVal = !!callback( elems[ i ], i ); | |
- if ( inv !== retVal ) { | |
- ret.push( elems[ i ] ); | |
+ for ( ; i < length; i++ ) { | |
+ callbackInverse = !callback( elems[ i ], i ); | |
+ if ( callbackInverse !== callbackExpect ) { | |
+ matches.push( elems[ i ] ); | |
} | |
} | |
- return ret; | |
+ return matches; | |
}, | |
// arg is for internal usage only | |
map: function( elems, callback, arg ) { | |
- var value, key, ret = [], | |
+ var length, value, | |
i = 0, | |
- length = elems.length, | |
- // jquery objects are treated as arrays | |
- isArray = elems instanceof jQuery || length !== undefi… | |
+ ret = []; | |
- // Go through the array, translating each of the items to their | |
- if ( isArray ) { | |
+ // Go through the array, translating each of the items to thei… | |
+ if ( isArrayLike( elems ) ) { | |
+ length = elems.length; | |
for ( ; i < length; i++ ) { | |
value = callback( elems[ i ], i, arg ); | |
if ( value != null ) { | |
- ret[ ret.length ] = value; | |
+ ret.push( value ); | |
} | |
} | |
// Go through every key on the object, | |
} else { | |
- for ( key in elems ) { | |
- value = callback( elems[ key ], key, arg ); | |
+ for ( i in elems ) { | |
+ value = callback( elems[ i ], i, arg ); | |
if ( value != null ) { | |
- ret[ ret.length ] = value; | |
+ ret.push( value ); | |
} | |
} | |
} | |
// Flatten any nested arrays | |
- return ret.concat.apply( [], ret ); | |
+ return concat.apply( [], ret ); | |
}, | |
// A global GUID counter for objects | |
t@@ -798,8 +482,10 @@ jQuery.extend({ | |
// Bind a function to a context, optionally partially applying any | |
// arguments. | |
proxy: function( fn, context ) { | |
+ var tmp, args, proxy; | |
+ | |
if ( typeof context === "string" ) { | |
- var tmp = fn[ context ]; | |
+ tmp = fn[ context ]; | |
context = fn; | |
fn = tmp; | |
} | |
t@@ -811,6151 +497,6095 @@ jQuery.extend({ | |
} | |
// Simulated bind | |
- var args = slice.call( arguments, 2 ), | |
- proxy = function() { | |
- return fn.apply( context, args.concat( slice.c… | |
- }; | |
+ args = slice.call( arguments, 2 ); | |
+ proxy = function() { | |
+ return fn.apply( context || this, args.concat( slice.c… | |
+ }; | |
// Set the guid of unique handler to the same of original hand… | |
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; | |
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
return proxy; | |
}, | |
- // Mutifunctional method to get and set values to 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; | |
+ now: Date.now, | |
- // Sets many values | |
- if ( key && typeof key === "object" ) { | |
- for ( i in key ) { | |
- jQuery.access( elems, fn, i, key[i], 1, emptyG… | |
- } | |
- chainable = 1; | |
+ // jQuery.support is not used in Core but other projects attach their | |
+ // properties to it so it needs to exist. | |
+ support: support | |
+} ); | |
- // Sets one value | |
- } else if ( value !== undefined ) { | |
- // Optionally, function values get executed if exec is… | |
- exec = pass === undefined && jQuery.isFunction( value … | |
+if ( typeof Symbol === "function" ) { | |
+ jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; | |
+} | |
- if ( bulk ) { | |
- // Bulk operations only iterate when executing… | |
- if ( exec ) { | |
- exec = fn; | |
- fn = function( elem, key, value ) { | |
- return exec.call( jQuery( elem… | |
- }; | |
+// Populate the class2type map | |
+jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Sy… | |
+function( i, name ) { | |
+ class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
+} ); | |
- // Otherwise they run against the entire set | |
- } else { | |
- fn.call( elems, value ); | |
- fn = null; | |
- } | |
- } | |
+function isArrayLike( obj ) { | |
- if ( fn ) { | |
- for (; i < length; i++ ) { | |
- fn( elems[i], key, exec ? value.call( … | |
- } | |
- } | |
+ // 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 = jQuery.type( obj ); | |
- chainable = 1; | |
- } | |
- | |
- return chainable ? | |
- elems : | |
+ if ( type === "function" || jQuery.isWindow( obj ) ) { | |
+ return false; | |
+ } | |
- // Gets | |
- bulk ? | |
- fn.call( elems ) : | |
- length ? fn( elems[0], key ) : emptyGet; | |
+ return type === "array" || length === 0 || | |
+ typeof length === "number" && length > 0 && ( length - 1 ) in … | |
+} | |
+var Sizzle = | |
+/*! | |
+ * Sizzle CSS Selector Engine v2.3.3 | |
+ * https://sizzlejs.com/ | |
+ * | |
+ * Copyright jQuery Foundation and other contributors | |
+ * Released under the MIT license | |
+ * http://jquery.org/license | |
+ * | |
+ * Date: 2016-08-08 | |
+ */ | |
+(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; | |
}, | |
- now: function() { | |
- return ( new Date() ).getTime(); | |
+ // 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 | |
+ // 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; | |
}, | |
- // Use of jQuery.browser is frowned upon. | |
- // More details: http://docs.jquery.com/Utilities/jQuery.browser | |
- uaMatch: function( ua ) { | |
- ua = ua.toLowerCase(); | |
+ booleans = "checked|selected|async|autofocus|autoplay|controls|defer|d… | |
- var match = rwebkit.exec( ua ) || | |
- ropera.exec( ua ) || | |
- rmsie.exec( ua ) || | |
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || | |
- []; | |
+ // Regular expressions | |
- return { browser: match[1] || "", version: match[2] || "0" }; | |
- }, | |
+ // http://www.w3.org/TR/css3-selectors/#whitespace | |
+ whitespace = "[\\x20\\t\\r\\n\\f]", | |
- 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… | |
- context = jQuerySub( context ); | |
- } | |
+ // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier | |
+ identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", | |
- return jQuery.fn.init.call( this, selector, context, r… | |
- }; | |
- jQuerySub.fn.init.prototype = jQuerySub.fn; | |
- var rootjQuerySub = jQuerySub(document); | |
- return jQuerySub; | |
- }, | |
+ // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-sele… | |
+ attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitesp… | |
+ // Operator (capture 2) | |
+ "*([*^$|!~]?=)" + whitespace + | |
+ // "Attribute values must be CSS identifiers [capture 5] or st… | |
+ "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + i… | |
+ "*\\]", | |
- browser: {} | |
-}); | |
+ pseudos = ":(" + identifier + ")(?:\\((" + | |
+ // To reduce the number of selectors needing tokenize in the p… | |
+ // 1. quoted (capture 3; capture 4 or capture 5) | |
+ "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + | |
+ // 2. simple (capture 6) | |
+ "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + | |
+ // 3. anything else (capture 2) | |
+ ".*" + | |
+ ")\\)|)", | |
-// Populate the class2type map | |
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" … | |
- class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
-}); | |
+ // Leading and non-escaped trailing whitespace, capturing some non-whi… | |
+ rwhitespace = new RegExp( whitespace + "+", "g" ), | |
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +… | |
-browserMatch = jQuery.uaMatch( userAgent ); | |
-if ( browserMatch.browser ) { | |
- jQuery.browser[ browserMatch.browser ] = true; | |
- jQuery.browser.version = browserMatch.version; | |
-} | |
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), | |
+ rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace … | |
-// Deprecated, use jQuery.browser.webkit instead | |
-if ( jQuery.browser.webkit ) { | |
- jQuery.browser.safari = true; | |
-} | |
+ rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + w… | |
-// IE doesn't match non-breaking spaces with \s | |
-if ( rnotwhite.test( "\xA0" ) ) { | |
- trimLeft = /^[\s\xA0]+/; | |
- trimRight = /[\s\xA0]+$/; | |
-} | |
+ rpseudo = new RegExp( pseudos ), | |
+ ridentifier = new RegExp( "^" + identifier + "$" ), | |
-// All jQuery objects should point back to these | |
-rootjQuery = jQuery(document); | |
+ 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|… | |
+ "*(even|odd|(([+-]|)(\\d*)n|)" + 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|… | |
+ whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)… | |
+ }, | |
-// Cleanup functions for the document ready method | |
-if ( document.addEventListener ) { | |
- DOMContentLoaded = function() { | |
- document.removeEventListener( "DOMContentLoaded", DOMContentLo… | |
- jQuery.ready(); | |
- }; | |
+ rinputs = /^(?:input|select|textarea|button)$/i, | |
+ rheader = /^h\d$/i, | |
-} else if ( document.attachEvent ) { | |
- DOMContentLoaded = function() { | |
- // Make sure body exists, at least, in case IE gets a little o… | |
- if ( document.readyState === "complete" ) { | |
- document.detachEvent( "onreadystatechange", DOMContent… | |
- jQuery.ready(); | |
- } | |
- }; | |
-} | |
+ rnative = /^[^{]+\{\s*\[native \w/, | |
-// The DOM ready check for Internet Explorer | |
-function doScrollCheck() { | |
- if ( jQuery.isReady ) { | |
- return; | |
- } | |
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors | |
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, | |
- try { | |
- // If IE is used, use the trick by Diego Perini | |
- // http://javascript.nwbox.com/IEContentLoaded/ | |
- document.documentElement.doScroll("left"); | |
- } catch(e) { | |
- setTimeout( doScrollCheck, 1 ); | |
- return; | |
- } | |
+ rsibling = /[+~]/, | |
- // and execute any waiting functions | |
- jQuery.ready(); | |
-} | |
+ // CSS escapes | |
+ // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters | |
+ runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + wh… | |
+ 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 pai… | |
+ String.fromCharCode( high >> 10 | 0xD800, high… | |
+ }, | |
-return jQuery; | |
+ // 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) nu… | |
+ return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.le… | |
+ } | |
-// String to Object flags format cache | |
-var flagsCache = {}; | |
+ // Other potentially-special ASCII characters get backslash-es… | |
+ return "\\" + ch; | |
+ }, | |
+ | |
+ // Used for iframes | |
+ // See setDocument() | |
+ // Removing the function wrapper causes a "Permission Denied" | |
+ // error in IE | |
+ unloadHandler = function() { | |
+ setDocument(); | |
+ }, | |
+ | |
+ disabledAncestor = addCombinator( | |
+ function( elem ) { | |
+ return elem.disabled === true && ("form" in elem || "l… | |
+ }, | |
+ { dir: "parentNode", next: "legend" } | |
+ ); | |
-// Convert String-formatted flags into Object-formatted ones and store in cache | |
-function createFlags( flags ) { | |
- var object = flagsCache[ flags ] = {}, | |
- i, length; | |
- flags = flags.split( /\s+/ ); | |
- for ( i = 0, length = flags.length; i < length; i++ ) { | |
- object[ flags[i] ] = true; | |
- } | |
- return object; | |
-} | |
+// 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) ); | |
+ } : | |
-/* | |
- * Create a callback list using the following parameters: | |
- * | |
- * flags: an optional list of space-separated flags that will ch… | |
- * the callback list behaves | |
- * | |
- * By default a callback list will act like an event callback list and can be | |
- * "fired" multiple times. | |
- * | |
- * Possible flags: | |
- * | |
- * once: will ensure the callback list can only … | |
- * | |
- * memory: will keep track of previous values an… | |
- * after the list has been fired right … | |
- * values (like a Deferred) | |
- * | |
- * unique: will ensure a callback can only be ad… | |
- * | |
- * stopOnFalse: interrupt callings when a callback returns false | |
- * | |
- */ | |
-jQuery.Callbacks = function( flags ) { | |
+ // 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; | |
+ } | |
+ }; | |
+} | |
- // Convert flags from String-formatted to Object-formatted | |
- // (we check in cache first) | |
- flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; | |
+function Sizzle( selector, context, results, seed ) { | |
+ var m, i, elem, nid, match, groups, newSelector, | |
+ newContext = context && context.ownerDocument, | |
- var // Actual callback list | |
- list = [], | |
- // Stack of fire calls for repeatable lists | |
- stack = [], | |
- // 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 n… | |
- firingIndex, | |
- // Add one or several callbacks to the list | |
- add = function( args ) { | |
- var i, | |
- length, | |
- elem, | |
- type, | |
- actual; | |
- for ( i = 0, length = args.length; i < length; i++ ) { | |
- elem = args[ i ]; | |
- type = jQuery.type( elem ); | |
- if ( type === "array" ) { | |
- // Inspect recursively | |
- add( elem ); | |
- } else if ( type === "function" ) { | |
- // Add if not in unique mode and callb… | |
- if ( !flags.unique || !self.has( elem … | |
- list.push( elem ); | |
- } | |
- } | |
- } | |
- }, | |
- // Fire callbacks | |
- fire = function( context, args ) { | |
- args = args || []; | |
- memory = !flags.memory || [ context, args ]; | |
- fired = true; | |
- firing = true; | |
- firingIndex = firingStart || 0; | |
- firingStart = 0; | |
- firingLength = list.length; | |
- for ( ; list && firingIndex < firingLength; firingInde… | |
- if ( list[ firingIndex ].apply( context, args … | |
- memory = true; // Mark as halted | |
- break; | |
- } | |
- } | |
- firing = false; | |
- if ( list ) { | |
- if ( !flags.once ) { | |
- if ( stack && stack.length ) { | |
- memory = stack.shift(); | |
- self.fireWith( memory[ 0 ], me… | |
- } | |
- } else if ( memory === true ) { | |
- self.disable(); | |
- } else { | |
- list = []; | |
- } | |
- } | |
- }, | |
- // Actual Callbacks object | |
- self = { | |
- // Add a callback or a collection of callbacks to the … | |
- add: function() { | |
- if ( list ) { | |
- var length = list.length; | |
- add( arguments ); | |
- // Do we need to add the callbacks to … | |
- // current firing batch? | |
- if ( firing ) { | |
- firingLength = list.length; | |
- // With memory, if we're not firing th… | |
- // we should call right away, unless p… | |
- // firing was halted (stopOnFalse) | |
- } else if ( memory && memory !== true … | |
- firingStart = length; | |
- fire( memory[ 0 ], memory[ 1 ]… | |
- } | |
- } | |
- return this; | |
- }, | |
- // Remove a callback from the list | |
- remove: function() { | |
- if ( list ) { | |
- var args = arguments, | |
- argIndex = 0, | |
- argLength = args.length; | |
- for ( ; argIndex < argLength ; argInde… | |
- for ( var i = 0; i < list.leng… | |
- if ( args[ argIndex ] … | |
- // Handle firi… | |
- if ( firing ) { | |
- if ( i… | |
- … | |
- … | |
- … | |
- … | |
- } | |
- } | |
- // Remove the … | |
- list.splice( i… | |
- // If we have … | |
- // we only nee… | |
- if ( flags.uni… | |
- break; | |
- } | |
- } | |
- } | |
- } | |
- } | |
- return this; | |
- }, | |
- // Control if a given callback is in the list | |
- has: function( fn ) { | |
- if ( list ) { | |
- var i = 0, | |
- length = list.length; | |
- for ( ; i < length; i++ ) { | |
- if ( fn === list[ i ] ) { | |
- return true; | |
- } | |
- } | |
- } | |
- return false; | |
- }, | |
- // 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 || memory === true ) { | |
- self.disable(); | |
- } | |
- return this; | |
- }, | |
- // Is it locked? | |
- locked: function() { | |
- return !stack; | |
- }, | |
- // Call all callbacks with the given context and argum… | |
- fireWith: function( context, args ) { | |
- if ( stack ) { | |
- if ( firing ) { | |
- if ( !flags.once ) { | |
- stack.push( [ context,… | |
- } | |
- } else if ( !( flags.once && memory ) … | |
- fire( context, 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 a… | |
- fired: function() { | |
- return !!fired; | |
- } | |
- }; | |
+ // nodeType defaults to 9, since context defaults to document | |
+ nodeType = context ? context.nodeType : 9; | |
- return self; | |
-}; | |
+ 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 doc… | |
+ if ( !seed ) { | |
-var // Static reference to slice | |
- sliceDeferred = [].slice; | |
+ if ( ( context ? context.ownerDocument || context : preferredD… | |
+ setDocument( context ); | |
+ } | |
+ context = context || document; | |
-jQuery.extend({ | |
+ if ( documentIsHTML ) { | |
- Deferred: function( func ) { | |
- var doneList = jQuery.Callbacks( "once memory" ), | |
- failList = jQuery.Callbacks( "once memory" ), | |
- progressList = jQuery.Callbacks( "memory" ), | |
- state = "pending", | |
- lists = { | |
- resolve: doneList, | |
- reject: failList, | |
- notify: progressList | |
- }, | |
- promise = { | |
- done: doneList.add, | |
- fail: failList.add, | |
- progress: progressList.add, | |
+ // If the selector is sufficiently simple, try using a… | |
+ // (excepting DocumentFragment context, where the meth… | |
+ if ( nodeType !== 11 && (match = rquickExpr.exec( sele… | |
- state: function() { | |
- return state; | |
- }, | |
+ // ID selector | |
+ if ( (m = match[1]) ) { | |
- // Deprecated | |
- isResolved: doneList.fired, | |
- isRejected: failList.fired, | |
+ // Document context | |
+ if ( nodeType === 9 ) { | |
+ if ( (elem = context.getElemen… | |
- then: function( doneCallbacks, failCallbacks, … | |
- deferred.done( doneCallbacks ).fail( f… | |
- return this; | |
- }, | |
- always: function() { | |
- deferred.done.apply( deferred, argumen… | |
- return this; | |
- }, | |
- pipe: function( fnDone, fnFail, fnProgress ) { | |
- return jQuery.Deferred(function( newDe… | |
- jQuery.each( { | |
- done: [ fnDone, "resol… | |
- fail: [ fnFail, "rejec… | |
- progress: [ fnProgress… | |
- }, function( handler, data ) { | |
- var fn = data[ 0 ], | |
- action = data[… | |
- returned; | |
- if ( jQuery.isFunction… | |
- deferred[ hand… | |
- return… | |
- if ( r… | |
- … | |
- } else… | |
- … | |
- } | |
- }); | |
- } else { | |
- deferred[ hand… | |
+ // Support: IE, Opera,… | |
+ // TODO: identify vers… | |
+ // getElementById can … | |
+ if ( elem.id === m ) { | |
+ results.push( … | |
+ return results; | |
} | |
- }); | |
- }).promise(); | |
- }, | |
- // Get a promise for this deferred | |
- // If obj is provided, the promise aspect is a… | |
- promise: function( obj ) { | |
- if ( obj == null ) { | |
- obj = promise; | |
+ } else { | |
+ return results; | |
+ } | |
+ | |
+ // Element context | |
} else { | |
- for ( var key in promise ) { | |
- obj[ key ] = promise[ … | |
+ | |
+ // Support: IE, Opera, Webkit | |
+ // TODO: identify versions | |
+ // getElementById can match el… | |
+ if ( newContext && (elem = new… | |
+ contains( context, ele… | |
+ elem.id === m ) { | |
+ | |
+ results.push( elem ); | |
+ return results; | |
} | |
} | |
- return obj; | |
+ | |
+ // Type selector | |
+ } else if ( match[2] ) { | |
+ push.apply( results, context.getElemen… | |
+ return results; | |
+ | |
+ // Class selector | |
+ } else if ( (m = match[3]) && support.getEleme… | |
+ context.getElementsByClassName ) { | |
+ | |
+ push.apply( results, context.getElemen… | |
+ return results; | |
} | |
- }, | |
- deferred = promise.promise({}), | |
- key; | |
+ } | |
- for ( key in lists ) { | |
- deferred[ key ] = lists[ key ].fire; | |
- deferred[ key + "With" ] = lists[ key ].fireWith; | |
- } | |
+ // Take advantage of querySelectorAll | |
+ if ( support.qsa && | |
+ !compilerCache[ selector + " " ] && | |
+ (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { | |
- // Handle state | |
- deferred.done( function() { | |
- state = "resolved"; | |
- }, failList.disable, progressList.lock ).fail( function() { | |
- state = "rejected"; | |
- }, doneList.disable, progressList.lock ); | |
+ if ( nodeType !== 1 ) { | |
+ newContext = context; | |
+ newSelector = selector; | |
- // Call given func if any | |
- if ( func ) { | |
- func.call( deferred, deferred ); | |
- } | |
+ // qSA looks outside Element context, which is… | |
+ // Thanks to Andrew Dupont for this workaround… | |
+ // Support: IE <=8 | |
+ // Exclude object elements | |
+ } else if ( context.nodeName.toLowerCase() !==… | |
- // All done! | |
- return deferred; | |
- }, | |
+ // Capture the context ID, setting it … | |
+ if ( (nid = context.getAttribute( "id"… | |
+ nid = nid.replace( rcssescape,… | |
+ } else { | |
+ context.setAttribute( "id", (n… | |
+ } | |
- // Deferred helper | |
- when: function( firstParam ) { | |
- var args = sliceDeferred.call( arguments, 0 ), | |
- i = 0, | |
- length = args.length, | |
- pValues = new Array( length ), | |
- count = length, | |
- pCount = length, | |
- deferred = length <= 1 && firstParam && jQuery.isFunct… | |
- firstParam : | |
- jQuery.Deferred(), | |
- promise = deferred.promise(); | |
- function resolveFunc( i ) { | |
- return function( value ) { | |
- args[ i ] = arguments.length > 1 ? sliceDeferr… | |
- if ( !( --count ) ) { | |
- deferred.resolveWith( deferred, args ); | |
+ // Prefix every selector in the list | |
+ groups = tokenize( selector ); | |
+ i = groups.length; | |
+ while ( i-- ) { | |
+ groups[i] = "#" + nid + " " + … | |
+ } | |
+ newSelector = groups.join( "," ); | |
+ | |
+ // Expand context for sibling selectors | |
+ newContext = rsibling.test( selector )… | |
+ context; | |
} | |
- }; | |
- } | |
- function progressFunc( i ) { | |
- return function( value ) { | |
- pValues[ i ] = arguments.length > 1 ? sliceDef… | |
- deferred.notifyWith( promise, pValues ); | |
- }; | |
- } | |
- if ( length > 1 ) { | |
- for ( ; i < length; i++ ) { | |
- if ( args[ i ] && args[ i ].promise && jQuery.… | |
- args[ i ].promise().then( resolveFunc(… | |
- } else { | |
- --count; | |
+ | |
+ if ( newSelector ) { | |
+ try { | |
+ push.apply( results, | |
+ newContext.querySelect… | |
+ ); | |
+ return results; | |
+ } catch ( qsaError ) { | |
+ } finally { | |
+ if ( nid === expando ) { | |
+ context.removeAttribut… | |
+ } | |
+ } | |
} | |
} | |
- if ( !count ) { | |
- deferred.resolveWith( deferred, args ); | |
- } | |
- } else if ( deferred !== firstParam ) { | |
- deferred.resolveWith( deferred, length ? [ firstParam … | |
} | |
- return promise; | |
} | |
-}); | |
+ // 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 i… | |
+ * property name the (space-suffixed) string and (if the cache is large… | |
+ * deleting the oldest entry | |
+ */ | |
+function createCache() { | |
+ var keys = []; | |
+ function cache( key, value ) { | |
+ // Use (key + " ") to avoid collision with native prototype pr… | |
+ if ( keys.push( key + " " ) > Expr.cacheLength ) { | |
+ // Only keep the most recent entries | |
+ delete cache[ keys.shift() ]; | |
+ } | |
+ return (cache[ key + " " ] = value); | |
+ } | |
+ return cache; | |
+} | |
-jQuery.support = (function() { | |
- | |
- var support, | |
- all, | |
- a, | |
- select, | |
- opt, | |
- input, | |
- fragment, | |
- tds, | |
- events, | |
- eventName, | |
- i, | |
- isSupported, | |
- div = document.createElement( "div" ), | |
- documentElement = document.documentElement; | |
- | |
- // Preliminary tests | |
- div.setAttribute("className", "t"); | |
- div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;… | |
- | |
- all = div.getElementsByTagName( "*" ); | |
- a = div.getElementsByTagName( "a" )[ 0 ]; | |
- | |
- // Can't get basic test support | |
- if ( !all || !all.length || !a ) { | |
- 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 in… | |
- // 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.55/.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 s… | |
- // (WebKit defaults to false instead of true, IE too, if it's … | |
- optSelected: opt.selected, | |
- | |
- // Test setAttribute on camelCase class. If it works, we need … | |
- 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 ).ou… | |
- | |
- // Will be defined later | |
- submitBubbles: true, | |
- changeBubbles: true, | |
- focusinBubbles: false, | |
- deleteExpando: true, | |
- noCloneEvent: true, | |
- inlineBlockNeedsLayout: false, | |
- shrinkWrapBlocks: false, | |
- reliableMarginRight: true, | |
- pixelMargin: true | |
- }; | |
+/** | |
+ * Mark a function for special use by Sizzle | |
+ * @param {Function} fn The function to mark | |
+ */ | |
+function markFunction( fn ) { | |
+ fn[ expando ] = true; | |
+ return fn; | |
+} | |
- // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel inst… | |
- jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Com… | |
+/** | |
+ * 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"); | |
- // Make sure checked status is properly cloned | |
- input.checked = true; | |
- support.noCloneChecked = input.cloneNode( true ).checked; | |
+ 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; | |
+ } | |
+} | |
- // Make sure that the options inside disabled selects aren't marked as… | |
- // (WebKit marks them as disabled) | |
- select.disabled = true; | |
- support.optDisabled = !opt.disabled; | |
+/** | |
+ * 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; | |
- // 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; | |
+ while ( i-- ) { | |
+ Expr.attrHandle[ arr[i] ] = handler; | |
} | |
+} | |
- if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { | |
- div.attachEvent( "onclick", function() { | |
- // Cloning a node shouldn't copy over any | |
- // bound event handlers (IE does this) | |
- support.noCloneEvent = false; | |
- }); | |
- div.cloneNode( true ).fireEvent( "onclick" ); | |
+/** | |
+ * 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 … | |
+ */ | |
+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 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"; | |
+ // Check if b follows a | |
+ if ( cur ) { | |
+ while ( (cur = cur.nextSibling) ) { | |
+ if ( cur === b ) { | |
+ return -1; | |
+ } | |
+ } | |
+ } | |
- input.setAttribute("checked", "checked"); | |
- | |
- // #11217 - WebKit loses check when the name is after the checked attr… | |
- input.setAttribute( "name", "t" ); | |
+ return a ? 1 : -1; | |
+} | |
- 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 ).last… | |
- | |
- // 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-… | |
- // 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: 1, | |
- change: 1, | |
- focusin: 1 | |
- }) { | |
- eventName = "on" + i; | |
- isSupported = ( eventName in div ); | |
- if ( !isSupported ) { | |
- div.setAttribute( eventName, "return;" ); | |
- isSupported = ( typeof div[ eventName ] === "f… | |
- } | |
- support[ i + "Bubbles" ] = isSupported; | |
- } | |
- } | |
- | |
- fragment.removeChild( div ); | |
- | |
- // Null elements to avoid leaks in IE | |
- fragment = select = opt = div = input = null; | |
- | |
- // Run tests that need a body at doc ready | |
- jQuery(function() { | |
- var container, outer, inner, table, td, offsetSupport, | |
- marginDiv, conMarginTop, style, html, positionTopLeftW… | |
- paddingMarginBorderVisibility, paddingMarginBorder, | |
- body = document.getElementsByTagName("body")[0]; | |
- | |
- if ( !body ) { | |
- // Return for frameset docs that don't have a body | |
- return; | |
- } | |
+/** | |
+ * 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; | |
+ }; | |
+} | |
- conMarginTop = 1; | |
- paddingMarginBorder = "padding:0;margin:0;border:"; | |
- positionTopLeftWidthHeight = "position:absolute;top:0;left:0;w… | |
- paddingMarginBorderVisibility = paddingMarginBorder + "0;visib… | |
- style = "style='" + positionTopLeftWidthHeight + paddingMargin… | |
- html = "<div " + style + "display:block;'><div style='" + padd… | |
- "<table " + style + "' cellpadding='0' cellspacing='0'… | |
- "<tr><td></td></tr></table>"; | |
- | |
- container = document.createElement("div"); | |
- container.style.cssText = paddingMarginBorderVisibility + "wid… | |
- 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 the… | |
- // to display:none and there are still other visible table cel… | |
- // table row; if so, offsetWidth/Height are not reliable for u… | |
- // determining if an element has been hidden directly using | |
- // display:none (it is still safe to use offsets if a parent e… | |
- // hidden; don safety goggles and see bug #4512 for more infor… | |
- // (only IE 8 fails this test) | |
- div.innerHTML = "<table><tr><td style='" + paddingMarginBorder… | |
- tds = div.getElementsByTagName( "td" ); | |
- 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 ].offs… | |
- | |
- // Check if div with explicit width and no margin-right incorr… | |
- // gets computed margin-right based on width of container. For… | |
- // info see bug #3333 | |
- // Fails in WebKit before Feb 2011 nightlies | |
- // WebKit Bug 13343 - getComputedStyle returns wrong value for… | |
- if ( window.getComputedStyle ) { | |
- div.innerHTML = ""; | |
- marginDiv = document.createElement( "div" ); | |
- marginDiv.style.width = "0"; | |
- marginDiv.style.marginRight = "0"; | |
- div.style.width = "2px"; | |
- div.appendChild( marginDiv ); | |
- support.reliableMarginRight = | |
- ( parseInt( ( window.getComputedStyle( marginD… | |
- } | |
- | |
- if ( typeof div.style.zoom !== "undefined" ) { | |
- // Check if natively block-level elements act like inl… | |
- // elements when setting their display to 'inline' and… | |
- // them layout | |
- // (IE < 8 does this) | |
- div.innerHTML = ""; | |
- div.style.width = div.style.padding = "1px"; | |
- div.style.border = 0; | |
- div.style.overflow = "hidden"; | |
- div.style.display = "inline"; | |
- div.style.zoom = 1; | |
- support.inlineBlockNeedsLayout = ( div.offsetWidth ===… | |
- | |
- // Check if elements with layout shrink-wrap their chi… | |
- // (IE 6 does this) | |
- div.style.display = "block"; | |
- div.style.overflow = "visible"; | |
- div.innerHTML = "<div style='width:5px;'></div>"; | |
- support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); | |
- } | |
- | |
- div.style.cssText = positionTopLeftWidthHeight + paddingMargin… | |
- div.innerHTML = html; | |
- | |
- outer = div.firstChild; | |
- inner = outer.firstChild; | |
- td = outer.nextSibling.firstChild.firstChild; | |
- | |
- offsetSupport = { | |
- doesNotAddBorder: ( inner.offsetTop !== 5 ), | |
- doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) | |
- }; | |
+/** | |
+ * 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 ==… | |
+ }; | |
+} | |
- inner.style.position = "fixed"; | |
- inner.style.top = "20px"; | |
+/** | |
+ * 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… | |
+ return function( elem ) { | |
+ | |
+ // Only certain elements can match :enabled or :disabled | |
+ // https://html.spec.whatwg.org/multipage/scripting.html#selec… | |
+ // https://html.spec.whatwg.org/multipage/scripting.html#selec… | |
+ if ( "form" in elem ) { | |
+ | |
+ // Check for inherited disabledness on relevant non-di… | |
+ // * listed form-associated elements in a disabled fie… | |
+ // https://html.spec.whatwg.org/multipage/forms.html… | |
+ // https://html.spec.whatwg.org/multipage/forms.html… | |
+ // * option elements in a disabled optgroup | |
+ // https://html.spec.whatwg.org/multipage/forms.html… | |
+ // All such elements have a "form" property. | |
+ if ( elem.parentNode && elem.disabled === false ) { | |
+ | |
+ // Option elements defer to a parent optgroup … | |
+ if ( "label" in elem ) { | |
+ if ( "label" in elem.parentNode ) { | |
+ return elem.parentNode.disable… | |
+ } else { | |
+ return elem.disabled === disab… | |
+ } | |
+ } | |
- // safari subtracts parent border width here which is 5px | |
- offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inne… | |
- inner.style.position = inner.style.top = ""; | |
+ // Support: IE 6 - 11 | |
+ // Use the isDisabled shortcut property to che… | |
+ return elem.isDisabled === disabled || | |
- outer.style.overflow = "hidden"; | |
- outer.style.position = "relative"; | |
+ // Where there is no isDisabled, check… | |
+ /* jshint -W018 */ | |
+ elem.isDisabled !== !disabled && | |
+ disabledAncestor( elem ) === d… | |
+ } | |
- offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.o… | |
- offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offset… | |
+ return elem.disabled === disabled; | |
- if ( window.getComputedStyle ) { | |
- div.style.marginTop = "1%"; | |
- support.pixelMargin = ( window.getComputedStyle( div, … | |
+ // Try to winnow out elements that can't be disabled before tr… | |
+ // Some victims get caught in our net (label, legend, menu, tr… | |
+ // even exist on them, let alone have a boolean value. | |
+ } else if ( "label" in elem ) { | |
+ return elem.disabled === disabled; | |
} | |
- if ( typeof container.style.zoom !== "undefined" ) { | |
- container.style.zoom = 1; | |
- } | |
+ // Remaining elements are neither :enabled nor :disabled | |
+ return false; | |
+ }; | |
+} | |
- body.removeChild( container ); | |
- marginDiv = div = container = null; | |
+/** | |
+ * 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; | |
- jQuery.extend( support, offsetSupport ); | |
+ // Match elements found at the specified indexes | |
+ while ( i-- ) { | |
+ if ( seed[ (j = matchIndexes[i]) ] ) { | |
+ seed[j] = !(matches[j] = seed[j]); | |
+ } | |
+ } | |
+ }); | |
}); | |
+} | |
- return support; | |
-})(); | |
- | |
- | |
+/** | |
+ * Checks a node for validity as a Sizzle context | |
+ * @param {Element|Object=} context | |
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a… | |
+ */ | |
+function testContext( context ) { | |
+ return context && typeof context.getElementsByTagName !== "undefined" … | |
+} | |
+// Expose support vars for convenience | |
+support = Sizzle.support = {}; | |
-var rbrace = /^(?:\{.*\}|\[.*\])$/, | |
- rmultiDash = /([A-Z])/g; | |
+/** | |
+ * 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).documentEle… | |
+ return documentElement ? documentElement.nodeName !== "HTML" : false; | |
+}; | |
-jQuery.extend({ | |
- cache: {}, | |
+/** | |
+ * Sets document-related variables once based on the current document | |
+ * @param {Element|Object} [doc] An element or document object to use to set t… | |
+ * @returns {Object} Returns the current document | |
+ */ | |
+setDocument = Sizzle.setDocument = function( node ) { | |
+ var hasCompare, subWindow, | |
+ doc = node ? node.ownerDocument || node : preferredDoc; | |
- // Please use with caution | |
- uuid: 0, | |
+ // Return early if doc is invalid or already selected | |
+ if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { | |
+ return document; | |
+ } | |
- // Unique for each copy of jQuery on the page | |
- // Non-digits removed to match rinlinejQuery | |
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/… | |
+ // Update global variables | |
+ document = doc; | |
+ docElem = document.documentElement; | |
+ documentIsHTML = !isXML( document ); | |
- // 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 | |
- }, | |
+ // Support: IE 9-11, Edge | |
+ // Accessing iframe documents after unload throws "permission denied" … | |
+ if ( preferredDoc !== document && | |
+ (subWindow = document.defaultView) && subWindow.top !== subWin… | |
- hasData: function( elem ) { | |
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : … | |
- return !!elem && !isEmptyDataObject( elem ); | |
- }, | |
+ // Support: IE 11, Edge | |
+ if ( subWindow.addEventListener ) { | |
+ subWindow.addEventListener( "unload", unloadHandler, f… | |
- data: function( elem, name, data, pvt /* Internal Use Only */ ) { | |
- if ( !jQuery.acceptData( elem ) ) { | |
- return; | |
+ // Support: IE 9 - 10 only | |
+ } else if ( subWindow.attachEvent ) { | |
+ subWindow.attachEvent( "onunload", unloadHandler ); | |
} | |
+ } | |
- var privateCache, thisCache, ret, | |
- internalKey = jQuery.expando, | |
- getByName = typeof name === "string", | |
+ /* Attributes | |
+ ----------------------------------------------------------------------… | |
- // We have to handle DOM nodes and JS objects differen… | |
- // can't GC object references properly across the DOM-… | |
- isNode = elem.nodeType, | |
+ // Support: IE<8 | |
+ // Verify that getAttribute really returns attributes and not properti… | |
+ // (excepting IE8 booleans) | |
+ support.attributes = assert(function( el ) { | |
+ el.className = "i"; | |
+ return !el.getAttribute("className"); | |
+ }); | |
- // Only DOM nodes need the global jQuery cache; JS obj… | |
- // attached directly to the object so GC can occur aut… | |
- cache = isNode ? jQuery.cache : elem, | |
+ /* getElement(s)By* | |
+ ----------------------------------------------------------------------… | |
- // Only defining an ID for JS objects if its cache alr… | |
- // the code to shortcut on the same path as a DOM node… | |
- id = isNode ? elem[ internalKey ] : elem[ internalKey … | |
- isEvents = name === "events"; | |
+ // Check if getElementsByTagName("*") returns only elements | |
+ support.getElementsByTagName = assert(function( el ) { | |
+ el.appendChild( document.createComment("") ); | |
+ return !el.getElementsByTagName("*").length; | |
+ }); | |
- // Avoid doing any more work than we need to when trying to ge… | |
- // object that has no data at all | |
- if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].da… | |
- return; | |
- } | |
+ // Support: IE<9 | |
+ support.getElementsByClassName = rnative.test( document.getElementsByC… | |
- if ( !id ) { | |
- // Only DOM nodes need a new unique ID for each elemen… | |
- // ends up in the global cache | |
- if ( isNode ) { | |
- elem[ internalKey ] = id = ++jQuery.uuid; | |
- } else { | |
- id = internalKey; | |
+ // Support: IE<10 | |
+ // Check if getElementById returns elements by name | |
+ // The broken getElementById methods don't pick up programmatically-se… | |
+ // so use a roundabout getElementsByName test | |
+ support.getById = assert(function( el ) { | |
+ docElem.appendChild( el ).id = expando; | |
+ return !document.getElementsByName || !document.getElementsByN… | |
+ }); | |
+ | |
+ // 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" && … | |
+ 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 !== "u… | |
+ 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" && … | |
+ var node, i, elems, | |
+ elem = context.getElementById( id ); | |
+ | |
+ if ( elem ) { | |
- if ( !cache[ id ] ) { | |
- cache[ id ] = {}; | |
+ // 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("… | |
+ if ( node && node.value === id… | |
+ return [ elem ]; | |
+ } | |
+ } | |
+ } | |
- // Avoids exposing jQuery metadata on plain JS objects… | |
- // is serialized using JSON.stringify | |
- if ( !isNode ) { | |
- cache[ id ].toJSON = jQuery.noop; | |
+ return []; | |
} | |
- } | |
+ }; | |
+ } | |
- // An object can be passed to jQuery.data instead of a key/val… | |
- // 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 ].… | |
+ // Tag | |
+ Expr.find["TAG"] = support.getElementsByTagName ? | |
+ function( tag, context ) { | |
+ if ( typeof context.getElementsByTagName !== "undefine… | |
+ 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 appe… | |
+ results = context.getElementsByTagName( tag ); | |
- privateCache = thisCache = cache[ id ]; | |
+ // Filter out possible comments | |
+ if ( tag === "*" ) { | |
+ while ( (elem = results[i++]) ) { | |
+ if ( elem.nodeType === 1 ) { | |
+ tmp.push( elem ); | |
+ } | |
+ } | |
- // jQuery data() is stored in a separate object inside the obj… | |
- // cache in order to avoid key collisions between internal dat… | |
- // data. | |
- if ( !pvt ) { | |
- if ( !thisCache.data ) { | |
- thisCache.data = {}; | |
+ return tmp; | |
} | |
+ return results; | |
+ }; | |
- thisCache = thisCache.data; | |
+ // Class | |
+ Expr.find["CLASS"] = support.getElementsByClassName && function( class… | |
+ if ( typeof context.getElementsByClassName !== "undefined" && … | |
+ return context.getElementsByClassName( className ); | |
} | |
+ }; | |
- if ( data !== undefined ) { | |
- thisCache[ jQuery.camelCase( name ) ] = data; | |
- } | |
+ /* QSA/matchesSelector | |
+ ----------------------------------------------------------------------… | |
- // Users should not attempt to inspect the internal events obj… | |
- // it is undocumented and subject to change. But does anyone l… | |
- if ( isEvents && !thisCache[ name ] ) { | |
- return privateCache.events; | |
- } | |
+ // QSA and matchesSelector support | |
- // Check for both converted-to-camel and non-converted data pr… | |
- // If a data property was specified | |
- if ( getByName ) { | |
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5) | |
+ rbuggyMatches = []; | |
- // First Try to find as-is property data | |
- ret = thisCache[ name ]; | |
+ // 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 I… | |
+ // See https://bugs.jquery.com/ticket/13378 | |
+ rbuggyQSA = []; | |
- // Test for null|undefined property data | |
- if ( ret == null ) { | |
+ if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { | |
+ // Build QSA regex | |
+ // Regex strategy adopted from Diego Perini | |
+ assert(function( el ) { | |
+ // 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='" + expa… | |
+ "<select id='" + expando + "-\r\\' msallowcapt… | |
+ "<option selected=''></option></select>"; | |
- // Try to find the camelCased property | |
- ret = thisCache[ jQuery.camelCase( name ) ]; | |
+ // Support: IE8, Opera 11-12.16 | |
+ // Nothing should be selected when empty strings follo… | |
+ // The test attribute must be unknown in Opera but "sa… | |
+ // https://msdn.microsoft.com/en-us/library/ie/hh46538… | |
+ if ( el.querySelectorAll("[msallowcapture^='']").lengt… | |
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:'… | |
} | |
- } else { | |
- ret = thisCache; | |
- } | |
- return ret; | |
- }, | |
+ // Support: IE8 | |
+ // Boolean attributes and "value" are not treated corr… | |
+ if ( !el.querySelectorAll("[selected]").length ) { | |
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:valu… | |
+ } | |
- removeData: function( elem, name, pvt /* Internal Use Only */ ) { | |
- if ( !jQuery.acceptData( elem ) ) { | |
- return; | |
- } | |
+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7… | |
+ if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).… | |
+ rbuggyQSA.push("~="); | |
+ } | |
- var thisCache, i, l, | |
+ // Webkit/Opera - :checked should return selected opti… | |
+ // http://www.w3.org/TR/2011/REC-css3-selectors-201109… | |
+ // IE8 throws error here and will not see later tests | |
+ if ( !el.querySelectorAll(":checked").length ) { | |
+ rbuggyQSA.push(":checked"); | |
+ } | |
- // Reference to internal data cache key | |
- internalKey = jQuery.expando, | |
+ // Support: Safari 8+, iOS 8+ | |
+ // https://bugs.webkit.org/show_bug.cgi?id=136851 | |
+ // In-page `selector#id sibling-combinator selector` f… | |
+ if ( !el.querySelectorAll( "a#" + expando + "+*" ).len… | |
+ rbuggyQSA.push(".#.+[+~]"); | |
+ } | |
+ }); | |
- isNode = elem.nodeType, | |
+ assert(function( el ) { | |
+ el.innerHTML = "<a href='' disabled='disabled'></a>" + | |
+ "<select disabled='disabled'><option/></select… | |
- // See jQuery.data for more information | |
- cache = isNode ? jQuery.cache : elem, | |
+ // Support: Windows 8 Native Apps | |
+ // The type and name attributes are restricted during … | |
+ var input = document.createElement("input"); | |
+ input.setAttribute( "type", "hidden" ); | |
+ el.appendChild( input ).setAttribute( "name", "D" ); | |
- // See jQuery.data for more information | |
- id = isNode ? elem[ internalKey ] : internalKey; | |
+ // Support: IE8 | |
+ // Enforce case-sensitivity of name attribute | |
+ if ( el.querySelectorAll("[name=d]").length ) { | |
+ rbuggyQSA.push( "name" + whitespace + "*[*^$|!… | |
+ } | |
- // If there is already no cache entry for this object, there i… | |
- // purpose in continuing | |
- if ( !cache[ id ] ) { | |
- return; | |
- } | |
+ // FF 3.5 - :enabled/:disabled and hidden elements (hi… | |
+ // IE8 throws error here and will not see later tests | |
+ if ( el.querySelectorAll(":enabled").length !== 2 ) { | |
+ rbuggyQSA.push( ":enabled", ":disabled" ); | |
+ } | |
- if ( name ) { | |
+ // Support: IE9-11+ | |
+ // IE's :disabled selector does not pick up the childr… | |
+ docElem.appendChild( el ).disabled = true; | |
+ if ( el.querySelectorAll(":disabled").length !== 2 ) { | |
+ rbuggyQSA.push( ":enabled", ":disabled" ); | |
+ } | |
- thisCache = pvt ? cache[ id ] : cache[ id ].data; | |
+ // Opera 10-11 does not throw on post-comma invalid ps… | |
+ el.querySelectorAll("*,:x"); | |
+ rbuggyQSA.push(",.*:"); | |
+ }); | |
+ } | |
- if ( thisCache ) { | |
+ if ( (support.matchesSelector = rnative.test( (matches = docElem.match… | |
+ docElem.webkitMatchesSelector || | |
+ docElem.mozMatchesSelector || | |
+ docElem.oMatchesSelector || | |
+ docElem.msMatchesSelector) )) ) { | |
- // Support array or space separated string nam… | |
- if ( !jQuery.isArray( name ) ) { | |
+ assert(function( el ) { | |
+ // Check to see if it's possible to do matchesSelector | |
+ // on a disconnected node (IE 9) | |
+ support.disconnectedMatch = matches.call( el, "*" ); | |
- // try the string as a key before any … | |
- if ( name in thisCache ) { | |
- name = [ name ]; | |
- } else { | |
+ // This should fail with an exception | |
+ // Gecko does not error, returns false instead | |
+ matches.call( el, "[s!='']:x" ); | |
+ rbuggyMatches.push( "!=", pseudos ); | |
+ }); | |
+ } | |
- // split the camel cased versi… | |
- name = jQuery.camelCase( name … | |
- if ( name in thisCache ) { | |
- name = [ name ]; | |
- } else { | |
- name = name.split( " "… | |
- } | |
+ 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.compare… | |
+ )); | |
+ } : | |
+ function( a, b ) { | |
+ if ( b ) { | |
+ while ( (b = b.parentNode) ) { | |
+ if ( b === a ) { | |
+ return true; | |
} | |
} | |
- | |
- for ( i = 0, l = name.length; i < l; i++ ) { | |
- delete thisCache[ name[i] ]; | |
- } | |
- | |
- // If there is no data left in the cache, we w… | |
- // and let the cache object itself get destroy… | |
- if ( !( pvt ? isEmptyDataObject : jQuery.isEmp… | |
- return; | |
- } | |
} | |
- } | |
+ return false; | |
+ }; | |
- // See jQuery.data for more information | |
- if ( !pvt ) { | |
- delete cache[ id ].data; | |
+ /* Sorting | |
+ ----------------------------------------------------------------------… | |
- // Don't destroy the parent cache unless the internal … | |
- // had been the only thing left in it | |
- if ( !isEmptyDataObject(cache[ id ]) ) { | |
- return; | |
- } | |
+ // Document order sorting | |
+ sortOrder = hasCompare ? | |
+ function( a, b ) { | |
+ | |
+ // Flag for duplicate removal | |
+ if ( a === b ) { | |
+ hasDuplicate = true; | |
+ return 0; | |
} | |
- // Browsers that fail expando deletion also refuse to delete e… | |
- // the window, but it will allow it on all other JS objects; o… | |
- // don't care | |
- // Ensure that `cache` is not a window object #10080 | |
- if ( jQuery.support.deleteExpando || !cache.setInterval ) { | |
- delete cache[ id ]; | |
- } else { | |
- cache[ id ] = null; | |
- } | |
- | |
- // We destroyed the cache and need to eliminate the expando on… | |
- // false lookups in the cache for entries that no longer exist | |
- if ( isNode ) { | |
- // IE does not allow us to delete expando properties f… | |
- // nor does it have a removeAttribute function on Docu… | |
- // we must handle all of these cases | |
- if ( jQuery.support.deleteExpando ) { | |
- delete elem[ internalKey ]; | |
- } else if ( elem.removeAttribute ) { | |
- elem.removeAttribute( internalKey ); | |
- } else { | |
- elem[ internalKey ] = null; | |
- } | |
+ // Sort on method existence if only one input has compareDocum… | |
+ var compare = !a.compareDocumentPosition - !b.compareDocumentP… | |
+ if ( compare ) { | |
+ return compare; | |
} | |
- }, | |
- // For internal use only. | |
- _data: function( elem, name, data ) { | |
- return jQuery.data( elem, name, data, true ); | |
- }, | |
+ // Calculate position if both inputs belong to the same docume… | |
+ compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b … | |
+ a.compareDocumentPosition( b ) : | |
- // A method for determining if a DOM node can handle the data expando | |
- acceptData: function( elem ) { | |
- if ( elem.nodeName ) { | |
- var match = jQuery.noData[ elem.nodeName.toLowerCase()… | |
+ // Otherwise we know they are disconnected | |
+ 1; | |
- if ( match ) { | |
- return !(match === true || elem.getAttribute("… | |
+ // Disconnected nodes | |
+ if ( compare & 1 || | |
+ (!support.sortDetached && b.compareDocumentPosition( a… | |
+ | |
+ // Choose the first element that is related to our pre… | |
+ if ( a === document || a.ownerDocument === preferredDo… | |
+ return -1; | |
} | |
+ if ( b === document || b.ownerDocument === preferredDo… | |
+ return 1; | |
+ } | |
+ | |
+ // Maintain original order | |
+ return sortInput ? | |
+ ( indexOf( sortInput, a ) - indexOf( sortInput… | |
+ 0; | |
} | |
- return true; | |
- } | |
-}); | |
+ return compare & 4 ? -1 : 1; | |
+ } : | |
+ function( a, b ) { | |
+ // Exit early if the nodes are identical | |
+ if ( a === b ) { | |
+ hasDuplicate = true; | |
+ return 0; | |
+ } | |
-jQuery.fn.extend({ | |
- data: function( key, value ) { | |
- var parts, part, attr, name, l, | |
- elem = this[0], | |
+ var cur, | |
i = 0, | |
- data = null; | |
+ 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… | |
+ 0; | |
- // Gets all values | |
- if ( key === undefined ) { | |
- if ( this.length ) { | |
- data = jQuery.data( elem ); | |
+ // If the nodes are siblings, we can do a quick check | |
+ } else if ( aup === bup ) { | |
+ return siblingCheck( a, b ); | |
+ } | |
- if ( elem.nodeType === 1 && !jQuery._data( ele… | |
- attr = elem.attributes; | |
- for ( l = attr.length; i < l; i++ ) { | |
- name = attr[i].name; | |
+ // Otherwise we need full lists of their ancestors for compari… | |
+ cur = a; | |
+ while ( (cur = cur.parentNode) ) { | |
+ ap.unshift( cur ); | |
+ } | |
+ cur = b; | |
+ while ( (cur = cur.parentNode) ) { | |
+ bp.unshift( cur ); | |
+ } | |
- if ( name.indexOf( "data-" ) =… | |
- name = jQuery.camelCas… | |
+ // Walk down the tree looking for a discrepancy | |
+ while ( ap[i] === bp[i] ) { | |
+ i++; | |
+ } | |
- dataAttr( elem, name, … | |
- } | |
- } | |
- jQuery._data( elem, "parsedAttrs", tru… | |
- } | |
- } | |
+ return i ? | |
+ // Do a sibling check if the nodes have a common ances… | |
+ siblingCheck( ap[i], bp[i] ) : | |
- return data; | |
- } | |
+ // Otherwise nodes in our document sort first | |
+ ap[i] === preferredDoc ? -1 : | |
+ bp[i] === preferredDoc ? 1 : | |
+ 0; | |
+ }; | |
- // Sets multiple values | |
- if ( typeof key === "object" ) { | |
- return this.each(function() { | |
- jQuery.data( this, key ); | |
- }); | |
- } | |
+ return document; | |
+}; | |
+ | |
+Sizzle.matches = function( expr, elements ) { | |
+ return Sizzle( expr, null, null, elements ); | |
+}; | |
- parts = key.split( ".", 2 ); | |
- parts[1] = parts[1] ? "." + parts[1] : ""; | |
- part = parts[1] + "!"; | |
+Sizzle.matchesSelector = function( elem, expr ) { | |
+ // Set document vars if needed | |
+ if ( ( elem.ownerDocument || elem ) !== document ) { | |
+ setDocument( elem ); | |
+ } | |
- return jQuery.access( this, function( value ) { | |
+ // Make sure that attribute selectors are quoted | |
+ expr = expr.replace( rattributeQuotes, "='$1']" ); | |
- if ( value === undefined ) { | |
- data = this.triggerHandler( "getData" + part, … | |
+ if ( support.matchesSelector && documentIsHTML && | |
+ !compilerCache[ expr + " " ] && | |
+ ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && | |
+ ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { | |
- // Try to fetch any internally stored data fir… | |
- if ( data === undefined && elem ) { | |
- data = jQuery.data( elem, key ); | |
- data = dataAttr( elem, key, data ); | |
- } | |
+ try { | |
+ var ret = matches.call( elem, expr ); | |
- return data === undefined && parts[1] ? | |
- this.data( parts[0] ) : | |
- data; | |
+ // IE 9's matchesSelector returns false on disconnecte… | |
+ if ( ret || support.disconnectedMatch || | |
+ // As well, disconnected nodes are sai… | |
+ // fragment in IE 9 | |
+ elem.document && elem.document.nodeTyp… | |
+ return ret; | |
} | |
+ } catch (e) {} | |
+ } | |
- parts[1] = value; | |
- this.each(function() { | |
- var self = jQuery( this ); | |
+ return Sizzle( expr, document, null, [ elem ] ).length > 0; | |
+}; | |
- self.triggerHandler( "setData" + part, parts ); | |
- jQuery.data( this, key, value ); | |
- self.triggerHandler( "changeData" + part, part… | |
- }); | |
- }, null, value, arguments.length > 1, null, false ); | |
- }, | |
+Sizzle.contains = function( context, elem ) { | |
+ // Set document vars if needed | |
+ if ( ( context.ownerDocument || context ) !== document ) { | |
+ setDocument( context ); | |
+ } | |
+ return contains( context, elem ); | |
+}; | |
- removeData: function( key ) { | |
- return this.each(function() { | |
- jQuery.removeData( this, key ); | |
- }); | |
+Sizzle.attr = function( elem, name ) { | |
+ // Set document vars if needed | |
+ if ( ( elem.ownerDocument || elem ) !== document ) { | |
+ setDocument( elem ); | |
} | |
-}); | |
-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 fn = Expr.attrHandle[ name.toLowerCase() ], | |
+ // Don't get fooled by Object.prototype properties (jQuery #13… | |
+ val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() )… | |
+ fn( elem, name, !documentIsHTML ) : | |
+ undefined; | |
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerC… | |
+ return val !== undefined ? | |
+ val : | |
+ support.attributes || !documentIsHTML ? | |
+ elem.getAttribute( name ) : | |
+ (val = elem.getAttributeNode(name)) && val.specified ? | |
+ val.value : | |
+ null; | |
+}; | |
- data = elem.getAttribute( name ); | |
+Sizzle.escape = function( sel ) { | |
+ return (sel + "").replace( rcssescape, fcssescape ); | |
+}; | |
- if ( typeof data === "string" ) { | |
- try { | |
- data = data === "true" ? true : | |
- data === "false" ? false : | |
- data === "null" ? null : | |
- jQuery.isNumeric( data ) ? +data : | |
- rbrace.test( data ) ? jQuery.parseJSON… | |
- data; | |
- } catch( e ) {} | |
+Sizzle.error = function( msg ) { | |
+ throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
+}; | |
- // Make sure we set the data so it isn't changed later | |
- jQuery.data( elem, key, data ); | |
+/** | |
+ * Document sorting and removing duplicates | |
+ * @param {ArrayLike} results | |
+ */ | |
+Sizzle.uniqueSort = function( results ) { | |
+ var elem, | |
+ duplicates = [], | |
+ j = 0, | |
+ i = 0; | |
- } else { | |
- data = undefined; | |
+ // 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 ); | |
} | |
} | |
- return data; | |
-} | |
+ // Clear input after sorting to release objects | |
+ // See https://github.com/jquery/sizzle/pull/225 | |
+ sortInput = null; | |
-// checks a cache object for emptiness | |
-function isEmptyDataObject( obj ) { | |
- for ( var name in obj ) { | |
+ return results; | |
+}; | |
- // if the public data object is empty, the private is still em… | |
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { | |
- continue; | |
+/** | |
+ * 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 ); | |
} | |
- if ( name !== "toJSON" ) { | |
- return false; | |
+ } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
+ // Use textContent for elements | |
+ // innerText usage removed for consistency of new lines (jQuer… | |
+ if ( typeof elem.textContent === "string" ) { | |
+ return elem.textContent; | |
+ } else { | |
+ // Traverse its children | |
+ for ( elem = elem.firstChild; elem; elem = elem.nextSi… | |
+ ret += getText( elem ); | |
+ } | |
} | |
+ } else if ( nodeType === 3 || nodeType === 4 ) { | |
+ return elem.nodeValue; | |
} | |
+ // Do not include comment or processing instruction nodes | |
- return true; | |
-} | |
+ return ret; | |
+}; | |
+Expr = Sizzle.selectors = { | |
+ // Can be adjusted by the user | |
+ cacheLength: 50, | |
+ createPseudo: markFunction, | |
-function handleQueueMarkDefer( elem, type, src ) { | |
- var deferDataKey = type + "defer", | |
- queueDataKey = type + "queue", | |
- markDataKey = type + "mark", | |
- defer = jQuery._data( elem, deferDataKey ); | |
- if ( defer && | |
- ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && | |
- ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { | |
- // Give room for hard-coded callbacks to fire first | |
- // and eventually mark/queue something else on the element | |
- setTimeout( function() { | |
- if ( !jQuery._data( elem, queueDataKey ) && | |
- !jQuery._data( elem, markDataKey ) ) { | |
- jQuery.removeData( elem, deferDataKey, true ); | |
- defer.fire(); | |
- } | |
- }, 0 ); | |
- } | |
-} | |
+ match: matchExpr, | |
-jQuery.extend({ | |
+ attrHandle: {}, | |
- _mark: function( elem, type ) { | |
- if ( elem ) { | |
- type = ( type || "fx" ) + "mark"; | |
- jQuery._data( elem, type, (jQuery._data( elem, type ) … | |
- } | |
+ find: {}, | |
+ | |
+ relative: { | |
+ ">": { dir: "parentNode", first: true }, | |
+ " ": { dir: "parentNode" }, | |
+ "+": { dir: "previousSibling", first: true }, | |
+ "~": { dir: "previousSibling" } | |
}, | |
- _unmark: function( force, elem, type ) { | |
- if ( force !== true ) { | |
- type = elem; | |
- elem = force; | |
- force = false; | |
- } | |
- if ( elem ) { | |
- type = type || "fx"; | |
- var key = type + "mark", | |
- count = force ? 0 : ( (jQuery._data( elem, key… | |
- if ( count ) { | |
- jQuery._data( elem, key, count ); | |
- } else { | |
- jQuery.removeData( elem, key, true ); | |
- handleQueueMarkDefer( elem, type, "mark" ); | |
+ preFilter: { | |
+ "ATTR": function( match ) { | |
+ match[1] = match[1].replace( runescape, funescape ); | |
+ | |
+ // Move the given value to match[3] whether quoted or … | |
+ match[3] = ( match[3] || match[4] || match[5] || "" ).… | |
+ | |
+ if ( match[2] === "~=" ) { | |
+ match[3] = " " + match[3] + " "; | |
} | |
- } | |
- }, | |
- queue: function( elem, type, data ) { | |
- var q; | |
- if ( elem ) { | |
- type = ( type || "fx" ) + "queue"; | |
- q = jQuery._data( elem, type ); | |
+ return match.slice( 0, 4 ); | |
+ }, | |
- // Speed up dequeue by getting out quickly if this is … | |
- if ( data ) { | |
- if ( !q || jQuery.isArray(data) ) { | |
- q = jQuery._data( elem, type, jQuery.m… | |
- } else { | |
- q.push( data ); | |
+ "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.… | |
+ // remember that false/true cast respectively … | |
+ match[4] = +( match[4] ? match[5] + (match[6] … | |
+ match[5] = +( ( match[7] + match[8] ) || match… | |
+ | |
+ // other types prohibit arguments | |
+ } else if ( match[3] ) { | |
+ Sizzle.error( match[0] ); | |
} | |
- return q || []; | |
- } | |
- }, | |
- dequeue: function( elem, type ) { | |
- type = type || "fx"; | |
+ return match; | |
+ }, | |
- var queue = jQuery.queue( elem, type ), | |
- fn = queue.shift(), | |
- hooks = {}; | |
+ "PSEUDO": function( match ) { | |
+ var excess, | |
+ unquoted = !match[6] && match[2]; | |
- // If the fx queue is dequeued, always remove the progress sen… | |
- if ( fn === "inprogress" ) { | |
- fn = queue.shift(); | |
- } | |
+ if ( matchExpr["CHILD"].test( match[0] ) ) { | |
+ return null; | |
+ } | |
- if ( fn ) { | |
- // Add a progress sentinel to prevent the fx queue fro… | |
- // automatically dequeued | |
- if ( type === "fx" ) { | |
- queue.unshift( "inprogress" ); | |
+ // 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.leng… | |
+ | |
+ // excess is a negative index | |
+ match[0] = match[0].slice( 0, excess ); | |
+ match[2] = unquoted.slice( 0, excess ); | |
} | |
- jQuery._data( elem, type + ".run", hooks ); | |
- fn.call( elem, function() { | |
- jQuery.dequeue( elem, type ); | |
- }, hooks ); | |
+ // Return only captures needed by the pseudo filter me… | |
+ return match.slice( 0, 3 ); | |
} | |
+ }, | |
- if ( !queue.length ) { | |
- jQuery.removeData( elem, type + "queue " + type + ".ru… | |
- handleQueueMarkDefer( elem, type, "queue" ); | |
- } | |
- } | |
-}); | |
+ filter: { | |
-jQuery.fn.extend({ | |
- queue: function( type, data ) { | |
- var setter = 2; | |
+ "TAG": function( nodeNameSelector ) { | |
+ var nodeName = nodeNameSelector.replace( runescape, fu… | |
+ return nodeNameSelector === "*" ? | |
+ function() { return true; } : | |
+ function( elem ) { | |
+ return elem.nodeName && elem.nodeName.… | |
+ }; | |
+ }, | |
- if ( typeof type !== "string" ) { | |
- data = type; | |
- type = "fx"; | |
- setter--; | |
- } | |
+ "CLASS": function( className ) { | |
+ var pattern = classCache[ className + " " ]; | |
- if ( arguments.length < setter ) { | |
- return jQuery.queue( this[0], type ); | |
- } | |
+ return pattern || | |
+ (pattern = new RegExp( "(^|" + whitespace + ")… | |
+ classCache( className, function( elem ) { | |
+ return pattern.test( typeof elem.class… | |
+ }); | |
+ }, | |
- return data === undefined ? | |
- this : | |
- this.each(function() { | |
- var queue = jQuery.queue( this, type, data ); | |
+ "ATTR": function( name, operator, check ) { | |
+ return function( elem ) { | |
+ var result = Sizzle.attr( elem, name ); | |
- if ( type === "fx" && queue[0] !== "inprogress… | |
- jQuery.dequeue( this, type ); | |
+ if ( result == null ) { | |
+ return operator === "!="; | |
} | |
- }); | |
- }, | |
- 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"; | |
+ if ( !operator ) { | |
+ return true; | |
+ } | |
+ | |
+ result += ""; | |
- return this.queue( type, function( next, hooks ) { | |
- var timeout = setTimeout( next, time ); | |
- hooks.stop = function() { | |
- clearTimeout( timeout ); | |
+ return operator === "=" ? result === check : | |
+ operator === "!=" ? result !== check : | |
+ operator === "^=" ? check && result.in… | |
+ operator === "*=" ? check && result.in… | |
+ operator === "$=" ? check && result.sl… | |
+ operator === "~=" ? ( " " + result.rep… | |
+ operator === "|=" ? result === check |… | |
+ false; | |
}; | |
- }); | |
- }, | |
- 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, object ) { | |
- if ( typeof type !== "string" ) { | |
- object = type; | |
- type = undefined; | |
- } | |
- type = type || "fx"; | |
- var defer = jQuery.Deferred(), | |
- elements = this, | |
- i = elements.length, | |
- count = 1, | |
- deferDataKey = type + "defer", | |
- queueDataKey = type + "queue", | |
- markDataKey = type + "mark", | |
- tmp; | |
- function resolve() { | |
- if ( !( --count ) ) { | |
- defer.resolveWith( elements, [ elements ] ); | |
- } | |
- } | |
- while( i-- ) { | |
- if (( tmp = jQuery.data( elements[ i ], deferDataKey, … | |
- ( jQuery.data( elements[ i ], queueDat… | |
- jQuery.data( elements[ i ], ma… | |
- jQuery.data( elements[ i ], deferDataK… | |
- count++; | |
- tmp.add( resolve ); | |
- } | |
- } | |
- resolve(); | |
- return defer.promise( object ); | |
- } | |
-}); | |
+ }, | |
+ "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, no… | |
+ dir = simple !== forward ? "ne… | |
+ parent = elem.parentNode, | |
+ name = ofType && elem.nodeName… | |
+ useCache = !xml && !ofType, | |
+ diff = false; | |
+ | |
+ if ( parent ) { | |
+ | |
+ // :(first|last|only)-(child|o… | |
+ if ( simple ) { | |
+ while ( dir ) { | |
+ node = elem; | |
+ while ( (node … | |
+ if ( o… | |
+ … | |
+ … | |
+ | |
+ … | |
+ } | |
+ } | |
+ // Reverse dir… | |
+ start = dir = … | |
+ } | |
+ return true; | |
+ } | |
+ start = [ forward ? parent.fir… | |
+ // non-xml :nth-child(...) sto… | |
+ if ( forward && useCache ) { | |
-var rclass = /[\n\t\r]/g, | |
- rspace = /\s+/, | |
- 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|disabl… | |
- getSetAttribute = jQuery.support.getSetAttribute, | |
- nodeHook, boolHook, fixSpecified; | |
+ // Seek `elem` from a … | |
-jQuery.fn.extend({ | |
- attr: function( name, value ) { | |
- return jQuery.access( this, jQuery.attr, name, value, argument… | |
- }, | |
+ // ...in a gzip-friend… | |
+ node = parent; | |
+ outerCache = node[ exp… | |
- removeAttr: function( name ) { | |
- return this.each(function() { | |
- jQuery.removeAttr( this, name ); | |
- }); | |
- }, | |
+ // Support: IE <9 only | |
+ // Defend against clon… | |
+ uniqueCache = outerCac… | |
+ (outerCache[ n… | |
- prop: function( name, value ) { | |
- return jQuery.access( this, jQuery.prop, name, value, argument… | |
- }, | |
+ cache = uniqueCache[ t… | |
+ nodeIndex = cache[ 0 ]… | |
+ diff = nodeIndex && ca… | |
+ node = nodeIndex && pa… | |
- removeProp: function( name ) { | |
- name = jQuery.propFix[ name ] || name; | |
- return this.each(function() { | |
- // try/catch handles cases where IE balks (such as rem… | |
- try { | |
- this[ name ] = undefined; | |
- delete this[ name ]; | |
- } catch( e ) {} | |
- }); | |
- }, | |
+ while ( (node = ++node… | |
- addClass: function( value ) { | |
- var classNames, i, l, elem, | |
- setClass, c, cl; | |
+ // Fallback to… | |
+ (diff = nodeIn… | |
- if ( jQuery.isFunction( value ) ) { | |
- return this.each(function( j ) { | |
- jQuery( this ).addClass( value.call(this, j, t… | |
- }); | |
- } | |
+ // When found,… | |
+ if ( node.node… | |
+ unique… | |
+ break; | |
+ } | |
+ } | |
- if ( value && typeof value === "string" ) { | |
- classNames = value.split( rspace ); | |
+ } else { | |
+ // Use previously-cach… | |
+ if ( useCache ) { | |
+ // ...in a gzi… | |
+ node = elem; | |
+ outerCache = n… | |
+ | |
+ // Support: IE… | |
+ // Defend agai… | |
+ uniqueCache = … | |
+ (outer… | |
+ | |
+ cache = unique… | |
+ nodeIndex = ca… | |
+ diff = nodeInd… | |
+ } | |
- for ( i = 0, l = this.length; i < l; i++ ) { | |
- elem = this[ i ]; | |
+ // xml :nth-child(...) | |
+ // or :nth-last-child(… | |
+ if ( diff === false ) { | |
+ // Use the sam… | |
+ while ( (node … | |
+ (diff … | |
- if ( elem.nodeType === 1 ) { | |
- if ( !elem.className && classNames.len… | |
- elem.className = value; | |
+ if ( (… | |
+ … | |
+ … | |
+ … | |
- } else { | |
- setClass = " " + elem.classNam… | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
- for ( c = 0, cl = classNames.l… | |
- if ( !~setClass.indexO… | |
- setClass += cl… | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ } | |
+ } | |
} | |
} | |
- elem.className = jQuery.trim( … | |
- } | |
- } | |
- } | |
- } | |
- return this; | |
- }, | |
+ // Incorporate the offset, the… | |
+ diff -= last; | |
+ return diff === first || ( dif… | |
+ } | |
+ }; | |
+ }, | |
- removeClass: function( value ) { | |
- var classNames, i, l, elem, className, c, cl; | |
+ "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 pseud… | |
+ // Remember that setFilters inherits from pseudos | |
+ var args, | |
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters… | |
+ Sizzle.error( "unsupported 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.… | |
+ markFunction(function( seed, matches )… | |
+ var idx, | |
+ matched = fn( seed, ar… | |
+ i = matched.length; | |
+ while ( i-- ) { | |
+ idx = indexOf( seed, m… | |
+ seed[ idx ] = !( match… | |
+ } | |
+ }) : | |
+ function( elem ) { | |
+ return fn( elem, 0, args ); | |
+ }; | |
+ } | |
- if ( jQuery.isFunction( value ) ) { | |
- return this.each(function( j ) { | |
- jQuery( this ).removeClass( value.call(this, j… | |
- }); | |
+ return fn; | |
} | |
+ }, | |
- if ( (value && typeof value === "string") || value === undefin… | |
- classNames = ( value || "" ).split( rspace ); | |
+ 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, "$… | |
- for ( i = 0, l = this.length; i < l; i++ ) { | |
- elem = this[ i ]; | |
+ return matcher[ expando ] ? | |
+ markFunction(function( seed, matches, context,… | |
+ var elem, | |
+ unmatched = matcher( seed, nul… | |
+ i = seed.length; | |
- if ( elem.nodeType === 1 && elem.className ) { | |
- if ( value ) { | |
- className = (" " + elem.classN… | |
- for ( c = 0, cl = classNames.l… | |
- className = className.… | |
+ // Match elements unmatched by `matche… | |
+ while ( i-- ) { | |
+ if ( (elem = unmatched[i]) ) { | |
+ seed[i] = !(matches[i]… | |
} | |
- elem.className = jQuery.trim( … | |
- | |
- } else { | |
- elem.className = ""; | |
} | |
- } | |
- } | |
- } | |
+ }) : | |
+ 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(); | |
+ }; | |
+ }), | |
- return this; | |
- }, | |
+ "has": markFunction(function( selector ) { | |
+ return function( elem ) { | |
+ return Sizzle( selector, elem ).length > 0; | |
+ }; | |
+ }), | |
- toggleClass: function( value, stateVal ) { | |
- var type = typeof value, | |
- isBool = typeof stateVal === "boolean"; | |
+ "contains": markFunction(function( text ) { | |
+ text = text.replace( runescape, funescape ); | |
+ return function( elem ) { | |
+ return ( elem.textContent || elem.innerText ||… | |
+ }; | |
+ }), | |
+ | |
+ // "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 p… | |
+ // 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 ).toLowerCas… | |
+ return function( elem ) { | |
+ var elemLang; | |
+ do { | |
+ if ( (elemLang = documentIsHTML ? | |
+ elem.lang : | |
+ elem.getAttribute("xml:lang") … | |
+ | |
+ elemLang = elemLang.toLowerCas… | |
+ return elemLang === lang || el… | |
+ } | |
+ } while ( (elem = elem.parentNode) && elem.nod… | |
+ return false; | |
+ }; | |
+ }), | |
- if ( jQuery.isFunction( value ) ) { | |
- return this.each(function( i ) { | |
- jQuery( this ).toggleClass( value.call(this, i… | |
- }); | |
- } | |
+ // Miscellaneous | |
+ "target": function( elem ) { | |
+ var hash = window.location && window.location.hash; | |
+ return hash && hash.slice( 1 ) === elem.id; | |
+ }, | |
- return this.each(function() { | |
- if ( type === "string" ) { | |
- // toggle individual class names | |
- var className, | |
- i = 0, | |
- self = jQuery( this ), | |
- state = stateVal, | |
- classNames = value.split( rspace ); | |
+ "root": function( elem ) { | |
+ return elem === docElem; | |
+ }, | |
- while ( (className = classNames[ i++ ]) ) { | |
- // check each className given, space s… | |
- state = isBool ? state : !self.hasClas… | |
- self[ state ? "addClass" : "removeClas… | |
- } | |
+ "focus": function( elem ) { | |
+ return elem === document.activeElement && (!document.h… | |
+ }, | |
- } else if ( type === "undefined" || type === "boolean"… | |
- if ( this.className ) { | |
- // store className if set | |
- jQuery._data( this, "__className__", t… | |
- } | |
+ // Boolean properties | |
+ "enabled": createDisabledPseudo( false ), | |
+ "disabled": createDisabledPseudo( true ), | |
+ | |
+ "checked": function( elem ) { | |
+ // In CSS3, :checked should return both checked and se… | |
+ // http://www.w3.org/TR/2011/REC-css3-selectors-201109… | |
+ var nodeName = elem.nodeName.toLowerCase(); | |
+ return (nodeName === "input" && !!elem.checked) || (no… | |
+ }, | |
- // toggle whole className | |
- this.className = this.className || value === f… | |
+ "selected": function( elem ) { | |
+ // Accessing this property makes selected-by-default | |
+ // options in Safari work properly | |
+ if ( elem.parentNode ) { | |
+ elem.parentNode.selectedIndex; | |
} | |
- }); | |
- }, | |
- hasClass: function( selector ) { | |
- var className = " " + selector + " ", | |
- i = 0, | |
- l = this.length; | |
- for ( ; i < l; i++ ) { | |
- if ( this[i].nodeType === 1 && (" " + this[i].classNam… | |
- return true; | |
+ 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 (… | |
+ // but not by others (comment: 8; processing instruc… | |
+ // nodeType < 6 works because attributes (2) do not ap… | |
+ for ( elem = elem.firstChild; elem; elem = elem.nextSi… | |
+ if ( elem.nodeType < 6 ) { | |
+ return false; | |
+ } | |
} | |
- } | |
+ return true; | |
+ }, | |
- return false; | |
- }, | |
+ "parent": function( elem ) { | |
+ return !Expr.pseudos["empty"]( elem ); | |
+ }, | |
- val: function( value ) { | |
- var hooks, ret, isFunction, | |
- elem = this[0]; | |
+ // Element/input types | |
+ "header": function( elem ) { | |
+ return rheader.test( elem.nodeName ); | |
+ }, | |
- if ( !arguments.length ) { | |
- if ( elem ) { | |
- hooks = jQuery.valHooks[ elem.type ] || jQuery… | |
+ "input": function( elem ) { | |
+ return rinputs.test( elem.nodeName ); | |
+ }, | |
- if ( hooks && "get" in hooks && (ret = hooks.g… | |
- return ret; | |
- } | |
+ "button": function( elem ) { | |
+ var name = elem.nodeName.toLowerCase(); | |
+ return name === "input" && elem.type === "button" || n… | |
+ }, | |
- ret = elem.value; | |
+ "text": function( elem ) { | |
+ var attr; | |
+ return elem.nodeName.toLowerCase() === "input" && | |
+ elem.type === "text" && | |
- return typeof ret === "string" ? | |
- // handle most common string cases | |
- ret.replace(rreturn, "") : | |
- // handle cases where value is null/un… | |
- ret == null ? "" : ret; | |
- } | |
+ // Support: IE<8 | |
+ // New HTML5 attribute values (e.g., "search")… | |
+ ( (attr = elem.getAttribute("type")) == null |… | |
+ }, | |
- return; | |
- } | |
+ // Position-in-collection | |
+ "first": createPositionalPseudo(function() { | |
+ return [ 0 ]; | |
+ }), | |
- isFunction = jQuery.isFunction( value ); | |
+ "last": createPositionalPseudo(function( matchIndexes, length … | |
+ return [ length - 1 ]; | |
+ }), | |
- return this.each(function( i ) { | |
- var self = jQuery(this), val; | |
+ "eq": createPositionalPseudo(function( matchIndexes, length, a… | |
+ return [ argument < 0 ? argument + length : argument ]; | |
+ }), | |
- if ( this.nodeType !== 1 ) { | |
- return; | |
+ "even": createPositionalPseudo(function( matchIndexes, length … | |
+ var i = 0; | |
+ for ( ; i < length; i += 2 ) { | |
+ matchIndexes.push( i ); | |
} | |
+ return matchIndexes; | |
+ }), | |
- if ( isFunction ) { | |
- val = value.call( this, i, self.val() ); | |
- } else { | |
- val = value; | |
+ "odd": createPositionalPseudo(function( matchIndexes, length )… | |
+ var i = 1; | |
+ for ( ; i < length; i += 2 ) { | |
+ matchIndexes.push( i ); | |
} | |
+ return matchIndexes; | |
+ }), | |
- // Treat null/undefined as ""; convert numbers to stri… | |
- 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 + ""; | |
- }); | |
+ "lt": createPositionalPseudo(function( matchIndexes, length, a… | |
+ var i = argument < 0 ? argument + length : argument; | |
+ for ( ; --i >= 0; ) { | |
+ matchIndexes.push( i ); | |
} | |
+ return matchIndexes; | |
+ }), | |
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHook… | |
- | |
- // If set returns undefined, fall back to normal setti… | |
- if ( !hooks || !("set" in hooks) || hooks.set( this, v… | |
- this.value = val; | |
+ "gt": createPositionalPseudo(function( matchIndexes, length, a… | |
+ var i = argument < 0 ? argument + length : argument; | |
+ for ( ; ++i < length; ) { | |
+ matchIndexes.push( i ); | |
} | |
- }); | |
+ return matchIndexes; | |
+ }) | |
} | |
-}); | |
+}; | |
-jQuery.extend({ | |
- valHooks: { | |
- option: { | |
- get: function( elem ) { | |
- // attributes.value is undefined in Blackberry… | |
- // uses .value. See #6932 | |
- var val = elem.attributes.value; | |
- return !val || val.specified ? elem.value : el… | |
- } | |
- }, | |
- select: { | |
- get: function( elem ) { | |
- var value, i, max, option, | |
- index = elem.selectedIndex, | |
- values = [], | |
- options = elem.options, | |
- one = elem.type === "select-one"; | |
+Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
- // Nothing was selected | |
- if ( index < 0 ) { | |
- return null; | |
- } | |
+// Add button/input type pseudos | |
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: t… | |
+ Expr.pseudos[ i ] = createInputPseudo( i ); | |
+} | |
+for ( i in { submit: true, reset: true } ) { | |
+ Expr.pseudos[ i ] = createButtonPseudo( i ); | |
+} | |
- // Loop through all the selected options | |
- i = one ? index : 0; | |
- max = one ? index + 1 : options.length; | |
- for ( ; i < max; i++ ) { | |
- option = options[ i ]; | |
+// Easy API for creating new setFilters | |
+function setFilters() {} | |
+setFilters.prototype = Expr.filters = Expr.pseudos; | |
+Expr.setFilters = new setFilters(); | |
- // Don't return options that are disab… | |
- if ( option.selected && (jQuery.suppor… | |
- (!option.parentNode.di… | |
+tokenize = Sizzle.tokenize = function( selector, parseOnly ) { | |
+ var matched, match, tokens, type, | |
+ soFar, groups, preFilters, | |
+ cached = tokenCache[ selector + " " ]; | |
- // Get the specific value for … | |
- value = jQuery( option ).val(); | |
+ if ( cached ) { | |
+ return parseOnly ? 0 : cached.slice( 0 ); | |
+ } | |
- // We don't need an array for … | |
- if ( one ) { | |
- return value; | |
- } | |
+ soFar = selector; | |
+ groups = []; | |
+ preFilters = Expr.preFilter; | |
- // Multi-Selects return an arr… | |
- values.push( value ); | |
- } | |
- } | |
+ while ( soFar ) { | |
- // Fixes Bug #2551 -- select.val() broken in I… | |
- if ( one && !values.length && options.length )… | |
- return jQuery( options[ index ] ).val(… | |
- } | |
+ // 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 ) || soFa… | |
+ } | |
+ groups.push( (tokens = []) ); | |
+ } | |
- return values; | |
- }, | |
+ matched = false; | |
- set: function( elem, value ) { | |
- var values = jQuery.makeArray( value ); | |
+ // 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 ); | |
+ } | |
- jQuery(elem).find("option").each(function() { | |
- this.selected = jQuery.inArray( jQuery… | |
+ // Filters | |
+ for ( type in Expr.filter ) { | |
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!pr… | |
+ (match = preFilters[ type ]( match ))) ) { | |
+ matched = match.shift(); | |
+ tokens.push({ | |
+ value: matched, | |
+ type: type, | |
+ matches: match | |
}); | |
- | |
- if ( !values.length ) { | |
- elem.selectedIndex = -1; | |
- } | |
- return values; | |
+ soFar = soFar.slice( matched.length ); | |
} | |
} | |
- }, | |
- attrFn: { | |
- val: true, | |
- css: true, | |
- html: true, | |
- text: true, | |
- data: true, | |
- width: true, | |
- height: true, | |
- offset: true | |
- }, | |
+ if ( !matched ) { | |
+ break; | |
+ } | |
+ } | |
- attr: function( elem, name, value, pass ) { | |
- var ret, hooks, notxml, | |
- nType = elem.nodeType; | |
+ // 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 ); | |
+}; | |
- // don't get/set attributes on text, comment and attribute nod… | |
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
- return; | |
- } | |
+function toSelector( tokens ) { | |
+ var i = 0, | |
+ len = tokens.length, | |
+ selector = ""; | |
+ for ( ; i < len; i++ ) { | |
+ selector += tokens[i].value; | |
+ } | |
+ return selector; | |
+} | |
- if ( pass && name in jQuery.attrFn ) { | |
- return jQuery( elem )[ name ]( value ); | |
- } | |
+function addCombinator( matcher, combinator, base ) { | |
+ var dir = combinator.dir, | |
+ skip = combinator.next, | |
+ key = skip || dir, | |
+ checkNonElements = base && key === "parentNode", | |
+ doneName = done++; | |
- // Fallback to prop when attributes are not supported | |
- if ( typeof elem.getAttribute === "undefined" ) { | |
- return jQuery.prop( elem, name, value ); | |
- } | |
+ 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; | |
+ } : | |
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
+ // Check against all ancestor/preceding elements | |
+ function( elem, context, xml ) { | |
+ var oldCache, uniqueCache, outerCache, | |
+ newCache = [ dirruns, doneName ]; | |
- // All attributes are lowercase | |
- // Grab necessary hook if one is defined | |
- if ( notxml ) { | |
- name = name.toLowerCase(); | |
- hooks = jQuery.attrHooks[ name ] || ( rboolean.test( n… | |
- } | |
+ // We can't set arbitrary data on XML nodes, so they d… | |
+ if ( xml ) { | |
+ while ( (elem = elem[ dir ]) ) { | |
+ if ( elem.nodeType === 1 || checkNonEl… | |
+ if ( matcher( elem, context, x… | |
+ return true; | |
+ } | |
+ } | |
+ } | |
+ } else { | |
+ while ( (elem = elem[ dir ]) ) { | |
+ if ( elem.nodeType === 1 || checkNonEl… | |
+ outerCache = elem[ expando ] |… | |
- if ( value !== undefined ) { | |
+ // Support: IE <9 only | |
+ // Defend against cloned attro… | |
+ uniqueCache = outerCache[ elem… | |
- if ( value === null ) { | |
- jQuery.removeAttr( elem, name ); | |
- return; | |
+ if ( skip && skip === elem.nod… | |
+ elem = elem[ dir ] || … | |
+ } else if ( (oldCache = unique… | |
+ oldCache[ 0 ] === dirr… | |
- } else if ( hooks && "set" in hooks && notxml && (ret … | |
- return ret; | |
+ // Assign to newCache … | |
+ return (newCache[ 2 ] … | |
+ } else { | |
+ // Reuse newcache so r… | |
+ uniqueCache[ key ] = n… | |
- } else { | |
- elem.setAttribute( name, "" + value ); | |
- return value; | |
+ // A match means we're… | |
+ if ( (newCache[ 2 ] = … | |
+ return true; | |
+ } | |
+ } | |
+ } | |
+ } | |
} | |
+ return false; | |
+ }; | |
+} | |
- } else if ( hooks && "get" in hooks && notxml && (ret = hooks.… | |
- return ret; | |
+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]; | |
+} | |
- } else { | |
+function multipleContexts( selector, contexts, results ) { | |
+ var i = 0, | |
+ len = contexts.length; | |
+ for ( ; i < len; i++ ) { | |
+ Sizzle( selector, contexts[i], results ); | |
+ } | |
+ return results; | |
+} | |
- ret = elem.getAttribute( name ); | |
+function condense( unmatched, map, filter, context, xml ) { | |
+ var elem, | |
+ newUnmatched = [], | |
+ i = 0, | |
+ len = unmatched.length, | |
+ mapped = map != null; | |
- // Non-existent attributes return null, we normalize t… | |
- return ret === null ? | |
- undefined : | |
- ret; | |
+ for ( ; i < len; i++ ) { | |
+ if ( (elem = unmatched[i]) ) { | |
+ if ( !filter || filter( elem, context, xml ) ) { | |
+ newUnmatched.push( elem ); | |
+ if ( mapped ) { | |
+ map.push( i ); | |
+ } | |
+ } | |
} | |
- }, | |
+ } | |
- removeAttr: function( elem, value ) { | |
- var propName, attrNames, name, l, isBool, | |
- i = 0; | |
+ return newUnmatched; | |
+} | |
+ | |
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, pos… | |
+ 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, | |
- if ( value && elem.nodeType === 1 ) { | |
- attrNames = value.toLowerCase().split( rspace ); | |
- l = attrNames.length; | |
+ // Get initial elements from seed or context | |
+ elems = seed || multipleContexts( selector || "*", con… | |
- for ( ; i < l; i++ ) { | |
- name = attrNames[ i ]; | |
+ // Prefilter to get matcher input, preserving a map fo… | |
+ matcherIn = preFilter && ( seed || !selector ) ? | |
+ condense( elems, preMap, preFilter, context, x… | |
+ elems, | |
+ | |
+ matcherOut = matcher ? | |
+ // If we have a postFinder, or filtered seed, … | |
+ postFinder || ( seed ? preFilter : preexisting… | |
+ | |
+ // ...intermediate processing is neces… | |
+ [] : | |
+ | |
+ // ...otherwise use results directly | |
+ results : | |
+ matcherIn; | |
+ | |
+ // Find primary matches | |
+ if ( matcher ) { | |
+ matcher( matcherIn, matcherOut, context, xml ); | |
+ } | |
- if ( name ) { | |
- propName = jQuery.propFix[ name ] || n… | |
- isBool = rboolean.test( name ); | |
+ // Apply postFilter | |
+ if ( postFilter ) { | |
+ temp = condense( matcherOut, postMap ); | |
+ postFilter( temp, [], context, xml ); | |
- // See #9699 for explanation of this a… | |
- // Do not do this for boolean attribut… | |
- if ( !isBool ) { | |
- jQuery.attr( elem, name, "" ); | |
+ // Un-match failing elements by moving them back to ma… | |
+ i = temp.length; | |
+ while ( i-- ) { | |
+ if ( (elem = temp[i]) ) { | |
+ matcherOut[ postMap[i] ] = !(matcherIn… | |
+ } | |
+ } | |
+ } | |
+ | |
+ if ( seed ) { | |
+ if ( postFinder || preFilter ) { | |
+ if ( postFinder ) { | |
+ // Get the final matcherOut by condens… | |
+ temp = []; | |
+ i = matcherOut.length; | |
+ while ( i-- ) { | |
+ if ( (elem = matcherOut[i]) ) { | |
+ // Restore matcherIn s… | |
+ temp.push( (matcherIn[… | |
+ } | |
} | |
- elem.removeAttribute( getSetAttribute … | |
+ postFinder( null, (matcherOut = []), t… | |
+ } | |
- // Set corresponding property to false… | |
- if ( isBool && propName in elem ) { | |
- elem[ propName ] = false; | |
+ // Move matched elements from seed to results … | |
+ i = matcherOut.length; | |
+ while ( i-- ) { | |
+ if ( (elem = matcherOut[i]) && | |
+ (temp = postFinder ? indexOf( … | |
+ | |
+ seed[temp] = !(results[temp] =… | |
} | |
} | |
} | |
+ | |
+ // Add elements to results, through postFinder if defined | |
+ } else { | |
+ matcherOut = condense( | |
+ matcherOut === results ? | |
+ matcherOut.splice( preexisting, matche… | |
+ matcherOut | |
+ ); | |
+ if ( postFinder ) { | |
+ postFinder( null, results, matcherOut, xml ); | |
+ } else { | |
+ push.apply( results, matcherOut ); | |
+ } | |
} | |
- }, | |
+ }); | |
+} | |
- attrHooks: { | |
- type: { | |
- set: function( elem, value ) { | |
- // We can't allow the type property to be chan… | |
- if ( rtype.test( elem.nodeName ) && elem.paren… | |
- jQuery.error( "type property can't be … | |
- } else if ( !jQuery.support.radioValue && valu… | |
- // Setting the type on a radio button … | |
- // Reset value to it's default in case… | |
- // This is for element creation | |
- var val = elem.value; | |
- elem.setAttribute( "type", value ); | |
- if ( val ) { | |
- elem.value = val; | |
+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 reachabl… | |
+ 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 !== o… | |
+ (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 ),… | |
+ } else { | |
+ matcher = Expr.filter[ tokens[i].type ].apply( null, t… | |
+ | |
+ // Return special upon seeing a positional matcher | |
+ if ( matcher[ expando ] ) { | |
+ // Find the next relative operator (if any) fo… | |
+ j = ++i; | |
+ for ( ; j < len; j++ ) { | |
+ if ( Expr.relative[ tokens[j].type ] )… | |
+ break; | |
} | |
- return value; | |
} | |
+ return setMatcher( | |
+ i > 1 && elementMatcher( matchers ), | |
+ i > 1 && toSelector( | |
+ // If the preceding token was … | |
+ tokens.slice( 0, i - 1 ).conca… | |
+ ).replace( rtrim, "$1" ), | |
+ matcher, | |
+ i < j && matcherFromTokens( tokens.sli… | |
+ j < len && matcherFromTokens( (tokens … | |
+ j < len && toSelector( tokens ) | |
+ ); | |
} | |
- }, | |
- // 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, "butto… | |
- return nodeHook.get( elem, name ); | |
- } | |
- return name in elem ? | |
- elem.value : | |
- null; | |
- }, | |
- set: function( elem, value, name ) { | |
- if ( nodeHook && jQuery.nodeName( elem, "butto… | |
- return nodeHook.set( elem, value, name… | |
+ 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, outermos… | |
+ var elem, j, matcher, | |
+ matchedCount = 0, | |
+ i = "0", | |
+ unmatched = seed && [], | |
+ setMatched = [], | |
+ contextBackup = outermostContext, | |
+ // We must always have either seed elements or… | |
+ elems = seed || byElement && Expr.find["TAG"](… | |
+ // Use integer dirruns iff this is the outermo… | |
+ dirrunsUnique = (dirruns += contextBackup == n… | |
+ len = elems.length; | |
+ | |
+ if ( outermost ) { | |
+ outermostContext = context === document || con… | |
+ } | |
+ | |
+ // Add elements passing elementMatchers directly to re… | |
+ // Support: IE<9, Safari | |
+ // Tolerate NodeList properties (IE: "length"; Safari:… | |
+ for ( ; i !== len && (elem = elems[i]) != null; i++ ) { | |
+ if ( byElement && elem ) { | |
+ j = 0; | |
+ if ( !context && elem.ownerDocument !=… | |
+ setDocument( elem ); | |
+ xml = !documentIsHTML; | |
+ } | |
+ while ( (matcher = elementMatchers[j++… | |
+ if ( matcher( elem, context ||… | |
+ results.push( elem ); | |
+ break; | |
+ } | |
+ } | |
+ if ( outermost ) { | |
+ dirruns = dirrunsUnique; | |
+ } | |
+ } | |
+ | |
+ // Track unmatched elements for set filters | |
+ if ( bySet ) { | |
+ // They will have gone through all pos… | |
+ if ( (elem = !matcher && elem) ) { | |
+ matchedCount--; | |
+ } | |
+ | |
+ // Lengthen the array for every elemen… | |
+ if ( seed ) { | |
+ unmatched.push( elem ); | |
+ } | |
} | |
- // Does not return so that setAttribute is als… | |
- 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" | |
- }, | |
+ // `i` is now the count of elements visited above, and… | |
+ // makes the latter nonnegative. | |
+ matchedCount += i; | |
- prop: function( elem, name, value ) { | |
- var ret, hooks, notxml, | |
- nType = elem.nodeType; | |
+ // Apply set filters to unmatched elements | |
+ // NOTE: This can be skipped if there are no unmatched… | |
+ // equals `i`), unless we didn't visit _any_ elements … | |
+ // no element matchers and no seed. | |
+ // Incrementing an initially-string "0" `i` allows `i`… | |
+ // case, which will result in a "00" `matchedCount` th… | |
+ // numerically zero. | |
+ if ( bySet && i !== matchedCount ) { | |
+ j = 0; | |
+ while ( (matcher = setMatchers[j++]) ) { | |
+ matcher( unmatched, setMatched, contex… | |
+ } | |
- // don't get/set properties on text, comment and attribute nod… | |
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
- return; | |
- } | |
+ if ( seed ) { | |
+ // Reintegrate element matches to elim… | |
+ if ( matchedCount > 0 ) { | |
+ while ( i-- ) { | |
+ if ( !(unmatched[i] ||… | |
+ setMatched[i] … | |
+ } | |
+ } | |
+ } | |
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
+ // Discard index placeholder values to… | |
+ setMatched = condense( setMatched ); | |
+ } | |
- if ( notxml ) { | |
- // Fix name and attach hooks | |
- name = jQuery.propFix[ name ] || name; | |
- hooks = jQuery.propHooks[ name ]; | |
- } | |
+ // Add matches to results | |
+ push.apply( results, setMatched ); | |
- if ( value !== undefined ) { | |
- if ( hooks && "set" in hooks && (ret = hooks.set( elem… | |
- return ret; | |
+ // Seedless set matches succeeding multiple su… | |
+ if ( outermost && !seed && setMatched.length >… | |
+ ( matchedCount + setMatchers.length ) … | |
- } else { | |
- return ( elem[ name ] = value ); | |
+ Sizzle.uniqueSort( results ); | |
+ } | |
} | |
- } else { | |
- if ( hooks && "get" in hooks && (ret = hooks.get( elem… | |
- return ret; | |
+ // 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… | |
+ if ( !match ) { | |
+ match = tokenize( selector ); | |
+ } | |
+ i = match.length; | |
+ while ( i-- ) { | |
+ cached = matcherFromTokens( match[i] ); | |
+ if ( cached[ expando ] ) { | |
+ setMatchers.push( cached ); | |
} else { | |
- return elem[ name ]; | |
+ elementMatchers.push( cached ); | |
} | |
} | |
- }, | |
- propHooks: { | |
- tabIndex: { | |
- get: function( elem ) { | |
- // elem.tabIndex doesn't always return the cor… | |
- // http://fluidproject.org/blog/2008/01/09/get… | |
- var attributeNode = elem.getAttributeNode("tab… | |
+ // Cache the compiled function | |
+ cached = compilerCache( selector, matcherFromGroupMatchers( el… | |
- return attributeNode && attributeNode.specifie… | |
- parseInt( attributeNode.value, 10 ) : | |
- rfocusable.test( elem.nodeName ) || rc… | |
- 0 : | |
- undefined; | |
- } | |
- } | |
+ // Save selector and tokenization | |
+ cached.selector = selector; | |
} | |
-}); | |
+ return cached; | |
+}; | |
-// Add the tabIndex propHook to attrHooks for back-compat (different case is i… | |
-jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; | |
+/** | |
+ * 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 || se… | |
-// 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… | |
- var attrNode, | |
- property = jQuery.prop( elem, name ); | |
- return property === true || typeof property !== "boolean" && (… | |
- 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… | |
- // Set boolean attributes to the same name and set the… | |
- propName = jQuery.propFix[ name ] || name; | |
- if ( propName in elem ) { | |
- // Only set the IDL specifically if it already… | |
- elem[ propName ] = true; | |
- } | |
+ results = results || []; | |
- elem.setAttribute( name, name.toLowerCase() ); | |
- } | |
- return name; | |
- } | |
-}; | |
+ // Try to minimize operations if there is only one selector in the lis… | |
+ // (the latter of which guarantees us context) | |
+ if ( match.length === 1 ) { | |
-// IE6/7 do not support getting/setting some attributes with get/setAttribute | |
-if ( !getSetAttribute ) { | |
+ // 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 && Ex… | |
- fixSpecified = { | |
- name: true, | |
- id: true, | |
- coords: true | |
- }; | |
+ context = ( Expr.find["ID"]( token.matches[0].replace(… | |
+ if ( !context ) { | |
+ return results; | |
- // 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.nodeValue !… | |
- ret.nodeValue : | |
- 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 ); | |
+ // Precompiled matchers will still verify ancestry, so… | |
+ } else if ( compiled ) { | |
+ context = context.parentNode; | |
} | |
- return ( ret.nodeValue = value + "" ); | |
+ | |
+ selector = selector.slice( tokens.shift().value.length… | |
} | |
- }; | |
- // Apply the nodeHook to tabindex | |
- jQuery.attrHooks.tabindex.set = nodeHook.set; | |
+ // Fetch a seed set for right-to-left matching | |
+ i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.le… | |
+ while ( i-- ) { | |
+ token = tokens[i]; | |
- // Set width and height to auto instead of 0 on empty string( Bug #815… | |
- // This is for removals | |
- jQuery.each([ "width", "height" ], function( i, name ) { | |
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ na… | |
- set: function( elem, value ) { | |
- if ( value === "" ) { | |
- elem.setAttribute( name, "auto" ); | |
- return value; | |
- } | |
+ // Abort if we hit a combinator | |
+ if ( Expr.relative[ (type = token.type) ] ) { | |
+ break; | |
} | |
- }); | |
- }); | |
+ if ( (find = Expr.find[ type ]) ) { | |
+ // Search, expanding context for leading sibli… | |
+ if ( (seed = find( | |
+ token.matches[0].replace( runescape, f… | |
+ rsibling.test( tokens[0].type ) && tes… | |
+ )) ) { | |
+ | |
+ // If seed is empty or no tokens remai… | |
+ tokens.splice( i, 1 ); | |
+ selector = seed.length && toSelector( … | |
+ if ( !selector ) { | |
+ push.apply( results, seed ); | |
+ return results; | |
+ } | |
- // 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"; | |
+ break; | |
+ } | |
} | |
- nodeHook.set( elem, value, name ); | |
} | |
- }; | |
-} | |
+ } | |
+ // Compile and execute a filtering function if one is not provided | |
+ // Provide `match` to avoid retokenization if we modified the selector… | |
+ ( compiled || compile( selector, match ) )( | |
+ seed, | |
+ context, | |
+ !documentIsHTML, | |
+ results, | |
+ !context || rsibling.test( selector ) && testContext( context.… | |
+ ); | |
+ return results; | |
+}; | |
-// 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[ na… | |
- get: function( elem ) { | |
- var ret = elem.getAttribute( name, 2 ); | |
- return ret === null ? undefined : ret; | |
- } | |
- }); | |
- }); | |
-} | |
+// One-time assignments | |
-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 prop… | |
- return elem.style.cssText.toLowerCase() || undefined; | |
- }, | |
- set: function( elem, value ) { | |
- return ( elem.style.cssText = "" + value ); | |
- } | |
- }; | |
-} | |
+// Sort stability | |
+support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; | |
-// 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; | |
+// Support: Chrome 14-35+ | |
+// Always assume duplicates if they aren't passed to the comparison function | |
+support.detectDuplicates = !!hasDuplicate; | |
- if ( parent ) { | |
- parent.selectedIndex; | |
+// Initialize against the default document | |
+setDocument(); | |
- // Make sure that it also works with optgroups… | |
- if ( parent.parentNode ) { | |
- parent.parentNode.selectedIndex; | |
- } | |
- } | |
- return null; | |
+// 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") … | |
+}); | |
+ | |
+// 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() ===… | |
} | |
}); | |
} | |
-// 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 retur… | |
- return elem.getAttribute("value") === null ? "… | |
- } | |
- }; | |
+// 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; | |
+ } | |
}); | |
} | |
-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… | |
- } | |
+ | |
+// 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.value : | |
+ null; | |
} | |
}); | |
-}); | |
+} | |
+return Sizzle; | |
+})( window ); | |
-var rformElems = /^(?:textarea|input|select)$/i, | |
- rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, | |
- rhoverHack = /(?:^|\s)hover(\.\S+)?\b/, | |
- rkeyEvent = /^key/, | |
- rmouseEvent = /^(?:mouse|contextmenu)|click/, | |
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
- rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, | |
- quickParse = function( selector ) { | |
- var quick = rquickIs.exec( selector ); | |
- if ( quick ) { | |
- // 0 1 2 3 | |
- // [ _, tag, id, class ] | |
- quick[1] = ( quick[1] || "" ).toLowerCase(); | |
- quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick… | |
- } | |
- return quick; | |
- }, | |
- quickIs = function( elem, m ) { | |
- var attrs = elem.attributes || {}; | |
- return ( | |
- (!m[1] || elem.nodeName.toLowerCase() === m[1]) && | |
- (!m[2] || (attrs.id || {}).value === m[2]) && | |
- (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) | |
- ); | |
- }, | |
- hoverHack = function( events ) { | |
- return jQuery.event.special.hover ? events : events.replace( r… | |
- }; | |
-/* | |
- * Helper functions for managing events -- not part of the public interface. | |
- * Props to Dean Edwards' addEvent library for many of the ideas. | |
- */ | |
-jQuery.event = { | |
+jQuery.find = Sizzle; | |
+jQuery.expr = Sizzle.selectors; | |
- add: function( elem, types, handler, data, selector ) { | |
+// 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 elemData, eventHandle, events, | |
- t, tns, type, namespaces, handleObj, | |
- handleObjIn, quick, handlers, special; | |
- // Don't attach events to noData or text/comment nodes (allow … | |
- if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !… | |
- return; | |
- } | |
- // Caller can pass in an object of custom data in lieu of the … | |
- if ( handler.handler ) { | |
- handleObjIn = handler; | |
- handler = handleObjIn.handler; | |
- selector = handleObjIn.selector; | |
- } | |
- // Make sure that the handler has a unique ID, used to find/re… | |
- if ( !handler.guid ) { | |
- handler.guid = jQuery.guid++; | |
- } | |
+var dir = function( elem, dir, until ) { | |
+ var matched = [], | |
+ truncate = until !== undefined; | |
- // Init the element's event structure and main handler, if thi… | |
- 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.… | |
- // when an event is called after a page has un… | |
- return typeof jQuery !== "undefined" && (!e ||… | |
- jQuery.event.dispatch.apply( eventHand… | |
- undefined; | |
- }; | |
- // Add elem as a property of the handle fn to prevent … | |
- eventHandle.elem = elem; | |
+ while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { | |
+ if ( elem.nodeType === 1 ) { | |
+ if ( truncate && jQuery( elem ).is( until ) ) { | |
+ break; | |
+ } | |
+ matched.push( elem ); | |
} | |
+ } | |
+ return matched; | |
+}; | |
- // 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 ha… | |
- special = jQuery.event.special[ type ] || {}; | |
+var siblings = function( n, elem ) { | |
+ var matched = []; | |
- // If selector defined, determine special event api ty… | |
- type = ( selector ? special.delegateType : special.bin… | |
- | |
- // 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, | |
- quick: selector && quickParse( selector ), | |
- namespace: namespaces.join(".") | |
- }, handleObjIn ); | |
+ for ( ; n; n = n.nextSibling ) { | |
+ if ( n.nodeType === 1 && n !== elem ) { | |
+ matched.push( n ); | |
+ } | |
+ } | |
- // Init the event handler queue if we're the first | |
- handlers = events[ type ]; | |
- if ( !handlers ) { | |
- handlers = events[ type ] = []; | |
- handlers.delegateCount = 0; | |
+ return matched; | |
+}; | |
- // Only use addEventListener/attachEvent if th… | |
- if ( !special.setup || special.setup.call( ele… | |
- // Bind the global event handler to th… | |
- if ( elem.addEventListener ) { | |
- elem.addEventListener( type, e… | |
- } else if ( elem.attachEvent ) { | |
- elem.attachEvent( "on" + type,… | |
- } | |
- } | |
- } | |
+var rneedsContext = jQuery.expr.match.needsContext; | |
- if ( special.add ) { | |
- special.add.call( elem, handleObj ); | |
+var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1… | |
- if ( !handleObj.handler.guid ) { | |
- handleObj.handler.guid = handler.guid; | |
- } | |
- } | |
- // Add to the element's handler list, delegates in fro… | |
- if ( selector ) { | |
- handlers.splice( handlers.delegateCount++, 0, … | |
- } else { | |
- handlers.push( handleObj ); | |
- } | |
- // Keep track of which events have ever been used, for… | |
- jQuery.event.global[ type ] = true; | |
- } | |
+var risSimple = /^.[^:#\[\.,]*$/; | |
- // Nullify elem to prevent memory leaks in IE | |
- elem = null; | |
- }, | |
+// Implement the identical functionality for filter and not | |
+function winnow( elements, qualifier, not ) { | |
+ if ( jQuery.isFunction( qualifier ) ) { | |
+ return jQuery.grep( elements, function( elem, i ) { | |
+ return !!qualifier.call( elem, i, elem ) !== not; | |
+ } ); | |
+ } | |
- global: {}, | |
+ // Single element | |
+ if ( qualifier.nodeType ) { | |
+ return jQuery.grep( elements, function( elem ) { | |
+ return ( elem === qualifier ) !== not; | |
+ } ); | |
+ } | |
- // Detach an event or set of events from an element | |
- remove: function( elem, types, handler, selector, mappedTypes ) { | |
+ // Arraylike of elements (jQuery, arguments, Array) | |
+ if ( typeof qualifier !== "string" ) { | |
+ return jQuery.grep( elements, function( elem ) { | |
+ return ( indexOf.call( qualifier, elem ) > -1 ) !== no… | |
+ } ); | |
+ } | |
- var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), | |
- t, tns, type, origType, namespaces, origCount, | |
- j, events, special, handle, eventType, handleObj; | |
+ // Simple selector that can be filtered directly, removing non-Elements | |
+ if ( risSimple.test( qualifier ) ) { | |
+ return jQuery.filter( qualifier, elements, not ); | |
+ } | |
- if ( !elemData || !(events = elemData.events) ) { | |
- return; | |
- } | |
+ // Complex selector, compare the two sets, removing non-Elements | |
+ qualifier = jQuery.filter( qualifier, elements ); | |
+ return jQuery.grep( elements, function( elem ) { | |
+ return ( indexOf.call( qualifier, elem ) > -1 ) !== not && ele… | |
+ } ); | |
+} | |
- // 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]; | |
+jQuery.filter = function( expr, elems, not ) { | |
+ var elem = elems[ 0 ]; | |
- // Unbind all events (on this namespace, if provided) … | |
- if ( !type ) { | |
- for ( type in events ) { | |
- jQuery.event.remove( elem, type + type… | |
- } | |
- continue; | |
- } | |
+ if ( not ) { | |
+ expr = ":not(" + expr + ")"; | |
+ } | |
- special = jQuery.event.special[ type ] || {}; | |
- type = ( selector? special.delegateType : special.bind… | |
- eventType = events[ type ] || []; | |
- origCount = eventType.length; | |
- namespaces = namespaces ? new RegExp("(^|\\.)" + names… | |
+ if ( elems.length === 1 && elem.nodeType === 1 ) { | |
+ return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : … | |
+ } | |
- // Remove matching events | |
- for ( j = 0; j < eventType.length; j++ ) { | |
- handleObj = eventType[ j ]; | |
+ return jQuery.find.matches( expr, jQuery.grep( elems, function( elem )… | |
+ return elem.nodeType === 1; | |
+ } ) ); | |
+}; | |
- if ( ( mappedTypes || origType === handleObj.o… | |
- ( !handler || handler.guid === handle… | |
- ( !namespaces || namespaces.test( han… | |
- ( !selector || selector === handleObj… | |
- eventType.splice( j--, 1 ); | |
+jQuery.fn.extend( { | |
+ find: function( selector ) { | |
+ var i, ret, | |
+ len = this.length, | |
+ self = this; | |
- if ( handleObj.selector ) { | |
- eventType.delegateCount--; | |
- } | |
- if ( special.remove ) { | |
- special.remove.call( elem, han… | |
+ if ( typeof selector !== "string" ) { | |
+ return this.pushStack( jQuery( selector ).filter( func… | |
+ for ( i = 0; i < len; i++ ) { | |
+ if ( jQuery.contains( self[ i ], this … | |
+ return true; | |
} | |
} | |
- } | |
- | |
- // Remove generic event handler if we removed somethin… | |
- // (avoids potential for endless recursion during remo… | |
- if ( eventType.length === 0 && origCount !== eventType… | |
- if ( !special.teardown || special.teardown.cal… | |
- jQuery.removeEvent( elem, type, elemDa… | |
- } | |
- | |
- delete events[ type ]; | |
- } | |
+ } ) ); | |
} | |
- // Remove the expando if it's no longer used | |
- if ( jQuery.isEmptyObject( events ) ) { | |
- handle = elemData.handle; | |
- if ( handle ) { | |
- handle.elem = null; | |
- } | |
+ ret = this.pushStack( [] ); | |
- // removeData also checks for emptiness and clears the… | |
- // so use it instead of delete | |
- jQuery.removeData( elem, [ "events", "handle" ], true … | |
+ for ( i = 0; i < len; i++ ) { | |
+ jQuery.find( selector, self[ i ], ret ); | |
} | |
- }, | |
- // Events that are safe to short-circuit if no handlers are attached. | |
- // Native DOM events should not be added, they may have inline handler… | |
- customEvent: { | |
- "getData": true, | |
- "setData": true, | |
- "changeData": true | |
+ 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 me… | |
+ // so $("p:first").is("p:last") won't return true for … | |
+ typeof selector === "string" && rneedsContext.test( se… | |
+ jQuery( selector ) : | |
+ selector || [], | |
+ false | |
+ ).length; | |
+ } | |
+} ); | |
- 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 type = event.type || event, | |
- namespaces = [], | |
- cache, exclusive, i, cur, old, ontype, special, handle… | |
- | |
- // focus/blur morphs to focusin/out; ensure we're not firing t… | |
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
- return; | |
- } | |
- | |
- if ( type.indexOf( "!" ) >= 0 ) { | |
- // Exclusive events trigger only for the exact event (… | |
- type = type.slice(0, -1); | |
- exclusive = true; | |
- } | |
- | |
- if ( type.indexOf( "." ) >= 0 ) { | |
- // Namespaced trigger; create a regexp to match event … | |
- namespaces = type.split("."); | |
- type = namespaces.shift(); | |
- namespaces.sort(); | |
- } | |
- if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.ev… | |
- // No jQuery handlers for this event type, and it can'… | |
- return; | |
- } | |
+// Initialize a jQuery object | |
- // Caller can pass in an Event, Object, or just an event type … | |
- 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("(^|\\.)" + n… | |
- ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; | |
+// A central reference to the root jQuery(document) | |
+var rootjQuery, | |
- // Handle a global trigger | |
- if ( !elem ) { | |
+ // 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-]+))$/, | |
- // TODO: Stop taunting the data cache; remove global e… | |
- cache = jQuery.cache; | |
- for ( i in cache ) { | |
- if ( cache[ i ].events && cache[ i ].events[ t… | |
- jQuery.event.trigger( event, data, cac… | |
- } | |
- } | |
- return; | |
- } | |
+ init = jQuery.fn.init = function( selector, context, root ) { | |
+ var match, elem; | |
- // Clean up the event in case it is being reused | |
- event.result = undefined; | |
- if ( !event.target ) { | |
- event.target = elem; | |
+ // HANDLE: $(""), $(null), $(undefined), $(false) | |
+ if ( !selector ) { | |
+ return this; | |
} | |
- // Clone any incoming data and prepend the event, creating the… | |
- 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 ) ==… | |
- return; | |
- } | |
+ // Method init() accepts an alternate rootjQuery | |
+ // so migrate can support jQuery.sub (gh-2101) | |
+ root = root || rootjQuery; | |
- // Determine event propagation path in advance, per W3C events… | |
- // Bubble up to document, then to window; watch for a global o… | |
- eventPath = [[ elem, special.bindType || type ]]; | |
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( e… | |
+ // Handle HTML strings | |
+ if ( typeof selector === "string" ) { | |
+ if ( selector[ 0 ] === "<" && | |
+ selector[ selector.length - 1 ] === ">" && | |
+ selector.length >= 3 ) { | |
- bubbleType = special.delegateType || type; | |
- cur = rfocusMorph.test( bubbleType + type ) ? elem : e… | |
- old = null; | |
- for ( ; cur; cur = cur.parentNode ) { | |
- eventPath.push([ cur, bubbleType ]); | |
- old = cur; | |
- } | |
+ // Assume that strings that start and end with… | |
+ match = [ null, selector, null ]; | |
- // Only add window if we got to document (e.g., not pl… | |
- if ( old && old === elem.ownerDocument ) { | |
- eventPath.push([ old.defaultView || old.parent… | |
+ } else { | |
+ match = rquickExpr.exec( selector ); | |
} | |
- } | |
- // Fire handlers on the event path | |
- for ( i = 0; i < eventPath.length && !event.isPropagationStopp… | |
- | |
- cur = eventPath[i][0]; | |
- event.type = eventPath[i][1]; | |
- | |
- handle = ( jQuery._data( cur, "events" ) || {} )[ even… | |
- if ( handle ) { | |
- handle.apply( cur, data ); | |
- } | |
- // Note that this is a bare JS function and not a jQue… | |
- handle = ontype && cur[ ontype ]; | |
- if ( handle && jQuery.acceptData( cur ) && handle.appl… | |
- event.preventDefault(); | |
- } | |
- } | |
- event.type = type; | |
+ // Match html or make sure no context is specified for… | |
+ if ( match && ( match[ 1 ] || !context ) ) { | |
- // If nobody prevented the default action, do it now | |
- if ( !onlyHandlers && !event.isDefaultPrevented() ) { | |
+ // HANDLE: $(html) -> $(array) | |
+ if ( match[ 1 ] ) { | |
+ context = context instanceof jQuery ? … | |
+ | |
+ // Option to run scripts is true for b… | |
+ // Intentionally let the error be thro… | |
+ jQuery.merge( this, jQuery.parseHTML( | |
+ match[ 1 ], | |
+ context && context.nodeType ? … | |
+ true | |
+ ) ); | |
+ | |
+ // HANDLE: $(html, props) | |
+ if ( rsingleTag.test( match[ 1 ] ) && … | |
+ for ( match in context ) { | |
+ | |
+ // Properties of conte… | |
+ if ( jQuery.isFunction… | |
+ this[ match ](… | |
+ | |
+ // ...and otherwise se… | |
+ } else { | |
+ this.attr( mat… | |
+ } | |
+ } | |
+ } | |
- if ( (!special._default || special._default.apply( ele… | |
- !(type === "click" && jQuery.nodeName( elem, "… | |
+ return this; | |
- // Call a native DOM method on the target with… | |
- // Can't use an .isFunction() check here becau… | |
- // Don't do default actions on window, that's … | |
- // IE<9 dies on focus/blur to hidden element (… | |
- if ( ontype && elem[ type ] && ((type !== "foc… | |
+ // HANDLE: $(#id) | |
+ } else { | |
+ elem = document.getElementById( match[… | |
- // Don't re-trigger an onFOO event whe… | |
- old = elem[ ontype ]; | |
+ if ( elem ) { | |
- if ( old ) { | |
- elem[ ontype ] = null; | |
+ // Inject the element directly… | |
+ this[ 0 ] = elem; | |
+ this.length = 1; | |
} | |
+ return this; | |
+ } | |
- // Prevent re-triggering of the same e… | |
- jQuery.event.triggered = type; | |
- elem[ type ](); | |
- jQuery.event.triggered = undefined; | |
+ // HANDLE: $(expr, $(...)) | |
+ } else if ( !context || context.jquery ) { | |
+ return ( context || root ).find( selector ); | |
- if ( old ) { | |
- elem[ ontype ] = old; | |
- } | |
- } | |
+ // HANDLE: $(expr, context) | |
+ // (which is just equivalent to: $(context).find(expr) | |
+ } else { | |
+ return this.constructor( context ).find( selec… | |
} | |
- } | |
- return event.result; | |
- }, | |
+ // HANDLE: $(DOMElement) | |
+ } else if ( selector.nodeType ) { | |
+ this[ 0 ] = selector; | |
+ this.length = 1; | |
+ return this; | |
- dispatch: function( event ) { | |
+ // HANDLE: $(function) | |
+ // Shortcut for document ready | |
+ } else if ( jQuery.isFunction( selector ) ) { | |
+ return root.ready !== undefined ? | |
+ root.ready( selector ) : | |
- // Make a writable jQuery.Event from the native event object | |
- event = jQuery.event.fix( event || window.event ); | |
+ // Execute immediately if ready is not present | |
+ selector( jQuery ); | |
+ } | |
- var handlers = ( (jQuery._data( this, "events" ) || {} )[ even… | |
- delegateCount = handlers.delegateCount, | |
- args = [].slice.call( arguments, 0 ), | |
- run_all = !event.exclusive && !event.namespace, | |
- special = jQuery.event.special[ event.type ] || {}, | |
- handlerQueue = [], | |
- i, j, cur, jqcur, ret, selMatch, matched, matches, han… | |
+ return jQuery.makeArray( selector, this ); | |
+ }; | |
- // Use the fix-ed jQuery.Event rather than the (read-only) nat… | |
- args[0] = event; | |
- event.delegateTarget = this; | |
+// Give the init function the jQuery prototype for later instantiation | |
+init.prototype = jQuery.fn; | |
- // Call the preDispatch hook for the mapped type, and let it b… | |
- if ( special.preDispatch && special.preDispatch.call( this, ev… | |
- return; | |
- } | |
+// Initialize central reference | |
+rootjQuery = jQuery( document ); | |
- // Determine handlers that should run if there are delegated e… | |
- // Avoid non-left-click bubbling in Firefox (#3861) | |
- if ( delegateCount && !(event.button && event.type === "click"… | |
- // Pregenerate a single jQuery object for reuse with .… | |
- jqcur = jQuery(this); | |
- jqcur.context = this.ownerDocument || this; | |
+var rparentsprev = /^(?:parents|prev(?:Until|All))/, | |
- for ( cur = event.target; cur != this; cur = cur.paren… | |
+ // Methods guaranteed to produce a unique set when starting from a uni… | |
+ guaranteedUnique = { | |
+ children: true, | |
+ contents: true, | |
+ next: true, | |
+ prev: true | |
+ }; | |
- // Don't process events on disabled elements (… | |
- if ( cur.disabled !== true ) { | |
- selMatch = {}; | |
- matches = []; | |
- jqcur[0] = cur; | |
- for ( i = 0; i < delegateCount; i++ ) { | |
- handleObj = handlers[ i ]; | |
- sel = handleObj.selector; | |
+jQuery.fn.extend( { | |
+ has: function( target ) { | |
+ var targets = jQuery( target, this ), | |
+ l = targets.length; | |
- if ( selMatch[ sel ] === undef… | |
- selMatch[ sel ] = ( | |
- handleObj.quic… | |
- ); | |
- } | |
- if ( selMatch[ sel ] ) { | |
- matches.push( handleOb… | |
- } | |
- } | |
- if ( matches.length ) { | |
- handlerQueue.push({ elem: cur,… | |
- } | |
+ return this.filter( function() { | |
+ var i = 0; | |
+ for ( ; i < l; i++ ) { | |
+ if ( jQuery.contains( this, targets[ i ] ) ) { | |
+ return true; | |
} | |
} | |
- } | |
- | |
- // Add the remaining (directly-bound) handlers | |
- if ( handlers.length > delegateCount ) { | |
- handlerQueue.push({ elem: this, matches: handlers.slic… | |
- } | |
- | |
- // Run delegates first; they may want to stop propagation bene… | |
- for ( i = 0; i < handlerQueue.length && !event.isPropagationSt… | |
- matched = handlerQueue[ i ]; | |
- event.currentTarget = matched.elem; | |
+ } ); | |
+ }, | |
- for ( j = 0; j < matched.matches.length && !event.isIm… | |
- handleObj = matched.matches[ j ]; | |
+ closest: function( selectors, context ) { | |
+ var cur, | |
+ i = 0, | |
+ l = this.length, | |
+ matched = [], | |
+ targets = typeof selectors !== "string" && jQuery( sel… | |
- // Triggered event must either 1) be non-exclu… | |
- // 2) have namespace(s) a subset or equal to t… | |
- if ( run_all || (!event.namespace && !handleOb… | |
+ // Positional selectors never match, since there's no _selecti… | |
+ if ( !rneedsContext.test( selectors ) ) { | |
+ for ( ; i < l; i++ ) { | |
+ for ( cur = this[ i ]; cur && cur !== context;… | |
- event.data = handleObj.data; | |
- event.handleObj = handleObj; | |
+ // Always skip document fragments | |
+ if ( cur.nodeType < 11 && ( targets ? | |
+ targets.index( cur ) > -1 : | |
- ret = ( (jQuery.event.special[ handleO… | |
- .apply( matched.elem, … | |
+ // Don't pass non-elements to … | |
+ cur.nodeType === 1 && | |
+ jQuery.find.matchesSel… | |
- if ( ret !== undefined ) { | |
- event.result = ret; | |
- if ( ret === false ) { | |
- event.preventDefault(); | |
- event.stopPropagation(… | |
- } | |
+ matched.push( cur ); | |
+ break; | |
} | |
} | |
} | |
} | |
- // Call the postDispatch hook for the mapped type | |
- if ( special.postDispatch ) { | |
- special.postDispatch.call( this, event ); | |
- } | |
- | |
- return event.result; | |
+ return this.pushStack( matched.length > 1 ? jQuery.uniqueSort(… | |
}, | |
- // Includes some event props shared by KeyEvent and MouseEvent | |
- // *** attrChange attrName relatedNode srcElement are not normalized,… | |
- props: "attrChange attrName relatedNode srcElement altKey bubbles canc… | |
+ // Determine the position of an element within the set | |
+ index: function( elem ) { | |
- fixHooks: {}, | |
+ // No argument, return index in parent | |
+ if ( !elem ) { | |
+ return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.fi… | |
+ } | |
- keyHooks: { | |
- props: "char charCode key keyCode".split(" "), | |
- filter: function( event, original ) { | |
+ // Index in selector | |
+ if ( typeof elem === "string" ) { | |
+ return indexOf.call( jQuery( elem ), this[ 0 ] ); | |
+ } | |
- // Add which for key events | |
- if ( event.which == null ) { | |
- event.which = original.charCode != null ? orig… | |
- } | |
+ // Locate the position of the desired element | |
+ return indexOf.call( this, | |
- return event; | |
- } | |
+ // If it receives a jQuery object, the first element i… | |
+ elem.jquery ? elem[ 0 ] : elem | |
+ ); | |
}, | |
- mouseHooks: { | |
- props: "button buttons clientX clientY fromElement offsetX off… | |
- filter: function( event, original ) { | |
- var eventDoc, doc, body, | |
- button = original.button, | |
- fromElement = original.fromElement; | |
+ add: function( selector, context ) { | |
+ return this.pushStack( | |
+ jQuery.uniqueSort( | |
+ jQuery.merge( this.get(), jQuery( selector, co… | |
+ ) | |
+ ); | |
+ }, | |
- // Calculate pageX/Y if missing and clientX/Y available | |
- if ( event.pageX == null && original.clientX != null )… | |
- eventDoc = event.target.ownerDocument || docum… | |
- doc = eventDoc.documentElement; | |
- body = eventDoc.body; | |
- | |
- event.pageX = original.clientX + ( doc && doc.… | |
- event.pageY = original.clientY + ( doc && doc.… | |
- } | |
- | |
- // Add relatedTarget, if necessary | |
- if ( !event.relatedTarget && fromElement ) { | |
- event.relatedTarget = fromElement === event.ta… | |
- } | |
+ addBack: function( selector ) { | |
+ return this.add( selector == null ? | |
+ this.prevObject : this.prevObject.filter( selector ) | |
+ ); | |
+ } | |
+} ); | |
- // Add which for click: 1 === left; 2 === middle; 3 ==… | |
- // Note: button is not normalized, so don't use it | |
- if ( !event.which && button !== undefined ) { | |
- event.which = ( button & 1 ? 1 : ( button & 2 … | |
- } | |
+function sibling( cur, dir ) { | |
+ while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} | |
+ return cur; | |
+} | |
- return event; | |
- } | |
+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 elem.contentDocument || jQuery.merge( [], elem.childNod… | |
+ } | |
+}, function( name, fn ) { | |
+ jQuery.fn[ name ] = function( until, selector ) { | |
+ var matched = jQuery.map( this, fn, until ); | |
- fix: function( event ) { | |
- if ( event[ jQuery.expando ] ) { | |
- return event; | |
- } | |
- | |
- // Create a writable copy of the event object and normalize so… | |
- var i, prop, | |
- originalEvent = event, | |
- fixHook = jQuery.event.fixHooks[ event.type ] || {}, | |
- copy = fixHook.props ? this.props.concat( fixHook.prop… | |
- | |
- 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 & Safari… | |
- 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; | |
+ if ( name.slice( -5 ) !== "Until" ) { | |
+ selector = until; | |
} | |
- // For mouse/key events; add metaKey if it's not there (#3368,… | |
- if ( event.metaKey === undefined ) { | |
- event.metaKey = event.ctrlKey; | |
+ if ( selector && typeof selector === "string" ) { | |
+ matched = jQuery.filter( selector, matched ); | |
} | |
- return fixHook.filter? fixHook.filter( event, originalEvent ) … | |
- }, | |
- | |
- special: { | |
- ready: { | |
- // Make sure the ready event is setup | |
- setup: jQuery.bindReady | |
- }, | |
- | |
- load: { | |
- // Prevent triggered image.load events from bubbling t… | |
- noBubble: true | |
- }, | |
- | |
- focus: { | |
- delegateType: "focusin" | |
- }, | |
- blur: { | |
- delegateType: "focusout" | |
- }, | |
- | |
- beforeunload: { | |
- setup: function( data, namespaces, eventHandle ) { | |
- // We only want to do this special case on win… | |
- if ( jQuery.isWindow( this ) ) { | |
- this.onbeforeunload = eventHandle; | |
- } | |
- }, | |
+ if ( this.length > 1 ) { | |
- teardown: function( namespaces, eventHandle ) { | |
- if ( this.onbeforeunload === eventHandle ) { | |
- this.onbeforeunload = null; | |
- } | |
+ // Remove duplicates | |
+ if ( !guaranteedUnique[ name ] ) { | |
+ jQuery.uniqueSort( matched ); | |
} | |
- } | |
- }, | |
- 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… | |
- // simulated event prevents default then we do the same on the… | |
- var e = jQuery.extend( | |
- new jQuery.Event(), | |
- event, | |
- { type: type, | |
- isSimulated: true, | |
- originalEvent: {} | |
+ // Reverse order for parents* and prev-derivatives | |
+ if ( rparentsprev.test( name ) ) { | |
+ matched.reverse(); | |
} | |
- ); | |
- 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 remove… | |
-// 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 ) { | |
- if ( elem.detachEvent ) { | |
- elem.detachEvent( "on" + type, handle ); | |
- } | |
+ return this.pushStack( matched ); | |
}; | |
+} ); | |
+var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); | |
-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 pre… | |
- // by a handler lower down the tree; reflect the correct value. | |
- this.isDefaultPrevented = ( src.defaultPrevented || src.return… | |
- src.getPreventDefault && src.getPreventDefault() ) ? r… | |
- // Event type | |
- } else { | |
- this.type = src; | |
- } | |
- // Put explicitly provided properties onto the event object | |
- if ( props ) { | |
- jQuery.extend( this, props ); | |
- } | |
+// 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 timestamp if incoming event doesn't have one | |
- this.timeStamp = src && src.timeStamp || jQuery.now(); | |
+/* | |
+ * Create a callback list using the following parameters: | |
+ * | |
+ * options: an optional list of space-separated options that will chang… | |
+ * the callback list behaves or a more traditional opti… | |
+ * | |
+ * 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 … | |
+ * | |
+ * memory: will keep track of previous values an… | |
+ * after the list has been fired right … | |
+ * values (like a Deferred) | |
+ * | |
+ * unique: will ensure a callback can only be ad… | |
+ * | |
+ * stopOnFalse: interrupt callings when a callback returns false | |
+ * | |
+ */ | |
+jQuery.Callbacks = function( options ) { | |
- // Mark it as fixed | |
- this[ jQuery.expando ] = true; | |
-}; | |
+ // Convert options from String-formatted to Object-formatted if needed | |
+ // (we check in cache first) | |
+ options = typeof options === "string" ? | |
+ createOptions( options ) : | |
+ jQuery.extend( {}, options ); | |
-function returnFalse() { | |
- return false; | |
-} | |
-function returnTrue() { | |
- return true; | |
-} | |
+ var // Flag to know if list is currently firing | |
+ firing, | |
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Languag… | |
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-bindin… | |
-jQuery.Event.prototype = { | |
- preventDefault: function() { | |
- this.isDefaultPrevented = returnTrue; | |
+ // Last fire value for non-forgettable lists | |
+ memory, | |
- var e = this.originalEvent; | |
- if ( !e ) { | |
- return; | |
- } | |
+ // Flag to know if list was already fired | |
+ fired, | |
- // if preventDefault exists run it on the original event | |
- if ( e.preventDefault ) { | |
- e.preventDefault(); | |
+ // Flag to prevent firing | |
+ locked, | |
- // otherwise set the returnValue property of the original even… | |
- } else { | |
- e.returnValue = false; | |
- } | |
- }, | |
- stopPropagation: function() { | |
- this.isPropagationStopped = returnTrue; | |
+ // Actual callback list | |
+ list = [], | |
- 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 eve… | |
- e.cancelBubble = true; | |
- }, | |
- stopImmediatePropagation: function() { | |
- this.isImmediatePropagationStopped = returnTrue; | |
- this.stopPropagation(); | |
- }, | |
- isDefaultPrevented: returnFalse, | |
- isPropagationStopped: returnFalse, | |
- isImmediatePropagationStopped: returnFalse | |
-}; | |
+ // Queue of execution data for repeatable lists | |
+ queue = [], | |
-// 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, | |
+ // Index of currently firing callback (modified by add/remove … | |
+ firingIndex = -1, | |
- handle: function( event ) { | |
- var target = this, | |
- related = event.relatedTarget, | |
- handleObj = event.handleObj, | |
- selector = handleObj.selector, | |
- ret; | |
+ // Fire callbacks | |
+ fire = function() { | |
- // For mousenter/leave call the handler if related is … | |
- // NB: No relatedTarget if the mouse left/entered the … | |
- if ( !related || (related !== target && !jQuery.contai… | |
- event.type = handleObj.origType; | |
- ret = handleObj.handler.apply( this, arguments… | |
- event.type = fix; | |
- } | |
- return ret; | |
- } | |
- }; | |
-}); | |
+ // Enforce single-firing | |
+ locked = options.once; | |
-// IE submit delegation | |
-if ( !jQuery.support.submitBubbles ) { | |
+ // 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 ) { | |
- jQuery.event.special.submit = { | |
- setup: function() { | |
- // Only need this for delegated form submit events | |
- if ( jQuery.nodeName( this, "form" ) ) { | |
- return false; | |
- } | |
+ // Run callback and check for early te… | |
+ if ( list[ firingIndex ].apply( memory… | |
+ options.stopOnFalse ) { | |
- // Lazy-add a submit handler when a descendant form ma… | |
- jQuery.event.add( this, "click._submit keypress._submi… | |
- // Node name check avoids a VML-related crash … | |
- var elem = e.target, | |
- form = jQuery.nodeName( elem, "input" … | |
- if ( form && !form._submit_attached ) { | |
- jQuery.event.add( form, "submit._submi… | |
- event._submit_bubble = true; | |
- }); | |
- form._submit_attached = true; | |
- } | |
- }); | |
- // return undefined since we don't need an event liste… | |
- }, | |
- | |
- postDispatch: function( event ) { | |
- // If form was submitted by the user, bubble the event… | |
- if ( event._submit_bubble ) { | |
- delete event._submit_bubble; | |
- if ( this.parentNode && !event.isTrigger ) { | |
- jQuery.event.simulate( "submit", this.… | |
+ // Jump to end and forget the … | |
+ firingIndex = list.length; | |
+ memory = false; | |
+ } | |
} | |
} | |
- }, | |
- teardown: function() { | |
- // Only need this for delegated form submit events | |
- if ( jQuery.nodeName( this, "form" ) ) { | |
- return false; | |
+ // Forget the data if we're done with it | |
+ if ( !options.memory ) { | |
+ memory = false; | |
} | |
- // Remove delegated handlers; cleanData eventually rea… | |
- jQuery.event.remove( this, "._submit" ); | |
- } | |
- }; | |
-} | |
- | |
-// IE change delegation and checkbox/radio fix | |
-if ( !jQuery.support.changeBubbles ) { | |
+ firing = false; | |
- jQuery.event.special.change = { | |
+ // Clean up if we're done firing for good | |
+ if ( locked ) { | |
- setup: function() { | |
+ // Keep an empty list if we have data for futu… | |
+ if ( memory ) { | |
+ list = []; | |
- if ( rformElems.test( this.nodeName ) ) { | |
- // IE doesn't fire change on a check/radio unt… | |
- // after a propertychange. Eat the blur-change… | |
- // This still fires onchange a second time for… | |
- if ( this.type === "checkbox" || this.type ===… | |
- jQuery.event.add( this, "propertychang… | |
- if ( event.originalEvent.prope… | |
- this._just_changed = t… | |
- } | |
- }); | |
- jQuery.event.add( this, "click._change… | |
- if ( this._just_changed && !ev… | |
- this._just_changed = f… | |
- jQuery.event.simulate(… | |
- } | |
- }); | |
+ // Otherwise, this object is spent | |
+ } else { | |
+ list = ""; | |
} | |
- return false; | |
} | |
- // Delegated event; lazy-add a change handler on desce… | |
- jQuery.event.add( this, "beforeactivate._change", func… | |
- var elem = e.target; | |
- | |
- if ( rformElems.test( elem.nodeName ) && !elem… | |
- jQuery.event.add( elem, "change._chang… | |
- if ( this.parentNode && !event… | |
- jQuery.event.simulate(… | |
- } | |
- }); | |
- elem._change_attached = true; | |
- } | |
- }); | |
}, | |
- handle: function( event ) { | |
- var elem = event.target; | |
- | |
- // Swallow native change events from checkbox/radio, w… | |
- if ( this !== elem || event.isSimulated || event.isTri… | |
- return event.handleObj.handler.apply( this, ar… | |
- } | |
- }, | |
+ // Actual Callbacks object | |
+ self = { | |
- teardown: function() { | |
- jQuery.event.remove( this, "._change" ); | |
+ // Add a callback or a collection of callbacks to the … | |
+ add: function() { | |
+ if ( list ) { | |
- return rformElems.test( this.nodeName ); | |
- } | |
- }; | |
-} | |
+ // If we have memory from a past run, … | |
+ if ( memory && !firing ) { | |
+ firingIndex = list.length - 1; | |
+ queue.push( memory ); | |
+ } | |
-// Create "bubbling" focus and blur events | |
-if ( !jQuery.support.focusinBubbles ) { | |
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fi… | |
+ ( function add( args ) { | |
+ jQuery.each( args, function( _… | |
+ if ( jQuery.isFunction… | |
+ if ( !options.… | |
+ list.p… | |
+ } | |
+ } else if ( arg && arg… | |
- // Attach a single capturing handler while someone wants focus… | |
- var attaches = 0, | |
- handler = function( event ) { | |
- jQuery.event.simulate( fix, event.target, jQue… | |
- }; | |
+ // Inspect rec… | |
+ add( arg ); | |
+ } | |
+ } ); | |
+ } )( arguments ); | |
- jQuery.event.special[ fix ] = { | |
- setup: function() { | |
- if ( attaches++ === 0 ) { | |
- document.addEventListener( orig, handl… | |
+ if ( memory && !firing ) { | |
+ fire(); | |
+ } | |
} | |
+ return this; | |
}, | |
- teardown: function() { | |
- if ( --attaches === 0 ) { | |
- document.removeEventListener( orig, ha… | |
- } | |
- } | |
- }; | |
- }); | |
-} | |
-jQuery.fn.extend({ | |
+ // Remove a callback from the list | |
+ remove: function() { | |
+ jQuery.each( arguments, function( _, arg ) { | |
+ var index; | |
+ while ( ( index = jQuery.inArray( arg,… | |
+ list.splice( index, 1 ); | |
+ | |
+ // Handle firing indexes | |
+ if ( index <= firingIndex ) { | |
+ firingIndex--; | |
+ } | |
+ } | |
+ } ); | |
+ return this; | |
+ }, | |
- on: function( types, selector, data, fn, /*INTERNAL*/ one ) { | |
- var origFn, type; | |
+ // Check if a given callback is in the list. | |
+ // If no argument is given, return whether or not list… | |
+ has: function( fn ) { | |
+ return fn ? | |
+ jQuery.inArray( fn, list ) > -1 : | |
+ list.length > 0; | |
+ }, | |
- // Types can be a map of types/handlers | |
- if ( typeof types === "object" ) { | |
- // ( types-Object, selector, data ) | |
- if ( typeof selector !== "string" ) { // && selector !… | |
- // ( types-Object, data ) | |
- data = data || selector; | |
- selector = undefined; | |
- } | |
- for ( type in types ) { | |
- this.on( type, selector, data, types[ type ], … | |
- } | |
- return this; | |
- } | |
+ // Remove all callbacks from the list | |
+ empty: function() { | |
+ if ( list ) { | |
+ list = []; | |
+ } | |
+ 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; | |
- } | |
+ // 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; | |
+ }, | |
- if ( one === 1 ) { | |
- origFn = fn; | |
- fn = function( event ) { | |
- // Can use an empty set, since event contains … | |
- 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 ) { | |
- if ( types && types.preventDefault && types.handleObj ) { | |
- // ( event ) dispatched jQuery.Event | |
- var handleObj = types.handleObj; | |
- jQuery( types.delegateTarget ).off( | |
- handleObj.namespace ? handleObj.origType + "."… | |
- handleObj.selector, | |
- handleObj.handler | |
- ); | |
- return this; | |
- } | |
- if ( typeof types === "object" ) { | |
- // ( types-object [, selector] ) | |
- for ( var 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 ); | |
- }); | |
- }, | |
+ // Disable .fire | |
+ // Also disable .add unless we have memory (since it w… | |
+ // Abort any pending executions | |
+ lock: function() { | |
+ locked = queue = []; | |
+ if ( !memory && !firing ) { | |
+ list = memory = ""; | |
+ } | |
+ return this; | |
+ }, | |
+ locked: function() { | |
+ return !!locked; | |
+ }, | |
- bind: function( types, data, fn ) { | |
- return this.on( types, null, data, fn ); | |
- }, | |
- unbind: function( types, fn ) { | |
- return this.off( types, null, fn ); | |
- }, | |
+ // Call all callbacks with the given context and argum… | |
+ fireWith: function( context, args ) { | |
+ if ( !locked ) { | |
+ args = args || []; | |
+ args = [ context, args.slice ? args.sl… | |
+ queue.push( args ); | |
+ if ( !firing ) { | |
+ fire(); | |
+ } | |
+ } | |
+ return this; | |
+ }, | |
- 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; | |
- }, | |
+ // Call all the callbacks with the given arguments | |
+ fire: function() { | |
+ self.fireWith( this, arguments ); | |
+ 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, "**" ) : thi… | |
- }, | |
+ // To know if the callbacks have already been called a… | |
+ fired: function() { | |
+ return !!fired; | |
+ } | |
+ }; | |
- 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… | |
- } | |
- }, | |
+ return self; | |
+}; | |
- 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, "lastTo… | |
- jQuery._data( this, "lastToggle" + fn.guid, la… | |
- // Make sure that clicks stop | |
- event.preventDefault(); | |
+function Identity( v ) { | |
+ return v; | |
+} | |
+function Thrower( ex ) { | |
+ throw ex; | |
+} | |
- // and execute the function | |
- return args[ lastToggle ].apply( this, argumen… | |
- }; | |
+function adoptValue( value, resolve, reject ) { | |
+ var method; | |
- // link all the functions, so any of them can unbind this clic… | |
- toggler.guid = guid; | |
- while ( i < args.length ) { | |
- args[ i++ ].guid = guid; | |
- } | |
+ try { | |
- return this.click( toggler ); | |
- }, | |
+ // Check for promise aspect first to privilege synchronous beh… | |
+ if ( value && jQuery.isFunction( ( method = value.promise ) ) … | |
+ method.call( value ).done( resolve ).fail( reject ); | |
- hover: function( fnOver, fnOut ) { | |
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
- } | |
-}); | |
+ // Other thenables | |
+ } else if ( value && jQuery.isFunction( ( method = value.then … | |
+ method.call( value, resolve, reject ); | |
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dbl… | |
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave … | |
- "change select submit keydown keypress keyup error contextmenu").split… | |
+ // Other non-thenables | |
+ } else { | |
- // Handle event binding | |
- jQuery.fn[ name ] = function( data, fn ) { | |
- if ( fn == null ) { | |
- fn = data; | |
- data = null; | |
+ // Support: Android 4.0 only | |
+ // Strict mode functions invoked without .call/.apply … | |
+ resolve.call( undefined, value ); | |
} | |
- return arguments.length > 0 ? | |
- this.on( name, null, data, fn ) : | |
- this.trigger( name ); | |
- }; | |
- | |
- if ( jQuery.attrFn ) { | |
- jQuery.attrFn[ name ] = true; | |
- } | |
- | |
- if ( rkeyEvent.test( name ) ) { | |
- jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; | |
- } | |
+ // For Promises/A+, convert exceptions into rejections | |
+ // Since jQuery.when doesn't unwrap thenables, we can skip the extra c… | |
+ // Deferred#then to conditionally suppress rejection. | |
+ } catch ( value ) { | |
- if ( rmouseEvent.test( name ) ) { | |
- jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; | |
+ // Support: Android 4.0 only | |
+ // Strict mode functions invoked without .call/.apply get glob… | |
+ reject.call( undefined, value ); | |
} | |
-}); | |
- | |
+} | |
+jQuery.extend( { | |
-/*! | |
- * Sizzle CSS Selector Engine | |
- * Copyright 2011, The Dojo Foundation | |
- * Released under the MIT, BSD, and GPL Licenses. | |
- * More information: http://sizzlejs.com/ | |
- */ | |
-(function(){ | |
+ Deferred: function( func ) { | |
+ var tuples = [ | |
+ | |
+ // action, add listener, callbacks, | |
+ // ... .then handlers, argument index, [final … | |
+ [ "notify", "progress", jQuery.Callbacks( "mem… | |
+ jQuery.Callbacks( "memory" ), 2 ], | |
+ [ "resolve", "done", jQuery.Callbacks( "once m… | |
+ jQuery.Callbacks( "once memory" ), 0, … | |
+ [ "reject", "fail", jQuery.Callbacks( "once me… | |
+ jQuery.Callbacks( "once memory" ), 1, … | |
+ ], | |
+ state = "pending", | |
+ promise = { | |
+ state: function() { | |
+ return state; | |
+ }, | |
+ always: function() { | |
+ deferred.done( arguments ).fail( argum… | |
+ return this; | |
+ }, | |
+ "catch": function( fn ) { | |
+ return promise.then( null, fn ); | |
+ }, | |
-var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]… | |
- expando = "sizcache" + (Math.random() + '').replace('.', ''), | |
- done = 0, | |
- toString = Object.prototype.toString, | |
- hasDuplicate = false, | |
- baseHasDuplicate = true, | |
- rBackslash = /\\/g, | |
- rReturn = /\r\n/g, | |
- rNonWord = /\W/; | |
- | |
-// Here we check if the JavaScript engine is using some sort of | |
-// optimization where it does not always call our comparision | |
-// function. If that is the case, discard the hasDuplicate value. | |
-// Thus far that includes Google Chrome. | |
-[0, 0].sort(function() { | |
- baseHasDuplicate = false; | |
- return 0; | |
-}); | |
+ // Keep pipe for back-compat | |
+ pipe: function( /* fnDone, fnFail, fnProgress … | |
+ var fns = arguments; | |
+ | |
+ return jQuery.Deferred( function( newD… | |
+ jQuery.each( tuples, function(… | |
+ | |
+ // Map tuples (progres… | |
+ var fn = jQuery.isFunc… | |
+ | |
+ // deferred.progress(f… | |
+ // deferred.done(funct… | |
+ // deferred.fail(funct… | |
+ deferred[ tuple[ 1 ] ]… | |
+ var returned =… | |
+ if ( returned … | |
+ return… | |
+ … | |
+ … | |
+ … | |
+ } else { | |
+ newDef… | |
+ … | |
+ … | |
+ ); | |
+ } | |
+ } ); | |
+ } ); | |
+ fns = null; | |
+ } ).promise(); | |
+ }, | |
+ then: function( onFulfilled, onRejected, onPro… | |
+ var maxDepth = 0; | |
+ function resolve( depth, deferred, han… | |
+ return function() { | |
+ var that = this, | |
+ args = argumen… | |
+ mightThrow = f… | |
+ var re… | |
+ | |
+ // Sup… | |
+ // htt… | |
+ // Ign… | |
+ if ( d… | |
+ … | |
+ } | |
-var Sizzle = function( selector, context, results, seed ) { | |
- results = results || []; | |
- context = context || document; | |
+ return… | |
- var origContext = context; | |
+ // Sup… | |
+ // htt… | |
+ if ( r… | |
+ … | |
+ } | |
- if ( context.nodeType !== 1 && context.nodeType !== 9 ) { | |
- return []; | |
- } | |
+ // Sup… | |
+ // htt… | |
+ // htt… | |
+ // Ret… | |
+ then =… | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ | |
+ // Han… | |
+ if ( j… | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
- if ( !selector || typeof selector !== "string" ) { | |
- return results; | |
- } | |
+ // Han… | |
+ } else… | |
- var m, set, checkSet, extra, ret, cur, pop, i, | |
- prune = true, | |
- contextXML = Sizzle.isXML( context ), | |
- parts = [], | |
- soFar = selector; | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
- // Reset the position of the chunker regexp (start from head) | |
- do { | |
- chunker.exec( "" ); | |
- m = chunker.exec( soFar ); | |
+ … | |
+ … | |
+ … | |
+ } | |
+ }, | |
+ | |
+ // Only normal… | |
+ process = spec… | |
+ mightT… | |
+ functi… | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ … | |
+ | |
+ … | |
+ … | |
+ … | |
+ }; | |
+ | |
+ // Support: Promises/A… | |
+ // https://promisesapl… | |
+ // Re-resolve promises… | |
+ // subsequent errors | |
+ if ( depth ) { | |
+ process(); | |
+ } else { | |
- if ( m ) { | |
- soFar = m[3]; | |
+ // Call an opt… | |
+ // since it's … | |
+ if ( jQuery.De… | |
+ proces… | |
+ } | |
+ window.setTime… | |
+ } | |
+ }; | |
+ } | |
- parts.push( m[1] ); | |
+ return jQuery.Deferred( function( newD… | |
+ | |
+ // progress_handlers.add( ... ) | |
+ tuples[ 0 ][ 3 ].add( | |
+ resolve( | |
+ 0, | |
+ newDefer, | |
+ jQuery.isFunct… | |
+ onProg… | |
+ Identi… | |
+ newDefer.notif… | |
+ ) | |
+ ); | |
+ | |
+ // fulfilled_handlers.add( ...… | |
+ tuples[ 1 ][ 3 ].add( | |
+ resolve( | |
+ 0, | |
+ newDefer, | |
+ jQuery.isFunct… | |
+ onFulf… | |
+ Identi… | |
+ ) | |
+ ); | |
+ | |
+ // rejected_handlers.add( ... ) | |
+ tuples[ 2 ][ 3 ].add( | |
+ resolve( | |
+ 0, | |
+ newDefer, | |
+ jQuery.isFunct… | |
+ onReje… | |
+ Thrower | |
+ ) | |
+ ); | |
+ } ).promise(); | |
+ }, | |
- if ( m[2] ) { | |
- extra = m[3]; | |
- break; | |
+ // Get a promise for this deferred | |
+ // If obj is provided, the promise aspect is a… | |
+ promise: function( obj ) { | |
+ return obj != null ? jQuery.extend( ob… | |
+ } | |
+ }, | |
+ 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., f… | |
+ // state = "rejected" | |
+ state = stateString; | |
+ }, | |
+ | |
+ // rejected_callbacks.disable | |
+ // fulfilled_callbacks.disable | |
+ tuples[ 3 - i ][ 2 ].disable, | |
+ | |
+ // progress_callbacks.lock | |
+ tuples[ 0 ][ 2 ].lock | |
+ ); | |
} | |
- } | |
- } while ( m ); | |
- if ( parts.length > 1 && origPOS.exec( selector ) ) { | |
+ // progress_handlers.fire | |
+ // fulfilled_handlers.fire | |
+ // rejected_handlers.fire | |
+ list.add( tuple[ 3 ].fire ); | |
- if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { | |
- set = posProcess( parts[0] + parts[1], context, seed ); | |
- | |
- } else { | |
- set = Expr.relative[ parts[0] ] ? | |
- [ context ] : | |
- Sizzle( parts.shift(), context ); | |
+ // deferred.notify = function() { deferred.notifyWith(… | |
+ // deferred.resolve = function() { deferred.resolveWit… | |
+ // deferred.reject = function() { deferred.rejectWith(… | |
+ deferred[ tuple[ 0 ] ] = function() { | |
+ deferred[ tuple[ 0 ] + "With" ]( this === defe… | |
+ return this; | |
+ }; | |
- while ( parts.length ) { | |
- selector = parts.shift(); | |
+ // deferred.notifyWith = list.fireWith | |
+ // deferred.resolveWith = list.fireWith | |
+ // deferred.rejectWith = list.fireWith | |
+ deferred[ tuple[ 0 ] + "With" ] = list.fireWith; | |
+ } ); | |
- if ( Expr.relative[ selector ] ) { | |
- selector += parts.shift(); | |
- } | |
+ // Make the deferred a promise | |
+ promise.promise( deferred ); | |
- set = posProcess( selector, set, seed ); | |
- } | |
+ // Call given func if any | |
+ if ( func ) { | |
+ func.call( deferred, deferred ); | |
} | |
- } else { | |
- // Take a shortcut and set the context if the root selector is… | |
- // (but not if it'll be faster if the inner selector is an ID) | |
- if ( !seed && parts.length > 1 && context.nodeType === 9 && !c… | |
- Expr.match.ID.test(parts[0]) && !Expr.match.ID… | |
+ // All done! | |
+ return deferred; | |
+ }, | |
- ret = Sizzle.find( parts.shift(), context, contextXML … | |
- context = ret.expr ? | |
- Sizzle.filter( ret.expr, ret.set )[0] : | |
- ret.set[0]; | |
- } | |
+ // Deferred helper | |
+ when: function( singleValue ) { | |
+ var | |
- if ( context ) { | |
- ret = seed ? | |
- { expr: parts.pop(), set: makeArray(seed) } : | |
- Sizzle.find( parts.pop(), parts.length === 1 &… | |
+ // count of uncompleted subordinates | |
+ remaining = arguments.length, | |
- set = ret.expr ? | |
- Sizzle.filter( ret.expr, ret.set ) : | |
- ret.set; | |
+ // count of unprocessed arguments | |
+ i = remaining, | |
- if ( parts.length > 0 ) { | |
- checkSet = makeArray( set ); | |
+ // subordinate fulfillment data | |
+ resolveContexts = Array( i ), | |
+ resolveValues = slice.call( arguments ), | |
- } else { | |
- prune = false; | |
- } | |
+ // the master Deferred | |
+ master = jQuery.Deferred(), | |
- while ( parts.length ) { | |
- cur = parts.pop(); | |
- pop = cur; | |
+ // subordinate callback factory | |
+ updateFunc = function( i ) { | |
+ return function( value ) { | |
+ resolveContexts[ i ] = this; | |
+ resolveValues[ i ] = arguments.length … | |
+ if ( !( --remaining ) ) { | |
+ master.resolveWith( resolveCon… | |
+ } | |
+ }; | |
+ }; | |
- if ( !Expr.relative[ cur ] ) { | |
- cur = ""; | |
- } else { | |
- pop = parts.pop(); | |
- } | |
+ // Single- and empty arguments are adopted like Promise.resolve | |
+ if ( remaining <= 1 ) { | |
+ adoptValue( singleValue, master.done( updateFunc( i ) … | |
- if ( pop == null ) { | |
- pop = context; | |
- } | |
+ // Use .then() to unwrap secondary thenables (cf. gh-3… | |
+ if ( master.state() === "pending" || | |
+ jQuery.isFunction( resolveValues[ i ] && resol… | |
- Expr.relative[ cur ]( checkSet, pop, contextXM… | |
+ return master.then(); | |
} | |
- | |
- } else { | |
- checkSet = parts = []; | |
} | |
- } | |
- if ( !checkSet ) { | |
- checkSet = set; | |
- } | |
+ // Multiple arguments are aggregated like Promise.all array el… | |
+ while ( i-- ) { | |
+ adoptValue( resolveValues[ i ], updateFunc( i ), maste… | |
+ } | |
- if ( !checkSet ) { | |
- Sizzle.error( cur || selector ); | |
+ return master.promise(); | |
} | |
+} ); | |
- if ( toString.call(checkSet) === "[object Array]" ) { | |
- if ( !prune ) { | |
- results.push.apply( results, checkSet ); | |
- } else if ( context && context.nodeType === 1 ) { | |
- for ( i = 0; checkSet[i] != null; i++ ) { | |
- if ( checkSet[i] && (checkSet[i] === true || c… | |
- results.push( set[i] ); | |
- } | |
- } | |
+// 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$/; | |
- } else { | |
- for ( i = 0; checkSet[i] != null; i++ ) { | |
- if ( checkSet[i] && checkSet[i].nodeType === 1… | |
- results.push( set[i] ); | |
- } | |
- } | |
- } | |
+jQuery.Deferred.exceptionHook = function( error, stack ) { | |
- } else { | |
- makeArray( checkSet, results ); | |
+ // 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.tes… | |
+ window.console.warn( "jQuery.Deferred exception: " + error.mes… | |
} | |
+}; | |
- if ( extra ) { | |
- Sizzle( extra, origContext, results, seed ); | |
- Sizzle.uniqueSort( results ); | |
- } | |
- return results; | |
+ | |
+ | |
+jQuery.readyException = function( error ) { | |
+ window.setTimeout( function() { | |
+ throw error; | |
+ } ); | |
}; | |
-Sizzle.uniqueSort = function( results ) { | |
- if ( sortOrder ) { | |
- hasDuplicate = baseHasDuplicate; | |
- results.sort( sortOrder ); | |
- if ( hasDuplicate ) { | |
- for ( var i = 1; i < results.length; i++ ) { | |
- if ( results[i] === results[ i - 1 ] ) { | |
- results.splice( i--, 1 ); | |
- } | |
- } | |
- } | |
- } | |
- return results; | |
-}; | |
-Sizzle.matches = function( expr, set ) { | |
- return Sizzle( expr, null, null, set ); | |
-}; | |
+// The deferred used on DOM ready | |
+var readyList = jQuery.Deferred(); | |
-Sizzle.matchesSelector = function( node, expr ) { | |
- return Sizzle( expr, null, null, [node] ).length > 0; | |
-}; | |
+jQuery.fn.ready = function( fn ) { | |
-Sizzle.find = function( expr, context, isXML ) { | |
- var set, i, len, match, type, left; | |
+ readyList | |
+ .then( fn ) | |
- if ( !expr ) { | |
- return []; | |
- } | |
+ // 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 ); | |
+ } ); | |
- for ( i = 0, len = Expr.order.length; i < len; i++ ) { | |
- type = Expr.order[i]; | |
+ return this; | |
+}; | |
- if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { | |
- left = match[1]; | |
- match.splice( 1, 1 ); | |
+jQuery.extend( { | |
- if ( left.substr( left.length - 1 ) !== "\\" ) { | |
- match[1] = (match[1] || "").replace( rBackslas… | |
- set = Expr.find[ type ]( match, context, isXML… | |
+ // Is the DOM ready to be used? Set to true once it occurs. | |
+ isReady: false, | |
- if ( set != null ) { | |
- expr = expr.replace( Expr.match[ type … | |
- break; | |
- } | |
- } | |
+ // 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 ); | |
} | |
- } | |
+ }, | |
- if ( !set ) { | |
- set = typeof context.getElementsByTagName !== "undefined" ? | |
- context.getElementsByTagName( "*" ) : | |
- []; | |
- } | |
+ // Handle when the DOM is ready | |
+ ready: function( wait ) { | |
- return { set: set, expr: expr }; | |
-}; | |
+ // Abort if there are pending holds or we're already ready | |
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { | |
+ return; | |
+ } | |
-Sizzle.filter = function( expr, set, inplace, not ) { | |
- var match, anyFound, | |
- type, found, item, filter, left, | |
- i, pass, | |
- old = expr, | |
- result = [], | |
- curLoop = set, | |
- isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); | |
+ // Remember that the DOM is ready | |
+ jQuery.isReady = true; | |
- while ( expr && set.length ) { | |
- for ( type in Expr.filter ) { | |
- if ( (match = Expr.leftMatch[ type ].exec( expr )) != … | |
- filter = Expr.filter[ type ]; | |
- left = match[1]; | |
+ // If a normal DOM Ready event fired, decrement, and wait if n… | |
+ if ( wait !== true && --jQuery.readyWait > 0 ) { | |
+ return; | |
+ } | |
- anyFound = false; | |
+ // If there are functions bound, to execute | |
+ readyList.resolveWith( document, [ jQuery ] ); | |
+ } | |
+} ); | |
- match.splice(1,1); | |
+jQuery.ready.then = readyList.then; | |
- if ( left.substr( left.length - 1 ) === "\\" )… | |
- continue; | |
- } | |
+// The ready event handler and self cleanup method | |
+function completed() { | |
+ document.removeEventListener( "DOMContentLoaded", completed ); | |
+ window.removeEventListener( "load", completed ); | |
+ jQuery.ready(); | |
+} | |
- if ( curLoop === result ) { | |
- result = []; | |
- } | |
+// 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.doScr… | |
- if ( Expr.preFilter[ type ] ) { | |
- match = Expr.preFilter[ type ]( match,… | |
+ // Handle it asynchronously to allow scripts the opportunity to delay … | |
+ window.setTimeout( jQuery.ready ); | |
- if ( !match ) { | |
- anyFound = found = true; | |
+} else { | |
- } else if ( match === true ) { | |
- continue; | |
- } | |
- } | |
+ // Use the handy event callback | |
+ document.addEventListener( "DOMContentLoaded", completed ); | |
- if ( match ) { | |
- for ( i = 0; (item = curLoop[i]) != nu… | |
- if ( item ) { | |
- found = filter( item, … | |
- pass = not ^ found; | |
+ // A fallback to window.onload, that will always work | |
+ window.addEventListener( "load", completed ); | |
+} | |
- if ( inplace && found … | |
- if ( pass ) { | |
- anyFou… | |
- } else { | |
- curLoo… | |
- } | |
- } else if ( pass ) { | |
- result.push( i… | |
- anyFound = tru… | |
- } | |
- } | |
- } | |
- } | |
- if ( found !== undefined ) { | |
- if ( !inplace ) { | |
- curLoop = result; | |
- } | |
+// 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; | |
- expr = expr.replace( Expr.match[ type … | |
+ // Sets many values | |
+ if ( jQuery.type( key ) === "object" ) { | |
+ chainable = true; | |
+ for ( i in key ) { | |
+ access( elems, fn, i, key[ i ], true, emptyGet, raw ); | |
+ } | |
- if ( !anyFound ) { | |
- return []; | |
- } | |
- | |
- break; | |
- } | |
- } | |
- } | |
+ // Sets one value | |
+ } else if ( value !== undefined ) { | |
+ chainable = true; | |
- // Improper expression | |
- if ( expr === old ) { | |
- if ( anyFound == null ) { | |
- Sizzle.error( expr ); | |
- | |
- } else { | |
- break; | |
- } | |
+ if ( !jQuery.isFunction( value ) ) { | |
+ raw = true; | |
} | |
- old = expr; | |
- } | |
- | |
- return curLoop; | |
-}; | |
+ if ( bulk ) { | |
-Sizzle.error = function( msg ) { | |
- throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
-}; | |
+ // Bulk operations run against the entire set | |
+ if ( raw ) { | |
+ fn.call( elems, value ); | |
+ fn = null; | |
-/** | |
- * Utility function for retreiving the text value of an array of DOM nodes | |
- * @param {Array|Element} elem | |
- */ | |
-var getText = Sizzle.getText = function( elem ) { | |
- var i, node, | |
- nodeType = elem.nodeType, | |
- ret = ""; | |
- | |
- if ( nodeType ) { | |
- if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
- // Use textContent || innerText for elements | |
- if ( typeof elem.textContent === 'string' ) { | |
- return elem.textContent; | |
- } else if ( typeof elem.innerText === 'string' ) { | |
- // Replace IE's carriage returns | |
- return elem.innerText.replace( rReturn, '' ); | |
+ // ...except when executing function values | |
} else { | |
- // Traverse it's children | |
- for ( elem = elem.firstChild; elem; elem = ele… | |
- ret += getText( elem ); | |
- } | |
+ bulk = fn; | |
+ fn = function( elem, key, value ) { | |
+ return bulk.call( jQuery( elem ), valu… | |
+ }; | |
} | |
- } else if ( nodeType === 3 || nodeType === 4 ) { | |
- return elem.nodeValue; | |
} | |
- } else { | |
- // If no nodeType, this is expected to be an array | |
- for ( i = 0; (node = elem[i]); i++ ) { | |
- // Do not traverse comment nodes | |
- if ( node.nodeType !== 8 ) { | |
- ret += getText( node ); | |
+ if ( fn ) { | |
+ for ( ; i < len; i++ ) { | |
+ fn( | |
+ elems[ i ], key, raw ? | |
+ value : | |
+ value.call( elems[ i ], i, fn( elems[ … | |
+ ); | |
} | |
} | |
} | |
- return ret; | |
-}; | |
- | |
-var Expr = Sizzle.selectors = { | |
- order: [ "ID", "NAME", "TAG" ], | |
- | |
- match: { | |
- ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, | |
- CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, | |
- NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, | |
- ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:([… | |
- TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, | |
- CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]… | |
- POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-… | |
- PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)… | |
- }, | |
- leftMatch: {}, | |
+ if ( chainable ) { | |
+ return elems; | |
+ } | |
- attrMap: { | |
- "class": "className", | |
- "for": "htmlFor" | |
- }, | |
+ // Gets | |
+ if ( bulk ) { | |
+ return fn.call( elems ); | |
+ } | |
- attrHandle: { | |
- href: function( elem ) { | |
- return elem.getAttribute( "href" ); | |
- }, | |
- type: function( elem ) { | |
- return elem.getAttribute( "type" ); | |
- } | |
- }, | |
+ return len ? fn( elems[ 0 ], key ) : emptyGet; | |
+}; | |
+var acceptData = function( owner ) { | |
+ | |
+ // Accepts only: | |
+ // - Node | |
+ // - Node.ELEMENT_NODE | |
+ // - Node.DOCUMENT_NODE | |
+ // - Object | |
+ // - Any | |
+ return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeT… | |
+}; | |
- relative: { | |
- "+": function(checkSet, part){ | |
- var isPartStr = typeof part === "string", | |
- isTag = isPartStr && !rNonWord.test( part ), | |
- isPartStrNotTag = isPartStr && !isTag; | |
- if ( isTag ) { | |
- part = part.toLowerCase(); | |
- } | |
- for ( var i = 0, l = checkSet.length, elem; i < l; i++… | |
- if ( (elem = checkSet[i]) ) { | |
- while ( (elem = elem.previousSibling) … | |
- checkSet[i] = isPartStrNotTag || elem … | |
- elem || false : | |
- elem === part; | |
- } | |
- } | |
+function Data() { | |
+ this.expando = jQuery.expando + Data.uid++; | |
+} | |
- if ( isPartStrNotTag ) { | |
- Sizzle.filter( part, checkSet, true ); | |
- } | |
- }, | |
+Data.uid = 1; | |
- ">": function( checkSet, part ) { | |
- var elem, | |
- isPartStr = typeof part === "string", | |
- i = 0, | |
- l = checkSet.length; | |
+Data.prototype = { | |
- if ( isPartStr && !rNonWord.test( part ) ) { | |
- part = part.toLowerCase(); | |
+ cache: function( owner ) { | |
- for ( ; i < l; i++ ) { | |
- elem = checkSet[i]; | |
+ // Check if the owner object already has a cache | |
+ var value = owner[ this.expando ]; | |
- if ( elem ) { | |
- var parent = elem.parentNode; | |
- checkSet[i] = parent.nodeName.… | |
- } | |
- } | |
+ // If not, create one | |
+ if ( !value ) { | |
+ value = {}; | |
- } else { | |
- for ( ; i < l; i++ ) { | |
- elem = checkSet[i]; | |
+ // We can accept data for non-element nodes in modern … | |
+ // but we should not, see #8335. | |
+ // Always return an empty object. | |
+ if ( acceptData( owner ) ) { | |
- if ( elem ) { | |
- checkSet[i] = isPartStr ? | |
- elem.parentNode : | |
- elem.parentNode === pa… | |
- } | |
- } | |
+ // If it is a node unlikely to be stringify-ed… | |
+ // use plain assignment | |
+ if ( owner.nodeType ) { | |
+ owner[ this.expando ] = value; | |
- if ( isPartStr ) { | |
- Sizzle.filter( part, checkSet, true ); | |
+ // Otherwise secure it in a non-enumerable pro… | |
+ // configurable must be true to allow the prop… | |
+ // deleted when data is removed | |
+ } else { | |
+ Object.defineProperty( owner, this.exp… | |
+ value: value, | |
+ configurable: true | |
+ } ); | |
} | |
} | |
- }, | |
- | |
- "": function(checkSet, part, isXML){ | |
- var nodeCheck, | |
- doneName = done++, | |
- checkFn = dirCheck; | |
+ } | |
- if ( typeof part === "string" && !rNonWord.test( part … | |
- part = part.toLowerCase(); | |
- nodeCheck = part; | |
- checkFn = dirNodeCheck; | |
- } | |
+ return value; | |
+ }, | |
+ set: function( owner, data, value ) { | |
+ var prop, | |
+ cache = this.cache( owner ); | |
- checkFn( "parentNode", part, doneName, checkSet, nodeC… | |
- }, | |
+ // Handle: [ owner, key, value ] args | |
+ // Always use camelCase key (gh-2257) | |
+ if ( typeof data === "string" ) { | |
+ cache[ jQuery.camelCase( data ) ] = value; | |
- "~": function( checkSet, part, isXML ) { | |
- var nodeCheck, | |
- doneName = done++, | |
- checkFn = dirCheck; | |
+ // Handle: [ owner, { properties } ] args | |
+ } else { | |
- if ( typeof part === "string" && !rNonWord.test( part … | |
- part = part.toLowerCase(); | |
- nodeCheck = part; | |
- checkFn = dirNodeCheck; | |
+ // Copy the properties one-by-one to the cache object | |
+ for ( prop in data ) { | |
+ cache[ jQuery.camelCase( prop ) ] = data[ prop… | |
} | |
- | |
- checkFn( "previousSibling", part, doneName, checkSet, … | |
} | |
+ return cache; | |
}, | |
+ get: function( owner, key ) { | |
+ return key === undefined ? | |
+ this.cache( owner ) : | |
- find: { | |
- ID: function( match, context, isXML ) { | |
- if ( typeof context.getElementById !== "undefined" && … | |
- var m = context.getElementById(match[1]); | |
- // Check parentNode to catch when Blackberry 4… | |
- // nodes that are no longer in the document #6… | |
- return m && m.parentNode ? [m] : []; | |
- } | |
- }, | |
+ // Always use camelCase key (gh-2257) | |
+ owner[ this.expando ] && owner[ this.expando ][ jQuery… | |
+ }, | |
+ access: function( owner, key, value ) { | |
- NAME: function( match, context ) { | |
- if ( typeof context.getElementsByName !== "undefined" … | |
- var ret = [], | |
- results = context.getElementsByName( m… | |
+ // 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 … | |
- for ( var i = 0, l = results.length; i < l; i+… | |
- if ( results[i].getAttribute("name") =… | |
- ret.push( results[i] ); | |
- } | |
- } | |
+ return this.get( owner, key ); | |
+ } | |
- return ret.length === 0 ? null : ret; | |
- } | |
- }, | |
+ // 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 ); | |
- TAG: function( match, context ) { | |
- if ( typeof context.getElementsByTagName !== "undefine… | |
- return context.getElementsByTagName( match[1] … | |
- } | |
- } | |
+ // 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; | |
}, | |
- preFilter: { | |
- CLASS: function( match, curLoop, inplace, result, not, isXML )… | |
- match = " " + match[1].replace( rBackslash, "" ) + " "; | |
- | |
- if ( isXML ) { | |
- return match; | |
- } | |
+ remove: function( owner, key ) { | |
+ var i, | |
+ cache = owner[ this.expando ]; | |
- for ( var i = 0, elem; (elem = curLoop[i]) != null; i+… | |
- if ( elem ) { | |
- if ( not ^ (elem.className && (" " + e… | |
- if ( !inplace ) { | |
- result.push( elem ); | |
- } | |
+ if ( cache === undefined ) { | |
+ return; | |
+ } | |
- } else if ( inplace ) { | |
- curLoop[i] = false; | |
- } | |
- } | |
- } | |
+ if ( key !== undefined ) { | |
- return false; | |
- }, | |
+ // Support array or space separated string of keys | |
+ if ( jQuery.isArray( key ) ) { | |
- ID: function( match ) { | |
- return match[1].replace( rBackslash, "" ); | |
- }, | |
+ // If key is an array of keys... | |
+ // We always set camelCase keys, so remove tha… | |
+ key = key.map( jQuery.camelCase ); | |
+ } else { | |
+ key = jQuery.camelCase( key ); | |
- TAG: function( match, curLoop ) { | |
- return match[1].replace( rBackslash, "" ).toLowerCase(… | |
- }, | |
+ // If a key with the spaces exists, use it. | |
+ // Otherwise, create an array by matching non-… | |
+ key = key in cache ? | |
+ [ key ] : | |
+ ( key.match( rnothtmlwhite ) || [] ); | |
+ } | |
- CHILD: function( match ) { | |
- if ( match[1] === "nth" ) { | |
- if ( !match[2] ) { | |
- Sizzle.error( match[0] ); | |
- } | |
+ i = key.length; | |
- match[2] = match[2].replace(/^\+|\s*/g, ''); | |
+ while ( i-- ) { | |
+ delete cache[ key[ i ] ]; | |
+ } | |
+ } | |
- // parse equations like 'even', 'odd', '5', '2… | |
- var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( | |
- match[2] === "even" && "2n" || match[2… | |
- !/\D/.test( match[2] ) && "0n+" + matc… | |
+ // Remove the expando if there's no more data | |
+ if ( key === undefined || jQuery.isEmptyObject( cache ) ) { | |
- // calculate the numbers (first)n+(last) inclu… | |
- match[2] = (test[1] + (test[2] || 1)) - 0; | |
- match[3] = test[3] - 0; | |
- } | |
- else if ( match[2] ) { | |
- Sizzle.error( match[0] ); | |
+ // Support: Chrome <=35 - 45 | |
+ // Webkit & Blink performance suffers when deleting pr… | |
+ // from DOM nodes, so set to undefined instead | |
+ // https://bugs.chromium.org/p/chromium/issues/detail?… | |
+ 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(); | |
- // TODO: Move to normal caching system | |
- match[0] = done++; | |
+var dataUser = new Data(); | |
- return match; | |
- }, | |
- ATTR: function( match, curLoop, inplace, result, not, isXML ) { | |
- var name = match[1] = match[1].replace( rBackslash, ""… | |
- if ( !isXML && Expr.attrMap[name] ) { | |
- match[1] = Expr.attrMap[name]; | |
- } | |
+// 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" dat… | |
+// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _re… | |
+// 5. Avoid exposing implementation details on user objects (eg. expand… | |
+// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 | |
- // Handle if an un-quoted value was used | |
- match[4] = ( match[4] || match[5] || "" ).replace( rBa… | |
+var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, | |
+ rmultiDash = /[A-Z]/g; | |
- if ( match[2] === "~=" ) { | |
- match[4] = " " + match[4] + " "; | |
- } | |
+function getData( data ) { | |
+ if ( data === "true" ) { | |
+ return true; | |
+ } | |
- return match; | |
- }, | |
+ if ( data === "false" ) { | |
+ return false; | |
+ } | |
- PSEUDO: function( match, curLoop, inplace, result, not ) { | |
- if ( match[1] === "not" ) { | |
- // If we're dealing with a complex expression,… | |
- if ( ( chunker.exec(match[3]) || "" ).length >… | |
- match[3] = Sizzle(match[3], null, null… | |
+ if ( data === "null" ) { | |
+ return null; | |
+ } | |
- } else { | |
- var ret = Sizzle.filter(match[3], curL… | |
+ // Only convert to a number if it doesn't change the string | |
+ if ( data === +data + "" ) { | |
+ return +data; | |
+ } | |
- if ( !inplace ) { | |
- result.push.apply( result, ret… | |
- } | |
+ if ( rbrace.test( data ) ) { | |
+ return JSON.parse( data ); | |
+ } | |
- return false; | |
- } | |
+ return data; | |
+} | |
- } else if ( Expr.match.POS.test( match[0] ) || Expr.ma… | |
- return true; | |
- } | |
+function dataAttr( elem, key, data ) { | |
+ var name; | |
- return match; | |
- }, | |
+ // 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 ); | |
- POS: function( match ) { | |
- match.unshift( true ); | |
+ if ( typeof data === "string" ) { | |
+ try { | |
+ data = getData( data ); | |
+ } catch ( e ) {} | |
- return match; | |
+ // 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 ); | |
}, | |
- filters: { | |
- enabled: function( elem ) { | |
- return elem.disabled === false && elem.type !== "hidde… | |
- }, | |
+ data: function( elem, name, data ) { | |
+ return dataUser.access( elem, name, data ); | |
+ }, | |
- disabled: function( elem ) { | |
- return elem.disabled === true; | |
- }, | |
+ removeData: function( elem, name ) { | |
+ dataUser.remove( elem, name ); | |
+ }, | |
- checked: function( elem ) { | |
- return elem.checked === true; | |
- }, | |
+ // 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 ); | |
+ }, | |
- selected: function( elem ) { | |
- // Accessing this property makes selected-by-default | |
- // options in Safari work properly | |
- if ( elem.parentNode ) { | |
- elem.parentNode.selectedIndex; | |
- } | |
+ _removeData: function( elem, name ) { | |
+ dataPriv.remove( elem, name ); | |
+ } | |
+} ); | |
- return elem.selected === true; | |
- }, | |
+jQuery.fn.extend( { | |
+ data: function( key, value ) { | |
+ var i, name, data, | |
+ elem = this[ 0 ], | |
+ attrs = elem && elem.attributes; | |
- parent: function( elem ) { | |
- return !!elem.firstChild; | |
- }, | |
+ // Gets all values | |
+ if ( key === undefined ) { | |
+ if ( this.length ) { | |
+ data = dataUser.get( elem ); | |
+ | |
+ if ( elem.nodeType === 1 && !dataPriv.get( ele… | |
+ i = attrs.length; | |
+ while ( i-- ) { | |
+ | |
+ // Support: IE 11 only | |
+ // The attrs elements can be n… | |
+ if ( attrs[ i ] ) { | |
+ name = attrs[ i ].name; | |
+ if ( name.indexOf( "da… | |
+ name = jQuery.… | |
+ dataAttr( elem… | |
+ } | |
+ } | |
+ } | |
+ dataPriv.set( elem, "hasDataAttrs", tr… | |
+ } | |
+ } | |
- empty: function( elem ) { | |
- return !elem.firstChild; | |
- }, | |
+ return data; | |
+ } | |
- has: function( elem, i, match ) { | |
- return !!Sizzle( match[3], elem ).length; | |
- }, | |
+ // Sets multiple values | |
+ if ( typeof key === "object" ) { | |
+ return this.each( function() { | |
+ dataUser.set( this, key ); | |
+ } ); | |
+ } | |
- header: function( elem ) { | |
- return (/h\d/i).test( elem.nodeName ); | |
- }, | |
+ return access( this, function( value ) { | |
+ var data; | |
- text: function( elem ) { | |
- var attr = elem.getAttribute( "type" ), type = elem.ty… | |
- // IE6 and 7 will map elem.type to 'text' for new HTML… | |
- // use getAttribute instead to test this case | |
- return elem.nodeName.toLowerCase() === "input" && "tex… | |
- }, | |
+ // The calling jQuery object (element matches) is not … | |
+ // (and therefore has an element appears at this[ 0 ])… | |
+ // `value` parameter was not undefined. An empty jQuer… | |
+ // will result in `undefined` for elem = this[ 0 ] whi… | |
+ // throw an exception if an attempt to read a data cac… | |
+ if ( elem && value === undefined ) { | |
- radio: function( elem ) { | |
- return elem.nodeName.toLowerCase() === "input" && "rad… | |
- }, | |
+ // 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; | |
+ } | |
- checkbox: function( elem ) { | |
- return elem.nodeName.toLowerCase() === "input" && "che… | |
- }, | |
+ // Attempt to "discover" the data in | |
+ // HTML5 custom data-* attrs | |
+ data = dataAttr( elem, key ); | |
+ if ( data !== undefined ) { | |
+ return data; | |
+ } | |
- file: function( elem ) { | |
- return elem.nodeName.toLowerCase() === "input" && "fil… | |
- }, | |
+ // We tried really hard, but the data doesn't … | |
+ return; | |
+ } | |
- password: function( elem ) { | |
- return elem.nodeName.toLowerCase() === "input" && "pas… | |
- }, | |
+ // Set the data... | |
+ this.each( function() { | |
- submit: function( elem ) { | |
- var name = elem.nodeName.toLowerCase(); | |
- return (name === "input" || name === "button") && "sub… | |
- }, | |
+ // We always store the camelCased key | |
+ dataUser.set( this, key, value ); | |
+ } ); | |
+ }, null, value, arguments.length > 1, null, true ); | |
+ }, | |
- image: function( elem ) { | |
- return elem.nodeName.toLowerCase() === "input" && "ima… | |
- }, | |
+ removeData: function( key ) { | |
+ return this.each( function() { | |
+ dataUser.remove( this, key ); | |
+ } ); | |
+ } | |
+} ); | |
- reset: function( elem ) { | |
- var name = elem.nodeName.toLowerCase(); | |
- return (name === "input" || name === "button") && "res… | |
- }, | |
- button: function( elem ) { | |
- var name = elem.nodeName.toLowerCase(); | |
- return name === "input" && "button" === elem.type || n… | |
- }, | |
+jQuery.extend( { | |
+ queue: function( elem, type, data ) { | |
+ var queue; | |
- input: function( elem ) { | |
- return (/input|select|textarea|button/i).test( elem.no… | |
- }, | |
+ if ( elem ) { | |
+ type = ( type || "fx" ) + "queue"; | |
+ queue = dataPriv.get( elem, type ); | |
- focus: function( elem ) { | |
- return elem === elem.ownerDocument.activeElement; | |
+ // Speed up dequeue by getting out quickly if this is … | |
+ if ( data ) { | |
+ if ( !queue || jQuery.isArray( data ) ) { | |
+ queue = dataPriv.access( elem, type, j… | |
+ } else { | |
+ queue.push( data ); | |
+ } | |
+ } | |
+ return queue || []; | |
} | |
}, | |
- setFilters: { | |
- first: function( elem, i ) { | |
- return i === 0; | |
- }, | |
- last: function( elem, i, match, array ) { | |
- return i === array.length - 1; | |
- }, | |
+ dequeue: function( elem, type ) { | |
+ type = type || "fx"; | |
- even: function( elem, i ) { | |
- return i % 2 === 0; | |
- }, | |
+ var queue = jQuery.queue( elem, type ), | |
+ startLength = queue.length, | |
+ fn = queue.shift(), | |
+ hooks = jQuery._queueHooks( elem, type ), | |
+ next = function() { | |
+ jQuery.dequeue( elem, type ); | |
+ }; | |
- odd: function( elem, i ) { | |
- return i % 2 === 1; | |
- }, | |
+ // If the fx queue is dequeued, always remove the progress sen… | |
+ if ( fn === "inprogress" ) { | |
+ fn = queue.shift(); | |
+ startLength--; | |
+ } | |
- lt: function( elem, i, match ) { | |
- return i < match[3] - 0; | |
- }, | |
+ if ( fn ) { | |
- gt: function( elem, i, match ) { | |
- return i > match[3] - 0; | |
- }, | |
+ // Add a progress sentinel to prevent the fx queue fro… | |
+ // automatically dequeued | |
+ if ( type === "fx" ) { | |
+ queue.unshift( "inprogress" ); | |
+ } | |
- nth: function( elem, i, match ) { | |
- return match[3] - 0 === i; | |
- }, | |
+ // Clear up the last queue stop function | |
+ delete hooks.stop; | |
+ fn.call( elem, next, hooks ); | |
+ } | |
- eq: function( elem, i, match ) { | |
- return match[3] - 0 === i; | |
+ if ( !startLength && hooks ) { | |
+ hooks.empty.fire(); | |
} | |
}, | |
- filter: { | |
- PSEUDO: function( elem, match, i, array ) { | |
- var name = match[1], | |
- filter = Expr.filters[ name ]; | |
- | |
- if ( filter ) { | |
- return filter( elem, i, match, array ); | |
- } else if ( name === "contains" ) { | |
- return (elem.textContent || elem.innerText || … | |
- | |
- } else if ( name === "not" ) { | |
- var not = match[3]; | |
- | |
- for ( var j = 0, l = not.length; j < l; j++ ) { | |
- if ( not[j] === elem ) { | |
- return false; | |
- } | |
- } | |
+ // 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 ]… | |
+ } ) | |
+ } ); | |
+ } | |
+} ); | |
- return true; | |
+jQuery.fn.extend( { | |
+ queue: function( type, data ) { | |
+ var setter = 2; | |
- } else { | |
- Sizzle.error( name ); | |
- } | |
- }, | |
+ if ( typeof type !== "string" ) { | |
+ data = type; | |
+ type = "fx"; | |
+ setter--; | |
+ } | |
- CHILD: function( elem, match ) { | |
- var first, last, | |
- doneName, parent, cache, | |
- count, diff, | |
- type = match[1], | |
- node = elem; | |
- | |
- switch ( type ) { | |
- case "only": | |
- case "first": | |
- while ( (node = node.previousSibling) … | |
- if ( node.nodeType === 1 ) { | |
- return false; | |
- } | |
- } | |
+ if ( arguments.length < setter ) { | |
+ return jQuery.queue( this[ 0 ], type ); | |
+ } | |
- if ( type === "first" ) { | |
- return true; | |
- } | |
+ return data === undefined ? | |
+ this : | |
+ this.each( function() { | |
+ var queue = jQuery.queue( this, type, data ); | |
- node = elem; | |
+ // Ensure a hooks for this queue | |
+ jQuery._queueHooks( this, type ); | |
- /* falls through */ | |
- case "last": | |
- while ( (node = node.nextSibling) ) { | |
- if ( node.nodeType === 1 ) { | |
- return false; | |
- } | |
- } | |
- | |
- return true; | |
+ if ( type === "fx" && queue[ 0 ] !== "inprogre… | |
+ jQuery.dequeue( this, type ); | |
+ } | |
+ } ); | |
+ }, | |
+ dequeue: function( type ) { | |
+ return this.each( function() { | |
+ jQuery.dequeue( this, type ); | |
+ } ); | |
+ }, | |
+ clearQueue: function( type ) { | |
+ return this.queue( type || "fx", [] ); | |
+ }, | |
- case "nth": | |
- first = match[2]; | |
- last = match[3]; | |
+ // 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, [ element… | |
+ } | |
+ }; | |
- if ( first === 1 && last === 0 ) { | |
- return true; | |
- } | |
+ if ( typeof type !== "string" ) { | |
+ obj = type; | |
+ type = undefined; | |
+ } | |
+ type = type || "fx"; | |
- doneName = match[0]; | |
- parent = elem.parentNode; | |
+ 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; | |
- if ( parent && (parent[ expando ] !== … | |
- count = 0; | |
+var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); | |
- for ( node = parent.firstChild… | |
- if ( node.nodeType ===… | |
- node.nodeIndex… | |
- } | |
- } | |
- parent[ expando ] = doneName; | |
- } | |
+var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; | |
- diff = elem.nodeIndex - last; | |
+var isHiddenWithinTree = function( elem, el ) { | |
- if ( first === 0 ) { | |
- return diff === 0; | |
+ // isHiddenWithinTree might be called from jQuery#filter funct… | |
+ // in that case, element will be second argument | |
+ elem = el || elem; | |
- } else { | |
- return ( diff % first === 0 &&… | |
- } | |
- } | |
- }, | |
+ // Inline style trumps all | |
+ return elem.style.display === "none" || | |
+ elem.style.display === "" && | |
- ID: function( elem, match ) { | |
- return elem.nodeType === 1 && elem.getAttribute("id") … | |
- }, | |
+ // Otherwise, check computed style | |
+ // Support: Firefox <=43 - 45 | |
+ // Disconnected elements can have computed display: no… | |
+ // in the document. | |
+ jQuery.contains( elem.ownerDocument, elem ) && | |
- TAG: function( elem, match ) { | |
- return (match === "*" && elem.nodeType === 1) || !!ele… | |
- }, | |
+ jQuery.css( elem, "display" ) === "none"; | |
+ }; | |
- CLASS: function( elem, match ) { | |
- return (" " + (elem.className || elem.getAttribute("cl… | |
- .indexOf( match ) > -1; | |
- }, | |
+var swap = function( elem, options, callback, args ) { | |
+ var ret, name, | |
+ old = {}; | |
- ATTR: function( elem, match ) { | |
- var name = match[1], | |
- result = Sizzle.attr ? | |
- Sizzle.attr( elem, name ) : | |
- Expr.attrHandle[ name ] ? | |
- Expr.attrHandle[ name ]( elem ) : | |
- elem[ name ] != null ? | |
- elem[ name ] : | |
- elem.getAttribute( name ), | |
- value = result + "", | |
- type = match[2], | |
- check = match[4]; | |
- | |
- return result == null ? | |
- type === "!=" : | |
- !type && Sizzle.attr ? | |
- result != null : | |
- type === "=" ? | |
- value === check : | |
- type === "*=" ? | |
- value.indexOf(check) >= 0 : | |
- type === "~=" ? | |
- (" " + value + " ").indexOf(check) >= 0 : | |
- !check ? | |
- value && result !== false : | |
- type === "!=" ? | |
- value !== check : | |
- type === "^=" ? | |
- value.indexOf(check) === 0 : | |
- type === "$=" ? | |
- value.substr(value.length - check.length) === … | |
- type === "|=" ? | |
- value === check || value.substr(0, check.lengt… | |
- false; | |
- }, | |
+ // Remember the old values, and insert the new ones | |
+ for ( name in options ) { | |
+ old[ name ] = elem.style[ name ]; | |
+ elem.style[ name ] = options[ name ]; | |
+ } | |
- POS: function( elem, match, i, array ) { | |
- var name = match[2], | |
- filter = Expr.setFilters[ name ]; | |
+ ret = callback.apply( elem, args || [] ); | |
- if ( filter ) { | |
- return filter( elem, i, match, array ); | |
- } | |
- } | |
+ // Revert the old values | |
+ for ( name in options ) { | |
+ elem.style[ name ] = old[ name ]; | |
} | |
+ | |
+ return ret; | |
}; | |
-var origPOS = Expr.match.POS, | |
- fescape = function(all, num){ | |
- return "\\" + (num - 0 + 1); | |
- }; | |
-for ( var type in Expr.match ) { | |
- Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[… | |
- Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.… | |
-} | |
-// Expose origPOS | |
-// "global" as in regardless of relation to brackets/parens | |
-Expr.match.globalPOS = origPOS; | |
-var makeArray = function( array, results ) { | |
- array = Array.prototype.slice.call( array, 0 ); | |
- if ( results ) { | |
- results.push.apply( results, array ); | |
- return results; | |
- } | |
+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[ pr… | |
- return array; | |
-}; | |
+ // Starting value computation is required for potential unit m… | |
+ initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" &&… | |
+ rcssNum.exec( jQuery.css( elem, prop ) ); | |
-// Perform a simple check to determine if the browser is capable of | |
-// converting a NodeList to an array using builtin methods. | |
-// Also verifies that the returned array holds DOM nodes | |
-// (which is not the case in the Blackberry browser) | |
-try { | |
- Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0… | |
+ if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { | |
-// Provide a fallback method if it does not work | |
-} catch( e ) { | |
- makeArray = function( array, results ) { | |
- var i = 0, | |
- ret = results || []; | |
+ // Trust units reported by jQuery.css | |
+ unit = unit || initialInUnit[ 3 ]; | |
- if ( toString.call(array) === "[object Array]" ) { | |
- Array.prototype.push.apply( ret, array ); | |
+ // Make sure we update the tween properties later on | |
+ valueParts = valueParts || []; | |
- } else { | |
- if ( typeof array.length === "number" ) { | |
- for ( var l = array.length; i < l; i++ ) { | |
- ret.push( array[i] ); | |
- } | |
+ // Iteratively approximate from a nonzero starting point | |
+ initialInUnit = +initial || 1; | |
- } else { | |
- for ( ; array[i]; i++ ) { | |
- ret.push( array[i] ); | |
- } | |
- } | |
- } | |
+ do { | |
- return ret; | |
- }; | |
-} | |
+ // If previous iteration zeroed out, double until we g… | |
+ // Use string for doubling so we don't accidentally se… | |
+ scale = scale || ".5"; | |
-var sortOrder, siblingCheck; | |
+ // Adjust and apply | |
+ initialInUnit = initialInUnit / scale; | |
+ jQuery.style( elem, prop, initialInUnit + unit ); | |
-if ( document.documentElement.compareDocumentPosition ) { | |
- sortOrder = function( a, b ) { | |
- if ( a === b ) { | |
- hasDuplicate = true; | |
- return 0; | |
- } | |
+ // Update scale, tolerating zero or NaN from tween.cur() | |
+ // Break the loop if scale is unchanged or perfect, or if we'v… | |
+ } while ( | |
+ scale !== ( scale = currentValue() / initial ) && scal… | |
+ ); | |
+ } | |
+ | |
+ if ( valueParts ) { | |
+ initialInUnit = +initialInUnit || +initial || 0; | |
- if ( !a.compareDocumentPosition || !b.compareDocumentPosition … | |
- return a.compareDocumentPosition ? -1 : 1; | |
+ // Apply relative offset (+=/-=) if specified | |
+ adjusted = valueParts[ 1 ] ? | |
+ initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ … | |
+ +valueParts[ 2 ]; | |
+ if ( tween ) { | |
+ tween.unit = unit; | |
+ tween.start = initialInUnit; | |
+ tween.end = adjusted; | |
} | |
+ } | |
+ return adjusted; | |
+} | |
- return a.compareDocumentPosition(b) & 4 ? -1 : 1; | |
- }; | |
-} else { | |
- sortOrder = function( a, b ) { | |
- // The nodes are identical, we can exit early | |
- if ( a === b ) { | |
- hasDuplicate = true; | |
- return 0; | |
+var defaultDisplayMap = {}; | |
- // Fallback to using sourceIndex (in IE) if it's available on … | |
- } else if ( a.sourceIndex && b.sourceIndex ) { | |
- return a.sourceIndex - b.sourceIndex; | |
- } | |
+function getDefaultDisplay( elem ) { | |
+ var temp, | |
+ doc = elem.ownerDocument, | |
+ nodeName = elem.nodeName, | |
+ display = defaultDisplayMap[ nodeName ]; | |
- var al, bl, | |
- ap = [], | |
- bp = [], | |
- aup = a.parentNode, | |
- bup = b.parentNode, | |
- cur = aup; | |
+ if ( display ) { | |
+ return display; | |
+ } | |
- // If the nodes are siblings (or identical) we can do a quick … | |
- if ( aup === bup ) { | |
- return siblingCheck( a, b ); | |
+ temp = doc.body.appendChild( doc.createElement( nodeName ) ); | |
+ display = jQuery.css( temp, "display" ); | |
- // If no parents were found then the nodes are disconnected | |
- } else if ( !aup ) { | |
- return -1; | |
+ temp.parentNode.removeChild( temp ); | |
- } else if ( !bup ) { | |
- return 1; | |
- } | |
+ if ( display === "none" ) { | |
+ display = "block"; | |
+ } | |
+ defaultDisplayMap[ nodeName ] = display; | |
- // 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; | |
- } | |
+ return display; | |
+} | |
- cur = bup; | |
+function showHide( elements, show ) { | |
+ var display, elem, | |
+ values = [], | |
+ index = 0, | |
+ length = elements.length; | |
- while ( cur ) { | |
- bp.unshift( cur ); | |
- cur = cur.parentNode; | |
+ // Determine new display value for elements that need to change | |
+ for ( ; index < length; index++ ) { | |
+ elem = elements[ index ]; | |
+ if ( !elem.style ) { | |
+ continue; | |
} | |
- al = ap.length; | |
- bl = bp.length; | |
+ display = elem.style.display; | |
+ if ( show ) { | |
- // 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] ); | |
+ // Since we force visibility upon cascade-hidden eleme… | |
+ // check is required in this first loop unless we have… | |
+ // inline or about-to-be-restored) | |
+ if ( display === "none" ) { | |
+ values[ index ] = dataPriv.get( elem, "display… | |
+ if ( !values[ index ] ) { | |
+ elem.style.display = ""; | |
+ } | |
} | |
- } | |
- | |
- // We ended someplace up the tree so do a sibling check | |
- return i === al ? | |
- siblingCheck( a, bp[i], -1 ) : | |
- siblingCheck( ap[i], b, 1 ); | |
- }; | |
- | |
- siblingCheck = function( a, b, ret ) { | |
- if ( a === b ) { | |
- return ret; | |
- } | |
- | |
- var cur = a.nextSibling; | |
+ if ( elem.style.display === "" && isHiddenWithinTree( … | |
+ values[ index ] = getDefaultDisplay( elem ); | |
+ } | |
+ } else { | |
+ if ( display !== "none" ) { | |
+ values[ index ] = "none"; | |
- while ( cur ) { | |
- if ( cur === b ) { | |
- return -1; | |
+ // Remember what we're overwriting | |
+ dataPriv.set( elem, "display", display ); | |
} | |
+ } | |
+ } | |
- cur = cur.nextSibling; | |
+ // Set the display of the elements in a second loop to avoid constant … | |
+ for ( index = 0; index < length; index++ ) { | |
+ if ( values[ index ] != null ) { | |
+ elements[ index ].style.display = values[ index ]; | |
} | |
+ } | |
- return 1; | |
- }; | |
+ return elements; | |
} | |
-// Check to see if the browser returns elements by name when | |
-// querying by getElementById (and provide a workaround) | |
-(function(){ | |
- // We're going to inject a fake input element with a specified name | |
- var form = document.createElement("div"), | |
- id = "script" + (new Date()).getTime(), | |
- root = document.documentElement; | |
+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(); | |
+ } | |
- form.innerHTML = "<a name='" + id + "'/>"; | |
+ return this.each( function() { | |
+ if ( isHiddenWithinTree( this ) ) { | |
+ jQuery( this ).show(); | |
+ } else { | |
+ jQuery( this ).hide(); | |
+ } | |
+ } ); | |
+ } | |
+} ); | |
+var rcheckableType = ( /^(?:checkbox|radio)$/i ); | |
- // Inject it into the root element, check its status, and remove it qu… | |
- root.insertBefore( form, root.firstChild ); | |
+var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); | |
- // The workaround has to do additional checks after a getElementById | |
- // Which slows things down for other browsers (hence the branching) | |
- if ( document.getElementById( id ) ) { | |
- Expr.find.ID = function( match, context, isXML ) { | |
- if ( typeof context.getElementById !== "undefined" && … | |
- var m = context.getElementById(match[1]); | |
+var rscriptType = ( /^$|\/(?:java|ecma)script/i ); | |
- return m ? | |
- m.id === match[1] || typeof m.getAttri… | |
- [m] : | |
- undefined : | |
- []; | |
- } | |
- }; | |
- Expr.filter.ID = function( elem, match ) { | |
- var node = typeof elem.getAttributeNode !== "undefined… | |
- return elem.nodeType === 1 && node && node.nodeValue =… | |
- }; | |
- } | |
+// We have to close these tags to support XHTML (#13200) | |
+var wrapMap = { | |
- root.removeChild( form ); | |
+ // Support: IE <=9 only | |
+ option: [ 1, "<select multiple='multiple'>", "</select>" ], | |
- // release memory in IE | |
- root = form = null; | |
-})(); | |
+ // 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>" ], | |
-(function(){ | |
- // Check to see if the browser returns only elements | |
- // when doing getElementsByTagName("*") | |
+ _default: [ 0, "", "" ] | |
+}; | |
- // Create a fake element | |
- var div = document.createElement("div"); | |
- div.appendChild( document.createComment("") ); | |
+// Support: IE <=9 only | |
+wrapMap.optgroup = wrapMap.option; | |
- // Make sure no comments are found | |
- if ( div.getElementsByTagName("*").length > 0 ) { | |
- Expr.find.TAG = function( match, context ) { | |
- var results = context.getElementsByTagName( match[1] ); | |
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.t… | |
+wrapMap.th = wrapMap.td; | |
- // Filter out possible comments | |
- if ( match[1] === "*" ) { | |
- var tmp = []; | |
- for ( var i = 0; results[i]; i++ ) { | |
- if ( results[i].nodeType === 1 ) { | |
- tmp.push( results[i] ); | |
- } | |
- } | |
+function getAll( context, tag ) { | |
- results = tmp; | |
- } | |
+ // Support: IE <=9 - 11 only | |
+ // Use typeof to avoid zero-argument method invocation on host objects… | |
+ var ret; | |
- return results; | |
- }; | |
- } | |
+ if ( typeof context.getElementsByTagName !== "undefined" ) { | |
+ ret = context.getElementsByTagName( tag || "*" ); | |
- // Check to see if an attribute returns normalized href attributes | |
- div.innerHTML = "<a href='#'></a>"; | |
+ } else if ( typeof context.querySelectorAll !== "undefined" ) { | |
+ ret = context.querySelectorAll( tag || "*" ); | |
- if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefin… | |
- div.firstChild.getAttribute("href") !== "#" ) { | |
+ } else { | |
+ ret = []; | |
+ } | |
- Expr.attrHandle.href = function( elem ) { | |
- return elem.getAttribute( "href", 2 ); | |
- }; | |
+ if ( tag === undefined || tag && jQuery.nodeName( context, tag ) ) { | |
+ return jQuery.merge( [ context ], ret ); | |
} | |
- // release memory in IE | |
- div = null; | |
-})(); | |
+ return ret; | |
+} | |
-if ( document.querySelectorAll ) { | |
- (function(){ | |
- var oldSizzle = Sizzle, | |
- div = document.createElement("div"), | |
- id = "__sizzle__"; | |
- div.innerHTML = "<p class='TEST'></p>"; | |
+// Mark scripts as having already been evaluated | |
+function setGlobalEval( elems, refElements ) { | |
+ var i = 0, | |
+ l = elems.length; | |
- // Safari can't handle uppercase or unicode characters when | |
- // in quirks mode. | |
- if ( div.querySelectorAll && div.querySelectorAll(".TEST").len… | |
- return; | |
- } | |
+ for ( ; i < l; i++ ) { | |
+ dataPriv.set( | |
+ elems[ i ], | |
+ "globalEval", | |
+ !refElements || dataPriv.get( refElements[ i ], "globa… | |
+ ); | |
+ } | |
+} | |
- Sizzle = function( query, context, extra, seed ) { | |
- context = context || document; | |
- // Only use querySelectorAll on non-XML documents | |
- // (ID selectors don't work in non-HTML documents) | |
- if ( !seed && !Sizzle.isXML(context) ) { | |
- // See if we find a selector to speed up | |
- var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$… | |
+var rhtml = /<|&#?\w+;/; | |
- if ( match && (context.nodeType === 1 || conte… | |
- // Speed-up: Sizzle("TAG") | |
- if ( match[1] ) { | |
- return makeArray( context.getE… | |
+function buildFragment( elems, context, scripts, selection, ignored ) { | |
+ var elem, tmp, tag, wrap, contains, j, | |
+ fragment = context.createDocumentFragment(), | |
+ nodes = [], | |
+ i = 0, | |
+ l = elems.length; | |
- // Speed-up: Sizzle(".CLASS") | |
- } else if ( match[2] && Expr.find.CLAS… | |
- return makeArray( context.getE… | |
- } | |
- } | |
+ for ( ; i < l; i++ ) { | |
+ elem = elems[ i ]; | |
- if ( context.nodeType === 9 ) { | |
- // Speed-up: Sizzle("body") | |
- // The body element only exists once, … | |
- if ( query === "body" && context.body … | |
- return makeArray( [ context.bo… | |
+ if ( elem || elem === 0 ) { | |
- // Speed-up: Sizzle("#ID") | |
- } else if ( match && match[3] ) { | |
- var elem = context.getElementB… | |
+ // Add nodes directly | |
+ if ( jQuery.type( elem ) === "object" ) { | |
- // Check parentNode to catch w… | |
- // nodes that are no longer in… | |
- if ( elem && elem.parentNode )… | |
- // Handle the case whe… | |
- // by name instead of … | |
- if ( elem.id === match… | |
- return makeArr… | |
- } | |
+ // Support: Android <=4.0 only, PhantomJS 1 on… | |
+ // push.apply(_, arraylike) throws on ancient … | |
+ jQuery.merge( nodes, elem.nodeType ? [ elem ] … | |
- } else { | |
- return makeArray( [], … | |
- } | |
- } | |
+ // Convert non-html into a text node | |
+ } else if ( !rhtml.test( elem ) ) { | |
+ nodes.push( context.createTextNode( elem ) ); | |
- try { | |
- return makeArray( context.quer… | |
- } catch(qsaError) {} | |
- | |
- // qSA works strangely on Element-rooted queri… | |
- // We can work around this by specifying an ex… | |
- // and working up from there (Thanks to Andrew… | |
- // IE 8 doesn't work on object elements | |
- } else if ( context.nodeType === 1 && context.… | |
- var oldContext = context, | |
- old = context.getAttribute( "i… | |
- nid = old || id, | |
- hasParent = context.parentNode, | |
- relativeHierarchySelector = /^… | |
- | |
- if ( !old ) { | |
- context.setAttribute( "id", ni… | |
- } else { | |
- nid = nid.replace( /'/g, "\\$&… | |
- } | |
- if ( relativeHierarchySelector && hasP… | |
- context = context.parentNode; | |
- } | |
+ // Convert html into DOM nodes | |
+ } else { | |
+ tmp = tmp || fragment.appendChild( context.cre… | |
- try { | |
- if ( !relativeHierarchySelecto… | |
- return makeArray( cont… | |
- } | |
+ // Deserialize a standard representation | |
+ tag = ( rtagName.exec( elem ) || [ "", "" ] )[… | |
+ wrap = wrapMap[ tag ] || wrapMap._default; | |
+ tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilt… | |
- } catch(pseudoError) { | |
- } finally { | |
- if ( !old ) { | |
- oldContext.removeAttri… | |
- } | |
- } | |
+ // Descend through wrappers to the right conte… | |
+ j = wrap[ 0 ]; | |
+ while ( j-- ) { | |
+ tmp = tmp.lastChild; | |
} | |
- } | |
- | |
- return oldSizzle(query, context, extra, seed); | |
- }; | |
- | |
- for ( var prop in oldSizzle ) { | |
- Sizzle[ prop ] = oldSizzle[ prop ]; | |
- } | |
- | |
- // release memory in IE | |
- div = null; | |
- })(); | |
-} | |
- | |
-(function(){ | |
- var html = document.documentElement, | |
- matches = html.matchesSelector || html.mozMatchesSelector || h… | |
- if ( matches ) { | |
- // Check to see if it's possible to do matchesSelector | |
- // on a disconnected node (IE 9 fails this) | |
- var disconnectedMatch = !matches.call( document.createElement(… | |
- pseudoWorks = false; | |
+ // Support: Android <=4.0 only, PhantomJS 1 on… | |
+ // push.apply(_, arraylike) throws on ancient … | |
+ jQuery.merge( nodes, tmp.childNodes ); | |
- try { | |
- // This should fail with an exception | |
- // Gecko does not error, returns false instead | |
- matches.call( document.documentElement, "[test!='']:si… | |
+ // Remember the top-level container | |
+ tmp = fragment.firstChild; | |
- } catch( pseudoError ) { | |
- pseudoWorks = true; | |
+ // Ensure the created nodes are orphaned (#123… | |
+ tmp.textContent = ""; | |
+ } | |
} | |
+ } | |
- Sizzle.matchesSelector = function( node, expr ) { | |
- // Make sure that attribute selectors are quoted | |
- expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); | |
+ // Remove wrapper from fragment | |
+ fragment.textContent = ""; | |
- if ( !Sizzle.isXML( node ) ) { | |
- try { | |
- if ( pseudoWorks || !Expr.match.PSEUDO… | |
- var ret = matches.call( node, … | |
- | |
- // IE 9's matchesSelector retu… | |
- if ( ret || !disconnectedMatch… | |
- // As well, di… | |
- // fragment in… | |
- node.document … | |
- return ret; | |
- } | |
- } | |
- } catch(e) {} | |
+ 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; | |
+ } | |
- return Sizzle(expr, null, null, [node]).length > 0; | |
- }; | |
- } | |
-})(); | |
+ contains = jQuery.contains( elem.ownerDocument, elem ); | |
-(function(){ | |
- var div = document.createElement("div"); | |
+ // Append to fragment | |
+ tmp = getAll( fragment.appendChild( elem ), "script" ); | |
- div.innerHTML = "<div class='test e'></div><div class='test'></div>"; | |
+ // Preserve script evaluation history | |
+ if ( contains ) { | |
+ setGlobalEval( tmp ); | |
+ } | |
- // Opera can't find a second classname (in 9.6) | |
- // Also, make sure that getElementsByClassName actually exists | |
- if ( !div.getElementsByClassName || div.getElementsByClassName("e").le… | |
- return; | |
+ // Capture executables | |
+ if ( scripts ) { | |
+ j = 0; | |
+ while ( ( elem = tmp[ j++ ] ) ) { | |
+ if ( rscriptType.test( elem.type || "" ) ) { | |
+ scripts.push( elem ); | |
+ } | |
+ } | |
+ } | |
} | |
- // Safari caches class attributes, doesn't catch changes (in 3.2) | |
- div.lastChild.className = "e"; | |
+ return fragment; | |
+} | |
- if ( div.getElementsByClassName("e").length === 1 ) { | |
- return; | |
- } | |
- Expr.order.splice(1, 0, "CLASS"); | |
- Expr.find.CLASS = function( match, context, isXML ) { | |
- if ( typeof context.getElementsByClassName !== "undefined" && … | |
- return context.getElementsByClassName(match[1]); | |
- } | |
- }; | |
+( function() { | |
+ var fragment = document.createDocumentFragment(), | |
+ div = fragment.appendChild( document.createElement( "div" ) ), | |
+ input = document.createElement( "input" ); | |
- // release memory in IE | |
- div = null; | |
-})(); | |
+ // 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" ); | |
-function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { | |
- for ( var i = 0, l = checkSet.length; i < l; i++ ) { | |
- var elem = checkSet[i]; | |
+ div.appendChild( input ); | |
- if ( elem ) { | |
- var match = false; | |
+ // Support: Android <=4.1 only | |
+ // Older WebKit doesn't clone checked state correctly in fragments | |
+ support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild… | |
- elem = elem[dir]; | |
+ // Support: IE <=11 only | |
+ // Make sure textarea (and checkbox) defaultValue is properly cloned | |
+ div.innerHTML = "<textarea>x</textarea>"; | |
+ support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValu… | |
+} )(); | |
+var documentElement = document.documentElement; | |
- while ( elem ) { | |
- if ( elem[ expando ] === doneName ) { | |
- match = checkSet[elem.sizset]; | |
- break; | |
- } | |
- if ( elem.nodeType === 1 && !isXML ){ | |
- elem[ expando ] = doneName; | |
- elem.sizset = i; | |
- } | |
- if ( elem.nodeName.toLowerCase() === cur ) { | |
- match = elem; | |
- break; | |
- } | |
+var | |
+ rkeyEvent = /^key/, | |
+ rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, | |
+ rtypenamespace = /^([^.]*)(?:\.(.+)|)/; | |
- elem = elem[dir]; | |
- } | |
+function returnTrue() { | |
+ return true; | |
+} | |
- checkSet[i] = match; | |
- } | |
- } | |
+function returnFalse() { | |
+ return false; | |
} | |
-function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { | |
- for ( var i = 0, l = checkSet.length; i < l; i++ ) { | |
- var elem = checkSet[i]; | |
+// Support: IE <=9 only | |
+// See #13393 for more info | |
+function safeActiveElement() { | |
+ try { | |
+ return document.activeElement; | |
+ } catch ( err ) { } | |
+} | |
- if ( elem ) { | |
- var match = false; | |
+function on( elem, types, selector, data, fn, one ) { | |
+ var origFn, type; | |
- elem = elem[dir]; | |
+ // Types can be a map of types/handlers | |
+ if ( typeof types === "object" ) { | |
- while ( elem ) { | |
- if ( elem[ expando ] === doneName ) { | |
- match = checkSet[elem.sizset]; | |
- break; | |
- } | |
+ // ( types-Object, selector, data ) | |
+ if ( typeof selector !== "string" ) { | |
- if ( elem.nodeType === 1 ) { | |
- if ( !isXML ) { | |
- elem[ expando ] = doneName; | |
- elem.sizset = i; | |
- } | |
+ // ( types-Object, data ) | |
+ data = data || selector; | |
+ selector = undefined; | |
+ } | |
+ for ( type in types ) { | |
+ on( elem, type, selector, data, types[ type ], one ); | |
+ } | |
+ return elem; | |
+ } | |
- if ( typeof cur !== "string" ) { | |
- if ( elem === cur ) { | |
- match = true; | |
- break; | |
- } | |
+ if ( data == null && fn == null ) { | |
- } else if ( Sizzle.filter( cur, [elem]… | |
- match = elem; | |
- break; | |
- } | |
- } | |
+ // ( types, fn ) | |
+ fn = selector; | |
+ data = selector = undefined; | |
+ } else if ( fn == null ) { | |
+ if ( typeof selector === "string" ) { | |
- elem = elem[dir]; | |
- } | |
+ // ( types, selector, fn ) | |
+ fn = data; | |
+ data = undefined; | |
+ } else { | |
- checkSet[i] = match; | |
+ // ( types, data, fn ) | |
+ fn = data; | |
+ data = selector; | |
+ selector = undefined; | |
} | |
} | |
-} | |
+ if ( fn === false ) { | |
+ fn = returnFalse; | |
+ } else if ( !fn ) { | |
+ return elem; | |
+ } | |
-if ( document.documentElement.contains ) { | |
- Sizzle.contains = function( a, b ) { | |
- return a !== b && (a.contains ? a.contains(b) : true); | |
- }; | |
+ if ( one === 1 ) { | |
+ origFn = fn; | |
+ fn = function( event ) { | |
-} else if ( document.documentElement.compareDocumentPosition ) { | |
- Sizzle.contains = function( a, b ) { | |
- return !!(a.compareDocumentPosition(b) & 16); | |
- }; | |
+ // Can use an empty set, since event contains the info | |
+ jQuery().off( event ); | |
+ return origFn.apply( this, arguments ); | |
+ }; | |
-} else { | |
- Sizzle.contains = function() { | |
- return false; | |
- }; | |
+ // 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 ); | |
+ } ); | |
} | |
-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 : 0).document… | |
+/* | |
+ * Helper functions for managing events -- not part of the public interface. | |
+ * Props to Dean Edwards' addEvent library for many of the ideas. | |
+ */ | |
+jQuery.event = { | |
- return documentElement ? documentElement.nodeName !== "HTML" : false; | |
-}; | |
+ global: {}, | |
-var posProcess = function( selector, context, seed ) { | |
- var match, | |
- tmpSet = [], | |
- later = "", | |
- root = context.nodeType ? [context] : context; | |
+ add: function( elem, types, handler, data, selector ) { | |
- // Position selectors must be done after the filter | |
- // And so must :not(positional) so we move all PSEUDOs to the end | |
- while ( (match = Expr.match.PSEUDO.exec( selector )) ) { | |
- later += match[0]; | |
- selector = selector.replace( Expr.match.PSEUDO, "" ); | |
- } | |
+ var handleObjIn, eventHandle, tmp, | |
+ events, t, handleObj, | |
+ special, handlers, type, namespaces, origType, | |
+ elemData = dataPriv.get( elem ); | |
- selector = Expr.relative[selector] ? selector + "*" : selector; | |
+ // Don't attach events to noData or text/comment nodes (but al… | |
+ if ( !elemData ) { | |
+ return; | |
+ } | |
- for ( var i = 0, l = root.length; i < l; i++ ) { | |
- Sizzle( selector, root[i], tmpSet, seed ); | |
- } | |
+ // Caller can pass in an object of custom data in lieu of the … | |
+ if ( handler.handler ) { | |
+ handleObjIn = handler; | |
+ handler = handleObjIn.handler; | |
+ selector = handleObjIn.selector; | |
+ } | |
- return Sizzle.filter( later, tmpSet ); | |
-}; | |
+ // Ensure that invalid selectors throw exceptions at attach ti… | |
+ // Evaluate against documentElement in case elem is a non-elem… | |
+ if ( selector ) { | |
+ jQuery.find.matchesSelector( documentElement, selector… | |
+ } | |
-// EXPOSE | |
-// Override sizzle attribute retrieval | |
-Sizzle.attr = jQuery.attr; | |
-Sizzle.selectors.attrMap = {}; | |
-jQuery.find = Sizzle; | |
-jQuery.expr = Sizzle.selectors; | |
-jQuery.expr[":"] = jQuery.expr.filters; | |
-jQuery.unique = Sizzle.uniqueSort; | |
-jQuery.text = Sizzle.getText; | |
-jQuery.isXMLDoc = Sizzle.isXML; | |
-jQuery.contains = Sizzle.contains; | |
+ // Make sure that the handler has a unique ID, used to find/re… | |
+ if ( !handler.guid ) { | |
+ handler.guid = jQuery.guid++; | |
+ } | |
+ // Init the element's event structure and main handler, if thi… | |
+ if ( !( events = elemData.events ) ) { | |
+ events = elemData.events = {}; | |
+ } | |
+ if ( !( eventHandle = elemData.handle ) ) { | |
+ eventHandle = elemData.handle = function( e ) { | |
-})(); | |
+ // Discard the second event of a jQuery.event.… | |
+ // when an event is called after a page has un… | |
+ return typeof jQuery !== "undefined" && jQuery… | |
+ jQuery.event.dispatch.apply( elem, arg… | |
+ }; | |
+ } | |
+ // 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… | |
+ if ( !type ) { | |
+ continue; | |
+ } | |
-var runtil = /Until$/, | |
- rparentsprev = /^(?:parents|prevUntil|prevAll)/, | |
- // Note: This RegExp should be improved, or likely pulled from Sizzle | |
- rmultiselector = /,/, | |
- isSimple = /^.[^:#\[\.,]*$/, | |
- slice = Array.prototype.slice, | |
- POS = jQuery.expr.match.globalPOS, | |
- // methods guaranteed to produce a unique set when starting from a uni… | |
- guaranteedUnique = { | |
- children: true, | |
- contents: true, | |
- next: true, | |
- prev: true | |
- }; | |
+ // If event changes its type, use the special event ha… | |
+ special = jQuery.event.special[ type ] || {}; | |
-jQuery.fn.extend({ | |
- find: function( selector ) { | |
- var self = this, | |
- i, l; | |
+ // If selector defined, determine special event api ty… | |
+ type = ( selector ? special.delegateType : special.bin… | |
- 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; | |
- } | |
- } | |
- }); | |
- } | |
+ // 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.ne… | |
+ namespace: namespaces.join( "." ) | |
+ }, handleObjIn ); | |
- var ret = this.pushStack( "", "find", selector ), | |
- length, n, r; | |
+ // Init the event handler queue if we're the first | |
+ if ( !( handlers = events[ type ] ) ) { | |
+ handlers = events[ type ] = []; | |
+ handlers.delegateCount = 0; | |
- for ( i = 0, l = this.length; i < l; i++ ) { | |
- length = ret.length; | |
- jQuery.find( selector, this[i], ret ); | |
+ // Only use addEventListener if the special ev… | |
+ if ( !special.setup || | |
+ special.setup.call( elem, data, namesp… | |
- 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; | |
- } | |
+ if ( elem.addEventListener ) { | |
+ elem.addEventListener( type, e… | |
} | |
} | |
} | |
- } | |
- return ret; | |
- }, | |
+ if ( special.add ) { | |
+ special.add.call( elem, handleObj ); | |
- has: function( target ) { | |
- var targets = jQuery( target ); | |
- return this.filter(function() { | |
- for ( var i = 0, l = targets.length; i < l; i++ ) { | |
- if ( jQuery.contains( this, targets[i] ) ) { | |
- return true; | |
+ if ( !handleObj.handler.guid ) { | |
+ handleObj.handler.guid = handler.guid; | |
} | |
} | |
- }); | |
- }, | |
- not: function( selector ) { | |
- return this.pushStack( winnow(this, selector, false), "not", s… | |
- }, | |
+ // Add to the element's handler list, delegates in fro… | |
+ if ( selector ) { | |
+ handlers.splice( handlers.delegateCount++, 0, … | |
+ } else { | |
+ handlers.push( handleObj ); | |
+ } | |
- filter: function( selector ) { | |
- return this.pushStack( winnow(this, selector, true), "filter",… | |
- }, | |
+ // Keep track of which events have ever been used, for… | |
+ jQuery.event.global[ type ] = true; | |
+ } | |
- is: function( selector ) { | |
- return !!selector && ( | |
- typeof selector === "string" ? | |
- // If this is a positional selector, check mem… | |
- // so $("p:first").is("p:last") won't return t… | |
- POS.test( selector ) ? | |
- jQuery( selector, this.context ).index… | |
- jQuery.filter( selector, this ).length… | |
- this.filter( selector ).length > 0 ); | |
}, | |
- closest: function( selectors, context ) { | |
- var ret = [], i, l, cur = this[0]; | |
+ // Detach an event or set of events from an element | |
+ remove: function( elem, types, handler, selector, mappedTypes ) { | |
- // Array (deprecated as of jQuery 1.7) | |
- if ( jQuery.isArray( selectors ) ) { | |
- var level = 1; | |
+ var j, origCount, tmp, | |
+ events, t, handleObj, | |
+ special, handlers, type, namespaces, origType, | |
+ elemData = dataPriv.hasData( elem ) && dataPriv.get( e… | |
- while ( cur && cur.ownerDocument && cur !== context ) { | |
- for ( i = 0; i < selectors.length; i++ ) { | |
+ if ( !elemData || !( events = elemData.events ) ) { | |
+ return; | |
+ } | |
- if ( jQuery( cur ).is( selectors[ i ] … | |
- ret.push({ selector: selectors… | |
- } | |
- } | |
+ // 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(); | |
- cur = cur.parentNode; | |
- level++; | |
+ // Unbind all events (on this namespace, if provided) … | |
+ if ( !type ) { | |
+ for ( type in events ) { | |
+ jQuery.event.remove( elem, type + type… | |
+ } | |
+ continue; | |
} | |
- return ret; | |
- } | |
- | |
- // String | |
- var pos = POS.test( selectors ) || typeof selectors !== "strin… | |
- jQuery( selectors, context || this.context ) : | |
- 0; | |
+ special = jQuery.event.special[ type ] || {}; | |
+ type = ( selector ? special.delegateType : special.bin… | |
+ handlers = events[ type ] || []; | |
+ tmp = tmp[ 2 ] && | |
+ new RegExp( "(^|\\.)" + namespaces.join( "\\.(… | |
- for ( i = 0, l = this.length; i < l; i++ ) { | |
- cur = this[i]; | |
+ // Remove matching events | |
+ origCount = j = handlers.length; | |
+ while ( j-- ) { | |
+ handleObj = handlers[ j ]; | |
- while ( cur ) { | |
- if ( pos ? pos.index(cur) > -1 : jQuery.find.m… | |
- ret.push( cur ); | |
- break; | |
+ if ( ( mappedTypes || origType === handleObj.o… | |
+ ( !handler || handler.guid === handleO… | |
+ ( !tmp || tmp.test( handleObj.namespac… | |
+ ( !selector || selector === handleObj.… | |
+ selector === "**" && handleObj… | |
+ handlers.splice( j, 1 ); | |
- } else { | |
- cur = cur.parentNode; | |
- if ( !cur || !cur.ownerDocument || cur… | |
- break; | |
+ if ( handleObj.selector ) { | |
+ handlers.delegateCount--; | |
+ } | |
+ if ( special.remove ) { | |
+ special.remove.call( elem, han… | |
} | |
} | |
} | |
- } | |
- | |
- ret = ret.length > 1 ? jQuery.unique( ret ) : ret; | |
- return this.pushStack( ret, "closest", selectors ); | |
- }, | |
+ // Remove generic event handler if we removed somethin… | |
+ // (avoids potential for endless recursion during remo… | |
+ if ( origCount && !handlers.length ) { | |
+ if ( !special.teardown || | |
+ special.teardown.call( elem, namespace… | |
- // Determine the position of an element within | |
- // the matched set of elements | |
- index: function( elem ) { | |
+ jQuery.removeEvent( elem, type, elemDa… | |
+ } | |
- // No argument, return index in parent | |
- if ( !elem ) { | |
- return ( this[0] && this[0].parentNode ) ? this.prevAl… | |
+ delete events[ type ]; | |
+ } | |
} | |
- // index in selector | |
- if ( typeof elem === "string" ) { | |
- return jQuery.inArray( this[0], jQuery( elem ) ); | |
+ // Remove data and the expando if it's no longer used | |
+ if ( jQuery.isEmptyObject( events ) ) { | |
+ dataPriv.remove( elem, "handle events" ); | |
} | |
- | |
- // Locate the position of the desired element | |
- return jQuery.inArray( | |
- // If it receives a jQuery object, the first element i… | |
- elem.jquery ? elem[0] : elem, this ); | |
}, | |
- add: function( selector, context ) { | |
- var set = typeof selector === "string" ? | |
- jQuery( selector, context ) : | |
- jQuery.makeArray( selector && selector.nodeTyp… | |
- all = jQuery.merge( this.get(), set ); | |
- | |
- return this.pushStack( isDisconnected( set[0] ) || isDisconnec… | |
- all : | |
- jQuery.unique( all ) ); | |
- }, | |
+ dispatch: function( nativeEvent ) { | |
- andSelf: function() { | |
- return this.add( this.prevObject ); | |
- } | |
-}); | |
+ // Make a writable jQuery.Event from the native event object | |
+ var event = jQuery.event.fix( nativeEvent ); | |
-// 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; | |
-} | |
+ var i, j, ret, matched, handleObj, handlerQueue, | |
+ args = new Array( arguments.length ), | |
+ handlers = ( dataPriv.get( this, "events" ) || {} )[ e… | |
+ special = jQuery.event.special[ event.type ] || {}; | |
-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 jQuery.nth( elem, 2, "nextSibling" ); | |
- }, | |
- prev: function( elem ) { | |
- return jQuery.nth( elem, 2, "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, e… | |
- }, | |
- children: function( elem ) { | |
- return jQuery.sibling( elem.firstChild ); | |
- }, | |
- contents: function( elem ) { | |
- return jQuery.nodeName( elem, "iframe" ) ? | |
- elem.contentDocument || elem.contentWindow.document : | |
- jQuery.makeArray( elem.childNodes ); | |
- } | |
-}, function( name, fn ) { | |
- jQuery.fn[ name ] = function( until, selector ) { | |
- var ret = jQuery.map( this, fn, until ); | |
+ // Use the fix-ed jQuery.Event rather than the (read-only) nat… | |
+ args[ 0 ] = event; | |
- if ( !runtil.test( name ) ) { | |
- selector = until; | |
+ for ( i = 1; i < arguments.length; i++ ) { | |
+ args[ i ] = arguments[ i ]; | |
} | |
- if ( selector && typeof selector === "string" ) { | |
- ret = jQuery.filter( selector, ret ); | |
+ event.delegateTarget = this; | |
+ | |
+ // Call the preDispatch hook for the mapped type, and let it b… | |
+ if ( special.preDispatch && special.preDispatch.call( this, ev… | |
+ return; | |
} | |
- ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.un… | |
+ // Determine handlers | |
+ handlerQueue = jQuery.event.handlers.call( this, event, handle… | |
- if ( (this.length > 1 || rmultiselector.test( selector )) && r… | |
- ret = ret.reverse(); | |
- } | |
+ // Run delegates first; they may want to stop propagation bene… | |
+ i = 0; | |
+ while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagat… | |
+ event.currentTarget = matched.elem; | |
- return this.pushStack( ret, name, slice.call( arguments ).join… | |
- }; | |
-}); | |
+ j = 0; | |
+ while ( ( handleObj = matched.handlers[ j++ ] ) && | |
+ !event.isImmediatePropagationStopped() ) { | |
-jQuery.extend({ | |
- filter: function( expr, elems, not ) { | |
- if ( not ) { | |
- expr = ":not(" + expr + ")"; | |
- } | |
+ // Triggered event must either 1) have no name… | |
+ // a subset or equal to those in the bound eve… | |
+ if ( !event.rnamespace || event.rnamespace.tes… | |
- return elems.length === 1 ? | |
- jQuery.find.matchesSelector(elems[0], expr) ? [ elems[… | |
- jQuery.find.matches(expr, elems); | |
- }, | |
+ event.handleObj = handleObj; | |
+ event.data = handleObj.data; | |
- dir: function( elem, dir, until ) { | |
- var matched = [], | |
- cur = elem[ dir ]; | |
+ ret = ( ( jQuery.event.special[ handle… | |
+ handleObj.handler ).apply( mat… | |
- while ( cur && cur.nodeType !== 9 && (until === undefined || c… | |
- if ( cur.nodeType === 1 ) { | |
- matched.push( cur ); | |
+ if ( ret !== undefined ) { | |
+ if ( ( event.result = ret ) ==… | |
+ event.preventDefault(); | |
+ event.stopPropagation(… | |
+ } | |
+ } | |
+ } | |
} | |
- cur = cur[dir]; | |
} | |
- return matched; | |
- }, | |
- | |
- nth: function( cur, result, dir, elem ) { | |
- result = result || 1; | |
- var num = 0; | |
- for ( ; cur; cur = cur[dir] ) { | |
- if ( cur.nodeType === 1 && ++num === result ) { | |
- break; | |
- } | |
+ // Call the postDispatch hook for the mapped type | |
+ if ( special.postDispatch ) { | |
+ special.postDispatch.call( this, event ); | |
} | |
- return cur; | |
+ return event.result; | |
}, | |
- sibling: function( n, elem ) { | |
- var r = []; | |
- | |
- for ( ; n; n = n.nextSibling ) { | |
- if ( n.nodeType === 1 && n !== elem ) { | |
- r.push( n ); | |
- } | |
- } | |
+ handlers: function( event, handlers ) { | |
+ var i, handleObj, sel, matchedHandlers, matchedSelectors, | |
+ handlerQueue = [], | |
+ delegateCount = handlers.delegateCount, | |
+ cur = event.target; | |
- return r; | |
- } | |
-}); | |
+ // Find delegate handlers | |
+ if ( delegateCount && | |
-// Implement the identical functionality for filter and not | |
-function winnow( elements, qualifier, keep ) { | |
+ // Support: IE <=9 | |
+ // Black-hole SVG <use> instance trees (trac-13180) | |
+ cur.nodeType && | |
- // Can't pass null or undefined to indexOf in Firefox 4 | |
- // Set to 0 to skip string check | |
- qualifier = qualifier || 0; | |
+ // Support: Firefox <=42 | |
+ // Suppress spec-violating clicks indicating a non-pri… | |
+ // https://www.w3.org/TR/DOM-Level-3-Events/#event-typ… | |
+ // Support: IE 11 only | |
+ // ...but not arrow key "clicks" of radio inputs, whic… | |
+ !( event.type === "click" && event.button >= 1 ) ) { | |
- if ( jQuery.isFunction( qualifier ) ) { | |
- return jQuery.grep(elements, function( elem, i ) { | |
- var retVal = !!qualifier.call( elem, i, elem ); | |
- return retVal === keep; | |
- }); | |
+ for ( ; cur !== this; cur = cur.parentNode || this ) { | |
- } else if ( qualifier.nodeType ) { | |
- return jQuery.grep(elements, function( elem, i ) { | |
- return ( elem === qualifier ) === keep; | |
- }); | |
+ // Don't check non-elements (#13208) | |
+ // Don't process clicks on disabled elements (… | |
+ if ( cur.nodeType === 1 && !( event.type === "… | |
+ matchedHandlers = []; | |
+ matchedSelectors = {}; | |
+ for ( i = 0; i < delegateCount; i++ ) { | |
+ handleObj = handlers[ i ]; | |
- } else if ( typeof qualifier === "string" ) { | |
- var filtered = jQuery.grep(elements, function( elem ) { | |
- return elem.nodeType === 1; | |
- }); | |
+ // Don't conflict with Object.… | |
+ sel = handleObj.selector + " "; | |
- if ( isSimple.test( qualifier ) ) { | |
- return jQuery.filter(qualifier, filtered, !keep); | |
- } else { | |
- qualifier = jQuery.filter( qualifier, filtered ); | |
+ if ( matchedSelectors[ sel ] =… | |
+ matchedSelectors[ sel … | |
+ jQuery( sel, t… | |
+ jQuery.find( s… | |
+ } | |
+ if ( matchedSelectors[ sel ] )… | |
+ matchedHandlers.push( … | |
+ } | |
+ } | |
+ if ( matchedHandlers.length ) { | |
+ handlerQueue.push( { elem: cur… | |
+ } | |
+ } | |
+ } | |
} | |
- } | |
- | |
- return jQuery.grep(elements, function( elem, i ) { | |
- return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; | |
- }); | |
-} | |
+ // Add the remaining (directly-bound) handlers | |
+ cur = this; | |
+ if ( delegateCount < handlers.length ) { | |
+ handlerQueue.push( { elem: cur, handlers: handlers.sli… | |
+ } | |
+ return handlerQueue; | |
+ }, | |
+ addProp: function( name, hook ) { | |
+ Object.defineProperty( jQuery.Event.prototype, name, { | |
+ enumerable: true, | |
+ configurable: true, | |
-function createSafeFragment( document ) { | |
- var list = nodeNames.split( "|" ), | |
- safeFrag = document.createDocumentFragment(); | |
+ get: jQuery.isFunction( hook ) ? | |
+ function() { | |
+ if ( this.originalEvent ) { | |
+ return hook( this.orig… | |
+ } | |
+ } : | |
+ function() { | |
+ if ( this.originalEvent ) { | |
+ return this.originalEv… | |
+ } | |
+ }, | |
- if ( safeFrag.createElement ) { | |
- while ( list.length ) { | |
- safeFrag.createElement( | |
- list.pop() | |
- ); | |
- } | |
- } | |
- return safeFrag; | |
-} | |
+ set: function( value ) { | |
+ Object.defineProperty( this, name, { | |
+ enumerable: true, | |
+ configurable: true, | |
+ writable: true, | |
+ value: value | |
+ } ); | |
+ } | |
+ } ); | |
+ }, | |
-var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|fig… | |
- "header|hgroup|mark|meter|nav|output|progress|section|summary|… | |
- rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, | |
- rleadingWhitespace = /^\s+/, | |
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:… | |
- rtagName = /<([\w:]+)/, | |
- rtbody = /<tbody/i, | |
- rhtml = /<|&#?\w+;/, | |
- rnoInnerhtml = /<(?:script|style)/i, | |
- rnocache = /<(?:script|object|embed|option|style)/i, | |
- rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), | |
- // checked="checked" or checked | |
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
- rscriptType = /\/(java|ecma)script/i, | |
- rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/, | |
- 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></ta… | |
- area: [ 1, "<map>", "</map>" ], | |
- _default: [ 0, "", "" ] | |
- }, | |
- safeFragment = createSafeFragment( document ); | |
+ fix: function( originalEvent ) { | |
+ return originalEvent[ jQuery.expando ] ? | |
+ originalEvent : | |
+ new jQuery.Event( originalEvent ); | |
+ }, | |
-wrapMap.optgroup = wrapMap.option; | |
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.t… | |
-wrapMap.th = wrapMap.td; | |
+ special: { | |
+ load: { | |
-// IE can't serialize <link> and <script> tags normally | |
-if ( !jQuery.support.htmlSerialize ) { | |
- wrapMap._default = [ 1, "div<div>", "</div>" ]; | |
-} | |
+ // Prevent triggered image.load events from bubbling t… | |
+ noBubble: true | |
+ }, | |
+ focus: { | |
-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].owne… | |
- }, null, value, arguments.length ); | |
- }, | |
- | |
- wrapAll: function( html ) { | |
- if ( jQuery.isFunction( html ) ) { | |
- return this.each(function(i) { | |
- jQuery(this).wrapAll( html.call(this, i) ); | |
- }); | |
- } | |
+ // Fire native event if possible so blur/focus sequenc… | |
+ trigger: function() { | |
+ if ( this !== safeActiveElement() && this.focu… | |
+ this.focus(); | |
+ return false; | |
+ } | |
+ }, | |
+ delegateType: "focusin" | |
+ }, | |
+ blur: { | |
+ trigger: function() { | |
+ if ( this === safeActiveElement() && this.blur… | |
+ this.blur(); | |
+ return false; | |
+ } | |
+ }, | |
+ delegateType: "focusout" | |
+ }, | |
+ click: { | |
- if ( this[0] ) { | |
- // The elements to wrap the target around | |
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0)… | |
+ // For checkbox, fire native event so checked state wi… | |
+ trigger: function() { | |
+ if ( this.type === "checkbox" && this.click &&… | |
+ this.click(); | |
+ return false; | |
+ } | |
+ }, | |
- if ( this[0].parentNode ) { | |
- wrap.insertBefore( this[0] ); | |
+ // For cross-browser consistency, don't fire native .c… | |
+ _default: function( event ) { | |
+ return jQuery.nodeName( event.target, "a" ); | |
} | |
+ }, | |
- wrap.map(function() { | |
- var elem = this; | |
+ beforeunload: { | |
+ postDispatch: function( event ) { | |
- while ( elem.firstChild && elem.firstChild.nod… | |
- elem = elem.firstChild; | |
+ // Support: Firefox 20+ | |
+ // Firefox doesn't alert if the returnValue fi… | |
+ if ( event.result !== undefined && event.origi… | |
+ event.originalEvent.returnValue = even… | |
} | |
- | |
- return elem; | |
- }).append( this ); | |
+ } | |
} | |
+ } | |
+}; | |
- return this; | |
- }, | |
+jQuery.removeEvent = function( elem, type, handle ) { | |
- wrapInner: function( html ) { | |
- if ( jQuery.isFunction( html ) ) { | |
- return this.each(function(i) { | |
- jQuery(this).wrapInner( html.call(this, i) ); | |
- }); | |
- } | |
+ // This "if" is needed for plain objects | |
+ if ( elem.removeEventListener ) { | |
+ elem.removeEventListener( type, handle ); | |
+ } | |
+}; | |
- return this.each(function() { | |
- var self = jQuery( this ), | |
- contents = self.contents(); | |
+jQuery.Event = function( src, props ) { | |
- if ( contents.length ) { | |
- contents.wrapAll( html ); | |
+ // Allow instantiation without the 'new' keyword | |
+ if ( !( this instanceof jQuery.Event ) ) { | |
+ return new jQuery.Event( src, props ); | |
+ } | |
- } else { | |
- self.append( html ); | |
- } | |
- }); | |
- }, | |
+ // Event object | |
+ if ( src && src.type ) { | |
+ this.originalEvent = src; | |
+ this.type = src.type; | |
- wrap: function( html ) { | |
- var isFunction = jQuery.isFunction( html ); | |
+ // Events bubbling up the document may have been marked as pre… | |
+ // by a handler lower down the tree; reflect the correct value. | |
+ this.isDefaultPrevented = src.defaultPrevented || | |
+ src.defaultPrevented === undefined && | |
- return this.each(function(i) { | |
- jQuery( this ).wrapAll( isFunction ? html.call(this, i… | |
- }); | |
- }, | |
+ // Support: Android <=2.3 only | |
+ src.returnValue === false ? | |
+ returnTrue : | |
+ returnFalse; | |
- unwrap: function() { | |
- return this.parent().each(function() { | |
- if ( !jQuery.nodeName( this, "body" ) ) { | |
- jQuery( this ).replaceWith( this.childNodes ); | |
- } | |
- }).end(); | |
- }, | |
+ // 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; | |
- append: function() { | |
- return this.domManip(arguments, true, function( elem ) { | |
- if ( this.nodeType === 1 ) { | |
- this.appendChild( elem ); | |
- } | |
- }); | |
- }, | |
+ this.currentTarget = src.currentTarget; | |
+ this.relatedTarget = src.relatedTarget; | |
- prepend: function() { | |
- return this.domManip(arguments, true, function( elem ) { | |
- if ( this.nodeType === 1 ) { | |
- this.insertBefore( elem, this.firstChild ); | |
- } | |
- }); | |
- }, | |
+ // Event type | |
+ } else { | |
+ this.type = src; | |
+ } | |
- before: function() { | |
- if ( this[0] && this[0].parentNode ) { | |
- return this.domManip(arguments, false, function( elem … | |
- this.parentNode.insertBefore( elem, this ); | |
- }); | |
- } else if ( arguments.length ) { | |
- var set = jQuery.clean( arguments ); | |
- set.push.apply( set, this.toArray() ); | |
- return this.pushStack( set, "before", arguments ); | |
- } | |
- }, | |
+ // Put explicitly provided properties onto the event object | |
+ if ( props ) { | |
+ jQuery.extend( this, props ); | |
+ } | |
- after: function() { | |
- if ( this[0] && this[0].parentNode ) { | |
- return this.domManip(arguments, false, function( elem … | |
- this.parentNode.insertBefore( elem, this.nextS… | |
- }); | |
- } else if ( arguments.length ) { | |
- var set = this.pushStack( this, "after", arguments ); | |
- set.push.apply( set, jQuery.clean(arguments) ); | |
- return set; | |
- } | |
- }, | |
+ // Create a timestamp if incoming event doesn't have one | |
+ this.timeStamp = src && src.timeStamp || jQuery.now(); | |
- // keepData is for internal use only--do not document | |
- remove: function( selector, keepData ) { | |
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { | |
- if ( !selector || jQuery.filter( selector, [ elem ] ).… | |
- if ( !keepData && elem.nodeType === 1 ) { | |
- jQuery.cleanData( elem.getElementsByTa… | |
- jQuery.cleanData( [ elem ] ); | |
- } | |
+ // Mark it as fixed | |
+ this[ jQuery.expando ] = true; | |
+}; | |
- if ( elem.parentNode ) { | |
- elem.parentNode.removeChild( elem ); | |
- } | |
- } | |
- } | |
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Languag… | |
+// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-bindi… | |
+jQuery.Event.prototype = { | |
+ constructor: jQuery.Event, | |
+ isDefaultPrevented: returnFalse, | |
+ isPropagationStopped: returnFalse, | |
+ isImmediatePropagationStopped: returnFalse, | |
+ isSimulated: false, | |
- return this; | |
- }, | |
+ preventDefault: function() { | |
+ var e = this.originalEvent; | |
- empty: function() { | |
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { | |
- // Remove element nodes and prevent memory leaks | |
- if ( elem.nodeType === 1 ) { | |
- jQuery.cleanData( elem.getElementsByTagName("*… | |
- } | |
+ this.isDefaultPrevented = returnTrue; | |
- // Remove any remaining nodes | |
- while ( elem.firstChild ) { | |
- elem.removeChild( elem.firstChild ); | |
- } | |
+ if ( e && !this.isSimulated ) { | |
+ e.preventDefault(); | |
} | |
- | |
- return this; | |
}, | |
+ stopPropagation: function() { | |
+ var e = this.originalEvent; | |
- clone: function( dataAndEvents, deepDataAndEvents ) { | |
- dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents … | |
+ this.isPropagationStopped = returnTrue; | |
- return this.map( function () { | |
- return jQuery.clone( this, dataAndEvents, deepDataAndE… | |
- }); | |
+ if ( e && !this.isSimulated ) { | |
+ e.stopPropagation(); | |
+ } | |
}, | |
+ stopImmediatePropagation: function() { | |
+ var e = this.originalEvent; | |
- html: function( value ) { | |
- return jQuery.access( this, function( value ) { | |
- var elem = this[0] || {}, | |
- i = 0, | |
- l = this.length; | |
+ this.isImmediatePropagationStopped = returnTrue; | |
- if ( value === undefined ) { | |
- return elem.nodeType === 1 ? | |
- elem.innerHTML.replace( rinlinejQuery,… | |
- null; | |
- } | |
+ if ( e && !this.isSimulated ) { | |
+ e.stopImmediatePropagation(); | |
+ } | |
+ this.stopPropagation(); | |
+ } | |
+}; | |
- if ( typeof value === "string" && !rnoInnerhtml.test( … | |
- ( jQuery.support.leadingWhitespace || !rleadin… | |
- !wrapMap[ ( rtagName.exec( value ) || ["", ""]… | |
+// Includes all common event props including KeyEvent and MouseEvent specific … | |
+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, | |
+ 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… | |
+ } | |
+ | |
+ // Add which for click: 1 === left; 2 === middle; 3 === right | |
+ if ( !event.which && button !== undefined && rmouseEvent.test(… | |
+ if ( button & 1 ) { | |
+ return 1; | |
+ } | |
+ | |
+ if ( button & 2 ) { | |
+ return 3; | |
+ } | |
+ | |
+ if ( button & 4 ) { | |
+ return 2; | |
+ } | |
- value = value.replace( rxhtmlTag, "<$1></$2>" … | |
+ return 0; | |
+ } | |
- try { | |
- for (; i < l; i++ ) { | |
- // Remove element nodes and pr… | |
- elem = this[i] || {}; | |
- if ( elem.nodeType === 1 ) { | |
- jQuery.cleanData( elem… | |
- elem.innerHTML = value; | |
- } | |
- } | |
+ return event.which; | |
+ } | |
+}, jQuery.event.addProp ); | |
- elem = 0; | |
+// 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, | |
- // If using innerHTML throws an exception, use… | |
- } catch(e) {} | |
- } | |
+ handle: function( event ) { | |
+ var ret, | |
+ target = this, | |
+ related = event.relatedTarget, | |
+ handleObj = event.handleObj; | |
- if ( elem ) { | |
- this.empty().append( value ); | |
+ // For mouseenter/leave call the handler if related is… | |
+ // NB: No relatedTarget if the mouse left/entered the … | |
+ if ( !related || ( related !== target && !jQuery.conta… | |
+ event.type = handleObj.origType; | |
+ ret = handleObj.handler.apply( this, arguments… | |
+ event.type = fix; | |
} | |
- }, null, value, arguments.length ); | |
- }, | |
+ return ret; | |
+ } | |
+ }; | |
+} ); | |
- replaceWith: function( value ) { | |
- if ( this[0] && this[0].parentNode ) { | |
- // Make sure that the elements are removed from the DO… | |
- // this can help fix replacing a parent with child ele… | |
- if ( jQuery.isFunction( value ) ) { | |
- return this.each(function(i) { | |
- var self = jQuery(this), old = self.ht… | |
- self.replaceWith( value.call( this, i,… | |
- }); | |
- } | |
+jQuery.fn.extend( { | |
- if ( typeof value !== "string" ) { | |
- value = jQuery( value ).detach(); | |
- } | |
+ 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 ) { | |
- return this.each(function() { | |
- var next = this.nextSibling, | |
- parent = this.parentNode; | |
+ // ( event ) dispatched jQuery.Event | |
+ handleObj = types.handleObj; | |
+ jQuery( types.delegateTarget ).off( | |
+ handleObj.namespace ? | |
+ handleObj.origType + "." + handleObj.n… | |
+ handleObj.origType, | |
+ handleObj.selector, | |
+ handleObj.handler | |
+ ); | |
+ return this; | |
+ } | |
+ if ( typeof types === "object" ) { | |
- jQuery( this ).remove(); | |
+ // ( types-object [, selector] ) | |
+ for ( type in types ) { | |
+ this.off( type, selector, types[ type ] ); | |
+ } | |
+ return this; | |
+ } | |
+ if ( selector === false || typeof selector === "function" ) { | |
- if ( next ) { | |
- jQuery(next).before( value ); | |
- } else { | |
- jQuery(parent).append( value ); | |
- } | |
- }); | |
- } else { | |
- return this.length ? | |
- this.pushStack( jQuery(jQuery.isFunction(value… | |
- this; | |
+ // ( types [, fn] ) | |
+ fn = selector; | |
+ selector = undefined; | |
} | |
- }, | |
+ if ( fn === false ) { | |
+ fn = returnFalse; | |
+ } | |
+ return this.each( function() { | |
+ jQuery.event.remove( this, types, fn, selector ); | |
+ } ); | |
+ } | |
+} ); | |
- detach: function( selector ) { | |
- return this.remove( selector, true ); | |
- }, | |
- domManip: function( args, table, callback ) { | |
- var results, first, fragment, parent, | |
- value = args[0], | |
- scripts = []; | |
+var | |
- // We can't cloneNode fragments that contain checked, in WebKit | |
- if ( !jQuery.support.checkClone && arguments.length === 3 && t… | |
- return this.each(function() { | |
- jQuery(this).domManip( args, table, callback, … | |
- }); | |
- } | |
+ /* eslint-disable max-len */ | |
- if ( jQuery.isFunction(value) ) { | |
- return this.each(function(i) { | |
- var self = jQuery(this); | |
- args[0] = value.call(this, i, table ? self.htm… | |
- self.domManip( args, table, callback ); | |
- }); | |
- } | |
+ // See https://github.com/eslint/eslint/issues/3229 | |
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z… | |
- if ( this[0] ) { | |
- parent = value && value.parentNode; | |
+ /* eslint-enable */ | |
- // If we're in a fragment, just use that instead of bu… | |
- if ( jQuery.support.parentNode && parent && parent.nod… | |
- results = { fragment: parent }; | |
+ // Support: IE <=10 - 11, Edge 12 - 13 | |
+ // In IE/Edge using regex groups here causes severe slowdowns. | |
+ // See https://connect.microsoft.com/IE/feedback/details/1736512/ | |
+ rnoInnerhtml = /<script|<style|<link/i, | |
- } else { | |
- results = jQuery.buildFragment( args, this, sc… | |
- } | |
+ // checked="checked" or checked | |
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
+ rscriptTypeMasked = /^true\/(.*)/, | |
+ rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; | |
- fragment = results.fragment; | |
+function manipulationTarget( elem, content ) { | |
+ if ( jQuery.nodeName( elem, "table" ) && | |
+ jQuery.nodeName( content.nodeType !== 11 ? content : content.f… | |
- if ( fragment.childNodes.length === 1 ) { | |
- first = fragment = fragment.firstChild; | |
- } else { | |
- first = fragment.firstChild; | |
- } | |
- | |
- if ( first ) { | |
- table = table && jQuery.nodeName( first, "tr" … | |
- | |
- for ( var i = 0, l = this.length, lastIndex = … | |
- callback.call( | |
- table ? | |
- root(this[i], first) : | |
- this[i], | |
- // Make sure that we do not le… | |
- // the original fragment (whic… | |
- // using it; in addition, use … | |
- // item instead of first becau… | |
- // in certain situations (Bug … | |
- // Fragments from the fragment… | |
- // in place. | |
- results.cacheable || ( l > 1 &… | |
- jQuery.clone( fragment… | |
- fragment | |
- ); | |
- } | |
- } | |
+ return elem.getElementsByTagName( "tbody" )[ 0 ] || elem; | |
+ } | |
- if ( scripts.length ) { | |
- jQuery.each( scripts, function( i, elem ) { | |
- if ( elem.src ) { | |
- jQuery.ajax({ | |
- type: "GET", | |
- global: false, | |
- url: elem.src, | |
- async: false, | |
- dataType: "script" | |
- }); | |
- } else { | |
- jQuery.globalEval( ( elem.text… | |
- } | |
+ return elem; | |
+} | |
- if ( elem.parentNode ) { | |
- elem.parentNode.removeChild( e… | |
- } | |
- }); | |
- } | |
- } | |
+// Replace/restore the type attribute of script elements for safe DOM manipula… | |
+function disableScript( elem ) { | |
+ elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; | |
+ return elem; | |
+} | |
+function restoreScript( elem ) { | |
+ var match = rscriptTypeMasked.exec( elem.type ); | |
- return this; | |
+ if ( match ) { | |
+ elem.type = match[ 1 ]; | |
+ } else { | |
+ elem.removeAttribute( "type" ); | |
} | |
-}); | |
-function root( elem, cur ) { | |
- return jQuery.nodeName(elem, "table") ? | |
- (elem.getElementsByTagName("tbody")[0] || | |
- elem.appendChild(elem.ownerDocument.createElement("tbody"))) : | |
- elem; | |
+ return elem; | |
} | |
function cloneCopyEvent( src, dest ) { | |
+ var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; | |
- if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { | |
+ if ( dest.nodeType !== 1 ) { | |
return; | |
} | |
- var type, i, l, | |
- oldData = jQuery._data( src ), | |
- curData = jQuery._data( dest, oldData ), | |
- events = oldData.events; | |
+ // 1. Copy private data: events, handlers, etc. | |
+ if ( dataPriv.hasData( src ) ) { | |
+ pdataOld = dataPriv.access( src ); | |
+ pdataCur = dataPriv.set( dest, pdataOld ); | |
+ events = pdataOld.events; | |
- if ( events ) { | |
- delete curData.handle; | |
- curData.events = {}; | |
+ if ( events ) { | |
+ delete pdataCur.handle; | |
+ pdataCur.events = {}; | |
- for ( type in events ) { | |
- for ( i = 0, l = events[ type ].length; i < l; i++ ) { | |
- jQuery.event.add( dest, type, events[ type ][ … | |
+ for ( type in events ) { | |
+ for ( i = 0, l = events[ type ].length; i < l;… | |
+ jQuery.event.add( dest, type, events[ … | |
+ } | |
} | |
} | |
} | |
- // make the cloned public data object a copy from the original | |
- if ( curData.data ) { | |
- curData.data = jQuery.extend( {}, curData.data ); | |
+ // 2. Copy user data | |
+ if ( dataUser.hasData( src ) ) { | |
+ udataOld = dataUser.access( src ); | |
+ udataCur = jQuery.extend( {}, udataOld ); | |
+ | |
+ dataUser.set( dest, udataCur ); | |
} | |
} | |
-function cloneFixAttributes( src, dest ) { | |
- var nodeName; | |
+// Fix IE bugs, see support tests | |
+function fixInput( src, dest ) { | |
+ var nodeName = dest.nodeName.toLowerCase(); | |
- // We do not need to do anything for non-Elements | |
- if ( dest.nodeType !== 1 ) { | |
- return; | |
- } | |
+ // Fails to persist the checked state of a cloned checkbox or radio bu… | |
+ if ( nodeName === "input" && rcheckableType.test( src.type ) ) { | |
+ dest.checked = src.checked; | |
- // clearAttributes removes the attributes, which we don't want, | |
- // but also removes the attachEvent events, which we *do* want | |
- if ( dest.clearAttributes ) { | |
- dest.clearAttributes(); | |
+ // Fails to return the selected option to the default selected state w… | |
+ } else if ( nodeName === "input" || nodeName === "textarea" ) { | |
+ dest.defaultValue = src.defaultValue; | |
} | |
+} | |
- // mergeAttributes, in contrast, only merges back on the | |
- // original attributes, not the events | |
- if ( dest.mergeAttributes ) { | |
- dest.mergeAttributes( src ); | |
- } | |
+function domManip( collection, args, callback, ignored ) { | |
- nodeName = dest.nodeName.toLowerCase(); | |
+ // Flatten any nested arrays | |
+ args = concat.apply( [], args ); | |
- // IE6-8 fail to clone children inside object elements that use | |
- // the proprietary classid attribute value (rather than the type | |
- // attribute) to identify the type of content to display | |
- if ( nodeName === "object" ) { | |
- dest.outerHTML = src.outerHTML; | |
+ var fragment, first, scripts, hasScripts, node, doc, | |
+ i = 0, | |
+ l = collection.length, | |
+ iNoClone = l - 1, | |
+ value = args[ 0 ], | |
+ isFunction = jQuery.isFunction( value ); | |
- } else if ( nodeName === "input" && (src.type === "checkbox" || src.ty… | |
- // IE6-8 fails to persist the checked state of a cloned checkb… | |
- // or radio button. Worse, IE6-7 fail to give the cloned eleme… | |
- // a checked appearance if the defaultChecked value isn't also… | |
- if ( src.checked ) { | |
- dest.defaultChecked = dest.checked = src.checked; | |
- } | |
+ // 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 ); | |
+ } ); | |
+ } | |
- // 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; | |
+ if ( l ) { | |
+ fragment = buildFragment( args, collection[ 0 ].ownerDocument,… | |
+ first = fragment.firstChild; | |
+ | |
+ if ( fragment.childNodes.length === 1 ) { | |
+ fragment = first; | |
} | |
- // IE6-8 fails to return the selected option to the default selected | |
- // state when cloning options | |
- } else if ( nodeName === "option" ) { | |
- dest.selected = src.defaultSelected; | |
+ // Require either new content or an interest in ignored elemen… | |
+ if ( first || ignored ) { | |
+ scripts = jQuery.map( getAll( fragment, "script" ), di… | |
+ hasScripts = scripts.length; | |
- // 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; | |
+ // Use the original fragment for the last item | |
+ // instead of the first because it can end up | |
+ // being emptied incorrectly in certain situations (#8… | |
+ for ( ; i < l; i++ ) { | |
+ node = fragment; | |
- // IE blanks contents when cloning scripts | |
- } else if ( nodeName === "script" && dest.text !== src.text ) { | |
- dest.text = src.text; | |
- } | |
+ if ( i !== iNoClone ) { | |
+ node = jQuery.clone( node, true, true … | |
- // Event data gets referenced instead of copied if the expando | |
- // gets copied too | |
- dest.removeAttribute( jQuery.expando ); | |
+ // Keep references to cloned scripts f… | |
+ if ( hasScripts ) { | |
- // Clear flags for bubbling special change/submit events, they must | |
- // be reattached when the newly cloned events are first activated | |
- dest.removeAttribute( "_submit_attached" ); | |
- dest.removeAttribute( "_change_attached" ); | |
-} | |
+ // Support: Android <=4.0 only… | |
+ // push.apply(_, arraylike) th… | |
+ jQuery.merge( scripts, getAll(… | |
+ } | |
+ } | |
-jQuery.buildFragment = function( args, nodes, scripts ) { | |
- var fragment, cacheable, cacheresults, doc, | |
- first = args[ 0 ]; | |
+ callback.call( collection[ i ], node, i ); | |
+ } | |
- // nodes may contain either an explicit document object, | |
- // a jQuery collection or context object. | |
- // If nodes[0] contains a valid object to assign to doc | |
- if ( nodes && nodes[0] ) { | |
- doc = nodes[0].ownerDocument || nodes[0]; | |
- } | |
+ if ( hasScripts ) { | |
+ doc = scripts[ scripts.length - 1 ].ownerDocum… | |
- // Ensure that an attr object doesn't incorrectly stand in as a docume… | |
- // Chrome and Firefox seem to allow this to occur and will throw excep… | |
- // Fixes #8950 | |
- if ( !doc.createDocumentFragment ) { | |
- doc = document; | |
- } | |
+ // Reenable scripts | |
+ jQuery.map( scripts, restoreScript ); | |
- // Only cache "small" (1/2 KB) HTML strings that are associated with t… | |
- // 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… | |
- // Also, WebKit does not clone 'checked' attributes on cloneNode, so d… | |
- // Lastly, IE6,7,8 will not correctly reuse cached fragments that were… | |
- if ( args.length === 1 && typeof first === "string" && first.length < … | |
- first.charAt(0) === "<" && !rnocache.test( first ) && | |
- (jQuery.support.checkClone || !rchecked.test( first )) && | |
- (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { | |
+ // Evaluate executable scripts on first docume… | |
+ for ( i = 0; i < hasScripts; i++ ) { | |
+ node = scripts[ i ]; | |
+ if ( rscriptType.test( node.type || ""… | |
+ !dataPriv.access( node, "globa… | |
+ jQuery.contains( doc, node ) )… | |
- cacheable = true; | |
+ if ( node.src ) { | |
- cacheresults = jQuery.fragments[ first ]; | |
- if ( cacheresults && cacheresults !== 1 ) { | |
- fragment = cacheresults; | |
+ // Optional AJAX depen… | |
+ if ( jQuery._evalUrl )… | |
+ jQuery._evalUr… | |
+ } | |
+ } else { | |
+ DOMEval( node.textCont… | |
+ } | |
+ } | |
+ } | |
+ } | |
} | |
} | |
- if ( !fragment ) { | |
- fragment = doc.createDocumentFragment(); | |
- jQuery.clean( args, doc, fragment, scripts ); | |
- } | |
- | |
- if ( cacheable ) { | |
- jQuery.fragments[ first ] = cacheresults ? fragment : 1; | |
- } | |
- | |
- return { fragment: fragment, cacheable: cacheable }; | |
-}; | |
- | |
-jQuery.fragments = {}; | |
+ return collection; | |
+} | |
-jQuery.each({ | |
- appendTo: "append", | |
- prependTo: "prepend", | |
- insertBefore: "before", | |
- insertAfter: "after", | |
- replaceAll: "replaceWith" | |
-}, function( name, original ) { | |
- jQuery.fn[ name ] = function( selector ) { | |
- var ret = [], | |
- insert = jQuery( selector ), | |
- parent = this.length === 1 && this[0].parentNode; | |
+function remove( elem, selector, keepData ) { | |
+ var node, | |
+ nodes = selector ? jQuery.filter( selector, elem ) : elem, | |
+ i = 0; | |
- if ( parent && parent.nodeType === 11 && parent.childNodes.len… | |
- insert[ original ]( this[0] ); | |
- return this; | |
+ for ( ; ( node = nodes[ i ] ) != null; i++ ) { | |
+ if ( !keepData && node.nodeType === 1 ) { | |
+ jQuery.cleanData( getAll( node ) ); | |
+ } | |
- } else { | |
- for ( var i = 0, l = insert.length; i < l; i++ ) { | |
- var elems = ( i > 0 ? this.clone(true) : this … | |
- jQuery( insert[i] )[ original ]( elems ); | |
- ret = ret.concat( elems ); | |
+ if ( node.parentNode ) { | |
+ if ( keepData && jQuery.contains( node.ownerDocument, … | |
+ setGlobalEval( getAll( node, "script" ) ); | |
} | |
- | |
- return this.pushStack( ret, name, insert.selector ); | |
+ node.parentNode.removeChild( node ); | |
} | |
- }; | |
-}); | |
- | |
-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 ( elem.type === "checkbox" || elem.type === "radio" ) { | |
- elem.defaultChecked = elem.checked; | |
- } | |
-} | |
-// Finds all inputs and passes them to fixDefaultChecked | |
-function findInputs( elem ) { | |
- var nodeName = ( elem.nodeName || "" ).toLowerCase(); | |
- if ( nodeName === "input" ) { | |
- fixDefaultChecked( elem ); | |
- // Skip scripts, get other children | |
- } else if ( nodeName !== "script" && typeof elem.getElementsByTagName … | |
- jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChe… | |
- } | |
+ return elem; | |
} | |
-// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js | |
-function shimCloneNode( elem ) { | |
- var div = document.createElement( "div" ); | |
- safeFragment.appendChild( div ); | |
- | |
- div.innerHTML = elem.outerHTML; | |
- return div.firstChild; | |
-} | |
+jQuery.extend( { | |
+ htmlPrefilter: function( html ) { | |
+ return html.replace( rxhtmlTag, "<$1></$2>" ); | |
+ }, | |
-jQuery.extend({ | |
clone: function( elem, dataAndEvents, deepDataAndEvents ) { | |
- var srcElements, | |
- destElements, | |
- i, | |
- // IE<=8 does not properly clone detached, unknown ele… | |
- clone = jQuery.support.html5Clone || jQuery.isXMLDoc(e… | |
- elem.cloneNode( true ) : | |
- shimCloneNode( elem ); | |
- | |
- if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneC… | |
- (elem.nodeType === 1 || elem.nodeType === 11) … | |
- // IE copies events bound via attachEvent when using c… | |
- // Calling detachEvent on the clone will also remove t… | |
- // from the original. In order to get around this, we … | |
- // proprietary methods to clear the events. Thanks to … | |
- // guys for this hotness. | |
- | |
- cloneFixAttributes( elem, clone ); | |
- | |
- // Using Sizzle here is crazy slow, so we use getEleme… | |
- srcElements = getAll( elem ); | |
+ var i, l, srcElements, destElements, | |
+ clone = elem.cloneNode( true ), | |
+ inPage = jQuery.contains( elem.ownerDocument, elem ); | |
+ | |
+ // Fix IE cloning issues | |
+ if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.… | |
+ !jQuery.isXMLDoc( elem ) ) { | |
+ | |
+ // We eschew Sizzle here for performance reasons: http… | |
destElements = getAll( clone ); | |
+ srcElements = getAll( elem ); | |
- // Weird iteration because IE will replace the length … | |
- // with an element if you are cloning the body and one… | |
- // elements on the page has a name or id of "length" | |
- for ( i = 0; srcElements[i]; ++i ) { | |
- // Ensure that the destination node is not nul… | |
- if ( destElements[i] ) { | |
- cloneFixAttributes( srcElements[i], de… | |
- } | |
+ 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 ) { | |
- cloneCopyEvent( elem, clone ); | |
- | |
if ( deepDataAndEvents ) { | |
- srcElements = getAll( elem ); | |
- destElements = getAll( clone ); | |
+ srcElements = srcElements || getAll( elem ); | |
+ destElements = destElements || getAll( clone ); | |
- for ( i = 0; srcElements[i]; ++i ) { | |
- cloneCopyEvent( srcElements[i], destEl… | |
+ for ( i = 0, l = srcElements.length; i < l; i+… | |
+ cloneCopyEvent( srcElements[ i ], dest… | |
} | |
+ } else { | |
+ cloneCopyEvent( elem, clone ); | |
} | |
} | |
- srcElements = destElements = null; | |
+ // Preserve script evaluation history | |
+ destElements = getAll( clone, "script" ); | |
+ if ( destElements.length > 0 ) { | |
+ setGlobalEval( destElements, !inPage && getAll( elem, … | |
+ } | |
// Return the cloned set | |
return clone; | |
}, | |
- clean: function( elems, context, fragment, scripts ) { | |
- var checkScriptType, script, j, | |
- ret = []; | |
- | |
- context = context || document; | |
- | |
- // !context.createElement fails in IE with an error but return… | |
- if ( typeof context.createElement === "undefined" ) { | |
- context = context.ownerDocument || context[0] && conte… | |
- } | |
- | |
- for ( var i = 0, elem; (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 { | |
- // Fix "XHTML"-style tags in all brows… | |
- elem = elem.replace(rxhtmlTag, "<$1></… | |
- | |
- // Trim whitespace, otherwise indexOf … | |
- var tag = ( rtagName.exec( elem ) || [… | |
- wrap = wrapMap[ tag ] || wrapM… | |
- depth = wrap[0], | |
- div = context.createElement("d… | |
- safeChildNodes = safeFragment.… | |
- remove; | |
- | |
- // Append wrapper element to unknown e… | |
- if ( context === document ) { | |
- // Use the fragment we've alre… | |
- safeFragment.appendChild( div … | |
- } else { | |
- // Use a fragment created with… | |
- createSafeFragment( context ).… | |
- } | |
- | |
- // Go to html and back, then peel off … | |
- div.innerHTML = wrap[1] + elem + wrap[… | |
- | |
- // Move to the right depth | |
- while ( depth-- ) { | |
- div = div.lastChild; | |
- } | |
- | |
- // Remove IE's autoinserted <tbody> fr… | |
- if ( !jQuery.support.tbody ) { | |
- | |
- // String was a <table>, *may*… | |
- var hasBody = rtbody.test(elem… | |
- tbody = tag === "table… | |
- div.firstChild… | |
+ cleanData: function( elems ) { | |
+ var data, elem, type, | |
+ special = jQuery.event.special, | |
+ i = 0; | |
- // String was … | |
- wrap[1] === "<… | |
- div.ch… | |
- []; | |
+ 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.r… | |
- for ( j = tbody.length - 1; j … | |
- if ( jQuery.nodeName( … | |
- tbody[ j ].par… | |
+ // This is a shortcut … | |
+ } else { | |
+ jQuery.removeE… | |
} | |
} | |
} | |
- // IE completely kills leading whitesp… | |
- if ( !jQuery.support.leadingWhitespace… | |
- div.insertBefore( context.crea… | |
- } | |
+ // Support: Chrome <=35 - 45+ | |
+ // Assign undefined instead of using d… | |
+ elem[ dataPriv.expando ] = undefined; | |
+ } | |
+ if ( elem[ dataUser.expando ] ) { | |
- elem = div.childNodes; | |
+ // Support: Chrome <=35 - 45+ | |
+ // Assign undefined instead of using d… | |
+ elem[ dataUser.expando ] = undefined; | |
+ } | |
+ } | |
+ } | |
+ } | |
+} ); | |
- // Clear elements from DocumentFragmen… | |
- // to avoid hoarding elements. Fixes #… | |
- if ( div ) { | |
- div.parentNode.removeChild( di… | |
+jQuery.fn.extend( { | |
+ detach: function( selector ) { | |
+ return remove( this, selector, true ); | |
+ }, | |
- // Guard against -1 index exce… | |
- if ( safeChildNodes.length > 0… | |
- remove = safeChildNode… | |
+ remove: function( selector ) { | |
+ return remove( this, selector ); | |
+ }, | |
- if ( remove && remove.… | |
- remove.parentN… | |
- } | |
- } | |
+ text: function( value ) { | |
+ return access( this, function( value ) { | |
+ return value === undefined ? | |
+ jQuery.text( this ) : | |
+ this.empty().each( function() { | |
+ if ( this.nodeType === 1 || this.nodeT… | |
+ this.textContent = value; | |
} | |
- } | |
+ } ); | |
+ }, null, value, arguments.length ); | |
+ }, | |
+ | |
+ append: function() { | |
+ return domManip( this, arguments, function( elem ) { | |
+ if ( this.nodeType === 1 || this.nodeType === 11 || th… | |
+ var target = manipulationTarget( this, elem ); | |
+ target.appendChild( elem ); | |
} | |
+ } ); | |
+ }, | |
- // Resets defaultChecked for any radios and checkboxes | |
- // about to be appended to the DOM in IE 6/7 (#8060) | |
- var len; | |
- if ( !jQuery.support.appendChecked ) { | |
- if ( elem[0] && typeof (len = elem.length) ===… | |
- for ( j = 0; j < len; j++ ) { | |
- findInputs( elem[j] ); | |
- } | |
- } else { | |
- findInputs( elem ); | |
- } | |
+ prepend: function() { | |
+ return domManip( this, arguments, function( elem ) { | |
+ if ( this.nodeType === 1 || this.nodeType === 11 || th… | |
+ var target = manipulationTarget( this, elem ); | |
+ target.insertBefore( elem, target.firstChild ); | |
} | |
+ } ); | |
+ }, | |
- if ( elem.nodeType ) { | |
- ret.push( elem ); | |
- } else { | |
- ret = jQuery.merge( ret, elem ); | |
+ before: function() { | |
+ return domManip( this, arguments, function( elem ) { | |
+ if ( this.parentNode ) { | |
+ this.parentNode.insertBefore( elem, this ); | |
} | |
- } | |
+ } ); | |
+ }, | |
- if ( fragment ) { | |
- checkScriptType = function( elem ) { | |
- return !elem.type || rscriptType.test( elem.ty… | |
- }; | |
- for ( i = 0; ret[i]; i++ ) { | |
- script = ret[i]; | |
- if ( scripts && jQuery.nodeName( script, "scri… | |
- scripts.push( script.parentNode ? scri… | |
+ after: function() { | |
+ return domManip( this, arguments, function( elem ) { | |
+ if ( this.parentNode ) { | |
+ this.parentNode.insertBefore( elem, this.nextS… | |
+ } | |
+ } ); | |
+ }, | |
- } else { | |
- if ( script.nodeType === 1 ) { | |
- var jsTags = jQuery.grep( scri… | |
+ empty: function() { | |
+ var elem, | |
+ i = 0; | |
- ret.splice.apply( ret, [i + 1,… | |
- } | |
- fragment.appendChild( script ); | |
- } | |
+ 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 ret; | |
+ return this; | |
}, | |
- cleanData: function( elems ) { | |
- var data, id, | |
- cache = jQuery.cache, | |
- special = jQuery.event.special, | |
- deleteExpando = jQuery.support.deleteExpando; | |
+ clone: function( dataAndEvents, deepDataAndEvents ) { | |
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents … | |
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { | |
- if ( elem.nodeName && jQuery.noData[elem.nodeName.toLo… | |
- continue; | |
+ return this.map( function() { | |
+ return jQuery.clone( this, dataAndEvents, deepDataAndE… | |
+ } ); | |
+ }, | |
+ | |
+ 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; | |
} | |
- id = elem[ jQuery.expando ]; | |
+ // See if we can take a shortcut and just use innerHTML | |
+ if ( typeof value === "string" && !rnoInnerhtml.test( … | |
+ !wrapMap[ ( rtagName.exec( value ) || [ "", ""… | |
- if ( id ) { | |
- data = cache[ id ]; | |
+ value = jQuery.htmlPrefilter( value ); | |
- if ( data && data.events ) { | |
- for ( var type in data.events ) { | |
- if ( special[ type ] ) { | |
- jQuery.event.remove( e… | |
+ try { | |
+ for ( ; i < l; i++ ) { | |
+ elem = this[ i ] || {}; | |
- // This is a shortcut to avoid… | |
- } else { | |
- jQuery.removeEvent( el… | |
+ // Remove element nodes and pr… | |
+ if ( elem.nodeType === 1 ) { | |
+ jQuery.cleanData( getA… | |
+ elem.innerHTML = value; | |
} | |
} | |
- // Null the DOM reference to avoid IE6… | |
- if ( data.handle ) { | |
- data.handle.elem = null; | |
- } | |
- } | |
+ elem = 0; | |
- if ( deleteExpando ) { | |
- delete elem[ jQuery.expando ]; | |
+ // If using innerHTML throws an exception, use… | |
+ } catch ( e ) {} | |
+ } | |
- } else if ( elem.removeAttribute ) { | |
- elem.removeAttribute( jQuery.expando ); | |
- } | |
+ if ( elem ) { | |
+ this.empty().append( value ); | |
+ } | |
+ }, null, value, arguments.length ); | |
+ }, | |
- delete cache[ id ]; | |
+ replaceWith: function() { | |
+ var ignored = []; | |
+ | |
+ // Make the changes, replacing each non-ignored context elemen… | |
+ 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 a… | |
+ push.apply( ret, elems.get() ); | |
+ } | |
-var ralpha = /alpha\([^)]*\)/i, | |
- ropacity = /opacity=([^)]*)/, | |
- // fixed for IE9, see #8346 | |
- rupper = /([A-Z]|^ms)/g, | |
- rnum = /^[\-+]?(?:\d*\.)?\d+$/i, | |
- rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i, | |
- rrelNum = /^([\-+])=([\-+.\de]+)/, | |
- rmargin = /^margin/, | |
+ return this.pushStack( ret ); | |
+ }; | |
+} ); | |
+var rmargin = ( /^margin/ ); | |
- cssShow = { position: "absolute", visibility: "hidden", display: "bloc… | |
+var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); | |
- // order is important! | |
- cssExpand = [ "Top", "Right", "Bottom", "Left" ], | |
+var getStyles = function( elem ) { | |
- curCSS, | |
+ // Support: IE <=11 only, Firefox <=30 (#15098, #14150) | |
+ // IE throws on elements created in popups | |
+ // FF meanwhile throws on frame elements through "defaultView.… | |
+ var view = elem.ownerDocument.defaultView; | |
- getComputedStyle, | |
- currentStyle; | |
+ if ( !view || !view.opener ) { | |
+ view = window; | |
+ } | |
-jQuery.fn.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 ); | |
-}; | |
+ return view.getComputedStyle( elem ); | |
+ }; | |
-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 … | |
- var ret = curCSS( elem, "opacity" ); | |
- return ret === "" ? "1" : ret; | |
- } else { | |
- return elem.style.opacity; | |
- } | |
- } | |
- } | |
- }, | |
- // 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 | |
- }, | |
+( function() { | |
- // 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" | |
- }, | |
+ // Executing both pixelPosition & boxSizingReliable tests require only… | |
+ // so they're executed at the same time to save the second computation. | |
+ function computeStyleTests() { | |
- // 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 || !e… | |
+ // This is a singleton, we need to execute it only once | |
+ if ( !div ) { | |
return; | |
} | |
- // Make sure that we're working with the right name | |
- var ret, type, origName = jQuery.camelCase( name ), | |
- style = elem.style, hooks = jQuery.cssHooks[ origName … | |
+ div.style.cssText = | |
+ "box-sizing:border-box;" + | |
+ "position:relative;display:block;" + | |
+ "margin:auto;border:1px;padding:1px;" + | |
+ "top:1%;width:50%"; | |
+ div.innerHTML = ""; | |
+ documentElement.appendChild( container ); | |
- name = jQuery.cssProps[ origName ] || origName; | |
+ var divStyle = window.getComputedStyle( div ); | |
+ pixelPositionVal = divStyle.top !== "1%"; | |
- // Check if we're setting a value | |
- if ( value !== undefined ) { | |
- type = typeof value; | |
+ // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 | |
+ reliableMarginLeftVal = divStyle.marginLeft === "2px"; | |
+ boxSizingReliableVal = divStyle.width === "4px"; | |
- // convert relative number strings (+= or -=) to relat… | |
- if ( type === "string" && (ret = rrelNum.exec( value )… | |
- value = ( +( ret[1] + 1) * +ret[2] ) + parseFl… | |
- // Fixes bug #9237 | |
- type = "number"; | |
- } | |
+ // Support: Android 4.0 - 4.3 only | |
+ // Some styles come back with percentage values, even though t… | |
+ div.style.marginRight = "50%"; | |
+ pixelMarginRightVal = divStyle.marginRight === "4px"; | |
- // Make sure that NaN and null values aren't set. See:… | |
- if ( value == null || type === "number" && isNaN( valu… | |
- return; | |
- } | |
+ documentElement.removeChild( container ); | |
- // If a number was passed in, add 'px' to the (except … | |
- if ( type === "number" && !jQuery.cssNumber[ origName … | |
- value += "px"; | |
- } | |
+ // 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; | |
+ } | |
- // If a hook was provided, use that value, otherwise j… | |
- if ( !hooks || !("set" in hooks) || (value = hooks.set… | |
- // Wrapped to prevent IE from throwing errors … | |
- // Fixes bug #5509 | |
- try { | |
- style[ name ] = value; | |
- } catch(e) {} | |
- } | |
+ var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, relia… | |
+ container = document.createElement( "div" ), | |
+ div = document.createElement( "div" ); | |
- } else { | |
- // If a hook was provided get the non-computed value f… | |
- if ( hooks && "get" in hooks && (ret = hooks.get( elem… | |
- return ret; | |
- } | |
+ // Finish early in limited (non-browser) environments | |
+ if ( !div.style ) { | |
+ return; | |
+ } | |
- // Otherwise just get the value from the style object | |
- return style[ name ]; | |
+ // 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"; | |
+ | |
+ container.style.cssText = "border:0;width:8px;height:0;top:0;left:-999… | |
+ "padding:0;margin-top:1px;position:absolute"; | |
+ container.appendChild( div ); | |
+ | |
+ jQuery.extend( support, { | |
+ pixelPosition: function() { | |
+ computeStyleTests(); | |
+ return pixelPositionVal; | |
+ }, | |
+ boxSizingReliable: function() { | |
+ computeStyleTests(); | |
+ return boxSizingReliableVal; | |
+ }, | |
+ pixelMarginRight: function() { | |
+ computeStyleTests(); | |
+ return pixelMarginRightVal; | |
+ }, | |
+ reliableMarginLeft: function() { | |
+ computeStyleTests(); | |
+ return reliableMarginLeftVal; | |
} | |
- }, | |
+ } ); | |
+} )(); | |
- css: function( elem, name, extra ) { | |
- var ret, hooks; | |
- // Make sure that we're working with the right name | |
- name = jQuery.camelCase( name ); | |
- hooks = jQuery.cssHooks[ name ]; | |
- name = jQuery.cssProps[ name ] || name; | |
+function curCSS( elem, name, computed ) { | |
+ var width, minWidth, maxWidth, ret, | |
+ style = elem.style; | |
- // cssFloat needs a special treatment | |
- if ( name === "cssFloat" ) { | |
- name = "float"; | |
- } | |
+ computed = computed || getStyles( elem ); | |
- // If a hook was provided get the computed value from there | |
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, … | |
- return ret; | |
+ // Support: IE <=9 only | |
+ // getPropertyValue is only needed for .css('filter') (#12537) | |
+ if ( computed ) { | |
+ ret = computed.getPropertyValue( name ) || computed[ name ]; | |
- // Otherwise, if a way to get the computed value exists, use t… | |
- } else if ( curCSS ) { | |
- return curCSS( elem, name ); | |
+ if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem … | |
+ ret = jQuery.style( elem, name ); | |
} | |
- }, | |
- // A method for quickly swapping in/out CSS properties to get correct … | |
- swap: function( elem, options, callback ) { | |
- var old = {}, | |
- ret, 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.pixelMarginRight() && rnumnonpx.test( ret ) && r… | |
- // Remember the old values, and insert the new ones | |
- for ( name in options ) { | |
- old[ name ] = elem.style[ name ]; | |
- elem.style[ name ] = options[ name ]; | |
- } | |
+ // Remember the original values | |
+ width = style.width; | |
+ minWidth = style.minWidth; | |
+ maxWidth = style.maxWidth; | |
- ret = callback.call( elem ); | |
+ // Put in the new values to get a computed value out | |
+ style.minWidth = style.maxWidth = style.width = ret; | |
+ ret = computed.width; | |
- // Revert the old values | |
- for ( name in options ) { | |
- elem.style[ name ] = old[ name ]; | |
+ // Revert the changed values | |
+ style.width = width; | |
+ style.minWidth = minWidth; | |
+ style.maxWidth = maxWidth; | |
} | |
- | |
- return ret; | |
} | |
-}); | |
-// DEPRECATED in 1.3, Use jQuery.css() instead | |
-jQuery.curCSS = jQuery.css; | |
+ return ret !== undefined ? | |
+ | |
+ // Support: IE <=9 - 11 only | |
+ // IE returns zIndex value as an integer. | |
+ ret + "" : | |
+ ret; | |
+} | |
-if ( document.defaultView && document.defaultView.getComputedStyle ) { | |
- getComputedStyle = function( elem, name ) { | |
- var ret, defaultView, computedStyle, width, | |
- style = elem.style; | |
- name = name.replace( rupper, "-$1" ).toLowerCase(); | |
+function addGetHookIf( conditionFn, hookFn ) { | |
- if ( (defaultView = elem.ownerDocument.defaultView) && | |
- (computedStyle = defaultView.getComputedStyle(… | |
+ // Define the hook, we'll check on the first run if it's really needed. | |
+ return { | |
+ get: function() { | |
+ if ( conditionFn() ) { | |
- ret = computedStyle.getPropertyValue( name ); | |
- if ( ret === "" && !jQuery.contains( elem.ownerDocumen… | |
- ret = jQuery.style( elem, name ); | |
+ // Hook not needed (or it's not possible to us… | |
+ // to missing dependency), remove it. | |
+ delete this.get; | |
+ return; | |
} | |
- } | |
- // A tribute to the "awesome hack by Dean Edwards" | |
- // WebKit uses "computed value (percentage if specified)" inst… | |
- // which is against the CSSOM draft spec: http://dev.w3.org/cs… | |
- if ( !jQuery.support.pixelMargin && computedStyle && rmargin.t… | |
- width = style.width; | |
- style.width = ret; | |
- ret = computedStyle.width; | |
- style.width = width; | |
+ // Hook needed; redefine it so that the support test i… | |
+ return ( this.get = hookFn ).apply( this, arguments ); | |
} | |
- | |
- return ret; | |
}; | |
} | |
-if ( document.documentElement.currentStyle ) { | |
- currentStyle = function( elem, name ) { | |
- var left, rsLeft, uncomputed, | |
- 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 && (uncomputed = style[ name ]) ) { | |
- ret = uncomputed; | |
- } | |
+var | |
- // From the awesome hack by Dean Edwards | |
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-1… | |
+ // 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/do… | |
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/, | |
+ cssShow = { position: "absolute", visibility: "hidden", display: "bloc… | |
+ cssNormalTransform = { | |
+ letterSpacing: "0", | |
+ fontWeight: "400" | |
+ }, | |
- // If we're not dealing with a regular pixel number | |
- // but a number that has a weird ending, we need to convert it… | |
- if ( rnumnonpx.test( ret ) ) { | |
+ cssPrefixes = [ "Webkit", "Moz", "ms" ], | |
+ emptyStyle = document.createElement( "div" ).style; | |
- // Remember the original values | |
- left = style.left; | |
- rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; | |
+// Return a css property mapped to a potentially vendor prefixed property | |
+function vendorPropName( name ) { | |
- // Put in the new values to get a computed value out | |
- if ( rsLeft ) { | |
- elem.runtimeStyle.left = elem.currentStyle.lef… | |
- } | |
- style.left = name === "fontSize" ? "1em" : ret; | |
- ret = style.pixelLeft + "px"; | |
+ // Shortcut for names that are not vendor prefixed | |
+ if ( name in emptyStyle ) { | |
+ return name; | |
+ } | |
- // Revert the changed values | |
- style.left = left; | |
- if ( rsLeft ) { | |
- elem.runtimeStyle.left = rsLeft; | |
- } | |
+ // 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 ret === "" ? "auto" : ret; | |
- }; | |
+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 c… | |
+ Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3… | |
+ value; | |
} | |
-curCSS = getComputedStyle || currentStyle; | |
+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { | |
+ var i, | |
+ val = 0; | |
-function getWidthOrHeight( elem, name, extra ) { | |
+ // If we already have the right measurement, avoid augmentation | |
+ if ( extra === ( isBorderBox ? "border" : "content" ) ) { | |
+ i = 4; | |
- // Start with offset property | |
- var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
- i = name === "width" ? 1 : 0, | |
- len = 4; | |
+ // Otherwise initialize for horizontal or vertical properties | |
+ } else { | |
+ i = name === "width" ? 1 : 0; | |
+ } | |
- if ( val > 0 ) { | |
- if ( extra !== "border" ) { | |
- for ( ; i < len; i += 2 ) { | |
- if ( !extra ) { | |
- val -= parseFloat( jQuery.css( elem, "… | |
- } | |
- if ( extra === "margin" ) { | |
- val += parseFloat( jQuery.css( elem, e… | |
- } else { | |
- val -= parseFloat( jQuery.css( elem, "… | |
- } | |
- } | |
+ 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,… | |
} | |
- return val + "px"; | |
- } | |
+ if ( isBorderBox ) { | |
- // Fall back to computed then uncomputed css if necessary | |
- val = curCSS( elem, name ); | |
- if ( val < 0 || val == null ) { | |
- val = elem.style[ name ]; | |
- } | |
+ // border-box includes padding, so remove it if we wan… | |
+ if ( extra === "content" ) { | |
+ val -= jQuery.css( elem, "padding" + cssExpand… | |
+ } | |
- // Computed unit is not pixels. Stop here and return. | |
- if ( rnumnonpx.test(val) ) { | |
- return val; | |
- } | |
+ // At this point, extra isn't border nor margin, so re… | |
+ if ( extra !== "margin" ) { | |
+ val -= jQuery.css( elem, "border" + cssExpand[… | |
+ } | |
+ } else { | |
- // Normalize "", auto, and prepare for extra | |
- val = parseFloat( val ) || 0; | |
+ // At this point, extra isn't content, so add padding | |
+ val += jQuery.css( elem, "padding" + cssExpand[ i ], t… | |
- // Add padding, border, margin | |
- if ( extra ) { | |
- for ( ; i < len; i += 2 ) { | |
- val += parseFloat( jQuery.css( elem, "padding" + cssEx… | |
+ // At this point, extra isn't content nor padding, so … | |
if ( extra !== "padding" ) { | |
- val += parseFloat( jQuery.css( elem, "border" … | |
- } | |
- if ( extra === "margin" ) { | |
- val += parseFloat( jQuery.css( elem, extra + c… | |
+ val += jQuery.css( elem, "border" + cssExpand[… | |
} | |
} | |
} | |
- return val + "px"; | |
+ return val; | |
} | |
-jQuery.each([ "height", "width" ], function( i, name ) { | |
- jQuery.cssHooks[ name ] = { | |
- get: function( elem, computed, extra ) { | |
- if ( computed ) { | |
- if ( elem.offsetWidth !== 0 ) { | |
- return getWidthOrHeight( elem, name, e… | |
- } else { | |
- return jQuery.swap( elem, cssShow, fun… | |
- return getWidthOrHeight( elem,… | |
- }); | |
- } | |
- } | |
- }, | |
+function getWidthOrHeight( elem, name, extra ) { | |
- set: function( elem, value ) { | |
- return rnum.test( value ) ? | |
- value + "px" : | |
- value; | |
+ // Start with offset property, which is equivalent to the border-box v… | |
+ var val, | |
+ valueIsBorderBox = true, | |
+ styles = getStyles( elem ), | |
+ isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) =… | |
+ | |
+ // Support: IE <=11 only | |
+ // Running getBoundingClientRect on a disconnected node | |
+ // in IE throws an error. | |
+ if ( elem.getClientRects().length ) { | |
+ val = elem.getBoundingClientRect()[ name ]; | |
+ } | |
+ | |
+ // Some non-html elements return undefined for offsetWidth, so check f… | |
+ // 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 ]; | |
} | |
- }; | |
-}); | |
-if ( !jQuery.support.opacity ) { | |
- jQuery.cssHooks.opacity = { | |
- get: function( elem, computed ) { | |
- // IE uses filters for opacity | |
- return ropacity.test( (computed && elem.currentStyle ?… | |
- ( parseFloat( RegExp.$1 ) / 100 ) + "" : | |
- computed ? "1" : ""; | |
- }, | |
+ // Computed unit is not pixels. Stop here and return. | |
+ if ( rnumnonpx.test( val ) ) { | |
+ return val; | |
+ } | |
- set: function( elem, value ) { | |
- var style = elem.style, | |
- currentStyle = elem.currentStyle, | |
- opacity = jQuery.isNumeric( value ) ? "alpha(o… | |
- filter = currentStyle && currentStyle.filter |… | |
+ // Check for style in case a browser which returns unreliable … | |
+ // for getComputedStyle silently falls back to the reliable el… | |
+ valueIsBorderBox = isBorderBox && | |
+ ( support.boxSizingReliable() || val === elem.style[ n… | |
+ | |
+ // Normalize "", auto, and prepare for extra | |
+ val = parseFloat( val ) || 0; | |
+ } | |
- // IE has trouble with opacity if it does not have lay… | |
- // Force it by setting the zoom level | |
- style.zoom = 1; | |
+ // Use the active box-sizing model to add/subtract irrelevant styles | |
+ return ( val + | |
+ augmentWidthOrHeight( | |
+ elem, | |
+ name, | |
+ extra || ( isBorderBox ? "border" : "content" ), | |
+ valueIsBorderBox, | |
+ styles | |
+ ) | |
+ ) + "px"; | |
+} | |
- // if setting opacity to 1, and no other filters exist… | |
- if ( value >= 1 && jQuery.trim( filter.replace( ralpha… | |
+jQuery.extend( { | |
- // Setting style.filter to null, "" & " " stil… | |
- // if "filter:" is present at all, clearType i… | |
- // style.removeAttribute is IE Only, but so ap… | |
- style.removeAttribute( "filter" ); | |
+ // 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 ) { | |
- // if there there is no filter style applied i… | |
- if ( currentStyle && !currentStyle.filter ) { | |
- return; | |
+ // We should always get a number back … | |
+ 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: { | |
+ "float": "cssFloat" | |
+ }, | |
+ | |
+ // Get and set the style property on a DOM Node | |
+ style: function( elem, name, value, extra ) { | |
- // otherwise, set new filter values | |
- style.filter = ralpha.test( filter ) ? | |
- filter.replace( ralpha, opacity ) : | |
- filter + " " + opacity; | |
+ // Don't set styles on text and comment nodes | |
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !e… | |
+ return; | |
} | |
- }; | |
-} | |
-jQuery(function() { | |
- // This hook cannot be added until DOM ready because the support test | |
- // for it is not run until after DOM ready | |
- if ( !jQuery.support.reliableMarginRight ) { | |
- jQuery.cssHooks.marginRight = { | |
- get: function( elem, computed ) { | |
- // WebKit Bug 13343 - getComputedStyle returns… | |
- // Work around by temporarily setting element … | |
- return jQuery.swap( elem, { "display": "inline… | |
- if ( computed ) { | |
- return curCSS( elem, "margin-r… | |
- } else { | |
- return elem.style.marginRight; | |
- } | |
- }); | |
+ // 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( origNa… | |
+ | |
+ // 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 … | |
+ value = adjustCSS( elem, name, ret ); | |
+ | |
+ // Fixes bug #9237 | |
+ type = "number"; | |
} | |
- }; | |
+ | |
+ // Make sure that null and NaN values aren't set (#711… | |
+ if ( value == null || value !== value ) { | |
+ return; | |
+ } | |
+ | |
+ // If a number was passed in, add the unit (except for… | |
+ if ( type === "number" ) { | |
+ value += ret && ret[ 3 ] || ( jQuery.cssNumber… | |
+ } | |
+ | |
+ // background-* props affect original clone's values | |
+ if ( !support.clearCloneStyle && value === "" && name.… | |
+ style[ name ] = "inherit"; | |
+ } | |
+ | |
+ // If a hook was provided, use that value, otherwise j… | |
+ if ( !hooks || !( "set" in hooks ) || | |
+ ( value = hooks.set( elem, value, extra ) ) !=… | |
+ | |
+ style[ name ] = value; | |
+ } | |
+ | |
+ } else { | |
+ | |
+ // If a hook was provided get the non-computed value f… | |
+ if ( hooks && "get" in hooks && | |
+ ( ret = hooks.get( elem, false, extra ) ) !== … | |
+ | |
+ 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 = jQuery.camelCase( name ); | |
+ | |
+ // Make sure that we're working with the right name | |
+ name = jQuery.cssProps[ origName ] || | |
+ ( jQuery.cssProps[ origName ] = vendorPropName( origNa… | |
+ | |
+ // 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 t… | |
+ 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 … | |
+ if ( extra === "" || extra ) { | |
+ num = parseFloat( val ); | |
+ return extra === true || isFinite( num ) ? num || 0 : … | |
+ } | |
+ return val; | |
} | |
-}); | |
+} ); | |
+ | |
+jQuery.each( [ "height", "width" ], function( i, name ) { | |
+ jQuery.cssHooks[ name ] = { | |
+ get: function( elem, computed, extra ) { | |
+ if ( computed ) { | |
-if ( jQuery.expr && jQuery.expr.filters ) { | |
- jQuery.expr.filters.hidden = function( elem ) { | |
- var width = elem.offsetWidth, | |
- height = elem.offsetHeight; | |
+ // Certain elements can have dimension info if… | |
+ // but it must have a current display style th… | |
+ return rdisplayswap.test( jQuery.css( elem, "d… | |
+ | |
+ // Support: Safari 8+ | |
+ // Table columns in Safari have non-ze… | |
+ // getBoundingClientRect().width unles… | |
+ // Support: IE <=11 only | |
+ // Running getBoundingClientRect on a … | |
+ // in IE throws an error. | |
+ ( !elem.getClientRects().length || !el… | |
+ swap( elem, cssShow, function(… | |
+ return getWidthOrHeigh… | |
+ } ) : | |
+ getWidthOrHeight( elem, name, … | |
+ } | |
+ }, | |
- return ( width === 0 && height === 0 ) || (!jQuery.support.rel… | |
- }; | |
+ set: function( elem, value, extra ) { | |
+ var matches, | |
+ styles = extra && getStyles( elem ), | |
+ subtract = extra && augmentWidthOrHeight( | |
+ elem, | |
+ name, | |
+ extra, | |
+ jQuery.css( elem, "boxSizing", false, … | |
+ styles | |
+ ); | |
+ | |
+ // Convert to pixels if value adjustment is needed | |
+ if ( subtract && ( matches = rcssNum.exec( value ) ) && | |
+ ( matches[ 3 ] || "px" ) !== "px" ) { | |
+ | |
+ elem.style[ name ] = value; | |
+ value = jQuery.css( elem, name ); | |
+ } | |
- jQuery.expr.filters.visible = function( elem ) { | |
- return !jQuery.expr.filters.hidden( elem ); | |
+ 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 }, functio… | |
+ return elem.getBoundingClientR… | |
+ } ) | |
+ ) + "px"; | |
+ } | |
+ } | |
+); | |
// These hooks are used by animate to expand properties | |
-jQuery.each({ | |
+jQuery.each( { | |
margin: "", | |
padding: "", | |
border: "Width" | |
}, function( prefix, suffix ) { | |
- | |
jQuery.cssHooks[ prefix + suffix ] = { | |
expand: function( value ) { | |
- var i, | |
+ var i = 0, | |
+ expanded = {}, | |
- // assumes a single number if not a string | |
- parts = typeof value === "string" ? value.spli… | |
- expanded = {}; | |
+ // Assumes a single number if not a string | |
+ parts = typeof value === "string" ? value.spli… | |
- for ( i = 0; i < 4; i++ ) { | |
+ for ( ; i < 4; i++ ) { | |
expanded[ prefix + cssExpand[ i ] + suffix ] = | |
parts[ i ] || parts[ i - 2 ] || parts[… | |
} | |
t@@ -6963,881 +6593,2007 @@ jQuery.each({ | |
return expanded; | |
} | |
}; | |
-}); | |
- | |
- | |
+ if ( !rmargin.test( prefix ) ) { | |
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; | |
+ } | |
+} ); | |
-var r20 = /%20/g, | |
- rbracket = /\[\]$/, | |
- rCRLF = /\r?\n/g, | |
- rhash = /#.*$/, | |
- rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r charact… | |
- rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|nu… | |
- // #7653, #8125, #8152: local protocol detection | |
- rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|wi… | |
- rnoContent = /^(?:GET|HEAD)$/, | |
- rprotocol = /^\/\//, | |
- rquery = /\?/, | |
- rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, | |
- rselectTextarea = /^(?:select|textarea)/i, | |
- rspacesAjax = /\s+/, | |
- rts = /([?&])_=[^&]*/, | |
- rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, | |
- | |
- // Keep a copy of the old load method | |
- _load = jQuery.fn.load, | |
+jQuery.fn.extend( { | |
+ css: function( name, value ) { | |
+ return access( this, function( elem, name, value ) { | |
+ var styles, len, | |
+ map = {}, | |
+ i = 0; | |
- /* Prefilters | |
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js… | |
- * 2) These are called: | |
- * - BEFORE asking for a transport | |
- * - AFTER param serialization (s.data is a string if s.processData… | |
- * 3) key is the dataType | |
- * 4) the catchall symbol "*" can be used | |
- * 5) execution will start with transport dataType and THEN continue d… | |
- */ | |
- prefilters = {}, | |
+ if ( jQuery.isArray( name ) ) { | |
+ styles = getStyles( elem ); | |
+ len = name.length; | |
- /* 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 "*" … | |
- */ | |
- transports = {}, | |
+ for ( ; i < len; i++ ) { | |
+ map[ name[ i ] ] = jQuery.css( elem, n… | |
+ } | |
- // Document location | |
- ajaxLocation, | |
+ return map; | |
+ } | |
- // Document location segments | |
- ajaxLocParts, | |
+ return value !== undefined ? | |
+ jQuery.style( elem, name, value ) : | |
+ jQuery.css( elem, name ); | |
+ }, name, value, arguments.length > 1 ); | |
+ } | |
+} ); | |
- // Avoid comment-prolog char sequence (#10098); must appease lint and … | |
- 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; | |
+function Tween( elem, options, prop, end, easing ) { | |
+ return new Tween.prototype.init( elem, options, prop, end, easing ); | |
} | |
+jQuery.Tween = Tween; | |
-// Segment location into parts | |
-ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | |
- | |
-// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | |
-function addToPrefiltersOrTransports( structure ) { | |
+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 ]; | |
- // dataTypeExpression is optional and defaults to "*" | |
- return function( dataTypeExpression, func ) { | |
+ return hooks && hooks.get ? | |
+ hooks.get( this ) : | |
+ Tween.propHooks._default.get( this ); | |
+ }, | |
+ run: function( percent ) { | |
+ var eased, | |
+ hooks = Tween.propHooks[ this.prop ]; | |
- if ( typeof dataTypeExpression !== "string" ) { | |
- func = dataTypeExpression; | |
- dataTypeExpression = "*"; | |
+ if ( this.options.duration ) { | |
+ this.pos = eased = jQuery.easing[ this.easing ]( | |
+ percent, this.options.duration * percent, 0, 1… | |
+ ); | |
+ } else { | |
+ this.pos = eased = percent; | |
} | |
+ this.now = ( this.end - this.start ) * eased + this.start; | |
- if ( jQuery.isFunction( func ) ) { | |
- var dataTypes = dataTypeExpression.toLowerCase().split… | |
- i = 0, | |
- length = dataTypes.length, | |
- dataType, | |
- list, | |
- placeBefore; | |
+ if ( this.options.step ) { | |
+ this.options.step.call( this.elem, this.now, this ); | |
+ } | |
- // 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[ data… | |
- // then we add to the structure accordingly | |
- list[ placeBefore ? "unshift" : "push" ]( func… | |
- } | |
+ if ( hooks && hooks.set ) { | |
+ hooks.set( this ); | |
+ } else { | |
+ Tween.propHooks._default.set( this ); | |
} | |
- }; | |
-} | |
+ return this; | |
+ } | |
+}; | |
-// Base inspection function for prefilters and transports | |
-function inspectPrefiltersOrTransports( structure, options, originalOptions, j… | |
- dataType /* internal */, inspected /* internal */ ) { | |
+Tween.prototype.init.prototype = Tween.prototype; | |
+ | |
+Tween.propHooks = { | |
+ _default: { | |
+ get: function( tween ) { | |
+ var result; | |
- dataType = dataType || options.dataTypes[ 0 ]; | |
- inspected = inspected || {}; | |
+ // Use a property on the element directly when it is n… | |
+ // or when there is no matching style property that ex… | |
+ if ( tween.elem.nodeType !== 1 || | |
+ tween.elem[ tween.prop ] != null && tween.elem… | |
+ return tween.elem[ tween.prop ]; | |
+ } | |
- inspected[ dataType ] = true; | |
+ // Passing an empty string as a 3rd parameter to .css … | |
+ // attempt a parseFloat and fallback to a string if th… | |
+ // Simple values such as "10px" are parsed to Float; | |
+ // complex values such as "rotate(1rad)" are returned … | |
+ result = jQuery.css( tween.elem, tween.prop, "" ); | |
- var list = structure[ dataType ], | |
- i = 0, | |
- length = list ? list.length : 0, | |
- executeOnly = ( structure === prefilters ), | |
- selection; | |
- | |
- 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; | |
+ // Empty strings, null, undefined and "auto" are conve… | |
+ 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 wh… | |
+ if ( jQuery.fx.step[ tween.prop ] ) { | |
+ jQuery.fx.step[ tween.prop ]( tween ); | |
+ } else if ( tween.elem.nodeType === 1 && | |
+ ( tween.elem.style[ jQuery.cssProps[ tween.pro… | |
+ jQuery.cssHooks[ tween.prop ] ) ) { | |
+ jQuery.style( tween.elem, tween.prop, tween.no… | |
} else { | |
- options.dataTypes.unshift( selection ); | |
- selection = inspectPrefiltersOrTransports( | |
- structure, options, originalOp… | |
+ tween.elem[ tween.prop ] = tween.now; | |
} | |
} | |
} | |
- // 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, "*… | |
- } | |
- // 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 = {} … | |
+// 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; | |
} | |
} | |
- if ( deep ) { | |
- jQuery.extend( true, target, deep ); | |
- } | |
-} | |
+}; | |
-jQuery.fn.extend({ | |
- load: function( url, params, callback ) { | |
- if ( typeof url !== "string" && _load ) { | |
- return _load.apply( this, arguments ); | |
+jQuery.easing = { | |
+ linear: function( p ) { | |
+ return p; | |
+ }, | |
+ swing: function( p ) { | |
+ return 0.5 - Math.cos( p * Math.PI ) / 2; | |
+ }, | |
+ _default: "swing" | |
+}; | |
- // Don't do a request if no elements are being requested | |
- } else if ( !this.length ) { | |
- return this; | |
- } | |
+jQuery.fx = Tween.prototype.init; | |
- var off = url.indexOf( " " ); | |
- if ( off >= 0 ) { | |
- var selector = url.slice( off, url.length ); | |
- url = url.slice( 0, off ); | |
- } | |
+// Back compat <1.8 extension point | |
+jQuery.fx.step = {}; | |
- // Default to a GET request | |
- var type = "GET"; | |
- // If the second parameter was provided | |
- if ( params ) { | |
- // 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 ( typeof params === "object" ) { | |
- params = jQuery.param( params, jQuery.ajaxSett… | |
- type = "POST"; | |
- } | |
- } | |
- var self = this; | |
+var | |
+ fxNow, timerId, | |
+ rfxtypes = /^(?:toggle|show|hide)$/, | |
+ rrun = /queueHooks$/; | |
- // Request the remote document | |
- jQuery.ajax({ | |
- url: url, | |
- type: type, | |
- dataType: "html", | |
- data: params, | |
- // Complete callback (responseText is used internally) | |
- complete: function( jqXHR, status, responseText ) { | |
- // Store the response as specified by the jqXH… | |
- responseText = jqXHR.responseText; | |
- // If successful, inject the HTML into all the… | |
- if ( jqXHR.isResolved() ) { | |
- // #4825: Get the actual response in c… | |
- // a dataFilter is present in ajaxSett… | |
- jqXHR.done(function( r ) { | |
- responseText = r; | |
- }); | |
- // See if a selector was specified | |
- self.html( selector ? | |
- // Create a dummy div to hold … | |
- jQuery("<div>") | |
- // inject the contents… | |
- // to avoid any 'Permi… | |
- .append(responseText.r… | |
- | |
- // Locate the specifie… | |
- .find(selector) : | |
- | |
- // If not, just inject the ful… | |
- responseText ); | |
- } | |
+function raf() { | |
+ if ( timerId ) { | |
+ window.requestAnimationFrame( raf ); | |
+ jQuery.fx.tick(); | |
+ } | |
+} | |
- if ( callback ) { | |
- self.each( callback, [ responseText, s… | |
- } | |
- } | |
- }); | |
+// Animations created synchronously will run synchronously | |
+function createFxNow() { | |
+ window.setTimeout( function() { | |
+ fxNow = undefined; | |
+ } ); | |
+ return ( fxNow = jQuery.now() ); | |
+} | |
- return this; | |
- }, | |
+// 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; | |
+ } | |
- serialize: function() { | |
- return jQuery.param( this.serializeArray() ); | |
- }, | |
+ if ( includeWidth ) { | |
+ attrs.opacity = attrs.width = type; | |
+ } | |
- serializeArray: function() { | |
- return this.map(function(){ | |
- return this.elements ? jQuery.makeArray( this.elements… | |
- }) | |
- .filter(function(){ | |
- return this.name && !this.disabled && | |
- ( this.checked || rselectTextarea.test( this.n… | |
- rinput.test( this.type ) ); | |
- }) | |
- .map(function( i, elem ){ | |
- var val = jQuery( this ).val(); | |
+ return attrs; | |
+} | |
- return val == null ? | |
- null : | |
- jQuery.isArray( val ) ? | |
- jQuery.map( val, function( val, i ){ | |
- return { name: elem.name, valu… | |
- }) : | |
- { name: elem.name, value: val.replace(… | |
- }).get(); | |
+function createTween( value, prop, animation ) { | |
+ var tween, | |
+ collection = ( Animation.tweeners[ prop ] || [] ).concat( Anim… | |
+ index = 0, | |
+ length = collection.length; | |
+ for ( ; index < length; index++ ) { | |
+ if ( ( tween = collection[ index ].call( animation, prop, valu… | |
+ | |
+ // We're done with this property | |
+ return tween; | |
+ } | |
} | |
-}); | |
+} | |
-// Attach a bunch of functions for handling common AJAX events | |
-jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".… | |
- jQuery.fn[ o ] = function( f ){ | |
- return this.on( o, f ); | |
- }; | |
-}); | |
+function defaultPrefilter( elem, props, opts ) { | |
+ var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, di… | |
+ 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++; | |
-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; | |
+ anim.always( function() { | |
+ | |
+ // Ensure the complete handler is called before this c… | |
+ 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[… | |
+ hidden = true; | |
+ | |
+ // Ignore all other no-op show/hide data | |
+ } else { | |
+ continue; | |
+ } | |
+ } | |
+ orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.… | |
} | |
+ } | |
- return jQuery.ajax({ | |
- type: method, | |
- url: url, | |
- data: data, | |
- success: callback, | |
- dataType: type | |
- }); | |
- }; | |
-}); | |
+ // Bail out if this is a no-op like .hide().hide() | |
+ propTween = !jQuery.isEmptyObject( props ); | |
+ if ( !propTween && jQuery.isEmptyObject( orig ) ) { | |
+ return; | |
+ } | |
-jQuery.extend({ | |
+ // Restrict "overflow" and "display" styles during box animations | |
+ if ( isBox && elem.nodeType === 1 ) { | |
- getScript: function( url, callback ) { | |
- return jQuery.get( url, undefined, callback, "script" ); | |
- }, | |
+ // Support: IE <=9 - 11, Edge 12 - 13 | |
+ // Record all 3 overflow attributes because IE does not infer … | |
+ // from identically-valued overflowX and overflowY | |
+ opts.overflow = [ style.overflow, style.overflowX, style.overf… | |
- getJSON: function( url, data, callback ) { | |
- return jQuery.get( url, data, callback, "json" ); | |
- }, | |
+ // Identify a display type, preferring old show/hide data over… | |
+ 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 { | |
- // 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; | |
+ // Get nonempty value(s) by temporarily forcin… | |
+ showHide( [ elem ], true ); | |
+ restoreDisplay = elem.style.display || restore… | |
+ display = jQuery.css( elem, "display" ); | |
+ showHide( [ elem ] ); | |
+ } | |
} | |
- 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, | |
- traditional: false, | |
- headers: {}, | |
- */ | |
+ // Animate inline elements as inline-block | |
+ if ( display === "inline" || display === "inline-block" && res… | |
+ if ( jQuery.css( elem, "float" ) === "none" ) { | |
- accepts: { | |
- xml: "application/xml, text/xml", | |
- html: "text/html", | |
- text: "text/plain", | |
- json: "application/json, text/javascript", | |
- "*": allTypes | |
- }, | |
+ // Restore the original display value at the e… | |
+ if ( !propTween ) { | |
+ anim.done( function() { | |
+ style.display = restoreDisplay; | |
+ } ); | |
+ if ( restoreDisplay == null ) { | |
+ display = style.display; | |
+ restoreDisplay = display === "… | |
+ } | |
+ } | |
+ style.display = "inline-block"; | |
+ } | |
+ } | |
+ } | |
- contents: { | |
- xml: /xml/, | |
- html: /html/, | |
- json: /json/ | |
- }, | |
+ if ( opts.overflow ) { | |
+ style.overflow = "hidden"; | |
+ anim.always( function() { | |
+ style.overflow = opts.overflow[ 0 ]; | |
+ style.overflowX = opts.overflow[ 1 ]; | |
+ style.overflowY = opts.overflow[ 2 ]; | |
+ } ); | |
+ } | |
- responseFields: { | |
- xml: "responseXML", | |
- text: "responseText" | |
- }, | |
+ // Implement show/hide animations | |
+ propTween = false; | |
+ for ( prop in orig ) { | |
- // List of data converters | |
- // 1) key format is "source_type destination_type" (a single s… | |
- // 2) the catchall symbol "*" can be used for source_type | |
- converters: { | |
+ // 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", { … | |
+ } | |
- // Convert anything to text | |
- "* text": window.String, | |
+ // Store hidden/visible for toggle so `.stop().toggle(… | |
+ if ( toggle ) { | |
+ dataShow.hidden = !hidden; | |
+ } | |
- // Text to html (true = no transformation) | |
- "text html": true, | |
+ // Show elements before animating them | |
+ if ( hidden ) { | |
+ showHide( [ elem ], true ); | |
+ } | |
- // Evaluate text as a json expression | |
- "text json": jQuery.parseJSON, | |
+ /* eslint-disable no-loop-func */ | |
- // Parse text as xml | |
- "text xml": jQuery.parseXML | |
- }, | |
+ anim.done( function() { | |
- // 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 | |
+ /* eslint-enable no-loop-func */ | |
+ | |
+ // The final step of a "hide" animation is act… | |
+ if ( !hidden ) { | |
+ showHide( [ elem ] ); | |
+ } | |
+ dataPriv.remove( elem, "fxshow" ); | |
+ for ( prop in orig ) { | |
+ jQuery.style( elem, prop, orig[ prop ]… | |
+ } | |
+ } ); | |
} | |
- }, | |
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
- ajaxTransport: addToPrefiltersOrTransports( transports ), | |
+ // Per-property setup | |
+ propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, … | |
+ if ( !( prop in dataShow ) ) { | |
+ dataShow[ prop ] = propTween.start; | |
+ if ( hidden ) { | |
+ propTween.end = propTween.start; | |
+ propTween.start = 0; | |
+ } | |
+ } | |
+ } | |
+} | |
- // Main method | |
- ajax: function( url, options ) { | |
+function propFilter( props, specialEasing ) { | |
+ var index, name, easing, value, hooks; | |
- // If url is an object, simulate pre-1.5 signature | |
- if ( typeof url === "object" ) { | |
- options = url; | |
- url = undefined; | |
+ // 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 ]; | |
} | |
- // Force options to be an object | |
- options = options || {}; | |
+ if ( index !== name ) { | |
+ props[ name ] = value; | |
+ delete props[ index ]; | |
+ } | |
- var // 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… | |
- // and if it's a DOM node or a jQuery collection | |
- globalEventContext = callbackContext !== s && | |
- ( callbackContext.nodeType || callbackContext … | |
- jQuery( callbackContext ) : jQ… | |
- // Deferreds | |
- deferred = jQuery.Deferred(), | |
- completeDeferred = jQuery.Callbacks( "once memory" ), | |
- // Status-dependent callbacks | |
- statusCode = s.statusCode || {}, | |
- // ifModified key | |
- ifModifiedKey, | |
- // Headers (they are sent all at once) | |
- requestHeaders = {}, | |
- requestHeadersNames = {}, | |
- // Response headers | |
- responseHeadersString, | |
- responseHeaders, | |
- // transport | |
- transport, | |
- // timeout handle | |
- timeoutTimer, | |
- // Cross-domain detection vars | |
- parts, | |
- // The jqXHR state | |
- state = 0, | |
- // To know if global events are to be dispatched | |
- fireGlobals, | |
- // Loop variable | |
- i, | |
- // Fake xhr | |
- jqXHR = { | |
+ hooks = jQuery.cssHooks[ name ]; | |
+ if ( hooks && "expand" in hooks ) { | |
+ value = hooks.expand( value ); | |
+ delete props[ name ]; | |
- readyState: 0, | |
+ // Not quite $.extend, this won't overwrite existing k… | |
+ // 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; | |
+ } | |
+ } | |
+} | |
- // Caches the header | |
- setRequestHeader: function( name, value ) { | |
- if ( !state ) { | |
- var lname = name.toLowerCase(); | |
- name = requestHeadersNames[ ln… | |
- requestHeaders[ name ] = value; | |
- } | |
- return this; | |
- }, | |
+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 +… | |
- // Raw string | |
- getAllResponseHeaders: function() { | |
- return state === 2 ? responseHeadersSt… | |
- }, | |
+ // Support: Android 2.3 only | |
+ // Archaic crash bug won't allow us to use `1 … | |
+ temp = remaining / animation.duration || 0, | |
+ percent = 1 - temp, | |
+ index = 0, | |
+ length = animation.tweens.length; | |
- // Builds headers hashtable if needed | |
- getResponseHeader: function( key ) { | |
- var match; | |
- if ( state === 2 ) { | |
- if ( !responseHeaders ) { | |
- responseHeaders = {}; | |
- while( ( match = rhead… | |
- responseHeader… | |
- } | |
- } | |
- match = responseHeaders[ key.t… | |
- } | |
- return match === undefined ? null : ma… | |
- }, | |
+ for ( ; index < length; index++ ) { | |
+ animation.tweens[ index ].run( percent ); | |
+ } | |
- // Overrides response content-type header | |
- overrideMimeType: function( type ) { | |
- if ( !state ) { | |
- s.mimeType = type; | |
- } | |
- return this; | |
- }, | |
+ deferred.notifyWith( elem, [ animation, percent, remai… | |
- // Cancel the request | |
- abort: function( statusText ) { | |
- statusText = statusText || "abort"; | |
- if ( transport ) { | |
- transport.abort( statusText ); | |
- } | |
- done( 0, statusText ); | |
+ 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… | |
+ animation.opts.specialEasing[ … | |
+ animation.tweens.push( tween ); | |
+ return tween; | |
+ }, | |
+ stop: function( gotoEnd ) { | |
+ var index = 0, | |
+ | |
+ // If we are going to the end, we want… | |
+ // otherwise we skip this part | |
+ length = gotoEnd ? animation.tweens.le… | |
+ if ( stopped ) { | |
return this; | |
} | |
- }; | |
- | |
- // Callback for when everything is done | |
- // It is defined here because jslint complains if it is declar… | |
- // at the end of the function (which would be more logical and… | |
- function done( status, nativeStatusText, responses, headers ) { | |
+ stopped = true; | |
+ for ( ; index < length; index++ ) { | |
+ animation.tweens[ index ].run( 1 ); | |
+ } | |
- // Called once | |
- if ( state === 2 ) { | |
- return; | |
+ // Resolve when we played the last frame; othe… | |
+ if ( gotoEnd ) { | |
+ deferred.notifyWith( elem, [ animation… | |
+ deferred.resolveWith( elem, [ animatio… | |
+ } else { | |
+ deferred.rejectWith( elem, [ animation… | |
+ } | |
+ return this; | |
} | |
+ } ), | |
+ props = animation.props; | |
- // State is "done" now | |
- state = 2; | |
+ propFilter( props, animation.opts.specialEasing ); | |
- // Clear timeout if it exists | |
- if ( timeoutTimer ) { | |
- clearTimeout( timeoutTimer ); | |
+ for ( ; index < length; index++ ) { | |
+ result = Animation.prefilters[ index ].call( animation, elem, … | |
+ if ( result ) { | |
+ if ( jQuery.isFunction( result.stop ) ) { | |
+ jQuery._queueHooks( animation.elem, animation.… | |
+ jQuery.proxy( result.stop, result ); | |
} | |
+ return result; | |
+ } | |
+ } | |
- // Dereference transport for early garbage collection | |
- // (no matter how long the jqXHR object will be used) | |
- transport = undefined; | |
+ jQuery.map( props, createTween, animation ); | |
- // Cache response headers | |
- responseHeadersString = headers || ""; | |
+ if ( jQuery.isFunction( animation.opts.start ) ) { | |
+ animation.opts.start.call( elem, animation ); | |
+ } | |
- // Set readyState | |
- jqXHR.readyState = status > 0 ? 4 : 0; | |
+ 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 ); | |
+} | |
- var isSuccess, | |
- success, | |
- error, | |
- statusText = nativeStatusText, | |
- response = responses ? ajaxHandleResponses( s,… | |
- lastModified, | |
- etag; | |
+jQuery.Animation = jQuery.extend( Animation, { | |
- // If successful, handle type chaining | |
- if ( status >= 200 && status < 300 || status === 304 )… | |
+ tweeners: { | |
+ "*": [ function( prop, value ) { | |
+ var tween = this.createTween( prop, value ); | |
+ adjustCSS( tween.elem, prop, rcssNum.exec( value ), tw… | |
+ return tween; | |
+ } ] | |
+ }, | |
- // Set the If-Modified-Since and/or If-None-Ma… | |
- if ( s.ifModified ) { | |
+ tweener: function( props, callback ) { | |
+ if ( jQuery.isFunction( props ) ) { | |
+ callback = props; | |
+ props = [ "*" ]; | |
+ } else { | |
+ props = props.match( rnothtmlwhite ); | |
+ } | |
- if ( ( lastModified = jqXHR.getRespons… | |
- jQuery.lastModified[ ifModifie… | |
- } | |
- if ( ( etag = jqXHR.getResponseHeader(… | |
- jQuery.etag[ ifModifiedKey ] =… | |
- } | |
- } | |
+ var prop, | |
+ index = 0, | |
+ length = props.length; | |
- // If not modified | |
- if ( status === 304 ) { | |
+ for ( ; index < length; index++ ) { | |
+ prop = props[ index ]; | |
+ Animation.tweeners[ prop ] = Animation.tweeners[ prop … | |
+ Animation.tweeners[ prop ].unshift( callback ); | |
+ } | |
+ }, | |
- statusText = "notmodified"; | |
- isSuccess = true; | |
+ prefilters: [ defaultPrefilter ], | |
- // If we have data | |
- } else { | |
+ 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( {}, spee… | |
+ complete: fn || !fn && easing || | |
+ jQuery.isFunction( speed ) && speed, | |
+ duration: speed, | |
+ easing: fn && easing || easing && !jQuery.isFunction( easing )… | |
+ }; | |
- try { | |
- success = ajaxConvert( s, resp… | |
- statusText = "success"; | |
- isSuccess = true; | |
- } catch(e) { | |
- // We have a parsererror | |
- statusText = "parsererror"; | |
- error = e; | |
- } | |
+ // Go to the end state if fx are off or if document is hidden | |
+ if ( jQuery.fx.off || document.hidden ) { | |
+ 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 ( 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( isHiddenWithinTree ).css( "opacity", 0 ).s… | |
+ | |
+ // Animate to the value specified | |
+ .end().animate( { opacity: to }, speed, easing, callba… | |
+ }, | |
+ 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 e… | |
+ var anim = Animation( this, jQuery.extend( {},… | |
+ | |
+ // Empty animations, or finishing resolves imm… | |
+ 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 && type !== false ) { | |
+ 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 { | |
- // We extract error from statusText | |
- // then normalize statusText and status for no… | |
- error = statusText; | |
- if ( !statusText || status ) { | |
- statusText = "error"; | |
- if ( status < 0 ) { | |
- status = 0; | |
+ for ( index in data ) { | |
+ if ( data[ index ] && data[ index ].st… | |
+ stopQueue( data[ index ] ); | |
} | |
} | |
} | |
- // Set data for the fake xhr object | |
- jqXHR.status = status; | |
- jqXHR.statusText = "" + ( nativeStatusText || statusTe… | |
+ for ( index = timers.length; index--; ) { | |
+ if ( timers[ index ].elem === this && | |
+ ( type == null || timers[ index ].queu… | |
- // Success/Error | |
- if ( isSuccess ) { | |
- deferred.resolveWith( callbackContext, [ succe… | |
- } else { | |
- deferred.rejectWith( callbackContext, [ jqXHR,… | |
+ timers[ index ].anim.stop( gotoEnd ); | |
+ dequeue = false; | |
+ timers.splice( index, 1 ); | |
+ } | |
} | |
- // Status-dependent callbacks | |
- jqXHR.statusCode( statusCode ); | |
- statusCode = undefined; | |
+ // Start the next in the queue if the last step wasn't… | |
+ // Timers currently will call their complete callbacks… | |
+ // 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; | |
- if ( fireGlobals ) { | |
- globalEventContext.trigger( "ajax" + ( isSucce… | |
- [ jqXHR, s, isSuccess ? succes… | |
+ // 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 ); | |
} | |
- // Complete | |
- completeDeferred.fireWith( callbackContext, [ jqXHR, s… | |
+ // Look for any active animations, and finish them | |
+ for ( index = timers.length; index--; ) { | |
+ if ( timers[ index ].elem === this && timers[ … | |
+ timers[ index ].anim.stop( true ); | |
+ timers.splice( index, 1 ); | |
+ } | |
+ } | |
- if ( fireGlobals ) { | |
- globalEventContext.trigger( "ajaxComplete", [ … | |
- // Handle the global AJAX counter | |
- if ( !( --jQuery.active ) ) { | |
- jQuery.event.trigger( "ajaxStop" ); | |
+ // Look for any animations in the old queue and finish… | |
+ 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, call… | |
+ }; | |
+} ); | |
+ | |
+// 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 = 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 ); | |
} | |
+ } | |
- // 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 ] = [ statusCo… | |
+ 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.requestAnimationFrame ? | |
+ window.requestAnimationFrame( raf ) : | |
+ window.setInterval( jQuery.fx.tick, jQuery.fx.interval… | |
+ } | |
+}; | |
+ | |
+jQuery.fx.stop = function() { | |
+ if ( window.cancelAnimationFrame ) { | |
+ window.cancelAnimationFrame( timerId ); | |
+ } else { | |
+ 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. | |
+// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.ph… | |
+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.lengt… | |
+ }, | |
+ | |
+ 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 nod… | |
+ 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 ) ? boolHo… | |
+ } | |
+ | |
+ if ( value !== undefined ) { | |
+ if ( value === null ) { | |
+ jQuery.removeAttr( elem, name ); | |
+ return; | |
+ } | |
+ | |
+ if ( hooks && "set" in hooks && | |
+ ( ret = hooks.set( elem, value, name ) ) !== u… | |
+ return ret; | |
+ } | |
+ | |
+ elem.setAttribute( name, value + "" ); | |
+ return value; | |
+ } | |
+ | |
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name … | |
+ return ret; | |
+ } | |
+ | |
+ ret = jQuery.find.attr( elem, name ); | |
+ | |
+ // Non-existent attributes return null, we normalize to undefi… | |
+ return ret == null ? undefined : ret; | |
+ }, | |
+ | |
+ attrHooks: { | |
+ type: { | |
+ set: function( elem, value ) { | |
+ if ( !support.radioValue && value === "radio" … | |
+ jQuery.nodeName( elem, "input" ) ) { | |
+ var val = elem.value; | |
+ elem.setAttribute( "type", value ); | |
+ if ( val ) { | |
+ elem.value = val; | |
} | |
- } else { | |
- tmp = map[ jqXHR.status ]; | |
- jqXHR.then( tmp, tmp ); | |
+ return value; | |
} | |
} | |
- return this; | |
- }; | |
+ } | |
+ }, | |
- // Remove hash character (#7531: and string promotion) | |
- // Add protocol if not provided (#5866: IE7 issue with protoco… | |
- // We also use the url parameter if available | |
- s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace… | |
+ removeAttr: function( elem, value ) { | |
+ var name, | |
+ i = 0, | |
- // Extract dataTypes list | |
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().s… | |
+ // Attribute names can contain non-HTML whitespace cha… | |
+ // https://html.spec.whatwg.org/multipage/syntax.html#… | |
+ attrNames = value && value.match( rnothtmlwhite ); | |
- // Determine if a cross-domain request is in order | |
- if ( s.crossDomain == null ) { | |
- parts = rurl.exec( s.url.toLowerCase() ); | |
- s.crossDomain = !!( parts && | |
- ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 … | |
- ( parts[ 3 ] || ( parts[ 1 ] === "http… | |
- ( ajaxLocParts[ 3 ] || ( ajaxL… | |
- ); | |
+ if ( attrNames && elem.nodeType === 1 ) { | |
+ while ( ( name = attrNames[ i++ ] ) ) { | |
+ elem.removeAttribute( name ); | |
+ } | |
} | |
+ } | |
+} ); | |
- // Convert data if not already a string | |
- if ( s.data && s.processData && typeof s.data !== "string" ) { | |
- s.data = jQuery.param( s.data, s.traditional ); | |
+// 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; | |
+ } | |
+}; | |
- // Apply prefilters | |
- inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name … | |
+ var getter = attrHandle[ name ] || jQuery.find.attr; | |
- // If request was aborted inside a prefilter, stop there | |
- if ( state === 2 ) { | |
- return false; | |
+ attrHandle[ name ] = function( elem, name, isXML ) { | |
+ var ret, handle, | |
+ lowercaseName = name.toLowerCase(); | |
+ | |
+ if ( !isXML ) { | |
+ | |
+ // Avoid an infinite loop by temporarily removing this… | |
+ handle = attrHandle[ lowercaseName ]; | |
+ attrHandle[ lowercaseName ] = ret; | |
+ ret = getter( elem, name, isXML ) != null ? | |
+ lowercaseName : | |
+ null; | |
+ attrHandle[ lowercaseName ] = handle; | |
} | |
+ return ret; | |
+ }; | |
+} ); | |
- // 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" ); | |
+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.lengt… | |
+ }, | |
+ | |
+ 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 nod… | |
+ if ( nType === 3 || nType === 8 || nType === 2 ) { | |
+ return; | |
} | |
- // More options handling for requests with no content | |
- if ( !s.hasContent ) { | |
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { | |
- // If data is available, append data to url | |
- if ( s.data ) { | |
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) … | |
- // #9682: remove data so that it's not used in… | |
- delete s.data; | |
+ // 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 ) ) !== u… | |
+ return ret; | |
} | |
- // Get ifModifiedKey before adding the anti-cache para… | |
- ifModifiedKey = s.url; | |
+ return ( elem[ name ] = value ); | |
+ } | |
+ | |
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name … | |
+ 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 explicitl… | |
+ // https://web.archive.org/web/20141116233347/… | |
+ // Use proper attribute retrieval(#12072) | |
+ var tabindex = jQuery.find.attr( elem, "tabind… | |
+ | |
+ 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://html.spec.whatwg.org/multipage/infrastructure.html#strip-an… | |
+ function stripAndCollapse( value ) { | |
+ var tokens = value.match( rnothtmlwhite ) || []; | |
+ return tokens.join( " " ); | |
+ } | |
+ | |
+ | |
+function getClass( elem ) { | |
+ return elem.getAttribute && elem.getAttribute( "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, … | |
+ } ); | |
+ } | |
+ | |
+ if ( typeof value === "string" && value ) { | |
+ classes = value.match( rnothtmlwhite ) || []; | |
+ | |
+ while ( ( elem = this[ i++ ] ) ) { | |
+ curValue = getClass( elem ); | |
+ cur = elem.nodeType === 1 && ( " " + stripAndC… | |
+ | |
+ if ( cur ) { | |
+ j = 0; | |
+ while ( ( clazz = classes[ j++ ] ) ) { | |
+ if ( cur.indexOf( " " + clazz … | |
+ cur += clazz + " "; | |
+ } | |
+ } | |
+ | |
+ // Only assign if different to avoid u… | |
+ finalValue = stripAndCollapse( cur ); | |
+ if ( curValue !== finalValue ) { | |
+ elem.setAttribute( "class", fi… | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
+ 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, … | |
+ } ); | |
+ } | |
+ | |
+ if ( !arguments.length ) { | |
+ return this.attr( "class", "" ); | |
+ } | |
+ | |
+ if ( typeof value === "string" && value ) { | |
+ classes = value.match( rnothtmlwhite ) || []; | |
+ | |
+ while ( ( elem = this[ i++ ] ) ) { | |
+ curValue = getClass( elem ); | |
+ | |
+ // This expression is here for better compress… | |
+ cur = elem.nodeType === 1 && ( " " + stripAndC… | |
+ | |
+ if ( cur ) { | |
+ j = 0; | |
+ while ( ( clazz = classes[ j++ ] ) ) { | |
+ | |
+ // Remove *all* instances | |
+ while ( cur.indexOf( " " + cla… | |
+ cur = cur.replace( " "… | |
+ } | |
+ } | |
+ | |
+ // Only assign if different to avoid u… | |
+ finalValue = stripAndCollapse( cur ); | |
+ if ( curValue !== finalValue ) { | |
+ elem.setAttribute( "class", fi… | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
+ return this; | |
+ }, | |
+ | |
+ toggleClass: function( value, stateVal ) { | |
+ var type = typeof value; | |
+ | |
+ if ( typeof stateVal === "boolean" && type === "string" ) { | |
+ return stateVal ? this.addClass( value ) : this.remove… | |
+ } | |
+ | |
+ if ( jQuery.isFunction( value ) ) { | |
+ return this.each( function( i ) { | |
+ jQuery( this ).toggleClass( | |
+ value.call( this, i, getClass( this ),… | |
+ 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( rnothtmlwhite ) || [… | |
+ | |
+ while ( ( className = classNames[ i++ ] ) ) { | |
+ | |
+ // Check each className given, space s… | |
+ 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__", c… | |
+ } | |
+ | |
+ // If the element has a class name or if we're… | |
+ // then remove the whole classname (if there w… | |
+ // Otherwise bring back whatever was previousl… | |
+ // falling back to the empty string if nothing… | |
+ if ( this.setAttribute ) { | |
+ this.setAttribute( "class", | |
+ className || value === false ? | |
+ "" : | |
+ dataPriv.get( this, "__classNa… | |
+ ); | |
+ } | |
+ } | |
+ } ); | |
+ }, | |
+ | |
+ hasClass: function( selector ) { | |
+ var className, elem, | |
+ i = 0; | |
+ | |
+ className = " " + selector + " "; | |
+ while ( ( elem = this[ i++ ] ) ) { | |
+ if ( elem.nodeType === 1 && | |
+ ( " " + stripAndCollapse( getClass( elem ) ) +… | |
+ return true; | |
+ } | |
+ } | |
+ | |
+ return false; | |
+ } | |
+} ); | |
+ | |
+ | |
+ | |
+ | |
+var rreturn = /\r/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.toLower… | |
+ | |
+ if ( hooks && | |
+ "get" in hooks && | |
+ ( ret = hooks.get( elem, "value" ) ) !… | |
+ ) { | |
+ 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 n… | |
+ return 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 stri… | |
+ 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.valHook… | |
+ | |
+ // If set returns undefined, fall back to normal setti… | |
+ if ( !hooks || !( "set" in hooks ) || hooks.set( this,… | |
+ 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 (#146… | |
+ // Strip and collapse whitespace | |
+ // https://html.spec.whatwg.org/#strip… | |
+ 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… | |
+ if ( ( option.selected || i === index … | |
+ | |
+ // Don't return option… | |
+ !option.disabled && | |
+ ( !option.parentNode.d… | |
+ !jQuery.nodeNa… | |
+ | |
+ // Get the specific value for … | |
+ value = jQuery( option ).val(); | |
+ | |
+ // We don't need an array for … | |
+ if ( one ) { | |
+ return value; | |
+ } | |
+ | |
+ // Multi-Selects return an arr… | |
+ 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.valHook… | |
+ ) { | |
+ optionSet = true; | |
+ } | |
+ | |
+ /* eslint-enable no-cond-assign */ | |
+ } | |
+ | |
+ // Force browsers to behave consistently when … | |
+ 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 ( jQuery.isArray( value ) ) { | |
+ return ( elem.checked = jQuery.inArray( jQuery… | |
+ } | |
+ } | |
+ }; | |
+ if ( !support.checkOn ) { | |
+ jQuery.valHooks[ this ].get = function( elem ) { | |
+ return elem.getAttribute( "value" ) === null ? "on" : … | |
+ }; | |
+ } | |
+} ); | |
+ | |
+ | |
+ | |
+ | |
+// Return jQuery for attributes-only inclusion | |
+ | |
+ | |
+var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; | |
+ | |
+jQuery.extend( jQuery.event, { | |
+ | |
+ trigger: function( event, data, elem, onlyHandlers ) { | |
+ | |
+ var i, cur, tmp, bubbleType, ontype, handle, special, | |
+ eventPath = [ elem || document ], | |
+ type = hasOwn.call( event, "type" ) ? event.type : eve… | |
+ namespaces = hasOwn.call( event, "namespace" ) ? event… | |
+ | |
+ 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 t… | |
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
+ return; | |
+ } | |
+ | |
+ if ( type.indexOf( "." ) > -1 ) { | |
+ | |
+ // Namespaced trigger; create a regexp to match event … | |
+ 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 a… | |
+ event = event[ jQuery.expando ] ? | |
+ event : | |
+ new jQuery.Event( type, typeof event === "object" && e… | |
+ | |
+ // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (a… | |
+ 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… | |
+ 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… | |
+ return; | |
+ } | |
+ | |
+ // Determine event propagation path in advance, per W3C events… | |
+ // Bubble up to document, then to window; watch for a global o… | |
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( e… | |
+ | |
+ 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 pl… | |
+ if ( tmp === ( elem.ownerDocument || document ) ) { | |
+ eventPath.push( tmp.defaultView || tmp.parentW… | |
+ } | |
+ } | |
+ | |
+ // Fire handlers on the event path | |
+ i = 0; | |
+ while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStop… | |
+ | |
+ event.type = i > 1 ? | |
+ bubbleType : | |
+ special.bindType || type; | |
+ | |
+ // jQuery handler | |
+ handle = ( dataPriv.get( cur, "events" ) || {} )[ even… | |
+ 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 … | |
+ acceptData( elem ) ) { | |
+ | |
+ // Call a native DOM method on the target with… | |
+ // Don't do default actions on window, that's … | |
+ if ( ontype && jQuery.isFunction( elem[ type ]… | |
+ | |
+ // Don't re-trigger an onFOO event whe… | |
+ tmp = elem[ ontype ]; | |
+ | |
+ if ( tmp ) { | |
+ elem[ ontype ] = null; | |
+ } | |
+ | |
+ // Prevent re-triggering of the same e… | |
+ jQuery.event.triggered = type; | |
+ elem[ type ](); | |
+ 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 ); | |
+ } | |
+ } | |
+} ); | |
+ | |
- // Add anti-cache in url if needed | |
- if ( s.cache === false ) { | |
+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 ) { | |
- var ts = jQuery.now(), | |
- // try replacing _= if it is there | |
- ret = s.url.replace( rts, "$1_=" + ts … | |
+ // Handle event binding | |
+ jQuery.fn[ name ] = function( data, fn ) { | |
+ return arguments.length > 0 ? | |
+ this.on( name, null, data, fn ) : | |
+ this.trigger( name ); | |
+ }; | |
+} ); | |
- // if nothing was replaced, add timestamp to t… | |
- s.url = ret + ( ( ret === s.url ) ? ( rquery.t… | |
- } | |
- } | |
+jQuery.fn.extend( { | |
+ hover: function( fnOver, fnOut ) { | |
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
+ } | |
+} ); | |
- // Set the correct header, if data is being sent | |
- if ( s.data && s.hasContent && s.contentType !== false || opti… | |
- jqXHR.setRequestHeader( "Content-Type", s.contentType … | |
- } | |
- // Set the If-Modified-Since and/or If-None-Match header, if i… | |
- if ( s.ifModified ) { | |
- ifModifiedKey = ifModifiedKey || s.url; | |
- if ( jQuery.lastModified[ ifModifiedKey ] ) { | |
- jqXHR.setRequestHeader( "If-Modified-Since", j… | |
- } | |
- if ( jQuery.etag[ ifModifiedKey ] ) { | |
- jqXHR.setRequestHeader( "If-None-Match", jQuer… | |
- } | |
- } | |
- // Set the Accepts header for the server, depending on the dat… | |
- jqXHR.setRequestHeader( | |
- "Accept", | |
- s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? | |
- s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0… | |
- s.accepts[ "*" ] | |
- ); | |
- // Check for headers option | |
- for ( i in s.headers ) { | |
- jqXHR.setRequestHeader( i, s.headers[ i ] ); | |
- } | |
+support.focusin = "onfocusin" in window; | |
- // Allow custom headers/mimetypes and early abort | |
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqX… | |
- // Abort if not done already | |
- jqXHR.abort(); | |
- return false; | |
- } | |
+// 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-f… | |
+// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=4498… | |
+if ( !support.focusin ) { | |
+ jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, f… | |
- // Install callbacks on deferreds | |
- for ( i in { success: 1, error: 1, complete: 1 } ) { | |
- jqXHR[ i ]( s[ i ] ); | |
- } | |
+ // Attach a single capturing handler on the document while som… | |
+ var handler = function( event ) { | |
+ jQuery.event.simulate( fix, event.target, jQuery.event… | |
+ }; | |
- // Get transport | |
- transport = inspectPrefiltersOrTransports( transports, s, opti… | |
+ jQuery.event.special[ fix ] = { | |
+ setup: function() { | |
+ var doc = this.ownerDocument || this, | |
+ attaches = dataPriv.access( doc, fix ); | |
- // If no transport, we auto-abort | |
- if ( !transport ) { | |
- done( -1, "No Transport" ); | |
- } else { | |
- jqXHR.readyState = 1; | |
- // Send global event | |
- if ( fireGlobals ) { | |
- globalEventContext.trigger( "ajaxSend", [ jqXH… | |
- } | |
- // Timeout | |
- if ( s.async && s.timeout > 0 ) { | |
- timeoutTimer = setTimeout( function(){ | |
- jqXHR.abort( "timeout" ); | |
- }, s.timeout ); | |
- } | |
+ if ( !attaches ) { | |
+ doc.addEventListener( orig, handler, t… | |
+ } | |
+ dataPriv.access( doc, fix, ( attaches || 0 ) +… | |
+ }, | |
+ teardown: function() { | |
+ var doc = this.ownerDocument || this, | |
+ attaches = dataPriv.access( doc, fix )… | |
+ | |
+ if ( !attaches ) { | |
+ doc.removeEventListener( orig, handler… | |
+ dataPriv.remove( doc, fix ); | |
- 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; | |
+ dataPriv.access( doc, fix, attaches ); | |
} | |
} | |
- } | |
+ }; | |
+ } ); | |
+} | |
+var location = window.location; | |
- return jqXHR; | |
- }, | |
+var nonce = jQuery.now(); | |
- // Serialize an array of form elements or a set of | |
- // key/values into a query string | |
- param: function( a, traditional ) { | |
- var s = [], | |
- add = function( key, value ) { | |
- // If value is a function, invoke it and retur… | |
- value = jQuery.isFunction( value ) ? value() :… | |
- s[ s.length ] = encodeURIComponent( key ) + "=… | |
- }; | |
+var rquery = ( /\?/ ); | |
- // Set traditional to true for jQuery <= 1.3.2 behavior. | |
- if ( traditional === undefined ) { | |
- traditional = jQuery.ajaxSettings.traditional; | |
- } | |
- // If an array was passed in, assume that it is an array of fo… | |
- if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObjec… | |
- // 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… | |
- // did it), otherwise encode params recursively. | |
- for ( var prefix in a ) { | |
- buildParams( prefix, a[ prefix ], traditional,… | |
- } | |
- } | |
+// Cross-browser xml parsing | |
+jQuery.parseXML = function( data ) { | |
+ var xml; | |
+ if ( !data || typeof data !== "string" ) { | |
+ return null; | |
+ } | |
- // Return the resulting serialization | |
- return s.join( "&" ).replace( r20, "+" ); | |
+ // Support: IE 9 - 11 only | |
+ // IE throws on parseFromString with invalid input. | |
+ try { | |
+ xml = ( new window.DOMParser() ).parseFromString( data, "text/… | |
+ } 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 ( 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 objec… | |
- // numeric index to resolve deserialization am… | |
- // Note that rack (as of 1.0.0) can't currentl… | |
- // nested arrays properly, and attempting to d… | |
- // a server error. Possible fixes are to modif… | |
- // deserialization algorithm or to provide an … | |
- // to force array serialization to be shallow. | |
- buildParams( prefix + "[" + ( typeof v === "ob… | |
+ | |
+ // Item is non-scalar (array or object), encod… | |
+ buildParams( | |
+ prefix + "[" + ( typeof v === "object"… | |
+ v, | |
+ traditional, | |
+ add | |
+ ); | |
} | |
- }); | |
+ } ); | |
} else if ( !traditional && jQuery.type( obj ) === "object" ) { | |
+ | |
// Serialize object item. | |
- for ( var name in obj ) { | |
+ for ( name in obj ) { | |
buildParams( prefix + "[" + name + "]", obj[ name ], t… | |
} | |
} else { | |
+ | |
// Serialize scalar item. | |
add( prefix, obj ); | |
} | |
} | |
-// This is still on the jQuery object... for now | |
-// Want to move this to jQuery.ajax some day | |
-jQuery.extend({ | |
+// 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 ) { | |
- // Counter for holding the number of active queries | |
- active: 0, | |
+ // If value is a function, invoke it and use its retur… | |
+ var value = jQuery.isFunction( valueOrFunction ) ? | |
+ valueOrFunction() : | |
+ valueOrFunction; | |
- // Last-Modified header cache for next request | |
- lastModified: {}, | |
- etag: {} | |
+ s[ s.length ] = encodeURIComponent( key ) + "=" + | |
+ encodeURIComponent( value == null ? "" : value… | |
+ }; | |
-}); | |
+ // If an array was passed in, assume that it is an array of form eleme… | |
+ 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( "&" ); | |
+}; | |
+ | |
+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 fo… | |
+ 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] w… | |
+ return this.name && !jQuery( this ).is( ":disabled" ) … | |
+ rsubmittable.test( this.nodeName ) && !rsubmit… | |
+ ( this.checked || !rcheckableType.test( type )… | |
+ } ) | |
+ .map( function( i, elem ) { | |
+ var val = jQuery( this ).val(); | |
+ | |
+ if ( val == null ) { | |
+ return null; | |
+ } | |
+ | |
+ if ( jQuery.isArray( val ) ) { | |
+ return jQuery.map( val, function( val ) { | |
+ return { name: elem.name, value: val.r… | |
+ } ); | |
+ } | |
+ | |
+ return { name: elem.name, value: val.replace( rCRLF, "… | |
+ } ).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|widg… | |
+ rnoContent = /^(?:GET|HEAD)$/, | |
+ rprotocol = /^\/\//, | |
+ | |
+ /* Prefilters | |
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js… | |
+ * 2) These are called: | |
+ * - BEFORE asking for a transport | |
+ * - AFTER param serialization (s.data is a string if s.processData… | |
+ * 3) key is the dataType | |
+ * 4) the catchall symbol "*" can be used | |
+ * 5) execution will start with transport dataType and THEN continue d… | |
+ */ | |
+ 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 "*" … | |
+ */ | |
+ transports = {}, | |
+ | |
+ // Avoid comment-prolog char sequence (#10098); must appease lint and … | |
+ 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( rn… | |
+ | |
+ if ( jQuery.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[ d… | |
+ | |
+ // Otherwise append | |
+ } else { | |
+ ( structure[ dataType ] = structure[ d… | |
+ } | |
+ } | |
+ } | |
+ }; | |
+} | |
+ | |
+// Base inspection function for prefilters and transports | |
+function inspectPrefiltersOrTransports( structure, options, originalOptions, j… | |
+ | |
+ var inspected = {}, | |
+ seekingTransport = ( structure === transports ); | |
+ | |
+ function inspect( dataType ) { | |
+ var selected; | |
+ inspected[ dataType ] = true; | |
+ jQuery.each( structure[ dataType ] || [], function( _, prefilt… | |
+ var dataTypeOrTransport = prefilterOrFactory( options,… | |
+ if ( typeof dataTypeOrTransport === "string" && | |
+ !seekingTransport && !inspected[ dataTypeOrTra… | |
+ | |
+ options.dataTypes.unshift( dataTypeOrTransport… | |
+ inspect( dataTypeOrTransport ); | |
+ return false; | |
+ } else if ( seekingTransport ) { | |
+ return !( selected = dataTypeOrTransport ); | |
+ } | |
+ } ); | |
+ return selected; | |
+ } | |
+ | |
+ return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspe… | |
+} | |
+ | |
+// 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 = {} … | |
+ } | |
+ } | |
+ if ( deep ) { | |
+ jQuery.extend( true, target, deep ); | |
+ } | |
+ | |
+ return target; | |
+} | |
/* Handles responses to an ajax request: | |
- * - sets all responseXXX fields accordingly | |
* - finds the right dataType (mediates between content-type and expected data… | |
* - returns the corresponding response | |
*/ | |
function ajaxHandleResponses( s, jqXHR, responses ) { | |
- var contents = s.contents, | |
- dataTypes = s.dataTypes, | |
- responseFields = s.responseFields, | |
- ct, | |
- type, | |
- finalDataType, | |
- firstDataType; | |
- | |
- // Fill responseXXX fields | |
- for ( type in responseFields ) { | |
- if ( type in responses ) { | |
- jqXHR[ responseFields[type] ] = responses[ type ]; | |
- } | |
- } | |
+ var ct, type, finalDataType, firstDataType, | |
+ contents = s.contents, | |
+ dataTypes = s.dataTypes; | |
// Remove auto dataType and get content-type in the process | |
- while( dataTypes[ 0 ] === "*" ) { | |
+ while ( dataTypes[ 0 ] === "*" ) { | |
dataTypes.shift(); | |
if ( ct === undefined ) { | |
- ct = s.mimeType || jqXHR.getResponseHeader( "content-t… | |
+ ct = s.mimeType || jqXHR.getResponseHeader( "Content-T… | |
} | |
} | |
t@@ -7855,9 +8611,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) { | |
if ( dataTypes[ 0 ] in responses ) { | |
finalDataType = dataTypes[ 0 ]; | |
} else { | |
+ | |
// Try convertible dataTypes | |
for ( type in responses ) { | |
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dat… | |
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dat… | |
finalDataType = type; | |
break; | |
} | |
t@@ -7865,6 +8622,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { | |
firstDataType = type; | |
} | |
} | |
+ | |
// Or just use first one | |
finalDataType = finalDataType || firstDataType; | |
} | |
t@@ -7880,1331 +8638,1285 @@ function ajaxHandleResponses( s, jqXHR, responses … | |
} | |
} | |
-// Chain conversions given the request and the original response | |
-function ajaxConvert( s, response ) { | |
+/* 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 = {}, | |
- // Apply the dataFilter if provided | |
- if ( s.dataFilter ) { | |
- response = s.dataFilter( response, s.dataType ); | |
+ // Work with a copy of dataTypes in case we need to modify it … | |
+ dataTypes = s.dataTypes.slice(); | |
+ | |
+ // Create converters map with lowercased keys | |
+ if ( dataTypes[ 1 ] ) { | |
+ for ( conv in s.converters ) { | |
+ converters[ conv.toLowerCase() ] = s.converters[ conv … | |
+ } | |
} | |
- var dataTypes = s.dataTypes, | |
- converters = {}, | |
- i, | |
- key, | |
- length = dataTypes.length, | |
- tmp, | |
- // Current and previous dataTypes | |
- current = dataTypes[ 0 ], | |
- prev, | |
- // Conversion expression | |
- conversion, | |
- // Conversion function | |
- conv, | |
- // Conversion functions (transitive conversion) | |
- conv1, | |
- conv2; | |
- | |
- // For each dataType in the chain | |
- for ( i = 1; i < length; i++ ) { | |
- | |
- // Create converters map | |
- // with lowercased keys | |
- if ( i === 1 ) { | |
- for ( key in s.converters ) { | |
- if ( typeof key === "string" ) { | |
- converters[ key.toLowerCase() ] = s.co… | |
- } | |
- } | |
- } | |
- | |
- // Get the dataTypes | |
+ 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[ i ]; | |
- | |
- // If current is auto dataType, update it to prev | |
- if ( current === "*" ) { | |
- current = prev; | |
- // If no auto and dataTypes are actually different | |
- } else if ( prev !== "*" && prev !== current ) { | |
- | |
- // Get the converter | |
- conversion = prev + " " + current; | |
- conv = converters[ conversion ] || converters[ "* " + … | |
- | |
- // If there is no direct converter, search transitively | |
- if ( !conv ) { | |
- conv2 = undefined; | |
- for ( conv1 in converters ) { | |
- tmp = conv1.split( " " ); | |
- if ( tmp[ 0 ] === prev || tmp[ 0 ] ===… | |
- conv2 = converters[ tmp[1] + "… | |
- if ( conv2 ) { | |
- conv1 = converters[ co… | |
- if ( conv1 === true ) { | |
- conv = conv2; | |
- } else if ( conv2 === … | |
- conv = conv1; | |
+ current = dataTypes.shift(); | |
+ | |
+ if ( current ) { | |
+ | |
+ // There's only work to do if current dataType is non-… | |
+ if ( current === "*" ) { | |
+ | |
+ current = prev; | |
+ | |
+ // Convert response if prev dataType is non-auto and d… | |
+ } else if ( prev !== "*" && prev !== current ) { | |
+ | |
+ // Seek a direct converter | |
+ conv = converters[ prev + " " + current ] || c… | |
+ | |
+ // 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 conv… | |
+ conv = converters[ pre… | |
+ converters[ "*… | |
+ if ( conv ) { | |
+ | |
+ // Condense eq… | |
+ if ( conv === … | |
+ conv =… | |
+ | |
+ // Otherwise, … | |
+ } else if ( co… | |
+ curren… | |
+ dataTy… | |
+ } | |
+ break; | |
} | |
- break; | |
} | |
} | |
} | |
- } | |
- // If we found no converter, dispatch an error | |
- if ( !( conv || conv2 ) ) { | |
- jQuery.error( "No conversion from " + conversi… | |
- } | |
- // If found converter is not an equivalence | |
- if ( conv !== true ) { | |
- // Convert with 1 or 2 converters accordingly | |
- response = conv ? conv( response ) : conv2( co… | |
+ | |
+ // Apply converter (if not an equivalence) | |
+ if ( conv !== true ) { | |
+ | |
+ // Unless errors are allowed to bubble… | |
+ if ( conv && s.throws ) { | |
+ response = conv( response ); | |
+ } else { | |
+ try { | |
+ response = conv( respo… | |
+ } catch ( e ) { | |
+ return { | |
+ state: "parser… | |
+ error: conv ? … | |
+ }; | |
+ } | |
+ } | |
+ } | |
} | |
} | |
} | |
- return response; | |
+ | |
+ 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/ | |
+ }, | |
-var jsc = jQuery.now(), | |
- jsre = /(\=)\?(&|$)|\?\?/i; | |
+ responseFields: { | |
+ xml: "responseXML", | |
+ text: "responseText", | |
+ json: "responseJSON" | |
+ }, | |
-// Default jsonp settings | |
-jQuery.ajaxSetup({ | |
- jsonp: "callback", | |
- jsonpCallback: function() { | |
- return jQuery.expando + "_" + ( jsc++ ); | |
- } | |
-}); | |
+ // Data converters | |
+ // Keys separate source (or catchall "*") and destination type… | |
+ converters: { | |
-// Detect, normalize options and install callbacks for jsonp requests | |
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
+ // Convert anything to text | |
+ "* text": String, | |
- var inspectData = ( typeof s.data === "string" ) && /^application\/x\-… | |
+ // Text to html (true = no transformation) | |
+ "text html": true, | |
- if ( s.dataTypes[ 0 ] === "jsonp" || | |
- s.jsonp !== false && ( jsre.test( s.url ) || | |
- inspectData && jsre.test( s.data ) ) ) { | |
+ // Evaluate text as a json expression | |
+ "text json": JSON.parse, | |
- var responseContainer, | |
- jsonpCallback = s.jsonpCallback = | |
- jQuery.isFunction( s.jsonpCallback ) ? s.jsonp… | |
- previous = window[ jsonpCallback ], | |
- url = s.url, | |
- data = s.data, | |
- replace = "$1" + jsonpCallback + "$2"; | |
+ // Parse text as xml | |
+ "text xml": jQuery.parseXML | |
+ }, | |
- if ( s.jsonp !== false ) { | |
- url = url.replace( jsre, replace ); | |
- if ( s.url === url ) { | |
- if ( inspectData ) { | |
- data = data.replace( jsre, replace ); | |
- } | |
- if ( s.data === data ) { | |
- // Add callback manually | |
- url += (/\?/.test( url ) ? "&" : "?") … | |
- } | |
- } | |
+ // 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 | |
} | |
+ }, | |
- s.url = url; | |
- s.data = data; | |
- | |
- // Install callback | |
- window[ jsonpCallback ] = function( response ) { | |
- responseContainer = [ response ]; | |
- }; | |
+ // 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 ? | |
- // Clean-up function | |
- jqXHR.always(function() { | |
- // Set callback back to previous value | |
- window[ jsonpCallback ] = previous; | |
- // Call if it was a function and we have a response | |
- if ( responseContainer && jQuery.isFunction( previous … | |
- window[ jsonpCallback ]( responseContainer[ 0 … | |
- } | |
- }); | |
+ // Building a settings object | |
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ),… | |
- // Use data converter to retrieve json after script execution | |
- s.converters["script json"] = function() { | |
- if ( !responseContainer ) { | |
- jQuery.error( jsonpCallback + " was not called… | |
- } | |
- return responseContainer[ 0 ]; | |
- }; | |
+ // Extending ajaxSettings | |
+ ajaxExtend( jQuery.ajaxSettings, target ); | |
+ }, | |
- // force json dataType | |
- s.dataTypes[ 0 ] = "json"; | |
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
+ ajaxTransport: addToPrefiltersOrTransports( transports ), | |
- // Delegate to script | |
- return "script"; | |
- } | |
-}); | |
+ // 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, | |
-// Install script dataType | |
-jQuery.ajaxSetup({ | |
- accepts: { | |
- script: "text/javascript, application/javascript, application/… | |
- }, | |
- contents: { | |
- script: /javascript|ecmascript/ | |
- }, | |
- converters: { | |
- "text script": function( text ) { | |
- jQuery.globalEval( text ); | |
- return text; | |
- } | |
- } | |
-}); | |
+ // URL without anti-cache param | |
+ cacheURL, | |
-// 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; | |
- } | |
-}); | |
+ // Response headers | |
+ responseHeadersString, | |
+ responseHeaders, | |
-// Bind script tag hack transport | |
-jQuery.ajaxTransport( "script", function(s) { | |
+ // timeout handle | |
+ timeoutTimer, | |
- // This transport only deals with cross domain requests | |
- if ( s.crossDomain ) { | |
+ // Url cleanup var | |
+ urlAnchor, | |
- var script, | |
- head = document.head || document.getElementsByTagName(… | |
+ // Request state (becomes false upon send and true upo… | |
+ completed, | |
- return { | |
+ // To know if global events are to be dispatched | |
+ fireGlobals, | |
- send: function( _, callback ) { | |
+ // Loop variable | |
+ i, | |
- script = document.createElement( "script" ); | |
+ // uncached part of the url | |
+ uncached, | |
- script.async = "async"; | |
+ // Create the final options object | |
+ s = jQuery.ajaxSetup( {}, options ), | |
- if ( s.scriptCharset ) { | |
- script.charset = s.scriptCharset; | |
- } | |
+ // Callbacks context | |
+ callbackContext = s.context || s, | |
- script.src = s.url; | |
+ // Context for global events is callbackContext if it … | |
+ globalEventContext = s.context && | |
+ ( callbackContext.nodeType || callbackContext.… | |
+ jQuery( callbackContext ) : | |
+ jQuery.event, | |
- // Attach handlers for all browsers | |
- script.onload = script.onreadystatechange = fu… | |
+ // Deferreds | |
+ deferred = jQuery.Deferred(), | |
+ completeDeferred = jQuery.Callbacks( "once memory" ), | |
- if ( isAbort || !script.readyState || … | |
+ // Status-dependent callbacks | |
+ statusCode = s.statusCode || {}, | |
- // Handle memory leak in IE | |
- script.onload = script.onready… | |
+ // Headers (they are sent all at once) | |
+ requestHeaders = {}, | |
+ requestHeadersNames = {}, | |
- // Remove the script | |
- if ( head && script.parentNode… | |
- head.removeChild( scri… | |
- } | |
+ // Default abort message | |
+ strAbort = "canceled", | |
- // Dereference the script | |
- script = undefined; | |
+ // Fake xhr | |
+ jqXHR = { | |
+ readyState: 0, | |
- // Callback if not abort | |
- if ( !isAbort ) { | |
- callback( 200, "succes… | |
+ // Builds headers hashtable if needed | |
+ getResponseHeader: function( key ) { | |
+ var match; | |
+ if ( completed ) { | |
+ if ( !responseHeaders ) { | |
+ responseHeaders = {}; | |
+ while ( ( match = rhea… | |
+ responseHeader… | |
+ } | |
} | |
+ match = responseHeaders[ key.t… | |
} | |
- }; | |
- // Use insertBefore instead of appendChild to… | |
- // This arises when a base node is used (#2709… | |
- head.insertBefore( script, head.firstChild ); | |
- }, | |
+ return match == null ? null : match; | |
+ }, | |
- abort: function() { | |
- if ( script ) { | |
- script.onload( 0, 1 ); | |
- } | |
- } | |
- }; | |
- } | |
-}); | |
+ // Raw string | |
+ getAllResponseHeaders: function() { | |
+ return completed ? responseHeadersStri… | |
+ }, | |
+ // Caches the header | |
+ setRequestHeader: function( name, value ) { | |
+ if ( completed == null ) { | |
+ name = requestHeadersNames[ na… | |
+ requestHeadersNames[ n… | |
+ 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 ) { | |
-var // #5280: Internet Explorer will keep connections alive if we don't abort … | |
- xhrOnUnloadAbort = window.ActiveXObject ? function() { | |
- // Abort all pending requests | |
- for ( var key in xhrCallbacks ) { | |
- xhrCallbacks[ key ]( 0, 1 ); | |
- } | |
- } : false, | |
- xhrId = 0, | |
- xhrCallbacks; | |
+ // Execute the appropr… | |
+ jqXHR.always( map[ jqX… | |
+ } else { | |
-// Functions to create xhrs | |
-function createStandardXHR() { | |
- try { | |
- return new window.XMLHttpRequest(); | |
- } catch( e ) {} | |
-} | |
+ // Lazy-add the new ca… | |
+ for ( code in map ) { | |
+ statusCode[ co… | |
+ } | |
+ } | |
+ } | |
+ return this; | |
+ }, | |
-function createActiveXHR() { | |
- try { | |
- return new window.ActiveXObject( "Microsoft.XMLHTTP" ); | |
- } catch( e ) {} | |
-} | |
+ // Cancel the request | |
+ abort: function( statusText ) { | |
+ var finalText = statusText || strAbort; | |
+ if ( transport ) { | |
+ transport.abort( finalText ); | |
+ } | |
+ done( 0, finalText ); | |
+ return this; | |
+ } | |
+ }; | |
-// 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() ); | |
+ // Attach deferreds | |
+ deferred.promise( jqXHR ); | |
-// Create transport if the browser can provide an xhr | |
-if ( jQuery.support.ajax ) { | |
+ // Add protocol if not provided (prefilters might expect it) | |
+ // Handle falsy url in the settings object (#10093: consistenc… | |
+ // We also use the url parameter if available | |
+ s.url = ( ( url || s.url || location.href ) + "" ) | |
+ .replace( rprotocol, location.protocol + "//" ); | |
- jQuery.ajaxTransport(function( s ) { | |
- // Cross domain only allowed if supported through XMLHttpReque… | |
- if ( !s.crossDomain || jQuery.support.cors ) { | |
+ // Alias method option to type as per ticket #12004 | |
+ s.type = options.method || options.type || s.method || s.type; | |
- var callback; | |
+ // Extract dataTypes list | |
+ s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnoth… | |
- return { | |
- send: function( headers, complete ) { | |
+ // A cross-domain request is in order when the origin doesn't … | |
+ if ( s.crossDomain == null ) { | |
+ urlAnchor = document.createElement( "a" ); | |
- // Get a new xhr | |
- var xhr = s.xhr(), | |
- handle, | |
- i; | |
+ // Support: IE <=8 - 11, Edge 12 - 13 | |
+ // IE throws exception on accessing the href property … | |
+ // e.g. http://example.com:80x/ | |
+ try { | |
+ urlAnchor.href = s.url; | |
- // Open the socket | |
- // Passing null username, generates a … | |
- if ( s.username ) { | |
- xhr.open( s.type, s.url, s.asy… | |
- } else { | |
- xhr.open( s.type, s.url, s.asy… | |
- } | |
+ // Support: IE <=8 - 11 only | |
+ // Anchor's host property isn't correctly set … | |
+ urlAnchor.href = urlAnchor.href; | |
+ s.crossDomain = originAnchor.protocol + "//" +… | |
+ urlAnchor.protocol + "//" + urlAnchor.… | |
+ } catch ( e ) { | |
- // Apply custom fields if provided | |
- if ( s.xhrFields ) { | |
- for ( i in s.xhrFields ) { | |
- xhr[ i ] = s.xhrFields… | |
- } | |
- } | |
+ // If there is an error parsing the URL, assum… | |
+ // it can be rejected by the transport if it i… | |
+ s.crossDomain = true; | |
+ } | |
+ } | |
- // Override mime type if needed | |
- if ( s.mimeType && xhr.overrideMimeTyp… | |
- xhr.overrideMimeType( s.mimeTy… | |
- } | |
+ // Convert data if not already a string | |
+ if ( s.data && s.processData && typeof s.data !== "string" ) { | |
+ s.data = jQuery.param( s.data, s.traditional ); | |
+ } | |
- // X-Requested-With header | |
- // For cross-domain requests, seeing a… | |
- // akin to a jigsaw puzzle, we simply … | |
- // (it can always be set on a per-requ… | |
- // For same-domain requests, won't cha… | |
- if ( !s.crossDomain && !headers["X-Req… | |
- headers[ "X-Requested-With" ] … | |
- } | |
+ // Apply prefilters | |
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
- // Need an extra try/catch for cross d… | |
- try { | |
- for ( i in headers ) { | |
- xhr.setRequestHeader( … | |
- } | |
- } catch( _ ) {} | |
+ // If request was aborted inside a prefilter, stop there | |
+ if ( completed ) { | |
+ return jqXHR; | |
+ } | |
- // Do send the request | |
- // This may raise an exception which i… | |
- // handled in jQuery.ajax (so no try/c… | |
- xhr.send( ( s.hasContent && s.data ) |… | |
+ // We can fire global events as of now if asked to | |
+ // Don't fire events if jQuery.event is undefined in an AMD-us… | |
+ fireGlobals = jQuery.event && s.global; | |
- // Listener | |
- callback = function( _, isAbort ) { | |
+ // Watch for a new set of requests | |
+ if ( fireGlobals && jQuery.active++ === 0 ) { | |
+ jQuery.event.trigger( "ajaxStart" ); | |
+ } | |
- var status, | |
- statusText, | |
- responseHeaders, | |
- responses, | |
- xml; | |
+ // Uppercase the type | |
+ s.type = s.type.toUpperCase(); | |
- // Firefox throws exceptions w… | |
- // of an xhr when a network er… | |
- // http://helpful.knobs-dials.… | |
- try { | |
+ // Determine if request has content | |
+ s.hasContent = !rnoContent.test( s.type ); | |
- // Was never called an… | |
- if ( callback && ( isA… | |
+ // 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, "" ); | |
- // Only called… | |
- callback = und… | |
+ // More options handling for requests with no content | |
+ if ( !s.hasContent ) { | |
- // Do not keep… | |
- if ( handle ) { | |
- xhr.on… | |
- if ( x… | |
- … | |
- } | |
- } | |
+ // Remember the hash so we can put it back | |
+ uncached = s.url.slice( cacheURL.length ); | |
- // If it's an … | |
- if ( isAbort )… | |
- // Abo… | |
- if ( x… | |
- … | |
- } | |
- } else { | |
- status… | |
- respon… | |
- respon… | |
- xml = … | |
- | |
- // Con… | |
- if ( x… | |
- … | |
- } | |
+ // If data is available, append data to url | |
+ if ( s.data ) { | |
+ cacheURL += ( rquery.test( cacheURL ) ? "&" : … | |
- // Whe… | |
- // on … | |
- try { | |
- … | |
- } catc… | |
- } | |
+ // #9682: remove data so that it's not used in… | |
+ delete s.data; | |
+ } | |
- // Fir… | |
- // sta… | |
- try { | |
- … | |
- } catc… | |
- … | |
- … | |
- } | |
+ // Add or update anti-cache param if needed | |
+ if ( s.cache === false ) { | |
+ cacheURL = cacheURL.replace( rantiCache, "$1" … | |
+ uncached = ( rquery.test( cacheURL ) ? "&" : "… | |
+ } | |
- // Fil… | |
+ // Put hash and anti-cache on the URL that will be req… | |
+ s.url = cacheURL + uncached; | |
- // If … | |
- // (su… | |
- // can… | |
- if ( !… | |
- … | |
- // IE … | |
- } else… | |
- … | |
- } | |
- } | |
- } | |
- } catch( firefoxAccessExceptio… | |
- if ( !isAbort ) { | |
- complete( -1, … | |
- } | |
- } | |
+ // Change '%20' to '+' if this is encoded form body content (g… | |
+ } else if ( s.data && s.processData && | |
+ ( s.contentType || "" ).indexOf( "application/x-www-fo… | |
+ s.data = s.data.replace( r20, "+" ); | |
+ } | |
- // Call complete if needed | |
- if ( responses ) { | |
- complete( status, stat… | |
- } | |
- }; | |
+ // Set the If-Modified-Since and/or If-None-Match header, if i… | |
+ if ( s.ifModified ) { | |
+ if ( jQuery.lastModified[ cacheURL ] ) { | |
+ jqXHR.setRequestHeader( "If-Modified-Since", j… | |
+ } | |
+ if ( jQuery.etag[ cacheURL ] ) { | |
+ jqXHR.setRequestHeader( "If-None-Match", jQuer… | |
+ } | |
+ } | |
- // if we're in sync mode or it's in ca… | |
- // and has been retrieved directly (IE… | |
- // we need to manually fire the callba… | |
- if ( !s.async || xhr.readyState === 4 … | |
- callback(); | |
- } else { | |
- handle = ++xhrId; | |
- if ( xhrOnUnloadAbort ) { | |
- // Create the active x… | |
- // and attach the unlo… | |
- if ( !xhrCallbacks ) { | |
- xhrCallbacks =… | |
- jQuery( window… | |
- } | |
- // Add to list of acti… | |
- xhrCallbacks[ handle ]… | |
- } | |
- xhr.onreadystatechange = callb… | |
- } | |
- }, | |
+ // Set the correct header, if data is being sent | |
+ if ( s.data && s.hasContent && s.contentType !== false || opti… | |
+ jqXHR.setRequestHeader( "Content-Type", s.contentType … | |
+ } | |
+ | |
+ // Set the Accepts header for the server, depending on the dat… | |
+ jqXHR.setRequestHeader( | |
+ "Accept", | |
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? | |
+ s.accepts[ s.dataTypes[ 0 ] ] + | |
+ ( s.dataTypes[ 0 ] !== "*" ? ", " + al… | |
+ s.accepts[ "*" ] | |
+ ); | |
- abort: function() { | |
- if ( callback ) { | |
- callback(0,1); | |
- } | |
- } | |
- }; | |
+ // 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 ) === f… | |
+ // Abort if not done already and return | |
+ return jqXHR.abort(); | |
+ } | |
+ // Aborting is no longer a cancellation | |
+ strAbort = "abort"; | |
-var elemdisplay = {}, | |
- iframe, iframeDoc, | |
- rfxtypes = /^(?:toggle|show|hide)$/, | |
- rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, | |
- timerId, | |
- fxAttrs = [ | |
- // height animations | |
- [ "height", "marginTop", "marginBottom", "paddingTop", "paddin… | |
- // width animations | |
- [ "width", "marginLeft", "marginRight", "paddingLeft", "paddin… | |
- // opacity animations | |
- [ "opacity" ] | |
- ], | |
- fxNow; | |
- | |
-jQuery.fn.extend({ | |
- show: function( speed, easing, callback ) { | |
- var elem, display; | |
- | |
- if ( speed || speed === 0 ) { | |
- return this.animate( genFx("show", 3), speed, easing, … | |
+ // Install callbacks on deferreds | |
+ completeDeferred.add( s.complete ); | |
+ jqXHR.done( s.success ); | |
+ jqXHR.fail( s.error ); | |
- } else { | |
- for ( var i = 0, j = this.length; i < j; i++ ) { | |
- elem = this[ i ]; | |
+ // Get transport | |
+ transport = inspectPrefiltersOrTransports( transports, s, opti… | |
- if ( elem.style ) { | |
- display = elem.style.display; | |
+ // If no transport, we auto-abort | |
+ if ( !transport ) { | |
+ done( -1, "No Transport" ); | |
+ } else { | |
+ jqXHR.readyState = 1; | |
- // Reset the inline display of this el… | |
- // being hidden by cascaded rules or n… | |
- if ( !jQuery._data(elem, "olddisplay")… | |
- display = elem.style.display =… | |
- } | |
+ // Send global event | |
+ if ( fireGlobals ) { | |
+ globalEventContext.trigger( "ajaxSend", [ jqXH… | |
+ } | |
- // Set elements which have been overri… | |
- // in a stylesheet to whatever the def… | |
- // for such an element | |
- if ( (display === "" && jQuery.css(ele… | |
- !jQuery.contains( elem.ownerDo… | |
- jQuery._data( elem, "olddispla… | |
- } | |
- } | |
+ // If request was aborted inside ajaxSend, stop there | |
+ if ( completed ) { | |
+ return jqXHR; | |
} | |
- // Set the display of most of the elements in a second… | |
- // to avoid the constant reflow | |
- for ( i = 0; i < j; i++ ) { | |
- elem = this[ i ]; | |
+ // Timeout | |
+ if ( s.async && s.timeout > 0 ) { | |
+ timeoutTimer = window.setTimeout( function() { | |
+ jqXHR.abort( "timeout" ); | |
+ }, s.timeout ); | |
+ } | |
- if ( elem.style ) { | |
- display = elem.style.display; | |
+ try { | |
+ completed = false; | |
+ transport.send( requestHeaders, done ); | |
+ } catch ( e ) { | |
- if ( display === "" || display === "no… | |
- elem.style.display = jQuery._d… | |
- } | |
+ // Rethrow post-completion exceptions | |
+ if ( completed ) { | |
+ throw e; | |
} | |
- } | |
- return this; | |
+ // Propagate others as results | |
+ done( -1, e ); | |
+ } | |
} | |
- }, | |
- hide: function( speed, easing, callback ) { | |
- if ( speed || speed === 0 ) { | |
- return this.animate( genFx("hide", 3), speed, easing, … | |
+ // Callback for when everything is done | |
+ function done( status, nativeStatusText, responses, headers ) { | |
+ var isSuccess, success, error, response, modified, | |
+ statusText = nativeStatusText; | |
- } else { | |
- var elem, display, | |
- i = 0, | |
- j = this.length; | |
+ // Ignore repeat invocations | |
+ if ( completed ) { | |
+ return; | |
+ } | |
- for ( ; i < j; i++ ) { | |
- elem = this[i]; | |
- if ( elem.style ) { | |
- display = jQuery.css( elem, "display" … | |
+ completed = true; | |
- if ( display !== "none" && !jQuery._da… | |
- jQuery._data( elem, "olddispla… | |
- } | |
- } | |
+ // Clear timeout if it exists | |
+ if ( timeoutTimer ) { | |
+ window.clearTimeout( timeoutTimer ); | |
} | |
- // Set the display of the elements in a second loop | |
- // to avoid the constant reflow | |
- for ( i = 0; i < j; i++ ) { | |
- if ( this[i].style ) { | |
- this[i].style.display = "none"; | |
- } | |
- } | |
+ // Dereference transport for early garbage collection | |
+ // (no matter how long the jqXHR object will be used) | |
+ transport = undefined; | |
- return this; | |
- } | |
- }, | |
+ // Cache response headers | |
+ responseHeadersString = headers || ""; | |
- // Save the old toggle function | |
- _toggle: jQuery.fn.toggle, | |
+ // Set readyState | |
+ jqXHR.readyState = status > 0 ? 4 : 0; | |
- toggle: function( fn, fn2, callback ) { | |
- var bool = typeof fn === "boolean"; | |
+ // Determine if successful | |
+ isSuccess = status >= 200 && status < 300 || status ==… | |
- if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { | |
- this._toggle.apply( this, arguments ); | |
+ // Get response data | |
+ if ( responses ) { | |
+ response = ajaxHandleResponses( s, jqXHR, resp… | |
+ } | |
- } else if ( fn == null || bool ) { | |
- this.each(function() { | |
- var state = bool ? fn : jQuery(this).is(":hidd… | |
- jQuery(this)[ state ? "show" : "hide" ](); | |
- }); | |
+ // Convert no matter what (that way responseXXX fields… | |
+ response = ajaxConvert( s, response, jqXHR, isSuccess … | |
- } else { | |
- this.animate(genFx("toggle", 3), fn, fn2, callback); | |
- } | |
+ // If successful, handle type chaining | |
+ if ( isSuccess ) { | |
- return this; | |
- }, | |
+ // Set the If-Modified-Since and/or If-None-Ma… | |
+ if ( s.ifModified ) { | |
+ modified = jqXHR.getResponseHeader( "L… | |
+ if ( modified ) { | |
+ jQuery.lastModified[ cacheURL … | |
+ } | |
+ modified = jqXHR.getResponseHeader( "e… | |
+ if ( modified ) { | |
+ jQuery.etag[ cacheURL ] = modi… | |
+ } | |
+ } | |
- fadeTo: function( speed, to, easing, callback ) { | |
- return this.filter(":hidden").css("opacity", 0).show().end() | |
- .animate({opacity: to}, speed, easing,… | |
- }, | |
+ // if no content | |
+ if ( status === 204 || s.type === "HEAD" ) { | |
+ statusText = "nocontent"; | |
- animate: function( prop, speed, easing, callback ) { | |
- var optall = jQuery.speed( speed, easing, callback ); | |
+ // if not modified | |
+ } else if ( status === 304 ) { | |
+ statusText = "notmodified"; | |
- if ( jQuery.isEmptyObject( prop ) ) { | |
- return this.each( optall.complete, [ false ] ); | |
- } | |
+ // If we have data, let's convert it | |
+ } else { | |
+ statusText = response.state; | |
+ success = response.data; | |
+ error = response.error; | |
+ isSuccess = !error; | |
+ } | |
+ } else { | |
- // Do not change referenced properties as per-property easing … | |
- prop = jQuery.extend( {}, prop ); | |
+ // Extract error from statusText and normalize… | |
+ error = statusText; | |
+ if ( status || !statusText ) { | |
+ statusText = "error"; | |
+ if ( status < 0 ) { | |
+ status = 0; | |
+ } | |
+ } | |
+ } | |
- function doAnimation() { | |
- // XXX 'this' does not always have a nodeName when run… | |
- // test suite | |
+ // Set data for the fake xhr object | |
+ jqXHR.status = status; | |
+ jqXHR.statusText = ( nativeStatusText || statusText ) … | |
- if ( optall.queue === false ) { | |
- jQuery._mark( this ); | |
+ // Success/Error | |
+ if ( isSuccess ) { | |
+ deferred.resolveWith( callbackContext, [ succe… | |
+ } else { | |
+ deferred.rejectWith( callbackContext, [ jqXHR,… | |
} | |
- var opt = jQuery.extend( {}, optall ), | |
- isElement = this.nodeType === 1, | |
- hidden = isElement && jQuery(this).is(":hidden… | |
- name, val, p, e, hooks, replace, | |
- parts, start, end, unit, | |
- method; | |
+ // Status-dependent callbacks | |
+ jqXHR.statusCode( statusCode ); | |
+ statusCode = undefined; | |
- // will store per property easing and be used to deter… | |
- opt.animatedProperties = {}; | |
+ if ( fireGlobals ) { | |
+ globalEventContext.trigger( isSuccess ? "ajaxS… | |
+ [ jqXHR, s, isSuccess ? success : erro… | |
+ } | |
- // first pass over propertys to expand / normalize | |
- for ( p in prop ) { | |
- name = jQuery.camelCase( p ); | |
- if ( p !== name ) { | |
- prop[ name ] = prop[ p ]; | |
- delete prop[ p ]; | |
- } | |
+ // Complete | |
+ completeDeferred.fireWith( callbackContext, [ jqXHR, s… | |
- if ( ( hooks = jQuery.cssHooks[ name ] ) && "e… | |
- replace = hooks.expand( prop[ name ] ); | |
- delete prop[ name ]; | |
+ if ( fireGlobals ) { | |
+ globalEventContext.trigger( "ajaxComplete", [ … | |
- // not quite $.extend, this wont overw… | |
- // also - reusing 'p' from above becau… | |
- for ( p in replace ) { | |
- if ( ! ( p in prop ) ) { | |
- prop[ p ] = replace[ p… | |
- } | |
- } | |
+ // Handle the global AJAX counter | |
+ if ( !( --jQuery.active ) ) { | |
+ jQuery.event.trigger( "ajaxStop" ); | |
} | |
} | |
+ } | |
- for ( name in prop ) { | |
- val = prop[ name ]; | |
- // easing resolution: per property > opt.speci… | |
- if ( jQuery.isArray( val ) ) { | |
- opt.animatedProperties[ name ] = val[ … | |
- val = prop[ name ] = val[ 0 ]; | |
- } else { | |
- opt.animatedProperties[ name ] = opt.s… | |
- } | |
+ return jqXHR; | |
+ }, | |
- if ( val === "hide" && hidden || val === "show… | |
- return opt.complete.call( this ); | |
- } | |
+ getJSON: function( url, data, callback ) { | |
+ return jQuery.get( url, data, callback, "json" ); | |
+ }, | |
+ | |
+ getScript: function( url, callback ) { | |
+ return jQuery.get( url, undefined, callback, "script" ); | |
+ } | |
+} ); | |
- if ( isElement && ( name === "height" || name … | |
- // Make sure that nothing sneaks out | |
- // Record all 3 overflow attributes be… | |
- // change the overflow attribute when … | |
- // overflowY are set to the same value | |
- opt.overflow = [ this.style.overflow, … | |
+jQuery.each( [ "get", "post" ], function( i, method ) { | |
+ jQuery[ method ] = function( url, data, callback, type ) { | |
- // Set display property to inline-bloc… | |
- // animations on inline elements that … | |
- if ( jQuery.css( this, "display" ) ===… | |
- jQuery.css( this, "flo… | |
+ // Shift arguments if data argument was omitted | |
+ if ( jQuery.isFunction( data ) ) { | |
+ type = type || callback; | |
+ callback = data; | |
+ data = undefined; | |
+ } | |
- // inline-level elements accep… | |
- // block-level elements need t… | |
- if ( !jQuery.support.inlineBlo… | |
- this.style.display = "… | |
+ // 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 ) ); | |
+ }; | |
+} ); | |
- } else { | |
- this.style.zoom = 1; | |
- } | |
- } | |
- } | |
- } | |
- if ( opt.overflow != null ) { | |
- this.style.overflow = "hidden"; | |
- } | |
+jQuery._evalUrl = function( url ) { | |
+ return jQuery.ajax( { | |
+ url: url, | |
- for ( p in prop ) { | |
- e = new jQuery.fx( this, opt, p ); | |
- val = prop[ p ]; | |
+ // Make this explicit, since user can override this through aj… | |
+ type: "GET", | |
+ dataType: "script", | |
+ cache: true, | |
+ async: false, | |
+ global: false, | |
+ "throws": true | |
+ } ); | |
+}; | |
- if ( rfxtypes.test( val ) ) { | |
- // Tracks whether to show or hide base… | |
- // data attached to the element | |
- method = jQuery._data( this, "toggle" … | |
- if ( method ) { | |
- jQuery._data( this, "toggle" +… | |
- e[ method ](); | |
- } else { | |
- e[ val ](); | |
- } | |
+jQuery.fn.extend( { | |
+ wrapAll: function( html ) { | |
+ var wrap; | |
- } else { | |
- parts = rfxnum.exec( val ); | |
- start = e.cur(); | |
- | |
- if ( parts ) { | |
- end = parseFloat( parts[2] ); | |
- unit = parts[3] || ( jQuery.cs… | |
- | |
- // We need to compute starting… | |
- if ( unit !== "px" ) { | |
- jQuery.style( this, p,… | |
- start = ( (end || 1) /… | |
- jQuery.style( this, p,… | |
- } | |
+ if ( this[ 0 ] ) { | |
+ if ( jQuery.isFunction( html ) ) { | |
+ html = html.call( this[ 0 ] ); | |
+ } | |
- // If a +=/-= token was provid… | |
- if ( parts[1] ) { | |
- end = ( (parts[ 1 ] ==… | |
- } | |
+ // The elements to wrap the target around | |
+ wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 )… | |
+ | |
+ if ( this[ 0 ].parentNode ) { | |
+ wrap.insertBefore( this[ 0 ] ); | |
+ } | |
- e.custom( start, end, unit ); | |
+ wrap.map( function() { | |
+ var elem = this; | |
- } else { | |
- e.custom( start, val, "" ); | |
- } | |
+ while ( elem.firstElementChild ) { | |
+ elem = elem.firstElementChild; | |
} | |
- } | |
- // For JS strict compliance | |
- return true; | |
+ return elem; | |
+ } ).append( this ); | |
} | |
- return optall.queue === false ? | |
- this.each( doAnimation ) : | |
- this.queue( optall.queue, doAnimation ); | |
+ return this; | |
}, | |
- stop: function( type, clearQueue, gotoEnd ) { | |
- if ( typeof type !== "string" ) { | |
- gotoEnd = clearQueue; | |
- clearQueue = type; | |
- type = undefined; | |
- } | |
- if ( clearQueue && type !== false ) { | |
- this.queue( type || "fx", [] ); | |
+ wrapInner: function( html ) { | |
+ if ( jQuery.isFunction( html ) ) { | |
+ return this.each( function( i ) { | |
+ jQuery( this ).wrapInner( html.call( this, i )… | |
+ } ); | |
} | |
- return this.each(function() { | |
- var index, | |
- hadTimers = false, | |
- timers = jQuery.timers, | |
- data = jQuery._data( this ); | |
- | |
- // clear marker counters if we know they won't be | |
- if ( !gotoEnd ) { | |
- jQuery._unmark( true, this ); | |
- } | |
+ return this.each( function() { | |
+ var self = jQuery( this ), | |
+ contents = self.contents(); | |
- function stopQueue( elem, data, index ) { | |
- var hooks = data[ index ]; | |
- jQuery.removeData( elem, index, true ); | |
- hooks.stop( gotoEnd ); | |
- } | |
+ if ( contents.length ) { | |
+ contents.wrapAll( html ); | |
- if ( type == null ) { | |
- for ( index in data ) { | |
- if ( data[ index ] && data[ index ].st… | |
- stopQueue( this, data, index ); | |
- } | |
- } | |
- } else if ( data[ index = type + ".run" ] && data[ ind… | |
- stopQueue( this, data, index ); | |
+ } else { | |
+ self.append( html ); | |
} | |
+ } ); | |
+ }, | |
- for ( index = timers.length; index--; ) { | |
- if ( timers[ index ].elem === this && (type ==… | |
- if ( gotoEnd ) { | |
+ wrap: function( html ) { | |
+ var isFunction = jQuery.isFunction( html ); | |
- // force the next step to be t… | |
- timers[ index ]( true ); | |
- } else { | |
- timers[ index ].saveState(); | |
- } | |
- hadTimers = true; | |
- timers.splice( index, 1 ); | |
- } | |
- } | |
+ return this.each( function( i ) { | |
+ jQuery( this ).wrapAll( isFunction ? html.call( this, … | |
+ } ); | |
+ }, | |
- // start the next in the queue if the last step wasn't… | |
- // timers currently will call their complete callbacks… | |
- // but only if they were gotoEnd | |
- if ( !( gotoEnd && hadTimers ) ) { | |
- jQuery.dequeue( this, type ); | |
- } | |
- }); | |
+ unwrap: function( selector ) { | |
+ this.parent( selector ).not( "body" ).each( function() { | |
+ jQuery( this ).replaceWith( this.childNodes ); | |
+ } ); | |
+ return this; | |
} | |
+} ); | |
-}); | |
-// Animations created synchronously will run synchronously | |
-function createFxNow() { | |
- setTimeout( clearFxNow, 0 ); | |
- return ( fxNow = jQuery.now() ); | |
-} | |
+jQuery.expr.pseudos.hidden = function( elem ) { | |
+ return !jQuery.expr.pseudos.visible( elem ); | |
+}; | |
+jQuery.expr.pseudos.visible = function( elem ) { | |
+ return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRect… | |
+}; | |
-function clearFxNow() { | |
- fxNow = undefined; | |
-} | |
-// Generate parameters to create a standard animation | |
-function genFx( type, num ) { | |
- var obj = {}; | |
- jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), functi… | |
- obj[ this ] = type; | |
- }); | |
- return obj; | |
-} | |
+jQuery.ajaxSettings.xhr = function() { | |
+ try { | |
+ return new window.XMLHttpRequest(); | |
+ } catch ( e ) {} | |
+}; | |
-// Generate shortcuts for custom animations | |
-jQuery.each({ | |
- slideDown: genFx( "show", 1 ), | |
- slideUp: genFx( "hide", 1 ), | |
- slideToggle: genFx( "toggle", 1 ), | |
- 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 ); | |
- }; | |
-}); | |
+var xhrSuccessStatus = { | |
-jQuery.extend({ | |
- speed: function( speed, easing, fn ) { | |
- var opt = speed && typeof speed === "object" ? jQuery.extend( … | |
- complete: fn || !fn && easing || | |
- jQuery.isFunction( speed ) && speed, | |
- duration: speed, | |
- easing: fn && easing || easing && !jQuery.isFunction( … | |
- }; | |
+ // File protocol always yields status code 0, assume 200 | |
+ 0: 200, | |
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "nu… | |
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ o… | |
+ // Support: IE <=9 only | |
+ // #1450: sometimes IE returns 1223 when it should be 204 | |
+ 1223: 204 | |
+ }, | |
+ xhrSupported = jQuery.ajaxSettings.xhr(); | |
- // normalize opt.queue - true/undefined/null -> "fx" | |
- if ( opt.queue == null || opt.queue === true ) { | |
- opt.queue = "fx"; | |
- } | |
+support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | |
+support.ajax = xhrSupported = !!xhrSupported; | |
- // Queueing | |
- opt.old = opt.complete; | |
+jQuery.ajaxTransport( function( options ) { | |
+ var callback, errorCallback; | |
- opt.complete = function( noUnmark ) { | |
- if ( jQuery.isFunction( opt.old ) ) { | |
- opt.old.call( this ); | |
- } | |
+ // 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 | |
+ ); | |
- if ( opt.queue ) { | |
- jQuery.dequeue( this, opt.queue ); | |
- } else if ( noUnmark !== false ) { | |
- jQuery._unmark( this ); | |
- } | |
- }; | |
+ // Apply custom fields if provided | |
+ if ( options.xhrFields ) { | |
+ for ( i in options.xhrFields ) { | |
+ xhr[ i ] = options.xhrFields[ … | |
+ } | |
+ } | |
- return opt; | |
- }, | |
+ // Override mime type if needed | |
+ if ( options.mimeType && xhr.overrideMimeType … | |
+ xhr.overrideMimeType( options.mimeType… | |
+ } | |
- easing: { | |
- linear: function( p ) { | |
- return p; | |
- }, | |
- swing: function( p ) { | |
- return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5; | |
- } | |
- }, | |
+ // X-Requested-With header | |
+ // For cross-domain requests, seeing as condit… | |
+ // akin to a jigsaw puzzle, we simply never se… | |
+ // (it can always be set on a per-request basi… | |
+ // For same-domain requests, won't change head… | |
+ if ( !options.crossDomain && !headers[ "X-Requ… | |
+ headers[ "X-Requested-With" ] = "XMLHt… | |
+ } | |
- timers: [], | |
+ // Set headers | |
+ for ( i in headers ) { | |
+ xhr.setRequestHeader( i, headers[ i ] … | |
+ } | |
- fx: function( elem, options, prop ) { | |
- this.options = options; | |
- this.elem = elem; | |
- this.prop = prop; | |
+ // Callback | |
+ callback = function( type ) { | |
+ return function() { | |
+ if ( callback ) { | |
+ callback = errorCallba… | |
+ xhr.onerror = … | |
- options.orig = options.orig || {}; | |
- } | |
+ if ( type === "abort" … | |
+ xhr.abort(); | |
+ } else if ( type === "… | |
-}); | |
+ // Support: IE… | |
+ // On a manual… | |
+ // errors on a… | |
+ if ( typeof xh… | |
+ comple… | |
+ } else { | |
+ comple… | |
-jQuery.fx.prototype = { | |
- // Simple function for setting a style value | |
- update: function() { | |
- if ( this.options.step ) { | |
- this.options.step.call( this.elem, this.now, this ); | |
- } | |
+ … | |
+ … | |
+ … | |
+ ); | |
+ } | |
+ } else { | |
+ complete( | |
+ xhrSuc… | |
+ xhr.st… | |
+ | |
+ // Sup… | |
+ // IE9… | |
+ // For… | |
+ ( xhr.… | |
+ typeof… | |
+ … | |
+ … | |
+ xhr.ge… | |
+ ); | |
+ } | |
+ } | |
+ }; | |
+ }; | |
- ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( th… | |
- }, | |
+ // Listen to events | |
+ xhr.onload = callback(); | |
+ errorCallback = xhr.onerror = callback( "error… | |
- // Get the current size | |
- cur: function() { | |
- if ( this.elem[ this.prop ] != null && (!this.elem.style || th… | |
- return this.elem[ this.prop ]; | |
- } | |
+ // 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 tim… | |
+ if ( xhr.readyState === 4 ) { | |
+ | |
+ // Allow onerror to be… | |
+ // but that will not h… | |
+ // Also, save errorCal… | |
+ // as xhr.onerror cann… | |
+ window.setTimeout( fun… | |
+ if ( callback … | |
+ errorC… | |
+ } | |
+ } ); | |
+ } | |
+ }; | |
+ } | |
- var parsed, | |
- r = jQuery.css( this.elem, this.prop ); | |
- // Empty strings, null, undefined and "auto" are converted to … | |
- // complex values such as "rotate(1rad)" are returned as is, | |
- // simple values such as "10px" are parsed to Float. | |
- return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" … | |
- }, | |
+ // Create the abort callback | |
+ callback = callback( "abort" ); | |
- // Start an animation from one number to another | |
- custom: function( from, to, unit ) { | |
- var self = this, | |
- fx = jQuery.fx; | |
+ try { | |
- this.startTime = fxNow || createFxNow(); | |
- this.end = to; | |
- this.now = this.start = from; | |
- this.pos = this.state = 0; | |
- this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop… | |
+ // Do send the request (this may raise… | |
+ xhr.send( options.hasContent && option… | |
+ } catch ( e ) { | |
- function t( gotoEnd ) { | |
- return self.step( gotoEnd ); | |
- } | |
+ // #14683: Only rethrow if this hasn't… | |
+ if ( callback ) { | |
+ throw e; | |
+ } | |
+ } | |
+ }, | |
- t.queue = this.options.queue; | |
- t.elem = this.elem; | |
- t.saveState = function() { | |
- if ( jQuery._data( self.elem, "fxshow" + self.prop ) =… | |
- if ( self.options.hide ) { | |
- jQuery._data( self.elem, "fxshow" + se… | |
- } else if ( self.options.show ) { | |
- jQuery._data( self.elem, "fxshow" + se… | |
+ abort: function() { | |
+ if ( callback ) { | |
+ callback(); | |
} | |
} | |
}; | |
+ } | |
+} ); | |
- if ( t() && jQuery.timers.push(t) && !timerId ) { | |
- timerId = setInterval( fx.tick, fx.interval ); | |
- } | |
- }, | |
- // Simple 'show' function | |
- show: function() { | |
- var dataShow = jQuery._data( this.elem, "fxshow" + this.prop ); | |
- // Remember where we started, so that we can go back to it lat… | |
- this.options.orig[ this.prop ] = dataShow || jQuery.style( thi… | |
- this.options.show = true; | |
- // Begin the animation | |
- // Make sure that we start at a small width/height to avoid an… | |
- if ( dataShow !== undefined ) { | |
- // This show is picking up where a previous hide or sh… | |
- this.custom( this.cur(), dataShow ); | |
- } else { | |
- this.custom( this.prop === "width" || this.prop === "h… | |
- } | |
+// Prevent auto-execution of scripts when no explicit dataType was provided (S… | |
+jQuery.ajaxPrefilter( function( s ) { | |
+ if ( s.crossDomain ) { | |
+ s.contents.script = false; | |
+ } | |
+} ); | |
- // Start by showing the element | |
- jQuery( this.elem ).show(); | |
+// Install script dataType | |
+jQuery.ajaxSetup( { | |
+ accepts: { | |
+ script: "text/javascript, application/javascript, " + | |
+ "application/ecmascript, application/x-ecmascript" | |
}, | |
- | |
- // Simple 'hide' function | |
- hide: function() { | |
- // Remember where we started, so that we can go back to it lat… | |
- this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxs… | |
- this.options.hide = true; | |
- | |
- // Begin the animation | |
- this.custom( this.cur(), 0 ); | |
+ contents: { | |
+ script: /\b(?:java|ecma)script\b/ | |
}, | |
+ converters: { | |
+ "text script": function( text ) { | |
+ jQuery.globalEval( text ); | |
+ return text; | |
+ } | |
+ } | |
+} ); | |
- // Each step of an animation | |
- step: function( gotoEnd ) { | |
- var p, n, complete, | |
- t = fxNow || createFxNow(), | |
- done = true, | |
- elem = this.elem, | |
- options = this.options; | |
+// 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"; | |
+ } | |
+} ); | |
- if ( gotoEnd || t >= options.duration + this.startTime ) { | |
- this.now = this.end; | |
- this.pos = this.state = 1; | |
- this.update(); | |
+// Bind script tag hack transport | |
+jQuery.ajaxTransport( "script", function( s ) { | |
- options.animatedProperties[ this.prop ] = true; | |
+ // This transport only deals with cross domain requests | |
+ if ( s.crossDomain ) { | |
+ var script, callback; | |
+ return { | |
+ send: function( _, complete ) { | |
+ script = jQuery( "<script>" ).prop( { | |
+ charset: s.scriptCharset, | |
+ src: s.url | |
+ } ).on( | |
+ "load error", | |
+ callback = function( evt ) { | |
+ script.remove(); | |
+ callback = null; | |
+ if ( evt ) { | |
+ complete( evt.type ===… | |
+ } | |
+ } | |
+ ); | |
- for ( p in options.animatedProperties ) { | |
- if ( options.animatedProperties[ p ] !== true … | |
- done = false; | |
+ // Use native DOM manipulation to avoid our do… | |
+ document.head.appendChild( script[ 0 ] ); | |
+ }, | |
+ abort: function() { | |
+ if ( callback ) { | |
+ callback(); | |
} | |
} | |
+ }; | |
+ } | |
+} ); | |
- if ( done ) { | |
- // Reset the overflow | |
- if ( options.overflow != null && !jQuery.suppo… | |
- jQuery.each( [ "", "X", "Y" ], functio… | |
- elem.style[ "overflow" + value… | |
- }); | |
- } | |
- // Hide the element if the "hide" operation wa… | |
- if ( options.hide ) { | |
- jQuery( elem ).hide(); | |
- } | |
- // Reset the properties, if the item has been … | |
- if ( options.hide || options.show ) { | |
- for ( p in options.animatedProperties … | |
- jQuery.style( elem, p, options… | |
- jQuery.removeData( elem, "fxsh… | |
- // Toggle data is no longer ne… | |
- jQuery.removeData( elem, "togg… | |
- } | |
- } | |
+var oldCallbacks = [], | |
+ rjsonp = /(=)\?(?=&|$)|\?\?/; | |
- // Execute the complete function | |
- // in the event that the complete function thr… | |
- // we must ensure it won't be called twice. #5… | |
+// Default jsonp settings | |
+jQuery.ajaxSetup( { | |
+ jsonp: "callback", | |
+ jsonpCallback: function() { | |
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + … | |
+ this[ callback ] = true; | |
+ return callback; | |
+ } | |
+} ); | |
- complete = options.complete; | |
- if ( complete ) { | |
+// Detect, normalize options and install callbacks for jsonp requests | |
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
- options.complete = false; | |
- complete.call( elem ); | |
- } | |
- } | |
+ var callbackName, overwritten, responseContainer, | |
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? | |
+ "url" : | |
+ typeof s.data === "string" && | |
+ ( s.contentType || "" ) | |
+ .indexOf( "application/x-www-form-urle… | |
+ rjsonp.test( s.data ) && "data" | |
+ ); | |
- return false; | |
+ // Handle iff the expected data type is "jsonp" or we have a parameter… | |
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { | |
- } else { | |
- // classical easing cannot be used with an Infinity du… | |
- if ( options.duration == Infinity ) { | |
- this.now = t; | |
- } else { | |
- n = t - this.startTime; | |
- this.state = n / options.duration; | |
+ // Get callback name, remembering preexisting value associated… | |
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCal… | |
+ s.jsonpCallback() : | |
+ s.jsonpCallback; | |
- // Perform the easing function, defaults to sw… | |
- this.pos = jQuery.easing[ options.animatedProp… | |
- this.now = this.start + ( (this.end - this.sta… | |
- } | |
- // Perform the next step of the animation | |
- this.update(); | |
+ // Insert callback into url or form data | |
+ if ( jsonProp ) { | |
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + … | |
+ } else if ( s.jsonp !== false ) { | |
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.json… | |
} | |
- return true; | |
- } | |
-}; | |
+ // 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 ]; | |
+ }; | |
-jQuery.extend( jQuery.fx, { | |
- tick: function() { | |
- var timer, | |
- timers = jQuery.timers, | |
- i = 0; | |
+ // Force json dataType | |
+ s.dataTypes[ 0 ] = "json"; | |
- 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 ); | |
- } | |
- } | |
+ // Install callback | |
+ overwritten = window[ callbackName ]; | |
+ window[ callbackName ] = function() { | |
+ responseContainer = arguments; | |
+ }; | |
- if ( !timers.length ) { | |
- jQuery.fx.stop(); | |
- } | |
- }, | |
+ // Clean-up function (fires after converters) | |
+ jqXHR.always( function() { | |
- interval: 13, | |
+ // If previous value didn't exist - remove it | |
+ if ( overwritten === undefined ) { | |
+ jQuery( window ).removeProp( callbackName ); | |
- stop: function() { | |
- clearInterval( timerId ); | |
- timerId = null; | |
- }, | |
+ // Otherwise restore preexisting value | |
+ } else { | |
+ window[ callbackName ] = overwritten; | |
+ } | |
- speeds: { | |
- slow: 600, | |
- fast: 200, | |
- // Default speed | |
- _default: 400 | |
- }, | |
+ // Save back as free | |
+ if ( s[ callbackName ] ) { | |
- step: { | |
- opacity: function( fx ) { | |
- jQuery.style( fx.elem, "opacity", fx.now ); | |
- }, | |
+ // Make sure that re-using the options doesn't… | |
+ s.jsonpCallback = originalSettings.jsonpCallba… | |
- _default: function( fx ) { | |
- if ( fx.elem.style && fx.elem.style[ fx.prop ] != null… | |
- fx.elem.style[ fx.prop ] = fx.now + fx.unit; | |
- } else { | |
- fx.elem[ fx.prop ] = fx.now; | |
+ // Save the callback name for future use | |
+ oldCallbacks.push( callbackName ); | |
} | |
- } | |
- } | |
-}); | |
-// Ensure props that can't be negative don't go there on undershoot easing | |
-jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) { | |
- // exclude marginTop, marginLeft, marginBottom and marginRight from th… | |
- if ( prop.indexOf( "margin" ) ) { | |
- jQuery.fx.step[ prop ] = function( fx ) { | |
- jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.… | |
- }; | |
+ // Call if it was a function and we have a response | |
+ if ( responseContainer && jQuery.isFunction( overwritt… | |
+ overwritten( responseContainer[ 0 ] ); | |
+ } | |
+ | |
+ responseContainer = overwritten = undefined; | |
+ } ); | |
+ | |
+ // Delegate to script | |
+ return "script"; | |
} | |
-}); | |
+} ); | |
-if ( jQuery.expr && jQuery.expr.filters ) { | |
- jQuery.expr.filters.animated = function( elem ) { | |
- return jQuery.grep(jQuery.timers, function( fn ) { | |
- return elem === fn.elem; | |
- }).length; | |
- }; | |
-} | |
-// Try to restore the default display value of an element | |
-function defaultDisplay( nodeName ) { | |
- if ( !elemdisplay[ nodeName ] ) { | |
- var body = document.body, | |
- elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), | |
- display = elem.css( "display" ); | |
- elem.remove(); | |
+// 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; | |
+} )(); | |
- // If the simple way fails, | |
- // get element's real default display by attaching it to a tem… | |
- if ( display === "none" || display === "" ) { | |
- // No iframe to use yet, so create it | |
- if ( !iframe ) { | |
- iframe = document.createElement( "iframe" ); | |
- iframe.frameBorder = iframe.width = iframe.hei… | |
- } | |
- body.appendChild( iframe ); | |
+// Argument "data" should be string of html | |
+// context (optional): If specified, the fragment will be created in this cont… | |
+// defaults to document | |
+// keepScripts (optional): If true, will include scripts passed in the html st… | |
+jQuery.parseHTML = function( data, context, keepScripts ) { | |
+ if ( typeof data !== "string" ) { | |
+ return []; | |
+ } | |
+ if ( typeof context === "boolean" ) { | |
+ keepScripts = context; | |
+ context = false; | |
+ } | |
- // Create a cacheable copy of the iframe document on f… | |
- // IE and Opera will allow us to reuse the iframeDoc w… | |
- // document to it; WebKit & Firefox won't allow reusin… | |
- if ( !iframeDoc || !iframe.createElement ) { | |
- iframeDoc = ( iframe.contentWindow || iframe.c… | |
- iframeDoc.write( ( jQuery.support.boxModel ? "… | |
- iframeDoc.close(); | |
- } | |
+ var base, parsed, scripts; | |
- elem = iframeDoc.createElement( nodeName ); | |
+ if ( !context ) { | |
- iframeDoc.body.appendChild( elem ); | |
+ // Stop scripts or inline event handlers from being executed i… | |
+ // by using document.implementation | |
+ if ( support.createHTMLDocument ) { | |
+ context = document.implementation.createHTMLDocument( … | |
- display = jQuery.css( elem, "display" ); | |
- body.removeChild( iframe ); | |
+ // 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; | |
} | |
+ } | |
- // Store the correct default display | |
- elemdisplay[ nodeName ] = display; | |
+ parsed = rsingleTag.exec( data ); | |
+ scripts = !keepScripts && []; | |
+ | |
+ // Single tag | |
+ if ( parsed ) { | |
+ return [ context.createElement( parsed[ 1 ] ) ]; | |
} | |
- return elemdisplay[ nodeName ]; | |
-} | |
+ parsed = buildFragment( [ data ], context, scripts ); | |
+ if ( scripts && scripts.length ) { | |
+ jQuery( scripts ).remove(); | |
+ } | |
+ return jQuery.merge( [], parsed.childNodes ); | |
+}; | |
-var getOffset, | |
- rtable = /^t(?:able|d|h)$/i, | |
- rroot = /^(?:body|html)$/i; | |
+/** | |
+ * 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 ( "getBoundingClientRect" in document.documentElement ) { | |
- getOffset = function( elem, doc, docElem, box ) { | |
- try { | |
- box = elem.getBoundingClientRect(); | |
- } catch(e) {} | |
+ // If it's a function | |
+ if ( jQuery.isFunction( params ) ) { | |
- // Make sure we're not dealing with a disconnected DOM node | |
- if ( !box || !jQuery.contains( docElem, elem ) ) { | |
- return box ? { top: box.top, left: box.left } : { top:… | |
- } | |
+ // We assume that it's the callback | |
+ callback = params; | |
+ params = undefined; | |
- var body = doc.body, | |
- win = getWindow( doc ), | |
- clientTop = docElem.clientTop || body.clientTop || … | |
- clientLeft = docElem.clientLeft || body.clientLeft || … | |
- scrollTop = win.pageYOffset || jQuery.support.boxMode… | |
- scrollLeft = win.pageXOffset || jQuery.support.boxMode… | |
- top = box.top + scrollTop - clientTop, | |
- left = box.left + scrollLeft - clientLeft; | |
+ // Otherwise, build a param string | |
+ } else if ( params && typeof params === "object" ) { | |
+ type = "POST"; | |
+ } | |
- return { top: top, left: left }; | |
- }; | |
+ // If we have elements to modify, make the request | |
+ if ( self.length > 0 ) { | |
+ jQuery.ajax( { | |
+ url: url, | |
-} else { | |
- getOffset = function( elem, doc, docElem ) { | |
- var computedStyle, | |
- offsetParent = elem.offsetParent, | |
- prevOffsetParent = elem, | |
- body = doc.body, | |
- defaultView = doc.defaultView, | |
- prevComputedStyle = defaultView ? defaultView.getCompu… | |
- top = elem.offsetTop, | |
- left = elem.offsetLeft; | |
- | |
- while ( (elem = elem.parentNode) && elem !== body && elem !== … | |
- if ( jQuery.support.fixedPosition && prevComputedStyle… | |
- break; | |
- } | |
+ // If "type" variable is undefined, then "GET" method … | |
+ // Make value of this field explicit since | |
+ // user can override it through ajaxSetup method | |
+ type: type || "GET", | |
+ dataType: "html", | |
+ data: params | |
+ } ).done( function( responseText ) { | |
- computedStyle = defaultView ? defaultView.getComputedS… | |
- top -= elem.scrollTop; | |
- left -= elem.scrollLeft; | |
+ // Save response for use in complete callback | |
+ response = arguments; | |
- if ( elem === offsetParent ) { | |
- top += elem.offsetTop; | |
- left += elem.offsetLeft; | |
+ self.html( selector ? | |
- if ( jQuery.support.doesNotAddBorder && !(jQue… | |
- top += parseFloat( computedStyle.bord… | |
- left += parseFloat( computedStyle.bord… | |
- } | |
+ // If a selector was specified, locate the rig… | |
+ // Exclude scripts to avoid IE 'Permission Den… | |
+ jQuery( "<div>" ).append( jQuery.parseHTML( re… | |
- prevOffsetParent = offsetParent; | |
- offsetParent = elem.offsetParent; | |
- } | |
+ // Otherwise use the full result | |
+ responseText ); | |
- if ( jQuery.support.subtractsBorderForOverflowNotVisib… | |
- top += parseFloat( computedStyle.borderTopWid… | |
- left += parseFloat( computedStyle.borderLeftWi… | |
- } | |
+ // If the request succeeds, this function gets "data", "status… | |
+ // 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.resp… | |
+ } ); | |
+ } ); | |
+ } | |
- prevComputedStyle = computedStyle; | |
- } | |
+ return this; | |
+}; | |
- if ( prevComputedStyle.position === "relative" || prevComputed… | |
- top += body.offsetTop; | |
- left += body.offsetLeft; | |
- } | |
- if ( jQuery.support.fixedPosition && prevComputedStyle.positio… | |
- top += Math.max( docElem.scrollTop, body.scrollTop ); | |
- left += Math.max( docElem.scrollLeft, body.scrollLeft … | |
- } | |
- return { top: top, left: left }; | |
- }; | |
-} | |
-jQuery.fn.offset = function( options ) { | |
- if ( arguments.length ) { | |
- return options === undefined ? | |
- this : | |
- this.each(function( i ) { | |
- jQuery.offset.setOffset( this, options, i ); | |
- }); | |
- } | |
+// 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 ); | |
+ }; | |
+} ); | |
- var elem = this[0], | |
- doc = elem && elem.ownerDocument; | |
- if ( !doc ) { | |
- return null; | |
- } | |
- if ( elem === doc.body ) { | |
- return jQuery.offset.bodyOffset( elem ); | |
- } | |
- return getOffset( elem, doc, doc.documentElement ); | |
+jQuery.expr.pseudos.animated = function( elem ) { | |
+ return jQuery.grep( jQuery.timers, function( fn ) { | |
+ return elem === fn.elem; | |
+ } ).length; | |
}; | |
-jQuery.offset = { | |
- bodyOffset: function( body ) { | |
- var top = body.offsetTop, | |
- left = body.offsetLeft; | |
- if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { | |
- top += parseFloat( jQuery.css(body, "marginTop") ) ||… | |
- left += parseFloat( jQuery.css(body, "marginLeft") ) |… | |
- } | |
- return { top: top, left: left }; | |
- }, | |
+/** | |
+ * Gets a window from an element | |
+ */ | |
+function getWindow( elem ) { | |
+ return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.de… | |
+} | |
+jQuery.offset = { | |
setOffset: function( elem, options, i ) { | |
- var position = jQuery.css( elem, "position" ); | |
+ var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSS… | |
+ position = jQuery.css( elem, "position" ), | |
+ curElem = jQuery( elem ), | |
+ props = {}; | |
- // set position first, in-case top/left are set even on static… | |
+ // Set position first, in-case top/left are set even on static… | |
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" || posit… | |
- props = {}, curPosition = {}, curTop, curLeft; | |
+ curOffset = curElem.offset(); | |
+ curCSSTop = jQuery.css( elem, "top" ); | |
+ curCSSLeft = jQuery.css( elem, "left" ); | |
+ calculatePosition = ( position === "absolute" || position === … | |
+ ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; | |
- // need to be able to calculate position if either top or left… | |
+ // 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 ); | |
+ | |
+ // Use jQuery.extend here to allow modification of coo… | |
+ options = options.call( elem, i, jQuery.extend( {}, cu… | |
} | |
if ( options.top != null ) { | |
t@@ -9216,189 +9928,292 @@ jQuery.offset = { | |
if ( "using" in options ) { | |
options.using.call( elem, props ); | |
+ | |
} else { | |
curElem.css( props ); | |
} | |
} | |
}; | |
+jQuery.fn.extend( { | |
+ offset: function( options ) { | |
+ | |
+ // Preserve chaining for setter | |
+ if ( arguments.length ) { | |
+ return options === undefined ? | |
+ this : | |
+ this.each( function( i ) { | |
+ jQuery.offset.setOffset( this, options… | |
+ } ); | |
+ } | |
+ | |
+ var docElem, win, rect, doc, | |
+ elem = this[ 0 ]; | |
+ | |
+ if ( !elem ) { | |
+ return; | |
+ } | |
+ | |
+ // Support: IE <=11 only | |
+ // Running getBoundingClientRect on a | |
+ // disconnected node in IE throws an error | |
+ if ( !elem.getClientRects().length ) { | |
+ return { top: 0, left: 0 }; | |
+ } | |
+ | |
+ rect = elem.getBoundingClientRect(); | |
+ | |
+ // Make sure element is not hidden (display: none) | |
+ if ( rect.width || rect.height ) { | |
+ doc = elem.ownerDocument; | |
+ win = getWindow( doc ); | |
+ docElem = doc.documentElement; | |
-jQuery.fn.extend({ | |
+ return { | |
+ top: rect.top + win.pageYOffset - docElem.clie… | |
+ left: rect.left + win.pageXOffset - docElem.cl… | |
+ }; | |
+ } | |
+ | |
+ // Return zeros for disconnected and hidden elements (gh-2310) | |
+ return rect; | |
+ }, | |
position: function() { | |
- if ( !this[0] ) { | |
- return null; | |
+ if ( !this[ 0 ] ) { | |
+ return; | |
} | |
- var elem = this[0], | |
+ var offsetParent, offset, | |
+ elem = this[ 0 ], | |
+ parentOffset = { top: 0, left: 0 }; | |
+ | |
+ // Fixed elements are offset from window (parentOffset = {top:… | |
+ // because it is its only offset parent | |
+ if ( jQuery.css( elem, "position" ) === "fixed" ) { | |
- // Get *real* offsetParent | |
- offsetParent = this.offsetParent(), | |
+ // Assume getBoundingClientRect is there when computed… | |
+ offset = elem.getBoundingClientRect(); | |
- // Get correct offsets | |
- offset = this.offset(), | |
- parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0… | |
+ } else { | |
+ | |
+ // Get *real* offsetParent | |
+ offsetParent = this.offsetParent(); | |
- // Subtract element margins | |
- // note: when an element has margin: auto the offsetLeft and m… | |
- // are the same in Safari causing offset.left to incorrectly b… | |
- offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || … | |
- offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) ||… | |
+ // Get correct offsets | |
+ offset = this.offset(); | |
+ if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { | |
+ parentOffset = offsetParent.offset(); | |
+ } | |
- // Add offsetParent borders | |
- parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "… | |
- parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "… | |
+ // Add offsetParent borders | |
+ parentOffset = { | |
+ top: parentOffset.top + jQuery.css( offsetPare… | |
+ left: parentOffset.left + jQuery.css( offsetPa… | |
+ }; | |
+ } | |
- // Subtract the two offsets | |
+ // Subtract parent offsets and element margins | |
return { | |
- top: offset.top - parentOffset.top, | |
- left: offset.left - parentOffset.left | |
+ top: offset.top - parentOffset.top - jQuery.css( elem,… | |
+ left: offset.left - parentOffset.left - jQuery.css( el… | |
}; | |
}, | |
+ // This method will return documentElement in the following cases: | |
+ // 1) For the element inside the iframe without offsetParent, this met… | |
+ // 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 wil… | |
+ // | |
+ // 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 … | |
offsetParent: function() { | |
- return this.map(function() { | |
- var offsetParent = this.offsetParent || document.body; | |
- while ( offsetParent && (!rroot.test(offsetParent.node… | |
+ return this.map( function() { | |
+ var offsetParent = this.offsetParent; | |
+ | |
+ while ( offsetParent && jQuery.css( offsetParent, "pos… | |
offsetParent = offsetParent.offsetParent; | |
} | |
- return offsetParent; | |
- }); | |
- } | |
-}); | |
+ return offsetParent || documentElement; | |
+ } ); | |
+ } | |
+} ); | |
// Create scrollLeft and scrollTop methods | |
-jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( … | |
- var top = /Y/.test( prop ); | |
+jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function… | |
+ var top = "pageYOffset" === prop; | |
jQuery.fn[ method ] = function( val ) { | |
- return jQuery.access( this, function( elem, method, val ) { | |
+ return access( this, function( elem, method, val ) { | |
var win = getWindow( elem ); | |
if ( val === undefined ) { | |
- return win ? (prop in win) ? win[ prop ] : | |
- jQuery.support.boxModel && win.documen… | |
- win.document.body[ method ] : | |
- elem[ method ]; | |
+ return win ? win[ prop ] : elem[ method ]; | |
} | |
if ( win ) { | |
win.scrollTo( | |
- !top ? val : jQuery( win ).scrollLeft(… | |
- top ? val : jQuery( win ).scrollTop() | |
+ !top ? val : win.pageXOffset, | |
+ top ? val : win.pageYOffset | |
); | |
} else { | |
elem[ method ] = val; | |
} | |
- }, method, val, arguments.length, null ); | |
+ }, method, val, arguments.length ); | |
}; | |
-}); | |
- | |
-function getWindow( elem ) { | |
- return jQuery.isWindow( elem ) ? | |
- elem : | |
- elem.nodeType === 9 ? | |
- elem.defaultView || elem.parentWindow : | |
- false; | |
-} | |
- | |
+} ); | |
+ | |
+// 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… | |
+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 o… | |
+ return rnumnonpx.test( computed ) ? | |
+ jQuery( elem ).position()[ prop ] + "p… | |
+ computed; | |
+ } | |
+ } | |
+ ); | |
+} ); | |
-// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth m… | |
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth m… | |
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { | |
- var clientProp = "client" + name, | |
- scrollProp = "scroll" + name, | |
- offsetProp = "offset" + name; | |
- | |
- // innerHeight and innerWidth | |
- jQuery.fn[ "inner" + name ] = function() { | |
- var elem = this[0]; | |
- return elem ? | |
- elem.style ? | |
- parseFloat( jQuery.css( elem, type, "padding" ) ) : | |
- this[ type ]() : | |
- null; | |
- }; | |
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + n… | |
+ function( defaultExtra, funcName ) { | |
- // outerHeight and outerWidth | |
- jQuery.fn[ "outer" + name ] = function( margin ) { | |
- var elem = this[0]; | |
- return elem ? | |
- elem.style ? | |
- parseFloat( jQuery.css( elem, type, margin ? "margin" … | |
- this[ type ]() : | |
- null; | |
- }; | |
+ // Margin is only for outerHeight, outerWidth | |
+ jQuery.fn[ funcName ] = function( margin, value ) { | |
+ var chainable = arguments.length && ( defaultExtra || … | |
+ extra = defaultExtra || ( margin === true || v… | |
- jQuery.fn[ type ] = function( value ) { | |
- return jQuery.access( this, function( elem, type, value ) { | |
- var doc, docElemProp, orig, ret; | |
+ return access( this, function( elem, type, value ) { | |
+ var doc; | |
- if ( jQuery.isWindow( elem ) ) { | |
- // 3rd condition allows Nokia support, as it s… | |
- doc = elem.document; | |
- docElemProp = doc.documentElement[ clientProp … | |
- return jQuery.support.boxModel && docElemProp … | |
- doc.body && doc.body[ clientProp ] || … | |
- } | |
+ if ( jQuery.isWindow( elem ) ) { | |
+ | |
+ // $( window ).outerWidth/Height retur… | |
+ return funcName.indexOf( "outer" ) ===… | |
+ elem[ "inner" + name ] : | |
+ elem.document.documentElement[… | |
+ } | |
- // Get document width or height | |
- if ( elem.nodeType === 9 ) { | |
- // Either scroll[Width/Height] or offset[Width… | |
- doc = elem.documentElement; | |
+ // Get document width or height | |
+ if ( elem.nodeType === 9 ) { | |
+ doc = elem.documentElement; | |
- // when a window > document, IE6 reports a off… | |
- // so we can't use max, as it'll choose the in… | |
- // instead we use the correct client[Width/Hei… | |
- // support:IE6 | |
- if ( doc[ clientProp ] >= doc[ scrollProp ] ) { | |
- return doc[ clientProp ]; | |
+ // Either scroll[Width/Height] or offs… | |
+ // whichever is greatest | |
+ return Math.max( | |
+ elem.body[ "scroll" + name ], … | |
+ elem.body[ "offset" + name ], … | |
+ doc[ "client" + name ] | |
+ ); | |
} | |
- return Math.max( | |
- elem.body[ scrollProp ], doc[ scrollPr… | |
- elem.body[ offsetProp ], doc[ offsetPr… | |
- ); | |
- } | |
+ return value === undefined ? | |
- // Get width or height on the element | |
- if ( value === undefined ) { | |
- orig = jQuery.css( elem, type ); | |
- ret = parseFloat( orig ); | |
- return jQuery.isNumeric( ret ) ? ret : orig; | |
- } | |
+ // Get width or height on the element,… | |
+ jQuery.css( elem, type, extra ) : | |
- // Set the width or height on the element | |
- jQuery( elem ).css( type, value ); | |
- }, type, value, arguments.length, null ); | |
- }; | |
-}); | |
+ // Set width or height on the element | |
+ jQuery.style( elem, type, value, extra… | |
+ }, type, chainable ? margin : undefined, chainable ); | |
+ }; | |
+ } ); | |
+} ); | |
+ | |
+ | |
+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 ); | |
+ } | |
+} ); | |
+ | |
+jQuery.parseJSON = JSON.parse; | |
-// Expose jQuery to the global object | |
-window.jQuery = window.$ = jQuery; | |
+// 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. | |
-// 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; } ); | |
+// 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-… | |
+ | |
+if ( typeof define === "function" && define.amd ) { | |
+ define( "jquery", [], function() { | |
+ return jQuery; | |
+ } ); | |
} | |
-})( window ); | |
+ | |
+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; | |
+} ); | |
diff --git a/doc/html/_static/minus.png b/doc/html/_static/minus.png | |
Binary files differ. | |
diff --git a/doc/html/_static/plus.png b/doc/html/_static/plus.png | |
Binary files differ. | |
diff --git a/doc/html/_static/pygments.css b/doc/html/_static/pygments.css | |
t@@ -4,8 +4,10 @@ | |
.highlight .err { border: 1px solid #FF0000 } /* Error */ | |
.highlight .k { color: #007020; font-weight: bold } /* Keyword */ | |
.highlight .o { color: #666666 } /* Operator */ | |
+.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ | |
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ | |
.highlight .cp { color: #007020 } /* Comment.Preproc */ | |
+.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile … | |
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ | |
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Specia… | |
.highlight .gd { color: #A00000 } /* Generic.Deleted */ | |
t@@ -40,12 +42,15 @@ | |
.highlight .nv { color: #bb60d5 } /* Name.Variable */ | |
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ | |
.highlight .w { color: #bbbbbb } /* Text.Whitespace */ | |
+.highlight .mb { color: #208050 } /* Literal.Number.Bin */ | |
.highlight .mf { color: #208050 } /* Literal.Number.Float */ | |
.highlight .mh { color: #208050 } /* Literal.Number.Hex */ | |
.highlight .mi { color: #208050 } /* Literal.Number.Integer */ | |
.highlight .mo { color: #208050 } /* Literal.Number.Oct */ | |
+.highlight .sa { color: #4070a0 } /* Literal.String.Affix */ | |
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ | |
.highlight .sc { color: #4070a0 } /* Literal.String.Char */ | |
+.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ | |
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ | |
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */ | |
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape … | |
t@@ -56,7 +61,9 @@ | |
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */ | |
.highlight .ss { color: #517918 } /* Literal.String.Symbol */ | |
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ | |
+.highlight .fm { color: #06287e } /* Name.Function.Magic */ | |
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ | |
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ | |
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ | |
+.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ | |
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ | |
\ No newline at end of file | |
diff --git a/doc/html/_static/searchtools.js b/doc/html/_static/searchtools.js | |
t@@ -2,41 +2,15 @@ | |
* searchtools.js_t | |
* ~~~~~~~~~~~~~~~~ | |
* | |
- * Sphinx JavaScript utilties for the full-text search. | |
+ * Sphinx JavaScript utilities for the full-text search. | |
* | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | |
* :license: BSD, see LICENSE for details. | |
* | |
*/ | |
-/** | |
- * helper function to return a node containing the | |
- * search summary for a given text. keywords is a list | |
- * of stemmed words, hlwords is the list of normal, unstemmed | |
- * words. the first one is used to find the occurance, the | |
- * latter for highlighting it. | |
- */ | |
- | |
-jQuery.makeSearchSummary = function(text, keywords, hlwords) { | |
- var textLower = text.toLowerCase(); | |
- var start = 0; | |
- $.each(keywords, function() { | |
- var i = textLower.indexOf(this.toLowerCase()); | |
- if (i > -1) | |
- start = i; | |
- }); | |
- start = Math.max(start - 120, 0); | |
- var excerpt = ((start > 0) ? '...' : '') + | |
- $.trim(text.substr(start, 240)) + | |
- ((start + 240 - text.length) ? '...' : ''); | |
- var rv = $('<div class="context"></div>').text(excerpt); | |
- $.each(hlwords, function() { | |
- rv = rv.highlightText(this, 'highlighted'); | |
- }); | |
- return rv; | |
-} | |
- | |
+/* Non-minified version JS is _stemmer.js if file is provided */ | |
/** | |
* Porter Stemmer | |
*/ | |
t@@ -220,6 +194,138 @@ var Stemmer = function() { | |
} | |
+ | |
+/** | |
+ * Simple result scoring code. | |
+ */ | |
+var Scorer = { | |
+ // Implement the following function to further tweak the score for each resu… | |
+ // The function takes a result array [filename, title, anchor, descr, score] | |
+ // and returns the new score. | |
+ /* | |
+ score: function(result) { | |
+ return result[4]; | |
+ }, | |
+ */ | |
+ | |
+ // query matches the full name of an object | |
+ objNameMatch: 11, | |
+ // or matches in the last dotted part of the object name | |
+ objPartialMatch: 6, | |
+ // Additive scores depending on the priority of the object | |
+ objPrio: {0: 15, // used to be importantResults | |
+ 1: 5, // used to be objectResults | |
+ 2: -5}, // used to be unimportantResults | |
+ // Used when the priority is not in the mapping. | |
+ objPrioDefault: 0, | |
+ | |
+ // query found in title | |
+ title: 15, | |
+ // query found in terms | |
+ term: 5 | |
+}; | |
+ | |
+ | |
+ | |
+ | |
+ | |
+var splitChars = (function() { | |
+ var result = {}; | |
+ var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, … | |
+ 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 270… | |
+ 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 297… | |
+ 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 334… | |
+ 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 376… | |
+ 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 482… | |
+ 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 812… | |
+ 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, … | |
+ 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019,… | |
+ 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; | |
+ var i, j, start, end; | |
+ for (i = 0; i < singles.length; i++) { | |
+ result[singles[i]] = true; | |
+ } | |
+ var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 1… | |
+ [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 11… | |
+ [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519],… | |
+ [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790],… | |
+ [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041],… | |
+ [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364],… | |
+ [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446],… | |
+ [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533],… | |
+ [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661],… | |
+ [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789],… | |
+ [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917],… | |
+ [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989],… | |
+ [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167],… | |
+ [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301],… | |
+ [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460],… | |
+ [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712],… | |
+ [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775],… | |
+ [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975],… | |
+ [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196],… | |
+ [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351],… | |
+ [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887],… | |
+ [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791],… | |
+ [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015],… | |
+ [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175],… | |
+ [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527],… | |
+ [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799],… | |
+ [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085],… | |
+ [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679],… | |
+ [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129],… | |
+ [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307],… | |
+ [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472],… | |
+ [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449],… | |
+ [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [1155… | |
+ [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [1182… | |
+ [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [1243… | |
+ [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [1272… | |
+ [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [1299… | |
+ [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [4250… | |
+ [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [4273… | |
+ [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [4306… | |
+ [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [4326… | |
+ [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [4348… | |
+ [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [4364… | |
+ [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [4374… | |
+ [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [5529… | |
+ [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [6426… | |
+ [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [6496… | |
+ [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [6537… | |
+ [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; | |
+ for (i = 0; i < ranges.length; i++) { | |
+ start = ranges[i][0]; | |
+ end = ranges[i][1]; | |
+ for (j = start; j <= end; j++) { | |
+ result[j] = true; | |
+ } | |
+ } | |
+ return result; | |
+})(); | |
+ | |
+function splitQuery(query) { | |
+ var result = []; | |
+ var start = -1; | |
+ for (var i = 0; i < query.length; i++) { | |
+ if (splitChars[query.charCodeAt(i)]) { | |
+ if (start !== -1) { | |
+ result.push(query.slice(start, i)); | |
+ start = -1; | |
+ } | |
+ } else if (start === -1) { | |
+ start = i; | |
+ } | |
+ } | |
+ if (start !== -1) { | |
+ result.push(query.slice(start)); | |
+ } | |
+ return result; | |
+} | |
+ | |
+ | |
+ | |
+ | |
/** | |
* Search Module | |
*/ | |
t@@ -273,19 +379,20 @@ var Search = { | |
if (this._pulse_status >= 0) | |
return; | |
function pulse() { | |
+ var i; | |
Search._pulse_status = (Search._pulse_status + 1) % 4; | |
var dotString = ''; | |
- for (var i = 0; i < Search._pulse_status; i++) | |
+ for (i = 0; i < Search._pulse_status; i++) | |
dotString += '.'; | |
Search.dots.text(dotString); | |
if (Search._pulse_status > -1) | |
window.setTimeout(pulse, 500); | |
- }; | |
+ } | |
pulse(); | |
}, | |
/** | |
- * perform a search for something | |
+ * perform a search for something (or wait until index is loaded) | |
*/ | |
performSearch : function(query) { | |
// create the required interface elements | |
t@@ -305,41 +412,46 @@ var Search = { | |
this.deferQuery(query); | |
}, | |
+ /** | |
+ * execute search (requires search index to be loaded) | |
+ */ | |
query : function(query) { | |
+ var i; | |
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in"… | |
- // Stem the searchterms and add them to the correct list | |
+ // stem the searchterms and add them to the correct list | |
var stemmer = new Stemmer(); | |
var searchterms = []; | |
var excluded = []; | |
var hlterms = []; | |
- var tmp = query.split(/\s+/); | |
+ var tmp = splitQuery(query); | |
var objectterms = []; | |
- for (var i = 0; i < tmp.length; i++) { | |
- if (tmp[i] != "") { | |
+ for (i = 0; i < tmp.length; i++) { | |
+ if (tmp[i] !== "") { | |
objectterms.push(tmp[i].toLowerCase()); | |
} | |
- if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) || | |
- tmp[i] == "") { | |
+ if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^… | |
+ tmp[i] === "") { | |
// skip this "word" | |
continue; | |
} | |
// stem the word | |
- var word = stemmer.stemWord(tmp[i]).toLowerCase(); | |
+ var word = stemmer.stemWord(tmp[i].toLowerCase()); | |
+ var toAppend; | |
// select the correct list | |
if (word[0] == '-') { | |
- var toAppend = excluded; | |
+ toAppend = excluded; | |
word = word.substr(1); | |
} | |
else { | |
- var toAppend = searchterms; | |
+ toAppend = searchterms; | |
hlterms.push(tmp[i].toLowerCase()); | |
} | |
// only add if not already in the list | |
- if (!$.contains(toAppend, word)) | |
+ if (!$u.contains(toAppend, word)) | |
toAppend.push(word); | |
- }; | |
+ } | |
var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" ")); | |
// console.debug('SEARCH: searching for:'); | |
t@@ -347,89 +459,50 @@ var Search = { | |
// console.info('excluded: ', excluded); | |
// prepare search | |
- var filenames = this._index.filenames; | |
- var titles = this._index.titles; | |
var terms = this._index.terms; | |
- var fileMap = {}; | |
- var files = null; | |
- // different result priorities | |
- var importantResults = []; | |
- var objectResults = []; | |
- var regularResults = []; | |
- var unimportantResults = []; | |
+ var titleterms = this._index.titleterms; | |
+ | |
+ // array of [filename, title, anchor, descr, score] | |
+ var results = []; | |
$('#search-progress').empty(); | |
// lookup as object | |
- for (var i = 0; i < objectterms.length; i++) { | |
- var others = [].concat(objectterms.slice(0,i), | |
- objectterms.slice(i+1, objectterms.length)) | |
- var results = this.performObjectSearch(objectterms[i], others); | |
- // Assume first word is most likely to be the object, | |
- // other words more likely to be in description. | |
- // Therefore put matches for earlier words first. | |
- // (Results are eventually used in reverse order). | |
- objectResults = results[0].concat(objectResults); | |
- importantResults = results[1].concat(importantResults); | |
- unimportantResults = results[2].concat(unimportantResults); | |
- } | |
- | |
- // perform the search on the required terms | |
- for (var i = 0; i < searchterms.length; i++) { | |
- var word = searchterms[i]; | |
- // no match but word was a required one | |
- if ((files = terms[word]) == null) | |
- break; | |
- if (files.length == undefined) { | |
- files = [files]; | |
- } | |
- // create the mapping | |
- for (var j = 0; j < files.length; j++) { | |
- var file = files[j]; | |
- if (file in fileMap) | |
- fileMap[file].push(word); | |
- else | |
- fileMap[file] = [word]; | |
- } | |
+ for (i = 0; i < objectterms.length; i++) { | |
+ var others = [].concat(objectterms.slice(0, i), | |
+ objectterms.slice(i+1, objectterms.length)); | |
+ results = results.concat(this.performObjectSearch(objectterms[i], others… | |
} | |
- // now check if the files don't contain excluded terms | |
- for (var file in fileMap) { | |
- var valid = true; | |
- | |
- // check if all requirements are matched | |
- if (fileMap[file].length != searchterms.length) | |
- continue; | |
- | |
- // ensure that none of the excluded terms is in the | |
- // search result. | |
- for (var i = 0; i < excluded.length; i++) { | |
- if (terms[excluded[i]] == file || | |
- $.contains(terms[excluded[i]] || [], file)) { | |
- valid = false; | |
- break; | |
- } | |
- } | |
+ // lookup as search terms in fulltext | |
+ results = results.concat(this.performTermsSearch(searchterms, excluded, te… | |
- // if we have still a valid result we can add it | |
- // to the result list | |
- if (valid) | |
- regularResults.push([filenames[file], titles[file], '', null]); | |
+ // let the scorer override scores with a custom scoring function | |
+ if (Scorer.score) { | |
+ for (i = 0; i < results.length; i++) | |
+ results[i][4] = Scorer.score(results[i]); | |
} | |
- // delete unused variables in order to not waste | |
- // memory until list is retrieved completely | |
- delete filenames, titles, terms; | |
- | |
- // now sort the regular results descending by title | |
- regularResults.sort(function(a, b) { | |
- var left = a[1].toLowerCase(); | |
- var right = b[1].toLowerCase(); | |
- return (left > right) ? -1 : ((left < right) ? 1 : 0); | |
+ // now sort the results by score (in opposite order of appearance, since t… | |
+ // display function below uses pop() to retrieve items) and then | |
+ // alphabetically | |
+ results.sort(function(a, b) { | |
+ var left = a[4]; | |
+ var right = b[4]; | |
+ if (left > right) { | |
+ return 1; | |
+ } else if (left < right) { | |
+ return -1; | |
+ } else { | |
+ // same score: sort alphabetically | |
+ left = a[1].toLowerCase(); | |
+ right = b[1].toLowerCase(); | |
+ return (left > right) ? -1 : ((left < right) ? 1 : 0); | |
+ } | |
}); | |
- // combine all results | |
- var results = unimportantResults.concat(regularResults) | |
- .concat(objectResults).concat(importantResults); | |
+ // for debugging | |
+ //Search.lastresults = results.slice(); // a copy | |
+ //console.info('search results:', Search.lastresults); | |
// print the results | |
var resultCount = results.length; | |
t@@ -438,7 +511,7 @@ var Search = { | |
if (results.length) { | |
var item = results.pop(); | |
var listItem = $('<li style="display:none"></li>'); | |
- if (DOCUMENTATION_OPTIONS.FILE_SUFFIX == '') { | |
+ if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') { | |
// dirhtml builder | |
var dirname = item[0] + '/'; | |
if (dirname.match(/\/index\/$/)) { | |
t@@ -466,8 +539,8 @@ var Search = { | |
dataType: "text", | |
complete: function(jqxhr, textstatus) { | |
var data = jqxhr.responseText; | |
- if (data !== '') { | |
- listItem.append($.makeSearchSummary(data, searchterms, h… | |
+ if (data !== '' && data !== undefined) { | |
+ listItem.append(Search.makeSearchSummary(data, searchter… | |
} | |
Search.output.append(listItem); | |
listItem.slideDown(5, function() { | |
t@@ -496,20 +569,32 @@ var Search = { | |
displayNextItem(); | |
}, | |
+ /** | |
+ * search for object names | |
+ */ | |
performObjectSearch : function(object, otherterms) { | |
var filenames = this._index.filenames; | |
var objects = this._index.objects; | |
var objnames = this._index.objnames; | |
var titles = this._index.titles; | |
- var importantResults = []; | |
- var objectResults = []; | |
- var unimportantResults = []; | |
+ var i; | |
+ var results = []; | |
for (var prefix in objects) { | |
for (var name in objects[prefix]) { | |
var fullname = (prefix ? prefix + '.' : '') + name; | |
if (fullname.toLowerCase().indexOf(object) > -1) { | |
+ var score = 0; | |
+ var parts = fullname.split('.'); | |
+ // check for different match types: exact matches of full name or | |
+ // "last name" (i.e. last dotted part) | |
+ if (fullname == object || parts[parts.length - 1] == object) { | |
+ score += Scorer.objNameMatch; | |
+ // matches in last name | |
+ } else if (parts[parts.length - 1].indexOf(object) > -1) { | |
+ score += Scorer.objPartialMatch; | |
+ } | |
var match = objects[prefix][name]; | |
var objname = objnames[match[1]][2]; | |
var title = titles[match[0]]; | |
t@@ -519,7 +604,7 @@ var Search = { | |
var haystack = (prefix + ' ' + name + ' ' + | |
objname + ' ' + title).toLowerCase(); | |
var allfound = true; | |
- for (var i = 0; i < otherterms.length; i++) { | |
+ for (i = 0; i < otherterms.length; i++) { | |
if (haystack.indexOf(otherterms[i]) == -1) { | |
allfound = false; | |
break; | |
t@@ -530,37 +615,136 @@ var Search = { | |
} | |
} | |
var descr = objname + _(', in ') + title; | |
- anchor = match[3]; | |
- if (anchor == '') | |
+ | |
+ var anchor = match[3]; | |
+ if (anchor === '') | |
anchor = fullname; | |
else if (anchor == '-') | |
anchor = objnames[match[1]][1] + '-' + fullname; | |
- result = [filenames[match[0]], fullname, '#'+anchor, descr]; | |
- switch (match[2]) { | |
- case 1: objectResults.push(result); break; | |
- case 0: importantResults.push(result); break; | |
- case 2: unimportantResults.push(result); break; | |
+ // add custom score for some objects according to scorer | |
+ if (Scorer.objPrio.hasOwnProperty(match[2])) { | |
+ score += Scorer.objPrio[match[2]]; | |
+ } else { | |
+ score += Scorer.objPrioDefault; | |
} | |
+ results.push([filenames[match[0]], fullname, '#'+anchor, descr, scor… | |
} | |
} | |
} | |
- // sort results descending | |
- objectResults.sort(function(a, b) { | |
- return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); | |
- }); | |
+ return results; | |
+ }, | |
- importantResults.sort(function(a, b) { | |
- return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); | |
- }); | |
+ /** | |
+ * search for full-text terms in the index | |
+ */ | |
+ performTermsSearch : function(searchterms, excluded, terms, titleterms) { | |
+ var filenames = this._index.filenames; | |
+ var titles = this._index.titles; | |
- unimportantResults.sort(function(a, b) { | |
- return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); | |
- }); | |
+ var i, j, file; | |
+ var fileMap = {}; | |
+ var scoreMap = {}; | |
+ var results = []; | |
- return [importantResults, objectResults, unimportantResults] | |
+ // perform the search on the required terms | |
+ for (i = 0; i < searchterms.length; i++) { | |
+ var word = searchterms[i]; | |
+ var files = []; | |
+ var _o = [ | |
+ {files: terms[word], score: Scorer.term}, | |
+ {files: titleterms[word], score: Scorer.title} | |
+ ]; | |
+ | |
+ // no match but word was a required one | |
+ if ($u.every(_o, function(o){return o.files === undefined;})) { | |
+ break; | |
+ } | |
+ // found search word in contents | |
+ $u.each(_o, function(o) { | |
+ var _files = o.files; | |
+ if (_files === undefined) | |
+ return | |
+ | |
+ if (_files.length === undefined) | |
+ _files = [_files]; | |
+ files = files.concat(_files); | |
+ | |
+ // set score for the word in each file to Scorer.term | |
+ for (j = 0; j < _files.length; j++) { | |
+ file = _files[j]; | |
+ if (!(file in scoreMap)) | |
+ scoreMap[file] = {} | |
+ scoreMap[file][word] = o.score; | |
+ } | |
+ }); | |
+ | |
+ // create the mapping | |
+ for (j = 0; j < files.length; j++) { | |
+ file = files[j]; | |
+ if (file in fileMap) | |
+ fileMap[file].push(word); | |
+ else | |
+ fileMap[file] = [word]; | |
+ } | |
+ } | |
+ | |
+ // now check if the files don't contain excluded terms | |
+ for (file in fileMap) { | |
+ var valid = true; | |
+ | |
+ // check if all requirements are matched | |
+ if (fileMap[file].length != searchterms.length) | |
+ continue; | |
+ | |
+ // ensure that none of the excluded terms is in the search result | |
+ for (i = 0; i < excluded.length; i++) { | |
+ if (terms[excluded[i]] == file || | |
+ titleterms[excluded[i]] == file || | |
+ $u.contains(terms[excluded[i]] || [], file) || | |
+ $u.contains(titleterms[excluded[i]] || [], file)) { | |
+ valid = false; | |
+ break; | |
+ } | |
+ } | |
+ | |
+ // if we have still a valid result we can add it to the result list | |
+ if (valid) { | |
+ // select one (max) score for the file. | |
+ // for better ranking, we should calculate ranking by using words stat… | |
+ var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[f… | |
+ results.push([filenames[file], titles[file], '', null, score]); | |
+ } | |
+ } | |
+ return results; | |
+ }, | |
+ | |
+ /** | |
+ * helper function to return a node containing the | |
+ * search summary for a given text. keywords is a list | |
+ * of stemmed words, hlwords is the list of normal, unstemmed | |
+ * words. the first one is used to find the occurrence, the | |
+ * latter for highlighting it. | |
+ */ | |
+ makeSearchSummary : function(text, keywords, hlwords) { | |
+ var textLower = text.toLowerCase(); | |
+ var start = 0; | |
+ $.each(keywords, function() { | |
+ var i = textLower.indexOf(this.toLowerCase()); | |
+ if (i > -1) | |
+ start = i; | |
+ }); | |
+ start = Math.max(start - 120, 0); | |
+ var excerpt = ((start > 0) ? '...' : '') + | |
+ $.trim(text.substr(start, 240)) + | |
+ ((start + 240 - text.length) ? '...' : ''); | |
+ var rv = $('<div class="context"></div>').text(excerpt); | |
+ $.each(hlwords, function() { | |
+ rv = rv.highlightText(this, 'highlighted'); | |
+ }); | |
+ return rv; | |
} | |
-} | |
+}; | |
$(document).ready(function() { | |
Search.init(); | |
diff --git a/doc/html/_static/sidebar.js b/doc/html/_static/sidebar.js | |
t@@ -16,12 +16,20 @@ | |
* Once the browser is closed the cookie is deleted and the position | |
* reset to the default (expanded). | |
* | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | |
* :license: BSD, see LICENSE for details. | |
* | |
*/ | |
$(function() { | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
// global elements used by the functions. | |
// the 'sidebarbutton' element is defined as global after its | |
// creation, in the add_sidebar_button function | |
t@@ -134,7 +142,7 @@ $(function() { | |
var items = document.cookie.split(';'); | |
for(var k=0; k<items.length; k++) { | |
var key_val = items[k].split('='); | |
- var key = key_val[0]; | |
+ var key = key_val[0].replace(/ /, ""); // strip leading spaces | |
if (key == 'sidebar') { | |
var value = key_val[1]; | |
if ((value == 'collapsed') && (!sidebar_is_collapsed())) | |
t@@ -148,4 +156,4 @@ $(function() { | |
add_sidebar_button(); | |
var sidebarbutton = $('#sidebarbutton'); | |
set_position_from_cookie(); | |
-}); | |
+}); | |
+\ No newline at end of file | |
diff --git a/doc/html/_static/underscore.js b/doc/html/_static/underscore.js | |
t@@ -1,6 +1,6 @@ | |
-// Underscore.js 1.4.4 | |
+// Underscore.js 1.8.3 | |
// http://underscorejs.org | |
-// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. | |
+// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporter… | |
// Underscore may be freely distributed under the MIT license. | |
(function() { | |
t@@ -8,40 +8,32 @@ | |
// Baseline setup | |
// -------------- | |
- // Establish the root object, `window` in the browser, or `global` on the se… | |
+ // Establish the root object, `window` in the browser, or `exports` on the s… | |
var root = this; | |
// Save the previous value of the `_` variable. | |
var previousUnderscore = root._; | |
- // Establish the object that gets returned to break out of a loop iteration. | |
- var breaker = {}; | |
- | |
// Save bytes in the minified (but not gzipped) version: | |
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = F… | |
// Create quick reference variables for speed access to core prototypes. | |
- var push = ArrayProto.push, | |
- slice = ArrayProto.slice, | |
- concat = ArrayProto.concat, | |
- toString = ObjProto.toString, | |
- hasOwnProperty = ObjProto.hasOwnProperty; | |
+ var | |
+ push = ArrayProto.push, | |
+ slice = ArrayProto.slice, | |
+ toString = ObjProto.toString, | |
+ hasOwnProperty = ObjProto.hasOwnProperty; | |
// All **ECMAScript 5** native function implementations that we hope to use | |
// are declared here. | |
var | |
- nativeForEach = ArrayProto.forEach, | |
- nativeMap = ArrayProto.map, | |
- nativeReduce = ArrayProto.reduce, | |
- nativeReduceRight = ArrayProto.reduceRight, | |
- nativeFilter = ArrayProto.filter, | |
- nativeEvery = ArrayProto.every, | |
- nativeSome = ArrayProto.some, | |
- nativeIndexOf = ArrayProto.indexOf, | |
- nativeLastIndexOf = ArrayProto.lastIndexOf, | |
nativeIsArray = Array.isArray, | |
nativeKeys = Object.keys, | |
- nativeBind = FuncProto.bind; | |
+ nativeBind = FuncProto.bind, | |
+ nativeCreate = Object.create; | |
+ | |
+ // Naked function reference for surrogate-prototype-swapping. | |
+ var Ctor = function(){}; | |
// Create a safe reference to the Underscore object for use below. | |
var _ = function(obj) { | |
t@@ -52,8 +44,7 @@ | |
// Export the Underscore object for **Node.js**, with | |
// backwards-compatibility for the old `require()` API. If we're in | |
- // the browser, add `_` as a global object via a string identifier, | |
- // for Closure Compiler "advanced" mode. | |
+ // the browser, add `_` as a global object. | |
if (typeof exports !== 'undefined') { | |
if (typeof module !== 'undefined' && module.exports) { | |
exports = module.exports = _; | |
t@@ -64,161 +55,217 @@ | |
} | |
// Current version. | |
- _.VERSION = '1.4.4'; | |
+ _.VERSION = '1.8.3'; | |
+ | |
+ // Internal function that returns an efficient (for current engines) version | |
+ // of the passed-in callback, to be repeatedly applied in other Underscore | |
+ // functions. | |
+ var optimizeCb = function(func, context, argCount) { | |
+ if (context === void 0) return func; | |
+ switch (argCount == null ? 3 : argCount) { | |
+ case 1: return function(value) { | |
+ return func.call(context, value); | |
+ }; | |
+ case 2: return function(value, other) { | |
+ return func.call(context, value, other); | |
+ }; | |
+ case 3: return function(value, index, collection) { | |
+ return func.call(context, value, index, collection); | |
+ }; | |
+ case 4: return function(accumulator, value, index, collection) { | |
+ return func.call(context, accumulator, value, index, collection); | |
+ }; | |
+ } | |
+ return function() { | |
+ return func.apply(context, arguments); | |
+ }; | |
+ }; | |
+ | |
+ // A mostly-internal function to generate callbacks that can be applied | |
+ // to each element in a collection, returning the desired result — either | |
+ // identity, an arbitrary callback, a property matcher, or a property access… | |
+ var cb = function(value, context, argCount) { | |
+ if (value == null) return _.identity; | |
+ if (_.isFunction(value)) return optimizeCb(value, context, argCount); | |
+ if (_.isObject(value)) return _.matcher(value); | |
+ return _.property(value); | |
+ }; | |
+ _.iteratee = function(value, context) { | |
+ return cb(value, context, Infinity); | |
+ }; | |
+ | |
+ // An internal function for creating assigner functions. | |
+ var createAssigner = function(keysFunc, undefinedOnly) { | |
+ return function(obj) { | |
+ var length = arguments.length; | |
+ if (length < 2 || obj == null) return obj; | |
+ for (var index = 1; index < length; index++) { | |
+ var source = arguments[index], | |
+ keys = keysFunc(source), | |
+ l = keys.length; | |
+ for (var i = 0; i < l; i++) { | |
+ var key = keys[i]; | |
+ if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; | |
+ } | |
+ } | |
+ return obj; | |
+ }; | |
+ }; | |
+ | |
+ // An internal function for creating a new object that inherits from another. | |
+ var baseCreate = function(prototype) { | |
+ if (!_.isObject(prototype)) return {}; | |
+ if (nativeCreate) return nativeCreate(prototype); | |
+ Ctor.prototype = prototype; | |
+ var result = new Ctor; | |
+ Ctor.prototype = null; | |
+ return result; | |
+ }; | |
+ | |
+ var property = function(key) { | |
+ return function(obj) { | |
+ return obj == null ? void 0 : obj[key]; | |
+ }; | |
+ }; | |
+ | |
+ // Helper for collection methods to determine whether a collection | |
+ // should be iterated as an array or as an object | |
+ // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength | |
+ // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 | |
+ var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; | |
+ var getLength = property('length'); | |
+ var isArrayLike = function(collection) { | |
+ var length = getLength(collection); | |
+ return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_IND… | |
+ }; | |
// Collection Functions | |
// -------------------- | |
// The cornerstone, an `each` implementation, aka `forEach`. | |
- // Handles objects with the built-in `forEach`, arrays, and raw objects. | |
- // Delegates to **ECMAScript 5**'s native `forEach` if available. | |
- var each = _.each = _.forEach = function(obj, iterator, context) { | |
- if (obj == null) return; | |
- if (nativeForEach && obj.forEach === nativeForEach) { | |
- obj.forEach(iterator, context); | |
- } else if (obj.length === +obj.length) { | |
- for (var i = 0, l = obj.length; i < l; i++) { | |
- if (iterator.call(context, obj[i], i, obj) === breaker) return; | |
+ // Handles raw objects in addition to array-likes. Treats all | |
+ // sparse array-likes as if they were dense. | |
+ _.each = _.forEach = function(obj, iteratee, context) { | |
+ iteratee = optimizeCb(iteratee, context); | |
+ var i, length; | |
+ if (isArrayLike(obj)) { | |
+ for (i = 0, length = obj.length; i < length; i++) { | |
+ iteratee(obj[i], i, obj); | |
} | |
} else { | |
- for (var key in obj) { | |
- if (_.has(obj, key)) { | |
- if (iterator.call(context, obj[key], key, obj) === breaker) return; | |
- } | |
+ var keys = _.keys(obj); | |
+ for (i = 0, length = keys.length; i < length; i++) { | |
+ iteratee(obj[keys[i]], keys[i], obj); | |
} | |
} | |
+ return obj; | |
}; | |
- // Return the results of applying the iterator to each element. | |
- // Delegates to **ECMAScript 5**'s native `map` if available. | |
- _.map = _.collect = function(obj, iterator, context) { | |
- var results = []; | |
- if (obj == null) return results; | |
- if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); | |
- each(obj, function(value, index, list) { | |
- results[results.length] = iterator.call(context, value, index, list); | |
- }); | |
+ // Return the results of applying the iteratee to each element. | |
+ _.map = _.collect = function(obj, iteratee, context) { | |
+ iteratee = cb(iteratee, context); | |
+ var keys = !isArrayLike(obj) && _.keys(obj), | |
+ length = (keys || obj).length, | |
+ results = Array(length); | |
+ for (var index = 0; index < length; index++) { | |
+ var currentKey = keys ? keys[index] : index; | |
+ results[index] = iteratee(obj[currentKey], currentKey, obj); | |
+ } | |
return results; | |
}; | |
- var reduceError = 'Reduce of empty array with no initial value'; | |
- | |
- // **Reduce** builds up a single result from a list of values, aka `inject`, | |
- // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. | |
- _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { | |
- var initial = arguments.length > 2; | |
- if (obj == null) obj = []; | |
- if (nativeReduce && obj.reduce === nativeReduce) { | |
- if (context) iterator = _.bind(iterator, context); | |
- return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); | |
+ // Create a reducing function iterating left or right. | |
+ function createReduce(dir) { | |
+ // Optimized iterator function as using arguments.length | |
+ // in the main function will deoptimize the, see #1991. | |
+ function iterator(obj, iteratee, memo, keys, index, length) { | |
+ for (; index >= 0 && index < length; index += dir) { | |
+ var currentKey = keys ? keys[index] : index; | |
+ memo = iteratee(memo, obj[currentKey], currentKey, obj); | |
+ } | |
+ return memo; | |
} | |
- each(obj, function(value, index, list) { | |
- if (!initial) { | |
- memo = value; | |
- initial = true; | |
- } else { | |
- memo = iterator.call(context, memo, value, index, list); | |
+ | |
+ return function(obj, iteratee, memo, context) { | |
+ iteratee = optimizeCb(iteratee, context, 4); | |
+ var keys = !isArrayLike(obj) && _.keys(obj), | |
+ length = (keys || obj).length, | |
+ index = dir > 0 ? 0 : length - 1; | |
+ // Determine the initial value if none is provided. | |
+ if (arguments.length < 3) { | |
+ memo = obj[keys ? keys[index] : index]; | |
+ index += dir; | |
} | |
- }); | |
- if (!initial) throw new TypeError(reduceError); | |
- return memo; | |
- }; | |
+ return iterator(obj, iteratee, memo, keys, index, length); | |
+ }; | |
+ } | |
+ | |
+ // **Reduce** builds up a single result from a list of values, aka `inject`, | |
+ // or `foldl`. | |
+ _.reduce = _.foldl = _.inject = createReduce(1); | |
// The right-associative version of reduce, also known as `foldr`. | |
- // Delegates to **ECMAScript 5**'s native `reduceRight` if available. | |
- _.reduceRight = _.foldr = function(obj, iterator, memo, context) { | |
- var initial = arguments.length > 2; | |
- if (obj == null) obj = []; | |
- if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { | |
- if (context) iterator = _.bind(iterator, context); | |
- return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(itera… | |
- } | |
- var length = obj.length; | |
- if (length !== +length) { | |
- var keys = _.keys(obj); | |
- length = keys.length; | |
- } | |
- each(obj, function(value, index, list) { | |
- index = keys ? keys[--length] : --length; | |
- if (!initial) { | |
- memo = obj[index]; | |
- initial = true; | |
- } else { | |
- memo = iterator.call(context, memo, obj[index], index, list); | |
- } | |
- }); | |
- if (!initial) throw new TypeError(reduceError); | |
- return memo; | |
- }; | |
+ _.reduceRight = _.foldr = createReduce(-1); | |
// Return the first value which passes a truth test. Aliased as `detect`. | |
- _.find = _.detect = function(obj, iterator, context) { | |
- var result; | |
- any(obj, function(value, index, list) { | |
- if (iterator.call(context, value, index, list)) { | |
- result = value; | |
- return true; | |
- } | |
- }); | |
- return result; | |
+ _.find = _.detect = function(obj, predicate, context) { | |
+ var key; | |
+ if (isArrayLike(obj)) { | |
+ key = _.findIndex(obj, predicate, context); | |
+ } else { | |
+ key = _.findKey(obj, predicate, context); | |
+ } | |
+ if (key !== void 0 && key !== -1) return obj[key]; | |
}; | |
// Return all the elements that pass a truth test. | |
- // Delegates to **ECMAScript 5**'s native `filter` if available. | |
// Aliased as `select`. | |
- _.filter = _.select = function(obj, iterator, context) { | |
+ _.filter = _.select = function(obj, predicate, context) { | |
var results = []; | |
- if (obj == null) return results; | |
- if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterato… | |
- each(obj, function(value, index, list) { | |
- if (iterator.call(context, value, index, list)) results[results.length] … | |
+ predicate = cb(predicate, context); | |
+ _.each(obj, function(value, index, list) { | |
+ if (predicate(value, index, list)) results.push(value); | |
}); | |
return results; | |
}; | |
// Return all the elements for which a truth test fails. | |
- _.reject = function(obj, iterator, context) { | |
- return _.filter(obj, function(value, index, list) { | |
- return !iterator.call(context, value, index, list); | |
- }, context); | |
+ _.reject = function(obj, predicate, context) { | |
+ return _.filter(obj, _.negate(cb(predicate)), context); | |
}; | |
// Determine whether all of the elements match a truth test. | |
- // Delegates to **ECMAScript 5**'s native `every` if available. | |
// Aliased as `all`. | |
- _.every = _.all = function(obj, iterator, context) { | |
- iterator || (iterator = _.identity); | |
- var result = true; | |
- if (obj == null) return result; | |
- if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, c… | |
- each(obj, function(value, index, list) { | |
- if (!(result = result && iterator.call(context, value, index, list))) re… | |
- }); | |
- return !!result; | |
+ _.every = _.all = function(obj, predicate, context) { | |
+ predicate = cb(predicate, context); | |
+ var keys = !isArrayLike(obj) && _.keys(obj), | |
+ length = (keys || obj).length; | |
+ for (var index = 0; index < length; index++) { | |
+ var currentKey = keys ? keys[index] : index; | |
+ if (!predicate(obj[currentKey], currentKey, obj)) return false; | |
+ } | |
+ return true; | |
}; | |
// Determine if at least one element in the object matches a truth test. | |
- // Delegates to **ECMAScript 5**'s native `some` if available. | |
// Aliased as `any`. | |
- var any = _.some = _.any = function(obj, iterator, context) { | |
- iterator || (iterator = _.identity); | |
- var result = false; | |
- if (obj == null) return result; | |
- if (nativeSome && obj.some === nativeSome) return obj.some(iterator, conte… | |
- each(obj, function(value, index, list) { | |
- if (result || (result = iterator.call(context, value, index, list))) ret… | |
- }); | |
- return !!result; | |
+ _.some = _.any = function(obj, predicate, context) { | |
+ predicate = cb(predicate, context); | |
+ var keys = !isArrayLike(obj) && _.keys(obj), | |
+ length = (keys || obj).length; | |
+ for (var index = 0; index < length; index++) { | |
+ var currentKey = keys ? keys[index] : index; | |
+ if (predicate(obj[currentKey], currentKey, obj)) return true; | |
+ } | |
+ return false; | |
}; | |
- // Determine if the array or object contains a given value (using `===`). | |
- // Aliased as `include`. | |
- _.contains = _.include = function(obj, target) { | |
- if (obj == null) return false; | |
- if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(tar… | |
- return any(obj, function(value) { | |
- return value === target; | |
- }); | |
+ // Determine if the array or object contains a given item (using `===`). | |
+ // Aliased as `includes` and `include`. | |
+ _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { | |
+ if (!isArrayLike(obj)) obj = _.values(obj); | |
+ if (typeof fromIndex != 'number' || guard) fromIndex = 0; | |
+ return _.indexOf(obj, item, fromIndex) >= 0; | |
}; | |
// Invoke a method (with arguments) on every item in a collection. | |
t@@ -226,89 +273,111 @@ | |
var args = slice.call(arguments, 2); | |
var isFunc = _.isFunction(method); | |
return _.map(obj, function(value) { | |
- return (isFunc ? method : value[method]).apply(value, args); | |
+ var func = isFunc ? method : value[method]; | |
+ return func == null ? func : func.apply(value, args); | |
}); | |
}; | |
// Convenience version of a common use case of `map`: fetching a property. | |
_.pluck = function(obj, key) { | |
- return _.map(obj, function(value){ return value[key]; }); | |
+ return _.map(obj, _.property(key)); | |
}; | |
// Convenience version of a common use case of `filter`: selecting only obje… | |
// containing specific `key:value` pairs. | |
- _.where = function(obj, attrs, first) { | |
- if (_.isEmpty(attrs)) return first ? null : []; | |
- return _[first ? 'find' : 'filter'](obj, function(value) { | |
- for (var key in attrs) { | |
- if (attrs[key] !== value[key]) return false; | |
- } | |
- return true; | |
- }); | |
+ _.where = function(obj, attrs) { | |
+ return _.filter(obj, _.matcher(attrs)); | |
}; | |
// Convenience version of a common use case of `find`: getting the first obj… | |
// containing specific `key:value` pairs. | |
_.findWhere = function(obj, attrs) { | |
- return _.where(obj, attrs, true); | |
- }; | |
- | |
- // Return the maximum element or (element-based computation). | |
- // Can't optimize arrays of integers longer than 65,535 elements. | |
- // See: https://bugs.webkit.org/show_bug.cgi?id=80797 | |
- _.max = function(obj, iterator, context) { | |
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 6553… | |
- return Math.max.apply(Math, obj); | |
+ return _.find(obj, _.matcher(attrs)); | |
+ }; | |
+ | |
+ // Return the maximum element (or element-based computation). | |
+ _.max = function(obj, iteratee, context) { | |
+ var result = -Infinity, lastComputed = -Infinity, | |
+ value, computed; | |
+ if (iteratee == null && obj != null) { | |
+ obj = isArrayLike(obj) ? obj : _.values(obj); | |
+ for (var i = 0, length = obj.length; i < length; i++) { | |
+ value = obj[i]; | |
+ if (value > result) { | |
+ result = value; | |
+ } | |
+ } | |
+ } else { | |
+ iteratee = cb(iteratee, context); | |
+ _.each(obj, function(value, index, list) { | |
+ computed = iteratee(value, index, list); | |
+ if (computed > lastComputed || computed === -Infinity && result === -I… | |
+ result = value; | |
+ lastComputed = computed; | |
+ } | |
+ }); | |
} | |
- if (!iterator && _.isEmpty(obj)) return -Infinity; | |
- var result = {computed : -Infinity, value: -Infinity}; | |
- each(obj, function(value, index, list) { | |
- var computed = iterator ? iterator.call(context, value, index, list) : v… | |
- computed >= result.computed && (result = {value : value, computed : comp… | |
- }); | |
- return result.value; | |
+ return result; | |
}; | |
// Return the minimum element (or element-based computation). | |
- _.min = function(obj, iterator, context) { | |
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 6553… | |
- return Math.min.apply(Math, obj); | |
+ _.min = function(obj, iteratee, context) { | |
+ var result = Infinity, lastComputed = Infinity, | |
+ value, computed; | |
+ if (iteratee == null && obj != null) { | |
+ obj = isArrayLike(obj) ? obj : _.values(obj); | |
+ for (var i = 0, length = obj.length; i < length; i++) { | |
+ value = obj[i]; | |
+ if (value < result) { | |
+ result = value; | |
+ } | |
+ } | |
+ } else { | |
+ iteratee = cb(iteratee, context); | |
+ _.each(obj, function(value, index, list) { | |
+ computed = iteratee(value, index, list); | |
+ if (computed < lastComputed || computed === Infinity && result === Inf… | |
+ result = value; | |
+ lastComputed = computed; | |
+ } | |
+ }); | |
} | |
- if (!iterator && _.isEmpty(obj)) return Infinity; | |
- var result = {computed : Infinity, value: Infinity}; | |
- each(obj, function(value, index, list) { | |
- var computed = iterator ? iterator.call(context, value, index, list) : v… | |
- computed < result.computed && (result = {value : value, computed : compu… | |
- }); | |
- return result.value; | |
+ return result; | |
}; | |
- // Shuffle an array. | |
+ // Shuffle a collection, using the modern version of the | |
+ // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffl… | |
_.shuffle = function(obj) { | |
- var rand; | |
- var index = 0; | |
- var shuffled = []; | |
- each(obj, function(value) { | |
- rand = _.random(index++); | |
- shuffled[index - 1] = shuffled[rand]; | |
- shuffled[rand] = value; | |
- }); | |
+ var set = isArrayLike(obj) ? obj : _.values(obj); | |
+ var length = set.length; | |
+ var shuffled = Array(length); | |
+ for (var index = 0, rand; index < length; index++) { | |
+ rand = _.random(0, index); | |
+ if (rand !== index) shuffled[index] = shuffled[rand]; | |
+ shuffled[rand] = set[index]; | |
+ } | |
return shuffled; | |
}; | |
- // An internal function to generate lookup iterators. | |
- var lookupIterator = function(value) { | |
- return _.isFunction(value) ? value : function(obj){ return obj[value]; }; | |
+ // Sample **n** random values from a collection. | |
+ // If **n** is not specified, returns a single random element. | |
+ // The internal `guard` argument allows it to work with `map`. | |
+ _.sample = function(obj, n, guard) { | |
+ if (n == null || guard) { | |
+ if (!isArrayLike(obj)) obj = _.values(obj); | |
+ return obj[_.random(obj.length - 1)]; | |
+ } | |
+ return _.shuffle(obj).slice(0, Math.max(0, n)); | |
}; | |
- // Sort the object's values by a criterion produced by an iterator. | |
- _.sortBy = function(obj, value, context) { | |
- var iterator = lookupIterator(value); | |
+ // Sort the object's values by a criterion produced by an iteratee. | |
+ _.sortBy = function(obj, iteratee, context) { | |
+ iteratee = cb(iteratee, context); | |
return _.pluck(_.map(obj, function(value, index, list) { | |
return { | |
- value : value, | |
- index : index, | |
- criteria : iterator.call(context, value, index, list) | |
+ value: value, | |
+ index: index, | |
+ criteria: iteratee(value, index, list) | |
}; | |
}).sort(function(left, right) { | |
var a = left.criteria; | |
t@@ -317,64 +386,65 @@ | |
if (a > b || a === void 0) return 1; | |
if (a < b || b === void 0) return -1; | |
} | |
- return left.index < right.index ? -1 : 1; | |
+ return left.index - right.index; | |
}), 'value'); | |
}; | |
// An internal function used for aggregate "group by" operations. | |
- var group = function(obj, value, context, behavior) { | |
- var result = {}; | |
- var iterator = lookupIterator(value || _.identity); | |
- each(obj, function(value, index) { | |
- var key = iterator.call(context, value, index, obj); | |
- behavior(result, key, value); | |
- }); | |
- return result; | |
+ var group = function(behavior) { | |
+ return function(obj, iteratee, context) { | |
+ var result = {}; | |
+ iteratee = cb(iteratee, context); | |
+ _.each(obj, function(value, index) { | |
+ var key = iteratee(value, index, obj); | |
+ behavior(result, value, key); | |
+ }); | |
+ return result; | |
+ }; | |
}; | |
// Groups the object's values by a criterion. Pass either a string attribute | |
// to group by, or a function that returns the criterion. | |
- _.groupBy = function(obj, value, context) { | |
- return group(obj, value, context, function(result, key, value) { | |
- (_.has(result, key) ? result[key] : (result[key] = [])).push(value); | |
- }); | |
- }; | |
+ _.groupBy = group(function(result, value, key) { | |
+ if (_.has(result, key)) result[key].push(value); else result[key] = [value… | |
+ }); | |
+ | |
+ // Indexes the object's values by a criterion, similar to `groupBy`, but for | |
+ // when you know that your index values will be unique. | |
+ _.indexBy = group(function(result, value, key) { | |
+ result[key] = value; | |
+ }); | |
// Counts instances of an object that group by a certain criterion. Pass | |
// either a string attribute to count by, or a function that returns the | |
// criterion. | |
- _.countBy = function(obj, value, context) { | |
- return group(obj, value, context, function(result, key) { | |
- if (!_.has(result, key)) result[key] = 0; | |
- result[key]++; | |
- }); | |
- }; | |
- | |
- // Use a comparator function to figure out the smallest index at which | |
- // an object should be inserted so as to maintain order. Uses binary search. | |
- _.sortedIndex = function(array, obj, iterator, context) { | |
- iterator = iterator == null ? _.identity : lookupIterator(iterator); | |
- var value = iterator.call(context, obj); | |
- var low = 0, high = array.length; | |
- while (low < high) { | |
- var mid = (low + high) >>> 1; | |
- iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; | |
- } | |
- return low; | |
- }; | |
+ _.countBy = group(function(result, value, key) { | |
+ if (_.has(result, key)) result[key]++; else result[key] = 1; | |
+ }); | |
- // Safely convert anything iterable into a real, live array. | |
+ // Safely create a real, live array from anything iterable. | |
_.toArray = function(obj) { | |
if (!obj) return []; | |
if (_.isArray(obj)) return slice.call(obj); | |
- if (obj.length === +obj.length) return _.map(obj, _.identity); | |
+ if (isArrayLike(obj)) return _.map(obj, _.identity); | |
return _.values(obj); | |
}; | |
// Return the number of elements in an object. | |
_.size = function(obj) { | |
if (obj == null) return 0; | |
- return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; | |
+ return isArrayLike(obj) ? obj.length : _.keys(obj).length; | |
+ }; | |
+ | |
+ // Split a collection into two arrays: one whose elements all satisfy the gi… | |
+ // predicate, and one whose elements all do not satisfy the predicate. | |
+ _.partition = function(obj, predicate, context) { | |
+ predicate = cb(predicate, context); | |
+ var pass = [], fail = []; | |
+ _.each(obj, function(value, key, obj) { | |
+ (predicate(value, key, obj) ? pass : fail).push(value); | |
+ }); | |
+ return [pass, fail]; | |
}; | |
// Array Functions | |
t@@ -385,34 +455,30 @@ | |
// allows it to work with `_.map`. | |
_.first = _.head = _.take = function(array, n, guard) { | |
if (array == null) return void 0; | |
- return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; | |
+ if (n == null || guard) return array[0]; | |
+ return _.initial(array, array.length - n); | |
}; | |
// Returns everything but the last entry of the array. Especially useful on | |
// the arguments object. Passing **n** will return all the values in | |
- // the array, excluding the last N. The **guard** check allows it to work wi… | |
- // `_.map`. | |
+ // the array, excluding the last N. | |
_.initial = function(array, n, guard) { | |
- return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); | |
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard… | |
}; | |
// Get the last element of an array. Passing **n** will return the last N | |
- // values in the array. The **guard** check allows it to work with `_.map`. | |
+ // values in the array. | |
_.last = function(array, n, guard) { | |
if (array == null) return void 0; | |
- if ((n != null) && !guard) { | |
- return slice.call(array, Math.max(array.length - n, 0)); | |
- } else { | |
- return array[array.length - 1]; | |
- } | |
+ if (n == null || guard) return array[array.length - 1]; | |
+ return _.rest(array, Math.max(0, array.length - n)); | |
}; | |
// Returns everything but the first entry of the array. Aliased as `tail` an… | |
// Especially useful on the arguments object. Passing an **n** will return | |
- // the rest N values in the array. The **guard** | |
- // check allows it to work with `_.map`. | |
+ // the rest N values in the array. | |
_.rest = _.tail = _.drop = function(array, n, guard) { | |
- return slice.call(array, (n == null) || guard ? 1 : n); | |
+ return slice.call(array, n == null || guard ? 1 : n); | |
}; | |
// Trim out all falsy values from an array. | |
t@@ -421,20 +487,28 @@ | |
}; | |
// Internal implementation of a recursive `flatten` function. | |
- var flatten = function(input, shallow, output) { | |
- each(input, function(value) { | |
- if (_.isArray(value)) { | |
- shallow ? push.apply(output, value) : flatten(value, shallow, output); | |
- } else { | |
- output.push(value); | |
+ var flatten = function(input, shallow, strict, startIndex) { | |
+ var output = [], idx = 0; | |
+ for (var i = startIndex || 0, length = getLength(input); i < length; i++) { | |
+ var value = input[i]; | |
+ if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { | |
+ //flatten current level of array or arguments object | |
+ if (!shallow) value = flatten(value, shallow, strict); | |
+ var j = 0, len = value.length; | |
+ output.length += len; | |
+ while (j < len) { | |
+ output[idx++] = value[j++]; | |
+ } | |
+ } else if (!strict) { | |
+ output[idx++] = value; | |
} | |
- }); | |
+ } | |
return output; | |
}; | |
- // Return a completely flattened version of an array. | |
+ // Flatten out an array, either recursively (by default), or just one level. | |
_.flatten = function(array, shallow) { | |
- return flatten(array, shallow, []); | |
+ return flatten(array, shallow, false); | |
}; | |
// Return a version of the array that does not contain the specified value(s… | |
t@@ -445,67 +519,88 @@ | |
// Produce a duplicate-free version of the array. If the array has already | |
// been sorted, you have the option of using a faster algorithm. | |
// Aliased as `unique`. | |
- _.uniq = _.unique = function(array, isSorted, iterator, context) { | |
- if (_.isFunction(isSorted)) { | |
- context = iterator; | |
- iterator = isSorted; | |
+ _.uniq = _.unique = function(array, isSorted, iteratee, context) { | |
+ if (!_.isBoolean(isSorted)) { | |
+ context = iteratee; | |
+ iteratee = isSorted; | |
isSorted = false; | |
} | |
- var initial = iterator ? _.map(array, iterator, context) : array; | |
- var results = []; | |
+ if (iteratee != null) iteratee = cb(iteratee, context); | |
+ var result = []; | |
var seen = []; | |
- each(initial, function(value, index) { | |
- if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains… | |
- seen.push(value); | |
- results.push(array[index]); | |
+ for (var i = 0, length = getLength(array); i < length; i++) { | |
+ var value = array[i], | |
+ computed = iteratee ? iteratee(value, i, array) : value; | |
+ if (isSorted) { | |
+ if (!i || seen !== computed) result.push(value); | |
+ seen = computed; | |
+ } else if (iteratee) { | |
+ if (!_.contains(seen, computed)) { | |
+ seen.push(computed); | |
+ result.push(value); | |
+ } | |
+ } else if (!_.contains(result, value)) { | |
+ result.push(value); | |
} | |
- }); | |
- return results; | |
+ } | |
+ return result; | |
}; | |
// Produce an array that contains the union: each distinct element from all … | |
// the passed-in arrays. | |
_.union = function() { | |
- return _.uniq(concat.apply(ArrayProto, arguments)); | |
+ return _.uniq(flatten(arguments, true, true)); | |
}; | |
// Produce an array that contains every item shared between all the | |
// passed-in arrays. | |
_.intersection = function(array) { | |
- var rest = slice.call(arguments, 1); | |
- return _.filter(_.uniq(array), function(item) { | |
- return _.every(rest, function(other) { | |
- return _.indexOf(other, item) >= 0; | |
- }); | |
- }); | |
+ var result = []; | |
+ var argsLength = arguments.length; | |
+ for (var i = 0, length = getLength(array); i < length; i++) { | |
+ var item = array[i]; | |
+ if (_.contains(result, item)) continue; | |
+ for (var j = 1; j < argsLength; j++) { | |
+ if (!_.contains(arguments[j], item)) break; | |
+ } | |
+ if (j === argsLength) result.push(item); | |
+ } | |
+ return result; | |
}; | |
// Take the difference between one array and a number of other arrays. | |
// Only the elements present in just the first array will remain. | |
_.difference = function(array) { | |
- var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
- return _.filter(array, function(value){ return !_.contains(rest, value); }… | |
+ var rest = flatten(arguments, true, true, 1); | |
+ return _.filter(array, function(value){ | |
+ return !_.contains(rest, value); | |
+ }); | |
}; | |
// Zip together multiple lists into a single array -- elements that share | |
// an index go together. | |
_.zip = function() { | |
- var args = slice.call(arguments); | |
- var length = _.max(_.pluck(args, 'length')); | |
- var results = new Array(length); | |
- for (var i = 0; i < length; i++) { | |
- results[i] = _.pluck(args, "" + i); | |
+ return _.unzip(arguments); | |
+ }; | |
+ | |
+ // Complement of _.zip. Unzip accepts an array of arrays and groups | |
+ // each array's elements on shared indices | |
+ _.unzip = function(array) { | |
+ var length = array && _.max(array, getLength).length || 0; | |
+ var result = Array(length); | |
+ | |
+ for (var index = 0; index < length; index++) { | |
+ result[index] = _.pluck(array, index); | |
} | |
- return results; | |
+ return result; | |
}; | |
// Converts lists into objects. Pass either a single array of `[key, value]` | |
// pairs, or two parallel arrays of the same length -- one of keys, and one … | |
// the corresponding values. | |
_.object = function(list, values) { | |
- if (list == null) return {}; | |
var result = {}; | |
- for (var i = 0, l = list.length; i < l; i++) { | |
+ for (var i = 0, length = getLength(list); i < length; i++) { | |
if (values) { | |
result[list[i]] = values[i]; | |
} else { | |
t@@ -515,57 +610,83 @@ | |
return result; | |
}; | |
- // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE… | |
- // we need this function. Return the position of the first occurrence of an | |
- // item in an array, or -1 if the item is not included in the array. | |
- // Delegates to **ECMAScript 5**'s native `indexOf` if available. | |
- // If the array is large and already in sort order, pass `true` | |
- // for **isSorted** to use binary search. | |
- _.indexOf = function(array, item, isSorted) { | |
- if (array == null) return -1; | |
- var i = 0, l = array.length; | |
- if (isSorted) { | |
- if (typeof isSorted == 'number') { | |
- i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); | |
- } else { | |
- i = _.sortedIndex(array, item); | |
- return array[i] === item ? i : -1; | |
+ // Generator function to create the findIndex and findLastIndex functions | |
+ function createPredicateIndexFinder(dir) { | |
+ return function(array, predicate, context) { | |
+ predicate = cb(predicate, context); | |
+ var length = getLength(array); | |
+ var index = dir > 0 ? 0 : length - 1; | |
+ for (; index >= 0 && index < length; index += dir) { | |
+ if (predicate(array[index], index, array)) return index; | |
} | |
- } | |
- if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf… | |
- for (; i < l; i++) if (array[i] === item) return i; | |
- return -1; | |
- }; | |
+ return -1; | |
+ }; | |
+ } | |
- // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. | |
- _.lastIndexOf = function(array, item, from) { | |
- if (array == null) return -1; | |
- var hasIndex = from != null; | |
- if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { | |
- return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item… | |
+ // Returns the first index on an array-like that passes a predicate test | |
+ _.findIndex = createPredicateIndexFinder(1); | |
+ _.findLastIndex = createPredicateIndexFinder(-1); | |
+ | |
+ // Use a comparator function to figure out the smallest index at which | |
+ // an object should be inserted so as to maintain order. Uses binary search. | |
+ _.sortedIndex = function(array, obj, iteratee, context) { | |
+ iteratee = cb(iteratee, context, 1); | |
+ var value = iteratee(obj); | |
+ var low = 0, high = getLength(array); | |
+ while (low < high) { | |
+ var mid = Math.floor((low + high) / 2); | |
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; | |
} | |
- var i = (hasIndex ? from : array.length); | |
- while (i--) if (array[i] === item) return i; | |
- return -1; | |
+ return low; | |
}; | |
+ // Generator function to create the indexOf and lastIndexOf functions | |
+ function createIndexFinder(dir, predicateFind, sortedIndex) { | |
+ return function(array, item, idx) { | |
+ var i = 0, length = getLength(array); | |
+ if (typeof idx == 'number') { | |
+ if (dir > 0) { | |
+ i = idx >= 0 ? idx : Math.max(idx + length, i); | |
+ } else { | |
+ length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; | |
+ } | |
+ } else if (sortedIndex && idx && length) { | |
+ idx = sortedIndex(array, item); | |
+ return array[idx] === item ? idx : -1; | |
+ } | |
+ if (item !== item) { | |
+ idx = predicateFind(slice.call(array, i, length), _.isNaN); | |
+ return idx >= 0 ? idx + i : -1; | |
+ } | |
+ for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += di… | |
+ if (array[idx] === item) return idx; | |
+ } | |
+ return -1; | |
+ }; | |
+ } | |
+ | |
+ // Return the position of the first occurrence of an item in an array, | |
+ // or -1 if the item is not included in the array. | |
+ // If the array is large and already in sort order, pass `true` | |
+ // for **isSorted** to use binary search. | |
+ _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); | |
+ _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); | |
+ | |
// Generate an integer Array containing an arithmetic progression. A port of | |
// the native Python `range()` function. See | |
// [the Python documentation](http://docs.python.org/library/functions.html#… | |
_.range = function(start, stop, step) { | |
- if (arguments.length <= 1) { | |
+ if (stop == null) { | |
stop = start || 0; | |
start = 0; | |
} | |
- step = arguments[2] || 1; | |
+ step = step || 1; | |
- var len = Math.max(Math.ceil((stop - start) / step), 0); | |
- var idx = 0; | |
- var range = new Array(len); | |
+ var length = Math.max(Math.ceil((stop - start) / step), 0); | |
+ var range = Array(length); | |
- while(idx < len) { | |
- range[idx++] = start; | |
- start += step; | |
+ for (var idx = 0; idx < length; idx++, start += step) { | |
+ range[idx] = start; | |
} | |
return range; | |
t@@ -574,79 +695,115 @@ | |
// Function (ahem) Functions | |
// ------------------ | |
+ // Determines whether to execute a function as a constructor | |
+ // or a normal function with the provided arguments | |
+ var executeBound = function(sourceFunc, boundFunc, context, callingContext, … | |
+ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(contex… | |
+ var self = baseCreate(sourceFunc.prototype); | |
+ var result = sourceFunc.apply(self, args); | |
+ if (_.isObject(result)) return result; | |
+ return self; | |
+ }; | |
+ | |
// Create a function bound to a given object (assigning `this`, and argument… | |
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if | |
// available. | |
_.bind = function(func, context) { | |
- if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, … | |
+ if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, … | |
+ if (!_.isFunction(func)) throw new TypeError('Bind must be called on a fun… | |
var args = slice.call(arguments, 2); | |
- return function() { | |
- return func.apply(context, args.concat(slice.call(arguments))); | |
+ var bound = function() { | |
+ return executeBound(func, bound, context, this, args.concat(slice.call(a… | |
}; | |
+ return bound; | |
}; | |
// Partially apply a function by creating a version that has had some of its | |
- // arguments pre-filled, without changing its dynamic `this` context. | |
+ // arguments pre-filled, without changing its dynamic `this` context. _ acts | |
+ // as a placeholder, allowing any combination of arguments to be pre-filled. | |
_.partial = function(func) { | |
- var args = slice.call(arguments, 1); | |
- return function() { | |
- return func.apply(this, args.concat(slice.call(arguments))); | |
+ var boundArgs = slice.call(arguments, 1); | |
+ var bound = function() { | |
+ var position = 0, length = boundArgs.length; | |
+ var args = Array(length); | |
+ for (var i = 0; i < length; i++) { | |
+ args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; | |
+ } | |
+ while (position < arguments.length) args.push(arguments[position++]); | |
+ return executeBound(func, bound, this, this, args); | |
}; | |
+ return bound; | |
}; | |
- // Bind all of an object's methods to that object. Useful for ensuring that | |
- // all callbacks defined on an object belong to it. | |
+ // Bind a number of an object's methods to that object. Remaining arguments | |
+ // are the method names to be bound. Useful for ensuring that all callbacks | |
+ // defined on an object belong to it. | |
_.bindAll = function(obj) { | |
- var funcs = slice.call(arguments, 1); | |
- if (funcs.length === 0) funcs = _.functions(obj); | |
- each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); | |
+ var i, length = arguments.length, key; | |
+ if (length <= 1) throw new Error('bindAll must be passed function names'); | |
+ for (i = 1; i < length; i++) { | |
+ key = arguments[i]; | |
+ obj[key] = _.bind(obj[key], obj); | |
+ } | |
return obj; | |
}; | |
// Memoize an expensive function by storing its results. | |
_.memoize = function(func, hasher) { | |
- var memo = {}; | |
- hasher || (hasher = _.identity); | |
- return function() { | |
- var key = hasher.apply(this, arguments); | |
- return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, argu… | |
+ var memoize = function(key) { | |
+ var cache = memoize.cache; | |
+ var address = '' + (hasher ? hasher.apply(this, arguments) : key); | |
+ if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); | |
+ return cache[address]; | |
}; | |
+ memoize.cache = {}; | |
+ return memoize; | |
}; | |
// Delays a function for the given number of milliseconds, and then calls | |
// it with the arguments supplied. | |
_.delay = function(func, wait) { | |
var args = slice.call(arguments, 2); | |
- return setTimeout(function(){ return func.apply(null, args); }, wait); | |
+ return setTimeout(function(){ | |
+ return func.apply(null, args); | |
+ }, wait); | |
}; | |
// Defers a function, scheduling it to run after the current call stack has | |
// cleared. | |
- _.defer = function(func) { | |
- return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); | |
- }; | |
+ _.defer = _.partial(_.delay, _, 1); | |
// Returns a function, that, when invoked, will only be triggered at most on… | |
- // during a given window of time. | |
- _.throttle = function(func, wait) { | |
- var context, args, timeout, result; | |
+ // during a given window of time. Normally, the throttled function will run | |
+ // as much as it can, without ever going more than once per `wait` duration; | |
+ // but if you'd like to disable the execution on the leading edge, pass | |
+ // `{leading: false}`. To disable execution on the trailing edge, ditto. | |
+ _.throttle = function(func, wait, options) { | |
+ var context, args, result; | |
+ var timeout = null; | |
var previous = 0; | |
+ if (!options) options = {}; | |
var later = function() { | |
- previous = new Date; | |
+ previous = options.leading === false ? 0 : _.now(); | |
timeout = null; | |
result = func.apply(context, args); | |
+ if (!timeout) context = args = null; | |
}; | |
return function() { | |
- var now = new Date; | |
+ var now = _.now(); | |
+ if (!previous && options.leading === false) previous = now; | |
var remaining = wait - (now - previous); | |
context = this; | |
args = arguments; | |
- if (remaining <= 0) { | |
- clearTimeout(timeout); | |
- timeout = null; | |
+ if (remaining <= 0 || remaining > wait) { | |
+ if (timeout) { | |
+ clearTimeout(timeout); | |
+ timeout = null; | |
+ } | |
previous = now; | |
result = func.apply(context, args); | |
- } else if (!timeout) { | |
+ if (!timeout) context = args = null; | |
+ } else if (!timeout && options.trailing !== false) { | |
timeout = setTimeout(later, remaining); | |
} | |
return result; | |
t@@ -658,31 +815,34 @@ | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
_.debounce = function(func, wait, immediate) { | |
- var timeout, result; | |
- return function() { | |
- var context = this, args = arguments; | |
- var later = function() { | |
+ var timeout, args, context, timestamp, result; | |
+ | |
+ var later = function() { | |
+ var last = _.now() - timestamp; | |
+ | |
+ if (last < wait && last >= 0) { | |
+ timeout = setTimeout(later, wait - last); | |
+ } else { | |
timeout = null; | |
- if (!immediate) result = func.apply(context, args); | |
- }; | |
- var callNow = immediate && !timeout; | |
- clearTimeout(timeout); | |
- timeout = setTimeout(later, wait); | |
- if (callNow) result = func.apply(context, args); | |
- return result; | |
+ if (!immediate) { | |
+ result = func.apply(context, args); | |
+ if (!timeout) context = args = null; | |
+ } | |
+ } | |
}; | |
- }; | |
- // Returns a function that will be executed at most one time, no matter how | |
- // often you call it. Useful for lazy initialization. | |
- _.once = function(func) { | |
- var ran = false, memo; | |
return function() { | |
- if (ran) return memo; | |
- ran = true; | |
- memo = func.apply(this, arguments); | |
- func = null; | |
- return memo; | |
+ context = this; | |
+ args = arguments; | |
+ timestamp = _.now(); | |
+ var callNow = immediate && !timeout; | |
+ if (!timeout) timeout = setTimeout(later, wait); | |
+ if (callNow) { | |
+ result = func.apply(context, args); | |
+ context = args = null; | |
+ } | |
+ | |
+ return result; | |
}; | |
}; | |
t@@ -690,29 +850,31 @@ | |
// allowing you to adjust arguments, run code before and after, and | |
// conditionally execute the original function. | |
_.wrap = function(func, wrapper) { | |
+ return _.partial(wrapper, func); | |
+ }; | |
+ | |
+ // Returns a negated version of the passed-in predicate. | |
+ _.negate = function(predicate) { | |
return function() { | |
- var args = [func]; | |
- push.apply(args, arguments); | |
- return wrapper.apply(this, args); | |
+ return !predicate.apply(this, arguments); | |
}; | |
}; | |
// Returns a function that is the composition of a list of functions, each | |
// consuming the return value of the function that follows. | |
_.compose = function() { | |
- var funcs = arguments; | |
+ var args = arguments; | |
+ var start = args.length - 1; | |
return function() { | |
- var args = arguments; | |
- for (var i = funcs.length - 1; i >= 0; i--) { | |
- args = [funcs[i].apply(this, args)]; | |
- } | |
- return args[0]; | |
+ var i = start; | |
+ var result = args[start].apply(this, arguments); | |
+ while (i--) result = args[i].call(this, result); | |
+ return result; | |
}; | |
}; | |
- // Returns a function that will only be executed after being called N times. | |
+ // Returns a function that will only be executed on and after the Nth call. | |
_.after = function(times, func) { | |
- if (times <= 0) return func(); | |
return function() { | |
if (--times < 1) { | |
return func.apply(this, arguments); | |
t@@ -720,36 +882,113 @@ | |
}; | |
}; | |
+ // Returns a function that will only be executed up to (but not including) t… | |
+ _.before = function(times, func) { | |
+ var memo; | |
+ return function() { | |
+ if (--times > 0) { | |
+ memo = func.apply(this, arguments); | |
+ } | |
+ if (times <= 1) func = null; | |
+ return memo; | |
+ }; | |
+ }; | |
+ | |
+ // Returns a function that will be executed at most one time, no matter how | |
+ // often you call it. Useful for lazy initialization. | |
+ _.once = _.partial(_.before, 2); | |
+ | |
// Object Functions | |
// ---------------- | |
- // Retrieve the names of an object's properties. | |
+ // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. | |
+ var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); | |
+ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', | |
+ 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleStrin… | |
+ | |
+ function collectNonEnumProps(obj, keys) { | |
+ var nonEnumIdx = nonEnumerableProps.length; | |
+ var constructor = obj.constructor; | |
+ var proto = (_.isFunction(constructor) && constructor.prototype) || ObjPro… | |
+ | |
+ // Constructor is a special case. | |
+ var prop = 'constructor'; | |
+ if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); | |
+ | |
+ while (nonEnumIdx--) { | |
+ prop = nonEnumerableProps[nonEnumIdx]; | |
+ if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop))… | |
+ keys.push(prop); | |
+ } | |
+ } | |
+ } | |
+ | |
+ // Retrieve the names of an object's own properties. | |
// Delegates to **ECMAScript 5**'s native `Object.keys` | |
- _.keys = nativeKeys || function(obj) { | |
- if (obj !== Object(obj)) throw new TypeError('Invalid object'); | |
+ _.keys = function(obj) { | |
+ if (!_.isObject(obj)) return []; | |
+ if (nativeKeys) return nativeKeys(obj); | |
+ var keys = []; | |
+ for (var key in obj) if (_.has(obj, key)) keys.push(key); | |
+ // Ahem, IE < 9. | |
+ if (hasEnumBug) collectNonEnumProps(obj, keys); | |
+ return keys; | |
+ }; | |
+ | |
+ // Retrieve all the property names of an object. | |
+ _.allKeys = function(obj) { | |
+ if (!_.isObject(obj)) return []; | |
var keys = []; | |
- for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; | |
+ for (var key in obj) keys.push(key); | |
+ // Ahem, IE < 9. | |
+ if (hasEnumBug) collectNonEnumProps(obj, keys); | |
return keys; | |
}; | |
// Retrieve the values of an object's properties. | |
_.values = function(obj) { | |
- var values = []; | |
- for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); | |
+ var keys = _.keys(obj); | |
+ var length = keys.length; | |
+ var values = Array(length); | |
+ for (var i = 0; i < length; i++) { | |
+ values[i] = obj[keys[i]]; | |
+ } | |
return values; | |
}; | |
+ // Returns the results of applying the iteratee to each element of the object | |
+ // In contrast to _.map it returns an object | |
+ _.mapObject = function(obj, iteratee, context) { | |
+ iteratee = cb(iteratee, context); | |
+ var keys = _.keys(obj), | |
+ length = keys.length, | |
+ results = {}, | |
+ currentKey; | |
+ for (var index = 0; index < length; index++) { | |
+ currentKey = keys[index]; | |
+ results[currentKey] = iteratee(obj[currentKey], currentKey, obj); | |
+ } | |
+ return results; | |
+ }; | |
+ | |
// Convert an object into a list of `[key, value]` pairs. | |
_.pairs = function(obj) { | |
- var pairs = []; | |
- for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); | |
+ var keys = _.keys(obj); | |
+ var length = keys.length; | |
+ var pairs = Array(length); | |
+ for (var i = 0; i < length; i++) { | |
+ pairs[i] = [keys[i], obj[keys[i]]]; | |
+ } | |
return pairs; | |
}; | |
// Invert the keys and values of an object. The values must be serializable. | |
_.invert = function(obj) { | |
var result = {}; | |
- for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; | |
+ var keys = _.keys(obj); | |
+ for (var i = 0, length = keys.length; i < length; i++) { | |
+ result[obj[keys[i]]] = keys[i]; | |
+ } | |
return result; | |
}; | |
t@@ -764,47 +1003,65 @@ | |
}; | |
// Extend a given object with all the properties in passed-in object(s). | |
- _.extend = function(obj) { | |
- each(slice.call(arguments, 1), function(source) { | |
- if (source) { | |
- for (var prop in source) { | |
- obj[prop] = source[prop]; | |
- } | |
- } | |
- }); | |
- return obj; | |
+ _.extend = createAssigner(_.allKeys); | |
+ | |
+ // Assigns a given object with all the own properties in the passed-in objec… | |
+ // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objec… | |
+ _.extendOwn = _.assign = createAssigner(_.keys); | |
+ | |
+ // Returns the first key on an object that passes a predicate test | |
+ _.findKey = function(obj, predicate, context) { | |
+ predicate = cb(predicate, context); | |
+ var keys = _.keys(obj), key; | |
+ for (var i = 0, length = keys.length; i < length; i++) { | |
+ key = keys[i]; | |
+ if (predicate(obj[key], key, obj)) return key; | |
+ } | |
}; | |
// Return a copy of the object only containing the whitelisted properties. | |
- _.pick = function(obj) { | |
- var copy = {}; | |
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
- each(keys, function(key) { | |
- if (key in obj) copy[key] = obj[key]; | |
- }); | |
- return copy; | |
+ _.pick = function(object, oiteratee, context) { | |
+ var result = {}, obj = object, iteratee, keys; | |
+ if (obj == null) return result; | |
+ if (_.isFunction(oiteratee)) { | |
+ keys = _.allKeys(obj); | |
+ iteratee = optimizeCb(oiteratee, context); | |
+ } else { | |
+ keys = flatten(arguments, false, false, 1); | |
+ iteratee = function(value, key, obj) { return key in obj; }; | |
+ obj = Object(obj); | |
+ } | |
+ for (var i = 0, length = keys.length; i < length; i++) { | |
+ var key = keys[i]; | |
+ var value = obj[key]; | |
+ if (iteratee(value, key, obj)) result[key] = value; | |
+ } | |
+ return result; | |
}; | |
// Return a copy of the object without the blacklisted properties. | |
- _.omit = function(obj) { | |
- var copy = {}; | |
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
- for (var key in obj) { | |
- if (!_.contains(keys, key)) copy[key] = obj[key]; | |
+ _.omit = function(obj, iteratee, context) { | |
+ if (_.isFunction(iteratee)) { | |
+ iteratee = _.negate(iteratee); | |
+ } else { | |
+ var keys = _.map(flatten(arguments, false, false, 1), String); | |
+ iteratee = function(value, key) { | |
+ return !_.contains(keys, key); | |
+ }; | |
} | |
- return copy; | |
+ return _.pick(obj, iteratee, context); | |
}; | |
// Fill in a given object with default properties. | |
- _.defaults = function(obj) { | |
- each(slice.call(arguments, 1), function(source) { | |
- if (source) { | |
- for (var prop in source) { | |
- if (obj[prop] == null) obj[prop] = source[prop]; | |
- } | |
- } | |
- }); | |
- return obj; | |
+ _.defaults = createAssigner(_.allKeys, true); | |
+ | |
+ // Creates an object that inherits from the given prototype object. | |
+ // If additional properties are provided then they will be added to the | |
+ // created object. | |
+ _.create = function(prototype, props) { | |
+ var result = baseCreate(prototype); | |
+ if (props) _.extendOwn(result, props); | |
+ return result; | |
}; | |
// Create a (shallow-cloned) duplicate of an object. | |
t@@ -821,11 +1078,24 @@ | |
return obj; | |
}; | |
+ // Returns whether an object has a given set of `key:value` pairs. | |
+ _.isMatch = function(object, attrs) { | |
+ var keys = _.keys(attrs), length = keys.length; | |
+ if (object == null) return !length; | |
+ var obj = Object(object); | |
+ for (var i = 0; i < length; i++) { | |
+ var key = keys[i]; | |
+ if (attrs[key] !== obj[key] || !(key in obj)) return false; | |
+ } | |
+ return true; | |
+ }; | |
+ | |
+ | |
// Internal recursive comparison function for `isEqual`. | |
var eq = function(a, b, aStack, bStack) { | |
// Identical objects are equal. `0 === -0`, but they aren't identical. | |
- // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id… | |
- if (a === b) return a !== 0 || 1 / a == 1 / b; | |
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?i… | |
+ if (a === b) return a !== 0 || 1 / a === 1 / b; | |
// A strict comparison is necessary because `null == undefined`. | |
if (a == null || b == null) return a === b; | |
// Unwrap any wrapped objects. | |
t@@ -833,97 +1103,98 @@ | |
if (b instanceof _) b = b._wrapped; | |
// Compare `[[Class]]` names. | |
var className = toString.call(a); | |
- if (className != toString.call(b)) return false; | |
+ if (className !== toString.call(b)) return false; | |
switch (className) { | |
- // Strings, numbers, dates, and booleans are compared by value. | |
+ // Strings, numbers, regular expressions, dates, and booleans are compar… | |
+ case '[object RegExp]': | |
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/… | |
case '[object String]': | |
// Primitives and their corresponding object wrappers are equivalent; … | |
// equivalent to `new String("5")`. | |
- return a == String(b); | |
+ return '' + a === '' + b; | |
case '[object Number]': | |
- // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is p… | |
- // other numeric values. | |
- return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); | |
+ // `NaN`s are equivalent, but non-reflexive. | |
+ // Object(NaN) is equivalent to NaN | |
+ if (+a !== +a) return +b !== +b; | |
+ // An `egal` comparison is performed for other numeric values. | |
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b; | |
case '[object Date]': | |
case '[object Boolean]': | |
// Coerce dates and booleans to numeric primitive values. Dates are co… | |
// millisecond representations. Note that invalid dates with milliseco… | |
// of `NaN` are not equivalent. | |
- return +a == +b; | |
- // RegExps are compared by their source patterns and flags. | |
- case '[object RegExp]': | |
- return a.source == b.source && | |
- a.global == b.global && | |
- a.multiline == b.multiline && | |
- a.ignoreCase == b.ignoreCase; | |
+ return +a === +b; | |
+ } | |
+ | |
+ var areArrays = className === '[object Array]'; | |
+ if (!areArrays) { | |
+ if (typeof a != 'object' || typeof b != 'object') return false; | |
+ | |
+ // Objects with different constructors are not equivalent, but `Object`s… | |
+ // from different frames are. | |
+ var aCtor = a.constructor, bCtor = b.constructor; | |
+ if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && | |
+ _.isFunction(bCtor) && bCtor instanceof bCtor) | |
+ && ('constructor' in a && 'constructor' in b)) { | |
+ return false; | |
+ } | |
} | |
- if (typeof a != 'object' || typeof b != 'object') return false; | |
// Assume equality for cyclic structures. The algorithm for detecting cycl… | |
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `… | |
+ | |
+ // Initializing stack of traversed objects. | |
+ // It's done here since we only need them for objects and arrays compariso… | |
+ aStack = aStack || []; | |
+ bStack = bStack || []; | |
var length = aStack.length; | |
while (length--) { | |
// Linear search. Performance is inversely proportional to the number of | |
// unique nested structures. | |
- if (aStack[length] == a) return bStack[length] == b; | |
+ if (aStack[length] === a) return bStack[length] === b; | |
} | |
+ | |
// Add the first object to the stack of traversed objects. | |
aStack.push(a); | |
bStack.push(b); | |
- var size = 0, result = true; | |
+ | |
// Recursively compare objects and arrays. | |
- if (className == '[object Array]') { | |
+ if (areArrays) { | |
// Compare array lengths to determine if a deep comparison is necessary. | |
- size = a.length; | |
- result = size == b.length; | |
- if (result) { | |
- // Deep compare the contents, ignoring non-numeric properties. | |
- while (size--) { | |
- if (!(result = eq(a[size], b[size], aStack, bStack))) break; | |
- } | |
+ length = a.length; | |
+ if (length !== b.length) return false; | |
+ // Deep compare the contents, ignoring non-numeric properties. | |
+ while (length--) { | |
+ if (!eq(a[length], b[length], aStack, bStack)) return false; | |
} | |
} else { | |
- // Objects with different constructors are not equivalent, but `Object`s | |
- // from different frames are. | |
- var aCtor = a.constructor, bCtor = b.constructor; | |
- if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor)… | |
- _.isFunction(bCtor) && (bCtor instanceof bCtor)… | |
- return false; | |
- } | |
// Deep compare objects. | |
- for (var key in a) { | |
- if (_.has(a, key)) { | |
- // Count the expected number of properties. | |
- size++; | |
- // Deep compare each member. | |
- if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack)))… | |
- } | |
- } | |
- // Ensure that both objects contain the same number of properties. | |
- if (result) { | |
- for (key in b) { | |
- if (_.has(b, key) && !(size--)) break; | |
- } | |
- result = !size; | |
+ var keys = _.keys(a), key; | |
+ length = keys.length; | |
+ // Ensure that both objects contain the same number of properties before… | |
+ if (_.keys(b).length !== length) return false; | |
+ while (length--) { | |
+ // Deep compare each member | |
+ key = keys[length]; | |
+ if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return fal… | |
} | |
} | |
// Remove the first object from the stack of traversed objects. | |
aStack.pop(); | |
bStack.pop(); | |
- return result; | |
+ return true; | |
}; | |
// Perform a deep comparison to check if two objects are equal. | |
_.isEqual = function(a, b) { | |
- return eq(a, b, [], []); | |
+ return eq(a, b); | |
}; | |
// Is a given array, string, or object empty? | |
// An "empty" object has no enumerable own-properties. | |
_.isEmpty = function(obj) { | |
if (obj == null) return true; | |
- if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; | |
- for (var key in obj) if (_.has(obj, key)) return false; | |
- return true; | |
+ if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArgument… | |
+ return _.keys(obj).length === 0; | |
}; | |
// Is a given value a DOM element? | |
t@@ -934,33 +1205,35 @@ | |
// Is a given value an array? | |
// Delegates to ECMA5's native Array.isArray | |
_.isArray = nativeIsArray || function(obj) { | |
- return toString.call(obj) == '[object Array]'; | |
+ return toString.call(obj) === '[object Array]'; | |
}; | |
// Is a given variable an object? | |
_.isObject = function(obj) { | |
- return obj === Object(obj); | |
+ var type = typeof obj; | |
+ return type === 'function' || type === 'object' && !!obj; | |
}; | |
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isD… | |
- each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], functi… | |
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isD… | |
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Erro… | |
_['is' + name] = function(obj) { | |
- return toString.call(obj) == '[object ' + name + ']'; | |
+ return toString.call(obj) === '[object ' + name + ']'; | |
}; | |
}); | |
- // Define a fallback version of the method in browsers (ahem, IE), where | |
+ // Define a fallback version of the method in browsers (ahem, IE < 9), where | |
// there isn't any inspectable "Arguments" type. | |
if (!_.isArguments(arguments)) { | |
_.isArguments = function(obj) { | |
- return !!(obj && _.has(obj, 'callee')); | |
+ return _.has(obj, 'callee'); | |
}; | |
} | |
- // Optimize `isFunction` if appropriate. | |
- if (typeof (/./) !== 'function') { | |
+ // Optimize `isFunction` if appropriate. Work around some typeof bugs in old… | |
+ // IE 11 (#1621), and in Safari 8 (#1929). | |
+ if (typeof /./ != 'function' && typeof Int8Array != 'object') { | |
_.isFunction = function(obj) { | |
- return typeof obj === 'function'; | |
+ return typeof obj == 'function' || false; | |
}; | |
} | |
t@@ -971,12 +1244,12 @@ | |
// Is the given value `NaN`? (NaN is the only number which does not equal it… | |
_.isNaN = function(obj) { | |
- return _.isNumber(obj) && obj != +obj; | |
+ return _.isNumber(obj) && obj !== +obj; | |
}; | |
// Is a given value a boolean? | |
_.isBoolean = function(obj) { | |
- return obj === true || obj === false || toString.call(obj) == '[object Boo… | |
+ return obj === true || obj === false || toString.call(obj) === '[object Bo… | |
}; | |
// Is a given value equal to null? | |
t@@ -992,7 +1265,7 @@ | |
// Shortcut function for checking if an object has a given property directly | |
// on itself (in other words, not on a prototype). | |
_.has = function(obj, key) { | |
- return hasOwnProperty.call(obj, key); | |
+ return obj != null && hasOwnProperty.call(obj, key); | |
}; | |
// Utility Functions | |
t@@ -1005,15 +1278,43 @@ | |
return this; | |
}; | |
- // Keep the identity function around for default iterators. | |
+ // Keep the identity function around for default iteratees. | |
_.identity = function(value) { | |
return value; | |
}; | |
+ // Predicate-generating functions. Often useful outside of Underscore. | |
+ _.constant = function(value) { | |
+ return function() { | |
+ return value; | |
+ }; | |
+ }; | |
+ | |
+ _.noop = function(){}; | |
+ | |
+ _.property = property; | |
+ | |
+ // Generates a function for a given object that returns a given property. | |
+ _.propertyOf = function(obj) { | |
+ return obj == null ? function(){} : function(key) { | |
+ return obj[key]; | |
+ }; | |
+ }; | |
+ | |
+ // Returns a predicate for checking whether an object has a given set of | |
+ // `key:value` pairs. | |
+ _.matcher = _.matches = function(attrs) { | |
+ attrs = _.extendOwn({}, attrs); | |
+ return function(obj) { | |
+ return _.isMatch(obj, attrs); | |
+ }; | |
+ }; | |
+ | |
// Run a function **n** times. | |
- _.times = function(n, iterator, context) { | |
- var accum = Array(n); | |
- for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); | |
+ _.times = function(n, iteratee, context) { | |
+ var accum = Array(Math.max(0, n)); | |
+ iteratee = optimizeCb(iteratee, context, 1); | |
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i); | |
return accum; | |
}; | |
t@@ -1026,53 +1327,47 @@ | |
return min + Math.floor(Math.random() * (max - min + 1)); | |
}; | |
- // List of HTML entities for escaping. | |
- var entityMap = { | |
- escape: { | |
- '&': '&', | |
- '<': '<', | |
- '>': '>', | |
- '"': '"', | |
- "'": ''', | |
- '/': '/' | |
- } | |
+ // A (possibly faster) way to get the current timestamp as an integer. | |
+ _.now = Date.now || function() { | |
+ return new Date().getTime(); | |
}; | |
- entityMap.unescape = _.invert(entityMap.escape); | |
- // Regexes containing the keys and values listed immediately above. | |
- var entityRegexes = { | |
- escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), | |
- unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') | |
+ // List of HTML entities for escaping. | |
+ var escapeMap = { | |
+ '&': '&', | |
+ '<': '<', | |
+ '>': '>', | |
+ '"': '"', | |
+ "'": ''', | |
+ '`': '`' | |
}; | |
+ var unescapeMap = _.invert(escapeMap); | |
// Functions for escaping and unescaping strings to/from HTML interpolation. | |
- _.each(['escape', 'unescape'], function(method) { | |
- _[method] = function(string) { | |
- if (string == null) return ''; | |
- return ('' + string).replace(entityRegexes[method], function(match) { | |
- return entityMap[method][match]; | |
- }); | |
+ var createEscaper = function(map) { | |
+ var escaper = function(match) { | |
+ return map[match]; | |
+ }; | |
+ // Regexes for identifying a key that needs to be escaped | |
+ var source = '(?:' + _.keys(map).join('|') + ')'; | |
+ var testRegexp = RegExp(source); | |
+ var replaceRegexp = RegExp(source, 'g'); | |
+ return function(string) { | |
+ string = string == null ? '' : '' + string; | |
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) … | |
}; | |
- }); | |
- | |
- // If the value of the named property is a function then invoke it; | |
- // otherwise, return it. | |
- _.result = function(object, property) { | |
- if (object == null) return null; | |
- var value = object[property]; | |
- return _.isFunction(value) ? value.call(object) : value; | |
}; | |
+ _.escape = createEscaper(escapeMap); | |
+ _.unescape = createEscaper(unescapeMap); | |
- // Add your own custom functions to the Underscore object. | |
- _.mixin = function(obj) { | |
- each(_.functions(obj), function(name){ | |
- var func = _[name] = obj[name]; | |
- _.prototype[name] = function() { | |
- var args = [this._wrapped]; | |
- push.apply(args, arguments); | |
- return result.call(this, func.apply(_, args)); | |
- }; | |
- }); | |
+ // If the value of the named `property` is a function then invoke it with the | |
+ // `object` as context; otherwise, return it. | |
+ _.result = function(object, property, fallback) { | |
+ var value = object == null ? void 0 : object[property]; | |
+ if (value === void 0) { | |
+ value = fallback; | |
+ } | |
+ return _.isFunction(value) ? value.call(object) : value; | |
}; | |
// Generate a unique integer id (unique within the entire client session). | |
t@@ -1103,22 +1398,26 @@ | |
'\\': '\\', | |
'\r': 'r', | |
'\n': 'n', | |
- '\t': 't', | |
'\u2028': 'u2028', | |
'\u2029': 'u2029' | |
}; | |
- var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; | |
+ var escaper = /\\|'|\r|\n|\u2028|\u2029/g; | |
+ | |
+ var escapeChar = function(match) { | |
+ return '\\' + escapes[match]; | |
+ }; | |
// JavaScript micro-templating, similar to John Resig's implementation. | |
// Underscore templating handles arbitrary delimiters, preserves whitespace, | |
// and correctly escapes quotes within interpolated code. | |
- _.template = function(text, data, settings) { | |
- var render; | |
+ // NB: `oldSettings` only exists for backwards compatibility. | |
+ _.template = function(text, settings, oldSettings) { | |
+ if (!settings && oldSettings) settings = oldSettings; | |
settings = _.defaults({}, settings, _.templateSettings); | |
// Combine delimiters into one regular expression via alternation. | |
- var matcher = new RegExp([ | |
+ var matcher = RegExp([ | |
(settings.escape || noMatch).source, | |
(settings.interpolate || noMatch).source, | |
(settings.evaluate || noMatch).source | |
t@@ -1128,19 +1427,18 @@ | |
var index = 0; | |
var source = "__p+='"; | |
text.replace(matcher, function(match, escape, interpolate, evaluate, offse… | |
- source += text.slice(index, offset) | |
- .replace(escaper, function(match) { return '\\' + escapes[match]; }); | |
+ source += text.slice(index, offset).replace(escaper, escapeChar); | |
+ index = offset + match.length; | |
if (escape) { | |
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; | |
- } | |
- if (interpolate) { | |
+ } else if (interpolate) { | |
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; | |
- } | |
- if (evaluate) { | |
+ } else if (evaluate) { | |
source += "';\n" + evaluate + "\n__p+='"; | |
} | |
- index = offset + match.length; | |
+ | |
+ // Adobe VMs need the match returned to produce the correct offest. | |
return match; | |
}); | |
source += "';\n"; | |
t@@ -1150,29 +1448,31 @@ | |
source = "var __t,__p='',__j=Array.prototype.join," + | |
"print=function(){__p+=__j.call(arguments,'');};\n" + | |
- source + "return __p;\n"; | |
+ source + 'return __p;\n'; | |
try { | |
- render = new Function(settings.variable || 'obj', '_', source); | |
+ var render = new Function(settings.variable || 'obj', '_', source); | |
} catch (e) { | |
e.source = source; | |
throw e; | |
} | |
- if (data) return render(data, _); | |
var template = function(data) { | |
return render.call(this, data, _); | |
}; | |
- // Provide the compiled function source as a convenience for precompilatio… | |
- template.source = 'function(' + (settings.variable || 'obj') + '){\n' + so… | |
+ // Provide the compiled source as a convenience for precompilation. | |
+ var argument = settings.variable || 'obj'; | |
+ template.source = 'function(' + argument + '){\n' + source + '}'; | |
return template; | |
}; | |
- // Add a "chain" function, which will delegate to the wrapper. | |
+ // Add a "chain" function. Start chaining a wrapped Underscore object. | |
_.chain = function(obj) { | |
- return _(obj).chain(); | |
+ var instance = _(obj); | |
+ instance._chain = true; | |
+ return instance; | |
}; | |
// OOP | |
t@@ -1182,45 +1482,67 @@ | |
// underscore functions. Wrapped objects may be chained. | |
// Helper function to continue chaining intermediate results. | |
- var result = function(obj) { | |
- return this._chain ? _(obj).chain() : obj; | |
+ var result = function(instance, obj) { | |
+ return instance._chain ? _(obj).chain() : obj; | |
+ }; | |
+ | |
+ // Add your own custom functions to the Underscore object. | |
+ _.mixin = function(obj) { | |
+ _.each(_.functions(obj), function(name) { | |
+ var func = _[name] = obj[name]; | |
+ _.prototype[name] = function() { | |
+ var args = [this._wrapped]; | |
+ push.apply(args, arguments); | |
+ return result(this, func.apply(_, args)); | |
+ }; | |
+ }); | |
}; | |
// Add all of the Underscore functions to the wrapper object. | |
_.mixin(_); | |
// Add all mutator Array functions to the wrapper. | |
- each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], funct… | |
+ _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], fun… | |
var method = ArrayProto[name]; | |
_.prototype[name] = function() { | |
var obj = this._wrapped; | |
method.apply(obj, arguments); | |
- if ((name == 'shift' || name == 'splice') && obj.length === 0) delete ob… | |
- return result.call(this, obj); | |
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) delete … | |
+ return result(this, obj); | |
}; | |
}); | |
// Add all accessor Array functions to the wrapper. | |
- each(['concat', 'join', 'slice'], function(name) { | |
+ _.each(['concat', 'join', 'slice'], function(name) { | |
var method = ArrayProto[name]; | |
_.prototype[name] = function() { | |
- return result.call(this, method.apply(this._wrapped, arguments)); | |
+ return result(this, method.apply(this._wrapped, arguments)); | |
}; | |
}); | |
- _.extend(_.prototype, { | |
- | |
- // Start chaining a wrapped Underscore object. | |
- chain: function() { | |
- this._chain = true; | |
- return this; | |
- }, | |
+ // Extracts the result from a wrapped and chained object. | |
+ _.prototype.value = function() { | |
+ return this._wrapped; | |
+ }; | |
- // Extracts the result from a wrapped and chained object. | |
- value: function() { | |
- return this._wrapped; | |
- } | |
+ // Provide unwrapping proxy for some methods used in engine operations | |
+ // such as arithmetic and JSON stringification. | |
+ _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; | |
- }); | |
+ _.prototype.toString = function() { | |
+ return '' + this._wrapped; | |
+ }; | |
-}).call(this); | |
+ // AMD registration happens at the end for compatibility with AMD loaders | |
+ // that may not enforce next-turn semantics on modules. Even though general | |
+ // practice for AMD registration is to be anonymous, underscore registers | |
+ // as a named module because, like jQuery, it is a base library that is | |
+ // popular enough to be bundled in a third party lib, but not be part of | |
+ // an AMD load request. Those cases could generate an error when an | |
+ // anonymous define() is called outside of a loader request. | |
+ if (typeof define === 'function' && define.amd) { | |
+ define('underscore', [], function() { | |
+ return _; | |
+ }); | |
+ } | |
+}.call(this)); | |
diff --git a/doc/html/_static/up-pressed.png b/doc/html/_static/up-pressed.png | |
Binary files differ. | |
diff --git a/doc/html/_static/up.png b/doc/html/_static/up.png | |
Binary files differ. | |
diff --git a/doc/html/_static/websupport.js b/doc/html/_static/websupport.js | |
t@@ -2,9 +2,9 @@ | |
* websupport.js | |
* ~~~~~~~~~~~~~ | |
* | |
- * sphinx.websupport utilties for all documentation. | |
+ * sphinx.websupport utilities for all documentation. | |
* | |
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. | |
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | |
* :license: BSD, see LICENSE for details. | |
* | |
*/ | |
t@@ -50,51 +50,51 @@ | |
} | |
function initEvents() { | |
- $('a.comment-close').live("click", function(event) { | |
+ $(document).on("click", 'a.comment-close', function(event) { | |
event.preventDefault(); | |
hide($(this).attr('id').substring(2)); | |
}); | |
- $('a.vote').live("click", function(event) { | |
+ $(document).on("click", 'a.vote', function(event) { | |
event.preventDefault(); | |
handleVote($(this)); | |
}); | |
- $('a.reply').live("click", function(event) { | |
+ $(document).on("click", 'a.reply', function(event) { | |
event.preventDefault(); | |
openReply($(this).attr('id').substring(2)); | |
}); | |
- $('a.close-reply').live("click", function(event) { | |
+ $(document).on("click", 'a.close-reply', function(event) { | |
event.preventDefault(); | |
closeReply($(this).attr('id').substring(2)); | |
}); | |
- $('a.sort-option').live("click", function(event) { | |
+ $(document).on("click", 'a.sort-option', function(event) { | |
event.preventDefault(); | |
handleReSort($(this)); | |
}); | |
- $('a.show-proposal').live("click", function(event) { | |
+ $(document).on("click", 'a.show-proposal', function(event) { | |
event.preventDefault(); | |
showProposal($(this).attr('id').substring(2)); | |
}); | |
- $('a.hide-proposal').live("click", function(event) { | |
+ $(document).on("click", 'a.hide-proposal', function(event) { | |
event.preventDefault(); | |
hideProposal($(this).attr('id').substring(2)); | |
}); | |
- $('a.show-propose-change').live("click", function(event) { | |
+ $(document).on("click", 'a.show-propose-change', function(event) { | |
event.preventDefault(); | |
showProposeChange($(this).attr('id').substring(2)); | |
}); | |
- $('a.hide-propose-change').live("click", function(event) { | |
+ $(document).on("click", 'a.hide-propose-change', function(event) { | |
event.preventDefault(); | |
hideProposeChange($(this).attr('id').substring(2)); | |
}); | |
- $('a.accept-comment').live("click", function(event) { | |
+ $(document).on("click", 'a.accept-comment', function(event) { | |
event.preventDefault(); | |
acceptComment($(this).attr('id').substring(2)); | |
}); | |
- $('a.delete-comment').live("click", function(event) { | |
+ $(document).on("click", 'a.delete-comment', function(event) { | |
event.preventDefault(); | |
deleteComment($(this).attr('id').substring(2)); | |
}); | |
- $('a.comment-markup').live("click", function(event) { | |
+ $(document).on("click", 'a.comment-markup', function(event) { | |
event.preventDefault(); | |
toggleCommentMarkupBox($(this).attr('id').substring(2)); | |
}); | |
t@@ -700,8 +700,8 @@ | |
(<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\ | |
<div class="comment-markup-box" id="mb<%id%>">\ | |
reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \ | |
- <tt>``code``</tt>, \ | |
- code blocks: <tt>::</tt> and an indented block after blank line</div>\ | |
+ <code>``code``</code>, \ | |
+ code blocks: <code>::</code> and an indented block after blank line</d… | |
<form method="post" id="cf<%id%>" class="comment-form" action="">\ | |
<textarea name="comment" cols="80"></textarea>\ | |
<p class="propose-button">\ | |
diff --git a/doc/html/cfd.html b/doc/html/cfd.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Fluid simulation and particle-fluid interaction — sphere 1.00… | |
+ <title>Fluid simulation and particle-fluid interaction — sphere 1.00… | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,12 +23,14 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
<link rel="next" title="Python API" href="python_api.html" /> | |
<link rel="prev" title="Discrete element method" href="dem.html" /> | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -46,14 +45,14 @@ | |
<li class="right" > | |
<a href="dem.html" title="Discrete element method" | |
accesskey="P">previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<div class="section" id="fluid-simulation-and-particle-fluid-interaction"> | |
<h1>Fluid simulation and particle-fluid interaction<a class="headerlink" href=… | |
t@@ -69,31 +68,31 @@ solution procedure and the numerical implementation.</p> | |
<p>Following the outline presented by <a class="reference external" href="http… | |
continuity equation for an incompressible fluid material is given by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/b588eea9cec4513a3be72255d8d3df214546bfe7.png" alt="\… | |
+<p><img src="_images/math/341e857d6da62b73593a73dea371b22a955fd8e9.png" alt="\… | |
</div><p>and the momentum equation:</p> | |
<div class="math"> | |
-<p><img src="_images/math/a00f5eb30a7a379b737fd4fafa61160bc0fce4a8.png" alt="\… | |
+<p><img src="_images/math/f4c62b9c99051d7d2ca2b222af4b3394d02e1b1d.png" alt="\… | |
+ \rho (\boldsymbol{v} \cdot \nabla \boldsymbol{v}) | |
= \nabla \cdot \boldsymbol{\sigma} | |
- \boldsymbol{f}^i | |
+ \rho \boldsymbol{g}"/></p> | |
-</div><p>Here, <img class="math" src="_images/math/d0b4b390a4806bb739c6b4adbdf… | |
-fluid density, <img class="math" src="_images/math/769bfdcb2a43bde2cd368d82a6f… | |
-<img class="math" src="_images/math/dbb95aa092c199cb518b2fdf22908d217988c251.p… | |
-<img class="math" src="_images/math/a1e91a45b4858dfcbacc9b0d3b28418f1a990df1.p… | |
+</div><p>Here, <img class="math" src="_images/math/c8e734bf3818506e254ebfa3504… | |
+fluid density, <img class="math" src="_images/math/b4104067dcc504da8eada069712… | |
+<img class="math" src="_images/math/3ac346ec0a0efeed60827b2d73c5776cf4605902.p… | |
+<img class="math" src="_images/math/af2f4149a102bb8a3d74e9afbfd0d21b4c2f7084.p… | |
Newtonian fluids, the Cauchy stress is given by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c9264cc703654b5651cb89a1c9f5e178b5d15cd0.png" alt="\… | |
-</div><p><img class="math" src="_images/math/36f73fc1312ee0349b3f3a0f3bd9eb550… | |
-tensor, and <img class="math" src="_images/math/023a7668d083165ce2aa65b49e876b… | |
+<p><img src="_images/math/9cb510f5a23b8a2cf167578e3197615a3cab7510.png" alt="\… | |
+</div><p><img class="math" src="_images/math/3eca8557203e86160952e1c0f735f7417… | |
+tensor, and <img class="math" src="_images/math/e29be0a3b86507644c82abbc0adfcb… | |
by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/25586671e456c2d987cd75cefd64d9cee69f50b9.png" alt="\… | |
+<p><img src="_images/math/2ac5fed54f92fbc94d2fefb2aa5f17a1e326282e.png" alt="\… | |
\mu_f \nabla \boldsymbol{v} | |
+ \mu_f (\nabla \boldsymbol{v})^T"/></p> | |
</div><p>By using the following vector identities:</p> | |
<div class="math"> | |
-<p><img src="_images/math/e4ca401f97df40e3568bc0624774cafa02d77cc1.png" alt="\… | |
+<p><img src="_images/math/ffe6c17031ff1e2333c5bdc57773967dda2bebcc.png" alt="\… | |
\nabla \cdot (\nabla \boldsymbol{v}) = \nabla^2 \boldsymbol{v} | |
t@@ -102,29 +101,29 @@ by:</p> | |
</div><p>the deviatoric component of the Cauchy stress tensor simplifies to the | |
following, assuming that spatial variations in the viscosity can be neglected:… | |
<div class="math"> | |
-<p><img src="_images/math/1053df745e2d73fc7ee27d39a01ad228c360072e.png" alt="=… | |
+<p><img src="_images/math/f220cc08054c66b15757b7073edbbfe33c2736e6.png" alt="=… | |
+ \mu_f \nabla^2 \boldsymbol{v}"/></p> | |
</div><p>Since we are dealing with fluid flow in a porous medium, additional t… | |
introduced to the equations for conservation of mass and momentum. In the | |
following, the equations are derived for the first spatial component. The | |
solution for the other components is trivial.</p> | |
<p>The porosity value (in the saturated porous medium the volumetric fraction … | |
-the fluid phase) denoted <img class="math" src="_images/math/2c175f60eecef1de7… | |
+the fluid phase) denoted <img class="math" src="_images/math/10e009bdb83f96c5f… | |
momentum equations. The continuity equation becomes:</p> | |
<div class="math"> | |
-<p><img src="_images/math/f8f0dc31c5c12bc6e3da6fc71519fa78ea04190b.png" alt="\… | |
+<p><img src="_images/math/6875433152b8a1a1624c131527286ababd8a8462.png" alt="\… | |
+ \nabla \cdot (\phi \boldsymbol{v}) = 0"/></p> | |
-</div><p>For the <img class="math" src="_images/math/26eeb5258ca5099acf8fe96b2… | |
-with a body force <img class="math" src="_images/math/69b1fdf87f9a78aaef8057a3… | |
+</div><p>For the <img class="math" src="_images/math/188c175aac0a8a9c224993367… | |
+with a body force <img class="math" src="_images/math/ce4f41d90f3fea6e5313ad3c… | |
<div class="math"> | |
-<p><img src="_images/math/4fd7ec1b618d0e036da7606d6876e79d81480584.png" alt="\… | |
+<p><img src="_images/math/60290a944b15183b06237a1483946560e640e1bf.png" alt="\… | |
= \frac{1}{\rho} \left[ \nabla \cdot (\phi \boldsymbol{\sigma}) \right]_x | |
- \frac{1}{\rho} f^i_x | |
+ \phi g"/></p> | |
</div><p>In the Eulerian formulation, an advection term is added, and the Cauc… | |
tensor is represented as isotropic and deviatoric components individually:</p> | |
<div class="math"> | |
-<p><img src="_images/math/ff29b7920019a21a45545381f042a08acfba3530.png" alt="\… | |
+<p><img src="_images/math/b991196699db1cde269ad006f427d8168fcfd679.png" alt="\… | |
+ \boldsymbol{v} \cdot \nabla (\phi v_x) | |
= \frac{1}{\rho} \left[ \nabla \cdot (-\phi p \boldsymbol{I}) | |
+ \phi \boldsymbol{\tau}) \right]_x | |
t@@ -133,7 +132,7 @@ tensor is represented as isotropic and deviatoric componen… | |
</div><p>Using vector identities to rewrite the advection term, and expanding … | |
stress tensor term:</p> | |
<div class="math"> | |
-<p><img src="_images/math/0e86ca4660ab213ac57b980a736e32499978d2dc.png" alt="\… | |
+<p><img src="_images/math/a85779399f71d0d2d7fd373c5c5f2b572cf3bfd7.png" alt="\… | |
+ \nabla \cdot (\phi v_x \boldsymbol{v}) | |
- \phi v_x (\nabla \cdot \boldsymbol{v}) | |
= \frac{1}{\rho} \left[ -\nabla \phi p \right]_x | |
t@@ -142,24 +141,24 @@ stress tensor term:</p> | |
+ \phi g_x"/></p> | |
</div><p>Spatial variations in the porosity are neglected,</p> | |
<div class="math"> | |
-<p><img src="_images/math/c42a32017c99646f19bb5807728595d4526c3b30.png" alt="\… | |
+<p><img src="_images/math/249fc7f1e5fa5aa23b21d1fdf32ed10f0fcef400.png" alt="\… | |
</div><p>and the pressure is attributed to the fluid phase alone (model B in Z… | |
2007 and Zhou et al. 2010). The divergence of fluid velocities is defined to be | |
zero:</p> | |
<div class="math"> | |
-<p><img src="_images/math/44fafcf5a158459730d0dd7c293b93cdcf62f0a4.png" alt="\… | |
+<p><img src="_images/math/96df96ab11be34dbe17cb0837626b7cc2772013e.png" alt="\… | |
</div><p>With these assumptions, the momentum equation simplifies to:</p> | |
<div class="math"> | |
-<p><img src="_images/math/7f7495bf6b7e8e4c468863b6fd083f72f3a844ac.png" alt="\… | |
+<p><img src="_images/math/e58aec0a9dc37c78b74f5c34874ff852d8839f43.png" alt="\… | |
+ \nabla \cdot (\phi v_x \boldsymbol{v}) | |
= -\frac{1}{\rho} \frac{\partial p}{\partial x} | |
+ \frac{1}{\rho} \left[ \nabla \cdot (\phi \boldsymbol{\tau}) \right]_x | |
- \frac{1}{\rho} f^i_x | |
+ \phi g_x"/></p> | |
-</div><p>The remaining part of the advection term is for the <img class="math"… | |
+</div><p>The remaining part of the advection term is for the <img class="math"… | |
found as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/967116fa65cb7eb073c2f71309b21af6aca77a09.png" alt="\… | |
+<p><img src="_images/math/8bd85c906906e83dd3471973969959e831d271d7.png" alt="\… | |
\left[ | |
\frac{\partial}{\partial x}, | |
\frac{\partial}{\partial y}, | |
t@@ -176,10 +175,10 @@ found as:</p> | |
\frac{\partial (\phi v_x v_x)}{\partial x} + | |
\frac{\partial (\phi v_x v_y)}{\partial y} + | |
\frac{\partial (\phi v_x v_z)}{\partial z}"/></p> | |
-</div><p>The deviatoric stress tensor is in this case symmetrical, i.e. <img c… | |
+</div><p>The deviatoric stress tensor is in this case symmetrical, i.e. <img c… | |
= \tau_{ji}"/>, and is found by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/9d3cd4785fd2621936d97aa60cb5005a7e95b5b7.png" alt="\… | |
+<p><img src="_images/math/66dc70aa131124c6f87d7f2cbb96350d8b0397b9.png" alt="\… | |
= \frac{1}{\rho} | |
\left[ | |
\left[ | |
t@@ -218,17 +217,17 @@ found as:</p> | |
+ \frac{\partial (\phi \tau_{xz})}{\partial z} | |
\right)"/></p> | |
</div><p>In a linear viscous fluid, the stress and strain rate | |
-(<img class="math" src="_images/math/7727554a4dfa1572695dec332d6f6ee255815c96.… | |
-viscosity parameter <img class="math" src="_images/math/6160e3f2050b4cd56b336f… | |
+(<img class="math" src="_images/math/1ee5b5b2fe535711338cab9fde51ba86968186e2.… | |
+viscosity parameter <img class="math" src="_images/math/a1a25b9ae9dc5911e30e15… | |
<div class="math"> | |
-<p><img src="_images/math/5fb7b1a39363304fc1fb9172ecd46e2f39274384.png" alt="\… | |
+<p><img src="_images/math/2133ec642b2fa2a0bdc0612dc9080df18f64da53.png" alt="\… | |
= \mu_f \left( | |
\frac{\partial v_i}{\partial x_j} + \frac{\partial v_j}{\partial x_i} | |
\right)"/></p> | |
</div><p>With this relationship, the deviatoric stress tensor components can be | |
calculated as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/f99450c7a8851772907f28ffd58be080f18894ae.png" alt="\… | |
+<p><img src="_images/math/4d94b19a340ed5d6cfc3285e3c0678be914c3834.png" alt="\… | |
\tau_{yy} = 2 \mu_f \frac{\partial v_y}{\partial y} \qquad | |
\tau_{zz} = 2 \mu_f \frac{\partial v_z}{\partial z} | |
t@@ -240,26 +239,26 @@ calculated as:</p> | |
\tau_{yz} = \mu_f \left( | |
\frac{\partial v_y}{\partial z} + \frac{\partial v_z}{\partial y} \right)"/></… | |
-</div><p>where <img class="math" src="_images/math/6160e3f2050b4cd56b336ff5523… | |
+</div><p>where <img class="math" src="_images/math/a1a25b9ae9dc5911e30e15d5ca2… | |
fluid rheology assumes identical bulk and shear viscosities. The derivation of | |
the equations for the other spatial components is trivial.</p> | |
</div> | |
<div class="section" id="porosity-estimation"> | |
<h2>Porosity estimation<a class="headerlink" href="#porosity-estimation" title… | |
<p>The solid volume in each fluid cell is determined by the ratio of the | |
-a cell-centered spherical cell volume (<img class="math" src="_images/math/24e… | |
-particle volumes (<img class="math" src="_images/math/3c93d2ecf99a3c5ee161c98a… | |
-<img class="math" src="_images/math/74958bc18d017328dd0fac99816d2184296bfd3d.p… | |
+a cell-centered spherical cell volume (<img class="math" src="_images/math/db9… | |
+particle volumes (<img class="math" src="_images/math/754decd655584a824e0979fc… | |
+<img class="math" src="_images/math/13e4be57cf47de5302fc2e1746d965a6ee0f332c.p… | |
the fluid cell width. The nearby particles are characterized by position | |
-<img class="math" src="_images/math/d1e970327c74ae0d8249c6283d2e3134d042f6ff.p… | |
+<img class="math" src="_images/math/ec1ce56da06483e62a9456229761ff166b345ed2.p… | |
as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/7fe490dcbc6c9eb978f05b3334d2a5856dc66149.png" alt="d… | |
+<p><img src="_images/math/68f7c3ca449a28047e11af58f55b159b3156685c.png" alt="d… | |
</div><p>The common volume of the two intersecting spheres is zero if the volu… | |
intersecting, lens shaped if they are intersecting, and spherical if the | |
particle is fully contained by the spherical cell volume:</p> | |
<div class="math"> | |
-<p><img src="_images/math/6d9a9e0ef32ea9506bb55413b682112d0f3308a6.png" alt="V… | |
+<p><img src="_images/math/2b8b39498e0fa8ab6324f088a2330d47ef18cbd5.png" alt="V… | |
\begin{cases} | |
0 & \textit{if } R_i + r_j \leq d_{ij} \\ | |
\frac{1}{12d_{ij}} \left[ \pi (R_i + r_j - d_{ij})^2 | |
t@@ -269,7 +268,7 @@ particle is fully contained by the spherical cell volume:<… | |
\end{cases}"/></p> | |
</div><p>Using this method, the cell porosity values are continuous through ti… | |
particles enter and exit the cell volume. The rate of porosity change | |
-(<img class="math" src="_images/math/38a6d1fc56073806115322bcd179578f05c88c02.… | |
+(<img class="math" src="_images/math/de27eb4f973d27763dc4d176bf2453607ecaae42.… | |
by considering the previous and current porosity.</p> | |
</div> | |
<div class="section" id="particle-fluid-interaction"> | |
t@@ -281,53 +280,53 @@ semi-empirical relationships. The drag force scales line… | |
difference in velocity between the fluid and particle phase. On the base of | |
Newton’s third law, the resulting drag force is applied with opposite si… | |
the particle and fluid.</p> | |
-<p>For fluid cells with porosities (<img class="math" src="_images/math/2c175f… | |
+<p>For fluid cells with porosities (<img class="math" src="_images/math/10e009… | |
force is based on the Ergun (1952) equation:</p> | |
<div class="math"> | |
-<p><img src="_images/math/baa542966f410097c2b4894388e41db6aa3cd996.png" alt="\… | |
+<p><img src="_images/math/c65c93ecc36954688972785ecbae82a6d7a14a3a.png" alt="\… | |
150 \frac{\mu_f (1-\phi)^2}{\phi\bar{d}^2} | |
+ 1.75 \frac{(1-\phi)\rho_f | |
||\boldsymbol{v}_f - \bar{\boldsymbol{v}}_p||}{\bar{d}} | |
\right) | |
(\boldsymbol{v}_f - \bar{\boldsymbol{v}}_p)"/></p> | |
-</div><p>here, <img class="math" src="_images/math/46a84b389d8f594cd16c800ba42… | |
-<img class="math" src="_images/math/cbe3f817ae974accdf9d422c0df8f6c90721037c.p… | |
-<img class="math" src="_images/math/3b432b0e58dea7c6cc143bf67184fc19b8cd4336.p… | |
+</div><p>here, <img class="math" src="_images/math/082bced08237667a772227c2e3e… | |
+<img class="math" src="_images/math/22b6d9dab340bfe13993da20589e4720449fe391.p… | |
+<img class="math" src="_images/math/5b7072008fcf4dedaeed4d537fe5c808adedb826.p… | |
particles in contact with the previously mentioned cell-centered sphere for | |
porosity estimation contribute to the average particle velocity and diameter in | |
the fluid cell.</p> | |
<p>If the porosity is greater than 0.8, the cell-averaged drag force | |
-(<img class="math" src="_images/math/a6c493a071c2c31758bc2bc9adc2beb10d7acfd0.… | |
+(<img class="math" src="_images/math/fa8a7b2fb896adf1c9f17077664691e511aeb8e5.… | |
which considers the fluid flow situation:</p> | |
<div class="math"> | |
-<p><img src="_images/math/7181906596d0aaac14cbde44ec57dd7e5866c81b.png" alt="\… | |
+<p><img src="_images/math/0949063a26c6869766d571d13e61cf78f3a38c06.png" alt="\… | |
\frac{3}{4} | |
\frac{C_d (1-\phi) \phi^{-2.65} \mu_f \rho_f | |
||\boldsymbol{v}_f - \bar{\boldsymbol{v}}_p||}{\bar{d}} | |
\right) | |
(\boldsymbol{v}_f - \bar{\boldsymbol{v}}_p)"/></p> | |
-</div><p>The drag coefficient <img class="math" src="_images/math/47bc1263e44f… | |
-Reynolds number <img class="math" src="_images/math/16ef95610462b9c2c03cba4c27… | |
+</div><p>The drag coefficient <img class="math" src="_images/math/1beccd9a659c… | |
+Reynolds number <img class="math" src="_images/math/0e0f0c7e69e0f315aed6d1762a… | |
<div class="math"> | |
-<p><img src="_images/math/49a90589ae1e8a839b1ae6afb3dd1d162b6a094c.png" alt="C… | |
+<p><img src="_images/math/e2872fb63d995fa1112c468dcb10669c69795aef.png" alt="C… | |
\begin{cases} | |
\frac{24}{Re} (1+0.15 (Re)^{0.687} & \textit{if } Re < 1,000 \\ | |
0.44 & \textit{if } Re \geq 1,000 | |
\end{cases}"/></p> | |
</div><p>where the Reynold’s number is found by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/8dbae01b96ab8dd591a50213f55caa3ac5958631.png" alt="R… | |
+<p><img src="_images/math/f4bf201ecead6e3486688493ab1b1e82c39d93df.png" alt="R… | |
||\boldsymbol{v}_f - \bar{\boldsymbol{v}}_p||"/></p> | |
</div><p>The interaction force is applied to the fluid with negative sign as a | |
-contribution to the body force <img class="math" src="_images/math/69b1fdf87f9… | |
+contribution to the body force <img class="math" src="_images/math/ce4f41d90f3… | |
force applied particles in the fluid cell is:</p> | |
<div class="math"> | |
-<p><img src="_images/math/ac40b59145892a5a3c0141c5f35023ad85972855.png" alt="\… | |
-</div><p>where <img class="math" src="_images/math/257ee6442468d7529f036a8a81e… | |
+<p><img src="_images/math/c24e3d875b09e3973624f97802672222ca57c3be.png" alt="\… | |
+</div><p>where <img class="math" src="_images/math/4d3f01b8ca8bdab3543eda695ff… | |
interaction force could be expanded to include the force induced by the fluid | |
pressure gradient:</p> | |
<div class="math"> | |
-<p><img src="_images/math/0fdafcde7733804669f8df4846e5bfdb36c7afa7.png" alt="\… | |
+<p><img src="_images/math/f8484aaf38ecdf73f7489fe6b43dec92ae505398.png" alt="\… | |
-\nabla p + | |
\frac{\bar{\boldsymbol{f}}_d}{1-\phi} | |
\right) V_p"/></p> | |
t@@ -337,10 +336,10 @@ pressure gradient:</p> | |
<p>The partial differential terms in the previously described equations are fo… | |
using finite central differences. Modifying the operator splitting methodology | |
presented by Langtangen et al. (2002), the predicted velocity | |
-<img class="math" src="_images/math/90c8bfc206db2d9f4d0dd102507c9646a70755db.p… | |
-<img class="math" src="_images/math/a1ffc0a012620941fe660cedabff822ce7162eca.p… | |
+<img class="math" src="_images/math/f5d499efbd23360f6e9229bdccf14e0951954730.p… | |
+<img class="math" src="_images/math/5b4271afe7fc7c0ee84172e0ad19b82caf450c00.p… | |
<div class="math"> | |
-<p><img src="_images/math/8d0831e0e18af6fd3f3f1060516faab8016dc054.png" alt="\… | |
+<p><img src="_images/math/4414da5fcbe9d66f08400308688cad041ca9dd9c.png" alt="\… | |
+ \nabla \cdot (\phi v_x \boldsymbol{v}) | |
= - \frac{1}{\rho} \frac{\Delta p}{\Delta x} | |
+ \frac{1}{\rho} \left[ \nabla \cdot (\phi \boldsymbol{\tau}) \right]_x | |
t@@ -356,10 +355,10 @@ presented by Langtangen et al. (2002), the predicted ve… | |
+ \frac{1}{\rho} \left[ \nabla \cdot (\phi \boldsymbol{\tau}) \right]_x | |
- \frac{1}{\rho} f^i_x | |
+ \phi g_x"/></p> | |
-</div><p>We want to isolate <img class="math" src="_images/math/b5e8dba2403c07… | |
+</div><p>We want to isolate <img class="math" src="_images/math/eee8ed92791a9c… | |
the new velocity.</p> | |
<div class="math"> | |
-<p><img src="_images/math/faee932adbe0b3f8663c9be6fa88d65f456385a7.png" alt="\… | |
+<p><img src="_images/math/609c6937a183637c7356d1ee9e2800015d73a5f4.png" alt="\… | |
= - \frac{1}{\rho} \frac{\Delta p}{\Delta x} | |
+ \frac{1}{\rho} \left[ \nabla \cdot (\phi \boldsymbol{\tau}) \right]_x | |
- \frac{1}{\rho} f^i_x | |
t@@ -375,13 +374,13 @@ the new velocity.</p> | |
+ \Delta t g_x | |
- v_x \frac{\Delta \phi}{\phi} | |
- \nabla \cdot (\phi v_x \boldsymbol{v}) \frac{\Delta t}{\phi}"/></p> | |
-</div><p>The term <img class="math" src="_images/math/fdb63b9e51abe6bbb16acfb5… | |
-in the range <img class="math" src="_images/math/402b1a3c25643899cdefbe2e62d33… | |
+</div><p>The term <img class="math" src="_images/math/8ce03f78ed945f2ef3dac87c… | |
+in the range <img class="math" src="_images/math/30d3be82eb9bf820400a3dc3e46e8… | |
values in the solution procedure (Langtangen et al. 2002). A value of 0 | |
corresponds to <a class="reference external" href="https://en.wikipedia.org/wi… | |
in <a class="reference external" href="http://www.ams.org/journals/mcom/1968-2… | |
<div class="math"> | |
-<p><img src="_images/math/9ec27d87740d654f43e3238d5bfe718e521368ce.png" alt="v… | |
+<p><img src="_images/math/7ac8e5caca3e02a9a9b6c9576ed9bd5effddb2fb.png" alt="v… | |
v_x^* = v_x^t | |
- \frac{\beta}{\rho} \frac{\Delta p^t}{\Delta x} \frac{\Delta t}{\phi^t} | |
t@@ -391,22 +390,22 @@ v_x^* = v_x^t | |
+ \Delta t g_x | |
- v^t_x \frac{\Delta \phi}{\phi^t} | |
- \nabla \cdot (\phi^t v_x^t \boldsymbol{v}^t) \frac{\Delta t}{\phi^t}"/></p> | |
-</div><p>Here, <img class="math" src="_images/math/1eb29f9de3753a59530941141fc… | |
-(<img class="math" src="_images/math/f04823ba99f1452d779894f7a0745da23b55fbef.… | |
-<img class="math" src="_images/math/79c874e814b2550448c61e2627dc072653b68197.p… | |
+</div><p>Here, <img class="math" src="_images/math/98a432864561550105d4de621bc… | |
+(<img class="math" src="_images/math/e6eadc1093d6e4f5a41f86b8301c0d7559d2c609.… | |
+<img class="math" src="_images/math/e35ec9f12692dad5164f15f68fc16f969099e241.p… | |
equation:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c305e13251e69e8ce59b2908f84afbbd085b5103.png" alt="\… | |
+<p><img src="_images/math/5a4c725fb6cd73a97b137a6ddc218bd457e95ab1.png" alt="\… | |
\boldsymbol{v}^{t+\Delta t}) = 0"/></p> | |
</div><p>The divergence of a scalar and vector can be <a class="reference exte… | |
<div class="math"> | |
-<p><img src="_images/math/41babe6999c89406f22db1ce5ed5e05ce939ed49.png" alt="\… | |
+<p><img src="_images/math/6b14a983094b158179fe53e0a59ebe0d53891195.png" alt="\… | |
\boldsymbol{v}^{t+\Delta t} \cdot \nabla \phi^t | |
+ \frac{\Delta \phi^t}{\Delta t} = 0"/></p> | |
</div><p>The predicted velocity is corrected using the new pressure (Langtange… | |
2002):</p> | |
<div class="math"> | |
-<p><img src="_images/math/52f771ea3758e7653af6c471262bbc0ff0d9cf5a.png" alt="\… | |
+<p><img src="_images/math/2fcd737952b690517150c61a5981d5e810d76268.png" alt="\… | |
%- \frac{\Delta t}{\rho} \nabla \epsilon | |
- \frac{\Delta t}{\rho \phi^t} \nabla \epsilon | |
\quad \text{where} \quad | |
t@@ -414,21 +413,21 @@ equation:</p> | |
</div><p>The above formulation of the future velocity is put into the continui… | |
equation:</p> | |
<div class="math"> | |
-<p><img src="_images/math/7b1a510ad1f355daa1f756cfd47f75a3a29f5660.png" alt="\… | |
+<p><img src="_images/math/915ee93516c4e9e5e9df4b596291692f2b283c00.png" alt="\… | |
\phi^t \nabla \cdot | |
\left( \boldsymbol{v}^* - \frac{\Delta t}{\rho \phi^t} \nabla \epsilon \right) | |
+ | |
\left( \boldsymbol{v}^* - \frac{\Delta t}{\rho \phi^t} \nabla \epsilon \right) | |
\cdot \nabla \phi^t + \frac{\Delta \phi^t}{\Delta t} = 0"/></p> | |
</div><div class="math"> | |
-<p><img src="_images/math/964fa43eb7c25fa23b82daf41b1b9e16e998ab55.png" alt="\… | |
+<p><img src="_images/math/a1bc6e0933f817147b43d6662c901ffc0b2b4151.png" alt="\… | |
\phi^t \nabla \cdot | |
\boldsymbol{v}^* - \frac{\Delta t}{\rho \phi^t} \phi^t \nabla^2 \epsilon | |
+ \nabla \phi^t \cdot \boldsymbol{v}^* | |
- \nabla \phi^t \cdot \nabla \epsilon \frac{\Delta t}{\rho \phi^t} | |
+ \frac{\Delta \phi^t}{\Delta t} = 0"/></p> | |
</div><div class="math"> | |
-<p><img src="_images/math/177b8a21bb3d0e2a33950cd8ceec4f96f5950bd6.png" alt="\… | |
+<p><img src="_images/math/03b863159155c1ff0a1478a3a14f9ceecb42221e.png" alt="\… | |
\frac{\Delta t}{\rho} \nabla^2 \epsilon | |
= \phi^t \nabla \cdot \boldsymbol{v}^* | |
+ \nabla \phi^t \cdot \boldsymbol{v}^* | |
t@@ -436,38 +435,38 @@ equation:</p> | |
+ \frac{\Delta \phi^t}{\Delta t}"/></p> | |
</div><p>The pressure difference in time becomes a <a class="reference externa… | |
<div class="math"> | |
-<p><img src="_images/math/22176d7707317572382e54a12e13095b61d90c26.png" alt="\… | |
+<p><img src="_images/math/49cc970cd820d4022dd996e66da2e453cf4aeeda.png" alt="\… | |
\nabla^2 \epsilon | |
= \frac{\nabla \cdot \boldsymbol{v}^* \phi^t \rho}{\Delta t} | |
+ \frac{\nabla \phi^t \cdot \boldsymbol{v}^* \rho}{\Delta t} | |
- \frac{\nabla \phi^t \cdot \nabla \epsilon}{\phi^t} | |
+ \frac{\Delta \phi^t \rho}{\Delta t^2}"/></p> | |
</div><p>The right hand side of the above equation is termed the <em>forcing f… | |
-<img class="math" src="_images/math/bb2c93730dbb48558bb3c4738c956c4e8f816437.p… | |
+<img class="math" src="_images/math/0001d02b63ede2fe3219e05a7cd09c82ae6298b6.p… | |
<div class="math"> | |
-<p><img src="_images/math/470d00b97569e3a8976841debcd99aaf9c78d7a8.png" alt="f… | |
+<p><img src="_images/math/ba756dc27a3f5d7f8ff7d7801d8c444393c13e6a.png" alt="f… | |
= \frac{\nabla \cdot \boldsymbol{v}^* \phi^t \rho}{\Delta t} | |
+ \frac{\nabla \phi^t \cdot \boldsymbol{v}^* \rho}{\Delta t} | |
+ \frac{\Delta \phi^t \rho}{\Delta t^2} | |
f_2 = | |
\frac{\nabla \phi^t \cdot \nabla \epsilon}{\phi^t}"/></p> | |
-</div><p>During the <a class="reference external" href="http://www.rsmas.miami… | |
-while <img class="math" src="_images/math/e31584cdce0b50ee39c63081564f6e2ec5a7… | |
-during the first iteration, while <img class="math" src="_images/math/e31584cd… | |
+</div><p>During the <a class="reference external" href="http://www.rsmas.miami… | |
+while <img class="math" src="_images/math/ff9078c258266635e46b9767b0c7e248c865… | |
+during the first iteration, while <img class="math" src="_images/math/ff9078c2… | |
of the forcing function is found as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c4f23b63471bb0807346dc89db91e3a684cfa236.png" alt="f… | |
+<p><img src="_images/math/2a6ab5768c27f4033a07a2bd556e89a39cdff6c0.png" alt="f… | |
</div><p>Using second-order finite difference approximations of the Laplace op… | |
second-order partial derivatives, the differential equations become a system of | |
equations that is solved using <a class="reference external" href="https://en.… | |
-number of unknowns is <img class="math" src="_images/math/954afa1fc1c88d82f51a… | |
+number of unknowns is <img class="math" src="_images/math/7774004c6a3397305cc7… | |
<p>The discrete Laplacian (approximation of the Laplace operator) can be obtai… | |
by a finite-difference seven-point stencil in a three-dimensional, cubic | |
-grid with cell spacing <img class="math" src="_images/math/3d41adff4943d60236f… | |
+grid with cell spacing <img class="math" src="_images/math/43e42baf6cef7e96200… | |
face neighbors:</p> | |
<div class="math"> | |
-<p><img src="_images/math/6e1feb8f41fb33ffbf60f657c5e095c2bb780e4d.png" alt="\… | |
+<p><img src="_images/math/ae70bc18ed864da95e96ab31ccce2f21f06d6979.png" alt="\… | |
\frac{\epsilon_{i_x-1,i_y,i_z} - 2 \epsilon_{i_x,i_y,i_z} | |
+ \epsilon_{i_x+1,i_y,i_z}}{\Delta x^2} | |
+ \frac{\epsilon_{i_x,i_y-1,i_z} - 2 \epsilon_{i_x,i_y,i_z} | |
t@@ -476,11 +475,11 @@ face neighbors:</p> | |
+ \frac{\epsilon_{i_x,i_y,i_z-1} - 2 \epsilon_{i_x,i_y,i_z} | |
+ \epsilon_{i_x,i_y,i_z+1}}{\Delta z^2} | |
\approx f_{i_x,i_y,i_z}"/></p> | |
-</div><p>Within a Jacobi iteration, the value of the unknowns (<img class="mat… | |
-used to find an updated solution estimate (<img class="math" src="_images/math… | |
+</div><p>Within a Jacobi iteration, the value of the unknowns (<img class="mat… | |
+used to find an updated solution estimate (<img class="math" src="_images/math… | |
The solution for the updated value takes the form:</p> | |
<div class="math"> | |
-<p><img src="_images/math/5dfeda3ba68db3f629c37ad0b4cc75095c2d6570.png" alt="\… | |
+<p><img src="_images/math/11c52ddf6d9f9157b67c1334ccb39807a8ee777c.png" alt="\… | |
= \frac{-\Delta x^2 \Delta y^2 \Delta z^2 f_{i_x,i_y,i_z} | |
+ \Delta y^2 \Delta z^2 (\epsilon^n_{i_x-1,i_y,i_z} + | |
\epsilon^n_{i_x+1,i_y,i_z}) | |
t@@ -494,42 +493,42 @@ The solution for the updated value takes the form:</p> | |
</div><p>The difference between the current and updated value is termed the <e… | |
residual</em>:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c6e0b5935589b4f8948c91faa0de425bf2791db4.png" alt="r… | |
+<p><img src="_images/math/a6f6238418bca503a9616e884c92c10d86d34fbc.png" alt="r… | |
- \epsilon^n_{i_x,i_y,i_z})^2}{(\epsilon^{n+1}_{i_x,i_y,i_z})^2}"/></p> | |
-</div><p>Note that the <img class="math" src="_images/math/eaf4418fbe935c15a60… | |
+</div><p>Note that the <img class="math" src="_images/math/19bc0073dde1bcd1a8e… | |
of the residual.</p> | |
<p>The updated values are at the end of the iteration stored as the current va… | |
and the maximal value of the normalized residual is found. If this value is | |
larger than a tolerance criteria, the procedure is repeated. The iterative | |
procedure is ended if the number of iterations exceeds a defined limit.</p> | |
-<p>After the values of <img class="math" src="_images/math/eaf4418fbe935c15a60… | |
+<p>After the values of <img class="math" src="_images/math/19bc0073dde1bcd1a8e… | |
pressures and velocities:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c15067d0b2458f2c3bfd62743d7309f7e48213f9.png" alt="\… | |
+<p><img src="_images/math/e80afabbf8aabeec85a867c9c73d1f2df69743fa.png" alt="\… | |
</div><div class="math"> | |
-<p><img src="_images/math/e170ccb91735f4ecee2e5ad7821bf13f8c888c12.png" alt="\… | |
+<p><img src="_images/math/26446b608e4ea66bd2ac56325be3b7dad3ec4261.png" alt="\… | |
\bar{\boldsymbol{v}}^* - \frac{\Delta t}{\rho\phi} \nabla \epsilon"/></p> | |
</div></div> | |
<div class="section" id="boundary-conditions"> | |
<h2>Boundary conditions<a class="headerlink" href="#boundary-conditions" title… | |
<p>The lateral boundaries are periodic. This cannot be changed in the current | |
-version of <tt class="docutils literal"><span class="pre">sphere</span></tt>. … | |
-parallel lateral (<img class="math" src="_images/math/26eeb5258ca5099acf8fe96b… | |
+version of <code class="docutils literal"><span class="pre">sphere</span></cod… | |
+parallel lateral (<img class="math" src="_images/math/188c175aac0a8a9c22499336… | |
leaving through one side reappears on the opposite side.</p> | |
<p>The top and bottom boundary conditions of the fluid grid can be either: | |
prescribed pressure (Dirichlet), or prescribed velocity (Neumann). The | |
(horizontal) velocities parallel to the boundaries are free to attain other | |
values (free slip). The Dirichlet boundary condition is enforced by keeping the | |
-value of <img class="math" src="_images/math/eaf4418fbe935c15a606516d8f55dc380… | |
+value of <img class="math" src="_images/math/19bc0073dde1bcd1a8e6a32b251e80cce… | |
<div class="math"> | |
-<p><img src="_images/math/01be15303939c78ee40a848a717482d046a9ad48.png" alt="\… | |
+<p><img src="_images/math/d04d640e7e6ee0fbcd4ba0e9fc6cb43f3e536d12.png" alt="\… | |
= | |
\epsilon^{n}_{i_x,i_y,i_z = 1 \vee n_z}"/></p> | |
</div><p>The Neumann boundary condition of no flow across the boundary is enfo… | |
-setting the gradient of <img class="math" src="_images/math/eaf4418fbe935c15a6… | |
+setting the gradient of <img class="math" src="_images/math/19bc0073dde1bcd1a8… | |
e.g.:</p> | |
<div class="math"> | |
-<p><img src="_images/math/bdc15139139f2cc22f5656d0456d7b432a72c4e8.png" alt="\… | |
+<p><img src="_images/math/f82d0eba51cfeff3da50b567ffa5126a8ed5b15f.png" alt="\… | |
</div></div> | |
<div class="section" id="numerical-implementation"> | |
<h2>Numerical implementation<a class="headerlink" href="#numerical-implementat… | |
t@@ -542,7 +541,7 @@ e.g.:</p> | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="index.html">Table Of Contents</a></h3> | |
<ul> | |
t@@ -563,29 +562,28 @@ e.g.:</p> | |
<h4>Next topic</h4> | |
<p class="topless"><a href="python_api.html" | |
title="next chapter">Python API</a></p> | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/cfd.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/cfd.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -600,12 +598,12 @@ e.g.:</p> | |
<li class="right" > | |
<a href="dem.html" title="Discrete element method" | |
>previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/dem.html b/doc/html/dem.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Discrete element method — sphere 1.00-alpha documentation</ti… | |
+ <title>Discrete element method — sphere 1.00-alpha documentation</ti… | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,12 +23,14 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
<link rel="next" title="Fluid simulation and particle-fluid interaction" h… | |
- <link rel="prev" title="Introduction" href="introduction.html" /> | |
+ <link rel="prev" title="Introduction and Installation" href="introduction.… | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -44,16 +43,16 @@ | |
<a href="cfd.html" title="Fluid simulation and particle-fluid intera… | |
accesskey="N">next</a> |</li> | |
<li class="right" > | |
- <a href="introduction.html" title="Introduction" | |
+ <a href="introduction.html" title="Introduction and Installation" | |
accesskey="P">previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<div class="section" id="discrete-element-method"> | |
<h1>Discrete element method<a class="headerlink" href="#discrete-element-metho… | |
t@@ -75,7 +74,7 @@ it simulates particles as separate entities, and calculates … | |
velocities, and accelerations through time. See Cundall and Strack (1979) and | |
<a class="reference external" href="http://anders-dc.github.io/2013/10/16/the-… | |
general introduction to the DEM. The following sections will highlight the | |
-DEM implementation in <tt class="docutils literal"><span class="pre">sphere</s… | |
+DEM implementation in <code class="docutils literal"><span class="pre">sphere<… | |
Damsgaard et al. 2013. In the used notation, a bold symbol denotes a | |
three-dimensional vector, and a dot denotes that the entity is a temporal | |
derivative.</p> | |
t@@ -83,10 +82,10 @@ derivative.</p> | |
<h2>Contact search<a class="headerlink" href="#contact-search" title="Permalin… | |
<p>Homogeneous cubic grid.</p> | |
<div class="math"> | |
-<p><img src="_images/math/b2cd17a83bb89dc6b4ff954979dba3b2fbc8e043.png" alt="\… | |
-</div><p>where <img class="math" src="_images/math/b55ca7a0aa88ab7d58f4fc03531… | |
-positional vector of a particle, and <img class="math" src="_images/math/34857… | |
-of two particles. Negative values of <img class="math" src="_images/math/dd84c… | |
+<p><img src="_images/math/7a1586ce67a2a8d709a374bb524625ca12559fd0.png" alt="\… | |
+</div><p>where <img class="math" src="_images/math/2ede365ad144ab396916ec60458… | |
+positional vector of a particle, and <img class="math" src="_images/math/a581f… | |
+of two particles. Negative values of <img class="math" src="_images/math/2822d… | |
are overlapping.</p> | |
</div> | |
<div class="section" id="contact-interaction"> | |
t@@ -97,12 +96,12 @@ interaction is decomposed into normal and tangential compo… | |
contact interface orientation. The normal vector to the contact interface is | |
found by:</p> | |
<div class="math"> | |
-<p><img src="_images/math/8bf1a4afd4cdf42bf3f7b27c9d9c99377a5d1898.png" alt="\… | |
+<p><img src="_images/math/b2f647d3f64c336d2581f03558393e1dbb92c919.png" alt="\… | |
\frac{\boldsymbol{x}^i - \boldsymbol{x}^j} | |
{||\boldsymbol{x}^i - \boldsymbol{x}^j||}"/></p> | |
-</div><p>The contact velocity <img class="math" src="_images/math/0dd32d7f3a00… | |
+</div><p>The contact velocity <img class="math" src="_images/math/522c9c96bc63… | |
<div class="math"> | |
-<p><img src="_images/math/767762b2cd832672331c1421813b919298d7e3b8.png" alt="\… | |
+<p><img src="_images/math/3e0f4950bf4cf691a83dd643eddd240f024b9806.png" alt="\… | |
(\boldsymbol{x}^i - \boldsymbol{x}^j) | |
+ (r^i + \frac{\delta_n^{ij}}{2}) | |
(\boldsymbol{n}^{ij} \times \boldsymbol{\omega}^{i}) | |
t@@ -111,46 +110,46 @@ found by:</p> | |
</div><p>The contact velocity is decomposed into normal and tangential compone… | |
relative to the contact interface. The normal component is:</p> | |
<div class="math"> | |
-<p><img src="_images/math/c5671cc4a4d93628081c7bf7c0fd2cc6ff6c1cd3.png" alt="\… | |
+<p><img src="_images/math/d5f7df718c75314abef3cc68396ac19229c2b55d.png" alt="\… | |
-(\dot{\boldsymbol{\delta}}^{ij} \cdot \boldsymbol{n}^{ij})"/></p> | |
</div><p>and the tangential velocity component is found as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/249d76d0a5d3773b138ce498e5df46c870f402b5.png" alt="\… | |
+<p><img src="_images/math/10eaed38fefc0732b59e674c14396ff74ea89c93.png" alt="\… | |
\dot{\boldsymbol{\delta}}^{ij} | |
- \boldsymbol{n}^{ij} | |
(\boldsymbol{n}^{ij} \cdot \dot{\boldsymbol{\delta}}^{ij})"/></p> | |
-</div><p>where <img class="math" src="_images/math/6922b3e4505e825344dc326ade5… | |
+</div><p>where <img class="math" src="_images/math/b95363838d60e863c4cb530ba40… | |
particle. The total tangential displacement on the contact plane is found | |
incrementally:</p> | |
<div class="math"> | |
-<p><img src="_images/math/213a272621ce146fc9f90ce519bc3dc1ac3337e8.png" alt="\… | |
+<p><img src="_images/math/904bfd360afed4f050929e89e2cc4f7c6f673e97.png" alt="\… | |
\int_0^{t_c} | |
\dot{\boldsymbol{\delta}}^{ij}_t \Delta t"/></p> | |
-</div><p>where <img class="math" src="_images/math/dfc85915a4cda974f3bd5c3c52b… | |
+</div><p>where <img class="math" src="_images/math/42ea00932c36940fb8965e6e7f4… | |
computational time step length. The tangential contact interface displacement … | |
set to zero when a contact pair no longer overlaps. At each time step, the val… | |
-of <img class="math" src="_images/math/bf7f4ceb6fce455ca0347cd7b704321b92e04f8… | |
+of <img class="math" src="_images/math/8cfa62046b3a57f37068f027941acea702d9bd8… | |
interface:</p> | |
<div class="math"> | |
-<p><img src="_images/math/9c2a28916b33bc70a170729d2f237eabae96c0c0.png" alt="\… | |
+<p><img src="_images/math/ef61e2c4dfb9fcb1053c8d2557e00bcf3d871b80.png" alt="\… | |
- (\boldsymbol{n} | |
(\boldsymbol{n} \cdot \boldsymbol{\delta}_{t,\text{uncorrected}}^{ij})"/></p> | |
</div><p>With all the geometrical and kinetic components determined, the resul… | |
-of the particle interaction can be determined using a contact model. <tt class… | |
+of the particle interaction can be determined using a contact model. <code cla… | |
features only one contact model in the normal direction to the contact; the | |
linear-elastic-viscous (<em>Hookean</em> with viscous damping, or <em>Kelvin-V… | |
contact model. The resulting force in the normal direction of the contact | |
-interface on particle <img class="math" src="_images/math/34857b3ba74ce5cd8607… | |
+interface on particle <img class="math" src="_images/math/a581f053bbfa5115f42c… | |
<div class="math"> | |
-<p><img src="_images/math/30d5d726338d5b3ac9d9b0003c564594fd6176ce.png" alt="\… | |
+<p><img src="_images/math/7d72e011d7f06b5df7ff7decf324f701eae33c3a.png" alt="\… | |
-k_n \delta_n^{ij} -\gamma_n \dot{\delta_n}^{ij} | |
\right) \boldsymbol{n}^{ij}"/></p> | |
-</div><p>The parameter <img class="math" src="_images/math/fd26dda3f4f507f3fdf… | |
-contact interface, and <img class="math" src="_images/math/55f6b5380d462f954b6… | |
+</div><p>The parameter <img class="math" src="_images/math/66a1d8738af51528641… | |
+contact interface, and <img class="math" src="_images/math/3640b174f15a44d33ad… | |
viscosity, also in the normal direction. The loss of energy in this interaction | |
-due to the viscous component is for particle <img class="math" src="_images/ma… | |
+due to the viscous component is for particle <img class="math" src="_images/ma… | |
<div class="math"> | |
-<p><img src="_images/math/68e0c54203bc81b45ebe5dbf7d89fc61aa794c1e.png" alt="\… | |
+<p><img src="_images/math/4305b4408a39583be7a127c3039d65ff0cd8c954.png" alt="\… | |
</div><p>The tangential force is determined by either a viscous-frictional con… | |
or a elastic-viscous-frictional contact model. The former contact model is very | |
computationally efficient, but somewhat inaccurate relative to the mechanics of | |
t@@ -158,24 +157,24 @@ real materials. The latter contact model is therefore t… | |
it results in longer computational times. The tangential force in the | |
visco-frictional contact model:</p> | |
<div class="math"> | |
-<p><img src="_images/math/2e9b3638163af9fc450acac1aba9911e57a5c691.png" alt="\… | |
-</div><p><img class="math" src="_images/math/55f6b5380d462f954b65d7a2cd05e02ff… | |
+<p><img src="_images/math/f808e880e30ba99dc461a8dfdaaca903e8433bc1.png" alt="\… | |
+</div><p><img class="math" src="_images/math/3640b174f15a44d33ad8f0622bc44dce8… | |
direction. The tangential displacement along the contact interface | |
-(<img class="math" src="_images/math/bf7f4ceb6fce455ca0347cd7b704321b92e04f8c.… | |
+(<img class="math" src="_images/math/8cfa62046b3a57f37068f027941acea702d9bd8a.… | |
model. The tangential force in the more realistic elastic-viscous-frictional | |
contact model:</p> | |
<div class="math"> | |
-<p><img src="_images/math/18950ecc92ecc7397337b5f39323453647e6434a.png" alt="\… | |
+<p><img src="_images/math/e3d643e0cb551cafec2614062e50e2369d7949ab.png" alt="\… | |
-k_t \boldsymbol{\delta}_t^{ij} -\gamma_t \dot{\boldsymbol{\delta}_t}^{ij}"/><… | |
-</div><p>The parameter <img class="math" src="_images/math/fd26dda3f4f507f3fdf… | |
+</div><p>The parameter <img class="math" src="_images/math/66a1d8738af51528641… | |
direction of the contact interface. Note that the tangential force is only | |
-found if the tangential displacement (<img class="math" src="_images/math/2ab5… | |
-velocity (<img class="math" src="_images/math/c51284f727b4cb7dac214d3517421141… | |
-zero. Otherwise it is defined as being <img class="math" src="_images/math/d5b… | |
+found if the tangential displacement (<img class="math" src="_images/math/d18b… | |
+velocity (<img class="math" src="_images/math/6b038d0d06f6fa38bcb85df9e6f8bed4… | |
+zero. Otherwise it is defined as being <img class="math" src="_images/math/b3c… | |
<p>For both types of contact model, the tangential force is limited by the Cou… | |
criterion of static and dynamic friction:</p> | |
<div class="math"> | |
-<p><img src="_images/math/1d24d160d60604202abbae47aba869e96fb450aa.png" alt="|… | |
+<p><img src="_images/math/5cc160009025ab2cd3b77343dcea454fb8c93795.png" alt="|… | |
\begin{cases} | |
\mu_s ||\boldsymbol{f}^{ij}_n|| & | |
\text{if} \quad ||\boldsymbol{f}_t^{ij}|| = 0 \\ | |
t@@ -186,7 +185,7 @@ criterion of static and dynamic friction:</p> | |
reached, the tangential displacement along the contact interface is limited to | |
this value:</p> | |
<div class="math"> | |
-<p><img src="_images/math/ac73c7c8c596c32306e6ea203ebd039dd3538f06.png" alt="\… | |
+<p><img src="_images/math/13ac3fb2c8f5e95101d362b1cb57b5fcb70e9a71.png" alt="\… | |
\frac{1}{k_t} \left( | |
\mu_d ||\boldsymbol{f}_n^{ij}|| | |
\frac{\boldsymbol{f}^{ij}_t}{||\boldsymbol{f}^{ij}_t||} | |
t@@ -194,30 +193,30 @@ this value:</p> | |
</div><p>If the tangential force reaches the Coulomb limit, the energy lost du… | |
frictional dissipation is calculated as:</p> | |
<div class="math"> | |
-<p><img src="_images/math/9d0d9139c35e749d7b4698592c91045d086d8b99.png" alt="\… | |
+<p><img src="_images/math/85bd2d6544d7812f80cc49d2b7e94be81541301c.png" alt="\… | |
\dot{\boldsymbol{\delta}}_t^{ij} \Delta t||}{\Delta t}"/></p> | |
</div><p>The loss of energy by viscous dissipation in the tangential direction… | |
found.</p> | |
</div> | |
<div class="section" id="temporal-integration"> | |
<h2>Temporal integration<a class="headerlink" href="#temporal-integration" tit… | |
-<p>In the DEM, the time is discretized into small steps (<img class="math" src… | |
+<p>In the DEM, the time is discretized into small steps (<img class="math" src… | |
step, the entire network of contacts is resolved, and the resulting forces and | |
torques for each particle are found. With these values at hand, the new | |
linear and rotational accelerations can be found using | |
<a class="reference external" href="https://en.wikipedia.org/wiki/Newton%27s_l… | |
-of the motion of solid bodies. If a particle with mass <img class="math" src="… | |
-experiences a sum of forces denoted <img class="math" src="_images/math/5ed374… | |
-(<img class="math" src="_images/math/486938d1819df5972cb80ef2d101517b20412366.… | |
+of the motion of solid bodies. If a particle with mass <img class="math" src="… | |
+experiences a sum of forces denoted <img class="math" src="_images/math/8f28ce… | |
+(<img class="math" src="_images/math/701df29c5482cdf1e577052c537c176f5a12caf5.… | |
<div class="math"> | |
-<p><img src="_images/math/c78863bcf0ada3d17f98c21c00ca8b115f6b61de.png" alt="\… | |
+<p><img src="_images/math/5bab09e6e7765565f55e2f7119251f199f472a4a.png" alt="\… | |
</div><p>The new velocity and position is found by integrating the above equat… | |
with regards to time. The simplest integration scheme in this regard is the | |
<a class="reference external" href="https://en.wikipedia.org/wiki/Euler_method… | |
<div class="math"> | |
-<p><img src="_images/math/fca2f0caf945233a44e5c1c1479f13d636edbf42.png" alt="\… | |
+<p><img src="_images/math/a038fb9a65b9138665b4a5c9d0bbba6bdf3b6dbc.png" alt="\… | |
</div><div class="math"> | |
-<p><img src="_images/math/93ddc61f81c056650ee9c02c3e62ed84e4a5327f.png" alt="\… | |
+<p><img src="_images/math/ef4b452d768af650e6ddc2fd95aff430284f74f2.png" alt="\… | |
</div></div> | |
</div> | |
t@@ -225,7 +224,7 @@ with regards to time. The simplest integration scheme in t… | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="index.html">Table Of Contents</a></h3> | |
<ul> | |
t@@ -239,33 +238,32 @@ with regards to time. The simplest integration scheme in… | |
<h4>Previous topic</h4> | |
<p class="topless"><a href="introduction.html" | |
- title="previous chapter">Introduction</a></p> | |
+ title="previous chapter">Introduction and Installation… | |
<h4>Next topic</h4> | |
<p class="topless"><a href="cfd.html" | |
title="next chapter">Fluid simulation and particle-flu… | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/dem.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/dem.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -278,14 +276,14 @@ with regards to time. The simplest integration scheme in… | |
<a href="cfd.html" title="Fluid simulation and particle-fluid intera… | |
>next</a> |</li> | |
<li class="right" > | |
- <a href="introduction.html" title="Introduction" | |
+ <a href="introduction.html" title="Introduction and Installation" | |
>previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/genindex.html b/doc/html/genindex.html | |
t@@ -1,7 +1,4 @@ | |
- | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -10,15 +7,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Index — sphere 1.00-alpha documentation</title> | |
+ <title>Index — sphere 1.00-alpha documentation</title> | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -28,10 +24,12 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="#" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -40,14 +38,14 @@ | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<h1 id="index">Index</h1> | |
t@@ -60,6 +58,7 @@ | |
| <a href="#E"><strong>E</strong></a> | |
| <a href="#F"><strong>F</strong></a> | |
| <a href="#G"><strong>G</strong></a> | |
+ | <a href="#H"><strong>H</strong></a> | |
| <a href="#I"><strong>I</strong></a> | |
| <a href="#K"><strong>K</strong></a> | |
| <a href="#L"><strong>L</strong></a> | |
t@@ -83,12 +82,16 @@ | |
</dt> | |
- <dt><a href="python_api.html#sphere.sim.addParticle">addParticle() (sphere.s… | |
+ <dt><a href="python_api.html#sphere.sim.adaptiveGrid">adaptiveGrid() (sphere… | |
</dt> | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.addParticle">addParticle() (sphere.s… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.adjustUpperWall">adjustUpperWall() (… | |
</dt> | |
t@@ -106,12 +109,12 @@ | |
<dt><a href="python_api.html#sphere.sim.bond">bond() (sphere.sim method)</a> | |
</dt> | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.bondsRose">bondsRose() (sphere.sim m… | |
</dt> | |
- </dl></td> | |
- <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.bulkPorosity">bulkPorosity() (sphere… | |
</dt> | |
t@@ -123,6 +126,10 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.cellSize">cellSize() (sphere.sim met… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.checkerboardColors">checkerboardColo… | |
</dt> | |
t@@ -147,6 +154,18 @@ | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.contactParticleArea">contactParticle… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.contactSurfaceArea">contactSurfaceAr… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.convergence">convergence() (sphere.s… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.convert">convert() (in module sphere)</a> | |
</dt> | |
t@@ -158,6 +177,10 @@ | |
<dt><a href="python_api.html#sphere.sim.currentNormalStress">currentNormalSt… | |
</dt> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.currentTime">currentTime() (sphere.s… | |
+ </dt> | |
+ | |
</dl></td> | |
</tr></table> | |
t@@ -176,16 +199,28 @@ | |
<dt><a href="python_api.html#sphere.sim.deleteAllParticles">deleteAllParticl… | |
</dt> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.deleteParticle">deleteParticle() (sp… | |
+ </dt> | |
+ | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
- <dt><a href="python_api.html#sphere.sim.deleteParticle">deleteParticle() (sp… | |
+ <dt><a href="sphere_internals.html#_CPPv23DEM">DEM (C++ class)</a> | |
</dt> | |
<dt><a href="python_api.html#sphere.sim.disableFluidPressureModulation">disa… | |
</dt> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.disableTopWallNormalStressModulation… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.dry">dry() (sphere.sim method)</a> | |
+ </dt> | |
+ | |
</dl></td> | |
</tr></table> | |
t@@ -203,16 +238,56 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
- <dt><a href="python_api.html#sphere.sim.forcechains">forcechains() (sphere.s… | |
+ <dt><a href="python_api.html#sphere.sim.findAllAverageParticlePairAreas">fin… | |
</dt> | |
- <dt><a href="python_api.html#sphere.sim.forcechainsRose">forcechainsRose() (… | |
+ <dt><a href="python_api.html#sphere.sim.findAllContactSurfaceAreas">findAllC… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findContactStresses">findContactStre… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findCoordinationNumber">findCoordina… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findHydraulicConductivities">findHyd… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findLoadedContacts">findLoadedContac… | |
</dt> | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.findMeanCoordinationNumber">findMean… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findNormalForces">findNormalForces()… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findOverlaps">findOverlaps() (sphere… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.findPermeabilities">findPermeabiliti… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.forcechains">forcechains() (sphere.s… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.forcechainsRose">forcechainsRose() (… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.frictionalEnergy">frictionalEnergy()… | |
</dt> | |
t@@ -235,10 +310,38 @@ | |
</dl></td> | |
</tr></table> | |
+<h2 id="H">H</h2> | |
+<table style="width: 100%" class="indextable genindextable"><tr> | |
+ <td style="width: 33%" valign="top"><dl> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.hydraulicConductivity">hydraulicCond… | |
+ </dt> | |
+ | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.hydraulicDiffusivity">hydraulicDiffu… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.hydraulicPermeability">hydraulicPerm… | |
+ </dt> | |
+ | |
+ </dl></td> | |
+</tr></table> | |
+ | |
<h2 id="I">I</h2> | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.id">id() (sphere.sim method)</a> | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.idAppend">idAppend() (sphere.sim met… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.inertiaParameterPlanarShear">inertia… | |
</dt> | |
t@@ -250,12 +353,12 @@ | |
<dt><a href="python_api.html#sphere.sim.initGrid">initGrid() (sphere.sim met… | |
</dt> | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.initGridAndWorldsize">initGridAndWor… | |
</dt> | |
- </dl></td> | |
- <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.initGridPos">initGridPos() (sphere.s… | |
</dt> | |
t@@ -289,6 +392,12 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.largestFluidTimeStep">largestFluidTi… | |
+ </dt> | |
+ | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
+ | |
<dt><a href="python_api.html#sphere.sim.largestMass">largestMass() (sphere.s… | |
</dt> | |
t@@ -302,12 +411,12 @@ | |
<dt><a href="python_api.html#sphere.sim.mass">mass() (sphere.sim method)</a> | |
</dt> | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.momentOfInertia">momentOfInertia() (… | |
</dt> | |
- </dl></td> | |
- <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.momentum">momentum() (sphere.sim met… | |
</dt> | |
t@@ -337,6 +446,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.plotContacts">plotContacts() (sphere… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.plotConvergence">plotConvergence() (… | |
</dt> | |
t@@ -371,6 +484,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.plotSinFunction">plotSinFunction() (… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.porosities">porosities() (sphere.sim… | |
</dt> | |
t@@ -404,10 +521,14 @@ | |
<dt><a href="python_api.html#sphere.sim.readsecond">readsecond() (sphere.sim… | |
</dt> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.readstep">readstep() (sphere.sim met… | |
+ </dt> | |
+ | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
- <dt><a href="python_api.html#sphere.sim.readstep">readstep() (sphere.sim met… | |
+ <dt><a href="python_api.html#sphere.sim.readTime">readTime() (sphere.sim met… | |
</dt> | |
t@@ -421,6 +542,10 @@ | |
</dl></dd> | |
+ <dt><a href="python_api.html#sphere.sim.ReynoldsNumber">ReynoldsNumber() (sp… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.rotationalEnergy">rotationalEnergy()… | |
</dt> | |
t@@ -441,6 +566,10 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.scaleSize">scaleSize() (sphere.sim m… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setBeta">setBeta() (sphere.sim metho… | |
</dt> | |
t@@ -457,6 +586,14 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setDynamicFriction">setDynamicFricti… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidBottomFixedFlux">setFluidBot… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setFluidBottomFixedPressure">setFlui… | |
</dt> | |
t@@ -469,10 +606,22 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setFluidCompressibility">setFluidCom… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidDensity">setFluidDensity() (… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setFluidPressureModulation">setFluid… | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setFluidTopFixedFlux">setFluidTopFix… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setFluidTopFixedPressure">setFluidTo… | |
</dt> | |
t@@ -485,6 +634,34 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setFluidViscosity">setFluidViscosity… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidXFixedPressure">setFluidXFix… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidXNoFlow">setFluidXNoFlow() (… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidXPeriodic">setFluidXPeriodic… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidYFixedPressure">setFluidYFix… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidYNoFlow">setFluidYNoFlow() (… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setFluidYPeriodic">setFluidYPeriodic… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setGamma">setGamma() (sphere.sim met… | |
</dt> | |
t@@ -495,6 +672,26 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setPermeabilityGrainSize">setPermeab… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setPermeabilityPrefactor">setPermeab… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setStaticFriction">setStaticFriction… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setStiffnessNormal">setStiffnessNorm… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setStiffnessTangential">setStiffness… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.setTheta">setTheta() (sphere.sim met… | |
</dt> | |
t@@ -503,6 +700,14 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.setTopWallNormalStressModulation">se… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.setYoungsModulus">setYoungsModulus()… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.shear">shear() (sphere.sim method)</… | |
</dt> | |
t@@ -511,6 +716,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.shearDisplacement">shearDisplacement… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.shearStrain">shearStrain() (sphere.s… | |
</dt> | |
t@@ -519,10 +728,22 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.shearStress">shearStress() (sphere.s… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.shearVel">shearVel() (sphere.sim met… | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.shearVelocity">shearVelocity() (sphe… | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.show">show() (sphere.sim method)</a> | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim">sim (class in sphere)</a> | |
</dt> | |
t@@ -535,6 +756,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.staticGrid">staticGrid() (sphere.sim… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.status">status() (in module sphere)</a> | |
</dt> | |
t@@ -544,6 +769,10 @@ | |
</dt> | |
</dl></dd> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.surfaceArea">surfaceArea() (sphere.s… | |
+ </dt> | |
+ | |
</dl></td> | |
</tr></table> | |
t@@ -567,6 +796,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.torqueScriptPenguin">torqueScriptPen… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.totalFrictionalEnergy">totalFriction… | |
</dt> | |
t@@ -577,6 +810,10 @@ | |
</dt> | |
+ <dt><a href="python_api.html#sphere.sim.totalMass">totalMass() (sphere.sim m… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.totalMomentum">totalMomentum() (sphe… | |
</dt> | |
t@@ -622,12 +859,12 @@ | |
</dt> | |
</dl></dd> | |
+ </dl></td> | |
+ <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.viscousEnergy">viscousEnergy() (sphe… | |
</dt> | |
- </dl></td> | |
- <td style="width: 33%" valign="top"><dl> | |
<dt><a href="python_api.html#sphere.sim.visualize">visualize() (sphere.sim m… | |
</dt> | |
t@@ -647,16 +884,24 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
- <dt><a href="python_api.html#sphere.sim.writebin">writebin() (sphere.sim met… | |
+ <dt><a href="python_api.html#sphere.sim.wall0iz">wall0iz() (sphere.sim metho… | |
</dt> | |
- <dt><a href="python_api.html#sphere.sim.writeFluidVTK">writeFluidVTK() (sphe… | |
+ <dt><a href="python_api.html#sphere.sim.wet">wet() (sphere.sim method)</a> | |
+ </dt> | |
+ | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.writebin">writebin() (sphere.sim met… | |
</dt> | |
</dl></td> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.sim.writeFluidVTK">writeFluidVTK() (sphe… | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.sim.writeVTK">writeVTK() (sphere.sim met… | |
</dt> | |
t@@ -664,6 +909,10 @@ | |
<dt><a href="python_api.html#sphere.sim.writeVTKall">writeVTKall() (sphere.s… | |
</dt> | |
+ | |
+ <dt><a href="python_api.html#sphere.sim.writeVTKforces">writeVTKforces() (sp… | |
+ </dt> | |
+ | |
</dl></td> | |
</tr></table> | |
t@@ -682,29 +931,26 @@ | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
-<div id="searchbox" style="display: none"> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -713,12 +959,12 @@ | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/index.html b/doc/html/index.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>The sphere documentation — sphere 1.00-alpha documentation</t… | |
+ <title>The sphere documentation — sphere 1.00-alpha documentation</t… | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,11 +23,13 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="#" /> | |
- <link rel="next" title="Introduction" href="introduction.html" /> | |
+ <link rel="next" title="Introduction and Installation" href="introduction.… | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -40,36 +39,36 @@ | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
<li class="right" > | |
- <a href="introduction.html" title="Introduction" | |
+ <a href="introduction.html" title="Introduction and Installation" | |
accesskey="N">next</a> |</li> | |
- <li><a href="#">sphere 1.00-alpha documentation</a> »</li> | |
+ <li class="nav-item nav-item-0"><a href="#">sphere 1.00-alpha document… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<div class="section" id="the-sphere-documentation"> | |
<h1>The sphere documentation<a class="headerlink" href="#the-sphere-documentat… | |
-<p>This is the official documentation for the <tt class="docutils literal"><sp… | |
+<p>This is the official documentation for the <code class="docutils literal"><… | |
software. This document aims at guiding the installation process, documenting | |
the usage, and explaining the relevant theory.</p> | |
-<p><tt class="docutils literal"><span class="pre">sphere</span></tt> is develo… | |
+<p><code class="docutils literal"><span class="pre">sphere</span></code> is de… | |
supervision of David Lundbek Egholm and Jan A. Piotrowski, all of the Departme… | |
of Geoscience, Aarhus University, Denmark. The author welcomes interested third | |
party developers. This document is a work in progress.</p> | |
-<p>Contact: Anders Damsgaard, <a class="reference external" href="http://cs.au… | |
+<p>Contact: Anders Damsgaard, <a class="reference external" href="https://adam… | |
<a class="reference external" href="mailto:anders.damsgaard%40… | |
<div class="section" id="contents"> | |
<h2>Contents<a class="headerlink" href="#contents" title="Permalink to this he… | |
<div class="toctree-wrapper compound"> | |
<ul> | |
-<li class="toctree-l1"><a class="reference internal" href="introduction.html">… | |
+<li class="toctree-l1"><a class="reference internal" href="introduction.html">… | |
<li class="toctree-l2"><a class="reference internal" href="introduction.html#r… | |
<li class="toctree-l2"><a class="reference internal" href="introduction.html#o… | |
-<li class="toctree-l2"><a class="reference internal" href="introduction.html#b… | |
+<li class="toctree-l2"><a class="reference internal" href="introduction.html#b… | |
<li class="toctree-l2"><a class="reference internal" href="introduction.html#u… | |
<li class="toctree-l2"><a class="reference internal" href="introduction.html#w… | |
</ul> | |
t@@ -91,7 +90,12 @@ party developers. This document is a work in progress.</p> | |
</li> | |
<li class="toctree-l1"><a class="reference internal" href="python_api.html">Py… | |
<li class="toctree-l2"><a class="reference internal" href="python_api.html#sam… | |
-<li class="toctree-l2"><a class="reference internal" href="python_api.html#mod… | |
+<li class="toctree-l2"><a class="reference internal" href="python_api.html#mod… | |
+</ul> | |
+</li> | |
+<li class="toctree-l1"><a class="reference internal" href="sphere_internals.ht… | |
+<li class="toctree-l2"><a class="reference internal" href="sphere_internals.ht… | |
+<li class="toctree-l2"><a class="reference internal" href="sphere_internals.ht… | |
</ul> | |
</li> | |
</ul> | |
t@@ -100,8 +104,8 @@ party developers. This document is a work in progress.</p> | |
<div class="section" id="indices-and-tables"> | |
<h2>Indices and tables<a class="headerlink" href="#indices-and-tables" title="… | |
<ul class="simple"> | |
-<li><a class="reference internal" href="genindex.html"><em>Index</em></a></li> | |
-<li><a class="reference internal" href="search.html"><em>Search Page</em></a><… | |
+<li><a class="reference internal" href="genindex.html"><span class="std std-re… | |
+<li><a class="reference internal" href="search.html"><span class="std std-ref"… | |
</ul> | |
</div> | |
</div> | |
t@@ -110,14 +114,12 @@ party developers. This document is a work in progress.</… | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="#">Table Of Contents</a></h3> | |
<ul> | |
<li><a class="reference internal" href="#">The sphere documentation</a><ul> | |
-<li><a class="reference internal" href="#contents">Contents</a><ul> | |
-</ul> | |
-</li> | |
+<li><a class="reference internal" href="#contents">Contents</a></li> | |
<li><a class="reference internal" href="#indices-and-tables">Indices and table… | |
</ul> | |
</li> | |
t@@ -125,30 +127,29 @@ party developers. This document is a work in progress.</… | |
<h4>Next topic</h4> | |
<p class="topless"><a href="introduction.html" | |
- title="next chapter">Introduction</a></p> | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/index.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ title="next chapter">Introduction and Installation</a>… | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/index.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -158,14 +159,14 @@ party developers. This document is a work in progress.</… | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
<li class="right" > | |
- <a href="introduction.html" title="Introduction" | |
+ <a href="introduction.html" title="Introduction and Installation" | |
>next</a> |</li> | |
- <li><a href="#">sphere 1.00-alpha documentation</a> »</li> | |
+ <li class="nav-item nav-item-0"><a href="#">sphere 1.00-alpha document… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/introduction.html b/doc/html/introduction.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Introduction — sphere 1.00-alpha documentation</title> | |
+ <title>Introduction and Installation — sphere 1.00-alpha documentati… | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,12 +23,14 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
<link rel="next" title="Discrete element method" href="dem.html" /> | |
<link rel="prev" title="The sphere documentation" href="index.html" /> | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -46,34 +45,34 @@ | |
<li class="right" > | |
<a href="index.html" title="The sphere documentation" | |
accesskey="P">previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
- <div class="section" id="introduction"> | |
-<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to… | |
-<p>The <tt class="docutils literal"><span class="pre">sphere</span></tt>-softw… | |
+ <div class="section" id="introduction-and-installation"> | |
+<h1>Introduction and Installation<a class="headerlink" href="#introduction-and… | |
+<p>The <code class="docutils literal"><span class="pre">sphere</span></code>-s… | |
(DEM) particle simulations. The source code is written in C++, CUDA C and | |
Python, and is compiled by the user. The main computations are performed on the | |
graphics processing unit (GPU) using NVIDIA’s general purpose parallel c… | |
architecture, CUDA. Simulation setup and data analysis is performed with the | |
included Python API.</p> | |
-<p>The ultimate aim of the <tt class="docutils literal"><span class="pre">sphe… | |
+<p>The ultimate aim of the <code class="docutils literal"><span class="pre">sp… | |
conditions, while retaining the flexibility to perform simulations of granular | |
material in other environments.</p> | |
<p>The purpose of this documentation is to provide the user with a walk-throug… | |
the installation, work-flow, data-analysis and visualization methods of | |
-<tt class="docutils literal"><span class="pre">sphere</span></tt>. In addition… | |
+<code class="docutils literal"><span class="pre">sphere</span></code>. In addi… | |
understanding of the discrete element method numerical routines taking place.<… | |
<div class="admonition note"> | |
<p class="first admonition-title">Note</p> | |
-<p class="last">Command examples in this document starting with the symbol <tt… | |
-meant to be executed in the shell of the operational system, and <tt class="do… | |
+<p class="last">Command examples in this document starting with the symbol <co… | |
+meant to be executed in the shell of the operational system, and <code class="… | |
means execution in Python. <a class="reference external" href="http://ipython.… | |
interactive Python shell.</p> | |
</div> | |
t@@ -90,20 +89,21 @@ release notes</a> for more information)</li> | |
<li><a class="reference external" href="http://www.cmake.org">CMake</a>, versi… | |
<li>The <a class="reference external" href="http://gcc.gnu.org/">GNU Compiler … | |
<li>The <a class="reference external" href="https://developer.nvidia.com/cuda-… | |
-version 5.0 or newer</li> | |
+version 8.0 or newer</li> | |
</ul> | |
</div></blockquote> | |
<p>In Debian GNU/Linux, these dependencies can be installed by running:</p> | |
-<div class="highlight-python"><pre>$ sudo apt-get install build-essential cmak… | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ sudo… | |
+</pre></div> | |
</div> | |
<p>Unfortunately, the Nvidia Toolkit is shipped under a non-free license. In o… | |
-to install it in Debian GNU/Linux, add <tt class="docutils literal"><span clas… | |
-<tt class="docutils literal"><span class="pre">/etc/apt/sources.list</span></t… | |
+to install it in Debian GNU/Linux, add <code class="docutils literal"><span cl… | |
+<code class="docutils literal"><span class="pre">/etc/apt/sources.list</span><… | |
<p>The runtime requirements are:</p> | |
<blockquote> | |
<div><ul class="simple"> | |
<li>A <a class="reference external" href="http://www.nvidia.com/object/cuda_gp… | |
-compute capability 1.1 or greater.</li> | |
+compute capability 2.0 or greater.</li> | |
<li>A Nvidia CUDA-enabled GPU and device driver</li> | |
</ul> | |
</div></blockquote> | |
t@@ -119,10 +119,11 @@ compute capability 1.1 or greater.</li> | |
</ul> | |
</div></blockquote> | |
<p>In Debian GNU/Linux, these dependencies can be installed by running:</p> | |
-<div class="highlight-python"><pre>$ sudo apt-get install python python-numpy … | |
- imagemagick libav-tools</pre> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ sudo… | |
+ imagemagick libav-tools | |
+</pre></div> | |
</div> | |
-<p><tt class="docutils literal"><span class="pre">sphere</span></tt> is distri… | |
+<p><code class="docutils literal"><span class="pre">sphere</span></code> is di… | |
following tools are required for building the documentation:</p> | |
<blockquote> | |
<div><ul class="simple"> | |
t@@ -133,23 +134,25 @@ following tools are required for building the documentat… | |
<li><a class="reference external" href="http://www.stack.nl/~dimitri/doxygen/"… | |
<li><a class="reference external" href="http://michaeljones.github.com/breathe… | |
<li><a class="reference external" href="http://www.nongnu.org/dvipng/">dvipng<… | |
-<li><a class="reference external" href="http://www.tug.org/texlive/">TeX Live<… | |
+<li><a class="reference external" href="http://www.tug.org/texlive/">TeX Live<… | |
</ul> | |
</div></blockquote> | |
<p>In Debian GNU/Linux, these dependencies can be installed by running:</p> | |
-<div class="highlight-python"><pre>$ sudo apt-get install python-sphinx python… | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ sudo… | |
python-sphinxcontrib-programoutput texlive-full | |
-$ sudo pip install breathe</pre> | |
+$ sudo pip install breathe | |
+</pre></div> | |
</div> | |
<p><a class="reference external" href="http://git-scm.com">Git</a> is used as … | |
-platform, and the source code is maintained at <a class="reference external" h… | |
+platform, and the source code is maintained at <a class="reference external" h… | |
Public License, v.3</a>.</p> | |
<div class="admonition note"> | |
<p class="first admonition-title">Note</p> | |
<p>All Debian GNU/Linux runtime, optional, and documentation dependencies | |
mentioned above can be installed by executing the following command from the | |
-<tt class="docutils literal"><span class="pre">doc/</span></tt> folder:</p> | |
-<div class="last highlight-python"><pre>$ make install-debian-pkgs</pre> | |
+<code class="docutils literal"><span class="pre">doc/</span></code> folder:</p> | |
+<div class="last highlight-default"><div class="highlight"><pre><span></span>$… | |
+</pre></div> | |
</div> | |
</div> | |
</div> | |
t@@ -158,92 +161,104 @@ mentioned above can be installed by executing the follo… | |
<p>The best way to keep up to date with subsequent updates, bugfixes and | |
development, is to use the Git version control system. To obtain a local | |
copy, execute:</p> | |
-<div class="highlight-python"><pre>$ git clone [email protected]:anders-dc/sphere… | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ git … | |
+</pre></div> | |
</div> | |
</div> | |
<div class="section" id="building-sphere"> | |
-<h2>Building <tt class="docutils literal"><span class="pre">sphere</span></tt>… | |
-<p><tt class="docutils literal"><span class="pre">sphere</span></tt> is built … | |
-and <tt class="docutils literal"><span class="pre">nvcc</span></tt> from the N… | |
-<p>If you plan to run <tt class="docutils literal"><span class="pre">sphere</s… | |
-from the root directory:</p> | |
-<div class="highlight-python"><pre>$ cmake . && make</pre> | |
-</div> | |
-<p>If you instead plan to execute it on a Fermi GPU, change <tt class="docutil… | |
-<span class="pre">1)</span></tt> to <tt class="docutils literal"><span class="… | |
+<h2>Building <code class="docutils literal"><span class="pre">sphere</span></c… | |
+<p><code class="docutils literal"><span class="pre">sphere</span></code> is bu… | |
+and <code class="docutils literal"><span class="pre">nvcc</span></code> from t… | |
+<p>If you instead plan to execute it on a Fermi GPU, change <code class="docut… | |
+<span class="pre">1)</span></code> to <code class="docutils literal"><span cla… | |
<p>In some cases the CMake FindCUDA module will have troubles locating the | |
-CUDA samples directory, and will complain about <tt class="docutils literal"><… | |
+CUDA samples directory, and will complain about <code class="docutils literal"… | |
found.</p> | |
-<p>In that case, modify the <tt class="docutils literal"><span class="pre">CUD… | |
-<tt class="docutils literal"><span class="pre">src/CMakeLists.txt</span></tt> … | |
-<tt class="docutils literal"><span class="pre">cmake</span> <span class="pre">… | |
-sample subdirectory <tt class="docutils literal"><span class="pre">common/inc/… | |
-directory, and run <tt class="docutils literal"><span class="pre">cmake</span>… | |
+<p>In that case, modify the <code class="docutils literal"><span class="pre">C… | |
+<code class="docutils literal"><span class="pre">src/CMakeLists.txt</span></co… | |
+<code class="docutils literal"><span class="pre">cmake</span> <span class="pre… | |
+sample subdirectory <code class="docutils literal"><span class="pre">common/in… | |
+directory, and run <code class="docutils literal"><span class="pre">cmake</spa… | |
sphere cannot be distributed with this file.</p> | |
-<p>After a successfull installation, the <tt class="docutils literal"><span cl… | |
+<p>If you plan to run <code class="docutils literal"><span class="pre">sphere<… | |
+from the root directory:</p> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ cmak… | |
+</pre></div> | |
+</div> | |
+<p>NOTE: If your system does not have a GCC compiler (e.g. GCC-5 for CUDA 8) | |
+compatible with the installed CUDA version, try using <code class="docutils li… | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ expo… | |
+</pre></div> | |
+</div> | |
+<p>After a successfull installation, the <code class="docutils literal"><span … | |
in the root folder. To make sure that all components are working correctly, | |
execute:</p> | |
-<div class="highlight-python"><pre>$ make test</pre> | |
-</div> | |
-<p>All instructions required for building <tt class="docutils literal"><span c… | |
-<tt class="docutils literal"><span class="pre">Makefile</span></tt>‘s. T… | |
-the root directory, and invoke CMake and GNU Make:</p> | |
-<div class="highlight-python"><pre>$ cmake . && make</pre> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ make… | |
+</pre></div> | |
</div> | |
-<p>If successfull, the Makefiles will create the required data folders, object | |
-files, as well as the <tt class="docutils literal"><span class="pre">sphere</s… | |
+<p>Disclaimer: On some systems the Navier-Stokes related tests will fail. If … | |
+do encounter these problems, but do not plan on using the Navier Stokes solver | |
+for fluid dynamics, carry on.</p> | |
+<p>If successful the Makefiles will create the required data folders, object | |
+files, as well as the <code class="docutils literal"><span class="pre">sphere<… | |
following commands to check the executable:</p> | |
-<div class="highlight-python"><pre>$ ./sphere --version</pre> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./sp… | |
+</pre></div> | |
</div> | |
<p>The output should look similar to this:</p> | |
-<div class="highlight-text"><div class="highlight"><pre>.---------------------… | |
-| _ Compiled for 3D | | |
+<div class="highlight-text"><div class="highlight"><pre><span></span>.--------… | |
+| _ | | |
| | | | | |
| ___ _ __ | |__ ___ _ __ ___ | | |
| / __| '_ \| '_ \ / _ \ '__/ _ \ | | |
| \__ \ |_) | | | | __/ | | __/ | | |
| |___/ .__/|_| |_|\___|_| \___| | | |
| | | | | |
-| |_| Version: 0.35 | | |
+| |_| Version: 2.15 | | |
`-------------------------------------´ | |
A discrete element method particle dynamics simulator. | |
- Written by Anders Damsgaard Christensen, license GPLv3+. | |
+ Written by Anders Damsgaard, license GPLv3+. | |
+ https://cs.au.dk/~adc/ | |
</pre></div> | |
</div> | |
<p>The build can be verified by running a number of automated tests:</p> | |
-<div class="highlight-python"><pre>$ make test</pre> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ make… | |
+</pre></div> | |
</div> | |
<p>The documentation can be read in the <a class="reference external" href="ht… | |
-the <tt class="docutils literal"><span class="pre">doc/sphinx/</span></tt> fol… | |
-<tt class="docutils literal"><span class="pre">doc/html</span></tt> and <tt cl… | |
+the <code class="docutils literal"><span class="pre">doc/sphinx/</span></code>… | |
+<code class="docutils literal"><span class="pre">doc/html</span></code> and <c… | |
<p>Optionally, the documentation can be built using the following commands:</p> | |
-<div class="highlight-python"><pre>$ cd doc/sphinx | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ cd d… | |
$ make html | |
-$ make latexpdf</pre> | |
+$ make latexpdf | |
+</pre></div> | |
</div> | |
<p>To see all available output formats, execute:</p> | |
-<div class="highlight-python"><pre>$ make help</pre> | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ make… | |
+</pre></div> | |
</div> | |
</div> | |
<div class="section" id="updating-sphere"> | |
<h2>Updating sphere<a class="headerlink" href="#updating-sphere" title="Permal… | |
-<p>To update your local version, type the following commands in the <tt class=… | |
+<p>To update your local version, type the following commands in the <code clas… | |
directory:</p> | |
-<div class="highlight-python"><pre>$ git pull && cmake . && ma… | |
+<div class="highlight-default"><div class="highlight"><pre><span></span>$ git … | |
+</pre></div> | |
</div> | |
</div> | |
<div class="section" id="work-flow"> | |
<h2>Work flow<a class="headerlink" href="#work-flow" title="Permalink to this … | |
-<p>After compiling the <tt class="docutils literal"><span class="pre">sphere</… | |
+<p>After compiling the <code class="docutils literal"><span class="pre">sphere… | |
a simulation is typically arranged in the following order:</p> | |
<blockquote> | |
<div><ul class="simple"> | |
<li>Setup of particle assemblage, physical properties and conditions using the | |
Python API.</li> | |
-<li>Execution of <tt class="docutils literal"><span class="pre">sphere</span><… | |
+<li>Execution of <code class="docutils literal"><span class="pre">sphere</span… | |
function of time, as a result of the conditions initially specified in the | |
input file.</li> | |
-<li>Inspection, analysis, interpretation and visualization of <tt class="docut… | |
+<li>Inspection, analysis, interpretation and visualization of <code class="doc… | |
in Python, and/or scene rendering using the built-in ray tracer.</li> | |
</ul> | |
</div></blockquote> | |
t@@ -254,14 +269,14 @@ in Python, and/or scene rendering using the built-in ray… | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="index.html">Table Of Contents</a></h3> | |
<ul> | |
-<li><a class="reference internal" href="#">Introduction</a><ul> | |
+<li><a class="reference internal" href="#">Introduction and Installation</a><u… | |
<li><a class="reference internal" href="#requirements">Requirements</a></li> | |
<li><a class="reference internal" href="#obtaining-sphere">Obtaining sphere</a… | |
-<li><a class="reference internal" href="#building-sphere">Building <tt class="… | |
+<li><a class="reference internal" href="#building-sphere">Building <code class… | |
<li><a class="reference internal" href="#updating-sphere">Updating sphere</a><… | |
<li><a class="reference internal" href="#work-flow">Work flow</a></li> | |
</ul> | |
t@@ -274,29 +289,28 @@ in Python, and/or scene rendering using the built-in ray… | |
<h4>Next topic</h4> | |
<p class="topless"><a href="dem.html" | |
title="next chapter">Discrete element method</a></p> | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/introduction.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/introduction.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -311,12 +325,12 @@ in Python, and/or scene rendering using the built-in ray… | |
<li class="right" > | |
<a href="index.html" title="The sphere documentation" | |
>previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/objects.inv b/doc/html/objects.inv | |
Binary files differ. | |
diff --git a/doc/html/py-modindex.html b/doc/html/py-modindex.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Python Module Index — sphere 1.00-alpha documentation</title> | |
+ <title>Python Module Index — sphere 1.00-alpha documentation</title> | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,6 +23,8 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
t@@ -35,8 +34,8 @@ | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -45,14 +44,14 @@ | |
<li class="right" > | |
<a href="#" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<h1>Python Module Index</h1> | |
t@@ -62,13 +61,13 @@ | |
</div> | |
<table class="indextable modindextable" cellspacing="0" cellpadding="2"> | |
- <tr class="pcap"><td></td><td> </td><td></td></tr> | |
+ <tr class="pcap"><td></td><td> </td><td></td></tr> | |
<tr class="cap" id="cap-s"><td></td><td> | |
<strong>s</strong></td><td></td></tr> | |
<tr> | |
<td></td> | |
<td> | |
- <a href="python_api.html#module-sphere"><tt class="xref">sphere</tt></a… | |
+ <a href="python_api.html#module-sphere"><code class="xref">sphere</code… | |
<em></em></td></tr> | |
</table> | |
t@@ -76,26 +75,23 @@ | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
-<div id="searchbox" style="display: none"> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -104,12 +100,12 @@ | |
<li class="right" > | |
<a href="#" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/python_api.html b/doc/html/python_api.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Python API — sphere 1.00-alpha documentation</title> | |
+ <title>Python API — sphere 1.00-alpha documentation</title> | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,11 +23,13 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
<link rel="prev" title="Fluid simulation and particle-fluid interaction" h… | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -42,27 +41,27 @@ | |
<li class="right" > | |
<a href="cfd.html" title="Fluid simulation and particle-fluid intera… | |
accesskey="P">previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<div class="section" id="python-api"> | |
<h1>Python API<a class="headerlink" href="#python-api" title="Permalink to thi… | |
-<p>The Python module <tt class="docutils literal"><span class="pre">sphere</sp… | |
+<p>The Python module <code class="docutils literal"><span class="pre">sphere</… | |
application. It is recommended to use this module for simulation setup, | |
simulation execution, and analysis of the simulation output data.</p> | |
-<p>In order to use the API, the file <tt class="docutils literal"><span class=… | |
+<p>In order to use the API, the file <code class="docutils literal"><span clas… | |
directory as the Python files.</p> | |
<div class="section" id="sample-usage"> | |
<h2>Sample usage<a class="headerlink" href="#sample-usage" title="Permalink to… | |
<p>Below is a simple, annotated example of how to setup, execute, and post-pro… | |
-a <tt class="docutils literal"><span class="pre">sphere</span></tt> simulation… | |
-<tt class="docutils literal"><span class="pre">collision.py</span></tt>.</p> | |
+a <code class="docutils literal"><span class="pre">sphere</span></code> simula… | |
+<code class="docutils literal"><span class="pre">collision.py</span></code>.</… | |
<div class="highlight-python"><table class="highlighttable"><tr><td class="lin… | |
2 | |
3 | |
t@@ -121,74 +120,74 @@ a <tt class="docutils literal"><span class="pre">sphere<… | |
56 | |
57 | |
58 | |
-59</pre></div></td><td class="code"><div class="highlight"><pre><span class="c… | |
+59</pre></div></td><td class="code"><div class="highlight"><pre><span></span><… | |
<span class="sd">'''</span> | |
<span class="sd">Example of two particles colliding.</span> | |
<span class="sd">Place script in sphere/python/ folder, and invoke with `pytho… | |
<span class="sd">'''</span> | |
-<span class="c"># Import the sphere module for setting up, running, and analyz… | |
-<span class="c"># experiment. We also need the numpy module when setting array… | |
-<span class="c"># object.</span> | |
+<span class="c1"># Import the sphere module for setting up, running, and analy… | |
+<span class="c1"># experiment. We also need the numpy module when setting arra… | |
+<span class="c1"># object.</span> | |
<span class="kn">import</span> <span class="nn">sphere</span> | |
<span class="kn">import</span> <span class="nn">numpy</span> | |
-<span class="c">### SIMULATION SETUP</span> | |
+<span class="c1">### SIMULATION SETUP</span> | |
-<span class="c"># Create a sphere object with two preallocated particles and a… | |
-<span class="n">SB</span> <span class="o">=</span> <span class="n">sphere</spa… | |
+<span class="c1"># Create a sphere object with two preallocated particles and … | |
+<span class="n">SB</span> <span class="o">=</span> <span class="n">sphere</spa… | |
-<span class="n">SB</span><span class="o">.</span><span class="n">radius</span>… | |
+<span class="n">SB</span><span class="o">.</span><span class="n">radius</span>… | |
-<span class="c"># Define the positions of the two particles</span> | |
-<span class="n">SB</span><span class="o">.</span><span class="n">x</span><span… | |
-<span class="n">SB</span><span class="o">.</span><span class="n">x</span><span… | |
+<span class="c1"># Define the positions of the two particles</span> | |
+<span class="n">SB</span><span class="o">.</span><span class="n">x</span><span… | |
+<span class="n">SB</span><span class="o">.</span><span class="n">x</span><span… | |
-<span class="c"># The default velocity is [0,0,0]. Slam particle 1 into partic… | |
-<span class="c"># a positive x velocity for particle 1.</span> | |
+<span class="c1"># The default velocity is [0,0,0]. Slam particle 1 into parti… | |
+<span class="c1"># a positive x velocity for particle 1.</span> | |
<span class="n">SB</span><span class="o">.</span><span class="n">vel</span><sp… | |
-<span class="c"># Set the world limits and the particle sorting grid. The part… | |
-<span class="c"># within the world limits for the entire simulation, otherwise… | |
+<span class="c1"># Set the world limits and the particle sorting grid. The par… | |
+<span class="c1"># within the world limits for the entire simulation, otherwis… | |
<span class="n">SB</span><span class="o">.</span><span class="n">initGridAndWo… | |
-<span class="c"># Define the temporal parameters, e.g. the total time (total) … | |
-<span class="c"># output interval (file_dt), both in seconds</span> | |
+<span class="c1"># Define the temporal parameters, e.g. the total time (total)… | |
+<span class="c1"># output interval (file_dt), both in seconds</span> | |
<span class="n">SB</span><span class="o">.</span><span class="n">initTemporal<… | |
-<span class="c"># Using a 'dry' run, the sphere main program will disp… | |
-<span class="c"># sphere will end after displaying these values.</span> | |
+<span class="c1"># Using a 'dry' run, the sphere main program will dis… | |
+<span class="c1"># sphere will end after displaying these values.</span> | |
<span class="n">SB</span><span class="o">.</span><span class="n">run</span><sp… | |
-<span class="c">### RUNNING THE SIMULATION</span> | |
+<span class="c1">### RUNNING THE SIMULATION</span> | |
-<span class="c"># Start the simulation on the GPU from the sphere program</spa… | |
+<span class="c1"># Start the simulation on the GPU from the sphere program</sp… | |
<span class="n">SB</span><span class="o">.</span><span class="n">run</span><sp… | |
-<span class="c">### ANALYSIS OF SIMULATION RESULTS</span> | |
+<span class="c1">### ANALYSIS OF SIMULATION RESULTS</span> | |
-<span class="c"># Plot the system energy through time, image saved as collisio… | |
-<span class="n">sphere</span><span class="o">.</span><span class="n">visualize… | |
+<span class="c1"># Plot the system energy through time, image saved as collisi… | |
+<span class="n">SB</span><span class="o">.</span><span class="n">visualize</sp… | |
-<span class="c"># Render the particles using the built-in raytracer</span> | |
+<span class="c1"># Render the particles using the built-in raytracer</span> | |
<span class="n">SB</span><span class="o">.</span><span class="n">render</span>… | |
-<span class="c"># Alternative visualization using ParaView. See the documentat… | |
-<span class="c"># ``sim.writeVTKall()`` for more information about displaying … | |
-<span class="c"># particles in ParaView.</span> | |
+<span class="c1"># Alternative visualization using ParaView. See the documenta… | |
+<span class="c1"># ``sim.writeVTKall()`` for more information about displaying… | |
+<span class="c1"># particles in ParaView.</span> | |
<span class="n">SB</span><span class="o">.</span><span class="n">writeVTKall</… | |
</pre></div> | |
</td></tr></table></div> | |
-<p>The full documentation of the <tt class="docutils literal"><span class="pre… | |
+<p>The full documentation of the <code class="docutils literal"><span class="p… | |
</div> | |
<div class="section" id="module-sphere"> | |
-<span id="the-sphere-module"></span><h2>The <tt class="docutils literal"><span… | |
+<span id="the-sphere-module"></span><h2>The <code class="docutils literal"><sp… | |
<dl class="function"> | |
<dt id="sphere.V_sphere"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">V_sphere</tt><big>(… | |
+<code class="descclassname">sphere.</code><code class="descname">V_sphere</cod… | |
<dd><p>Calculates the volume of a sphere with radius r</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -204,14 +203,14 @@ a <tt class="docutils literal"><span class="pre">sphere<… | |
<dl class="function"> | |
<dt id="sphere.cleanup"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">cleanup</tt><big>(<… | |
+<code class="descclassname">sphere.</code><code class="descname">cleanup</code… | |
<dd><p>Removes the input/output files and images belonging to the object simul… | |
-ID from the <tt class="docutils literal"><span class="pre">input/</span></tt>,… | |
+ID from the <code class="docutils literal"><span class="pre">input/</span></co… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
</tr> | |
</tbody> | |
</table> | |
t@@ -219,7 +218,7 @@ ID from the <tt class="docutils literal"><span class="pre"… | |
<dl class="function"> | |
<dt id="sphere.convert"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">convert</tt><big>(<… | |
+<code class="descclassname">sphere.</code><code class="descname">convert</code… | |
<dd><p>Converts all PPM images in img_out to graphics_format using Imagemagick… | |
PPM images are subsequently removed.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -238,8 +237,8 @@ PPM images are subsequently removed.</p> | |
<dl class="function"> | |
<dt id="sphere.render"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">render</tt><big>(</… | |
-<dd><p>Render target binary using the <tt class="docutils literal"><span class… | |
+<code class="descclassname">sphere.</code><code class="descname">render</code>… | |
+<dd><p>Render target binary using the <code class="docutils literal"><span cla… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -253,7 +252,7 @@ total displacement along the x-axis, ‘angpos’:… | |
position.</li> | |
<li><strong>max_val</strong> (<em>float</em>) – The maximum value of the… | |
<li><strong>lower_cutoff</strong> (<em>float</em>) – Do not render parti… | |
-value, of the field selected by <tt class="docutils literal"><span class="pre"… | |
+value, of the field selected by <code class="docutils literal"><span class="pr… | |
<li><strong>graphics_format</strong> (<em>str</em>) – Convert the PPM im… | |
tracer to this image format using Imagemagick</li> | |
<li><strong>verbose</strong> (<em>bool</em>) – Show verbose information … | |
t@@ -266,15 +265,15 @@ tracer to this image format using Imagemagick</li> | |
<dl class="function"> | |
<dt id="sphere.run"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">run</tt><big>(</big… | |
-<dd><p>Execute <tt class="docutils literal"><span class="pre">sphere</span></t… | |
+<code class="descclassname">sphere.</code><code class="descname">run</code><sp… | |
+<dd><p>Execute <code class="docutils literal"><span class="pre">sphere</span><… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
-<li><strong>binary</strong> (<em>str</em>) – Input file for <tt class="d… | |
-<li><strong>verbose</strong> (<em>bool</em>) – Show <tt class="docutils … | |
+<li><strong>binary</strong> (<em>str</em>) – Input file for <code class=… | |
+<li><strong>verbose</strong> (<em>bool</em>) – Show <code class="docutil… | |
<li><strong>hideinputfile</strong> (<em>bool</em>) – Hide the input file… | |
</ul> | |
</td> | |
t@@ -285,8 +284,8 @@ tracer to this image format using Imagemagick</li> | |
<dl class="class"> | |
<dt id="sphere.sim"> | |
-<em class="property">class </em><tt class="descclassname">sphere.</tt><tt clas… | |
-<dd><p>Class containing all <tt class="docutils literal"><span class="pre">sph… | |
+<em class="property">class </em><code class="descclassname">sphere.</code><cod… | |
+<dd><p>Class containing all <code class="docutils literal"><span class="pre">s… | |
<p>Contains functions for reading and writing binaries, as well as simulation | |
setup and data analysis. Most arrays are initialized to default values.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -301,14 +300,33 @@ setup and data analysis. Most arrays are initialized to … | |
<li><strong>sid</strong> (<em>str</em>) – The simulation id (default = &… | |
will be written with this base name.</li> | |
<li><strong>fluid</strong> (<em>bool</em>) – Setup fluid simulation (def… | |
+<li><strong>cfd_solver</strong> (<em>int</em>) – Fluid solver to use if … | |
+(default), 1: Darcy.</li> | |
</ul> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<dl class="method"> | |
+<dt id="sphere.sim.ReynoldsNumber"> | |
+<code class="descname">ReynoldsNumber</code><span class="sig-paren">(</span><s… | |
+<dd><p>Estimate the per-cell Reynolds number by: Re = rho * ||v_f|| * dx/mu. | |
+This value is returned and also stored in <cite>self.Re</cite>.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.acceleration"> | |
-<tt class="descname">acceleration</tt><big>(</big><em>idx=-1</em><big>)</big><… | |
+<code class="descname">acceleration</code><span class="sig-paren">(</span><em>… | |
<dd><p>Returns the acceleration of one or more particles, selected by their | |
index. If the index is equal to -1 (default value), all accelerations | |
are returned.</p> | |
t@@ -327,8 +345,18 @@ are returned.</p> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.adaptiveGrid"> | |
+<code class="descname">adaptiveGrid</code><span class="sig-paren">(</span><spa… | |
+<dd><p>Set the height of the fluid grid to automatically readjust to the | |
+height of the granular assemblage, as dictated by the position of the | |
+top wall. This will readjust <cite>self.L[2]</cite> during the simulation to | |
+equal the position of the top wall <cite>self.w_x[0]</cite>.</p> | |
+<p>See also <a class="reference internal" href="#sphere.sim.staticGrid" title=… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.addParticle"> | |
-<tt class="descname">addParticle</tt><big>(</big><em>x</em>, <em>radius</em>, … | |
+<code class="descname">addParticle</code><span class="sig-paren">(</span><em>x… | |
<dd><p>Add a single particle to the simulation object. The only required | |
parameters are the position (x) and the radius (radius).</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -359,8 +387,8 @@ velocity</li> | |
<dl class="method"> | |
<dt id="sphere.sim.adjustUpperWall"> | |
-<tt class="descname">adjustUpperWall</tt><big>(</big><em>z_adjust=1.1</em><big… | |
-<dd><p>Included for legacy purposes, calls <a class="reference internal" href=… | |
+<code class="descname">adjustUpperWall</code><span class="sig-paren">(</span><… | |
+<dd><p>Included for legacy purposes, calls <a class="reference internal" href=… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -374,7 +402,7 @@ allow for wall movement.</td> | |
<dl class="method"> | |
<dt id="sphere.sim.adjustWall"> | |
-<tt class="descname">adjustWall</tt><big>(</big><em>idx</em>, <em>adjust=1.1</… | |
+<code class="descname">adjustWall</code><span class="sig-paren">(</span><em>id… | |
<dd><p>Adjust grid and dynamic wall to max. particle position. The wall | |
thickness will by standard equal the maximum particle diameter. The | |
density equals the particle density, and the wall size is equal to the | |
t@@ -385,7 +413,7 @@ parameter.</p> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Param :</th><td class="fiel… | |
+<tr class="field-odd field"><th class="field-name">Param:</th><td class="field… | |
left wall, 2 = +x, right wall, 3 = -y, front wall, 4 = +y, back | |
wall.</td> | |
</tr> | |
t@@ -399,7 +427,7 @@ allow for wall movement.</td> | |
<dl class="method"> | |
<dt id="sphere.sim.bond"> | |
-<tt class="descname">bond</tt><big>(</big><em>i</em>, <em>j</em><big>)</big><a… | |
+<code class="descname">bond</code><span class="sig-paren">(</span><em>i</em>, … | |
<dd><p>Create a bond between particles with index i and j</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -417,7 +445,7 @@ allow for wall movement.</td> | |
<dl class="method"> | |
<dt id="sphere.sim.bondsRose"> | |
-<tt class="descname">bondsRose</tt><big>(</big><em>graphics_format='pdf'</em><… | |
+<code class="descname">bondsRose</code><span class="sig-paren">(</span><em>gra… | |
<dd><p>Visualize the trend and plunge angles of the bond pairs in a rose plot. | |
The plot is saved in the current folder as | |
‘bonds-<simulation id>-rose.<graphics_format>’.</p> | |
t@@ -433,23 +461,33 @@ The plot is saved in the current folder as | |
<dl class="method"> | |
<dt id="sphere.sim.bulkPorosity"> | |
-<tt class="descname">bulkPorosity</tt><big>(</big><big>)</big><a class="header… | |
-<dd><p>Calculates the bulk porosity</p> | |
+<code class="descname">bulkPorosity</code><span class="sig-paren">(</span><em>… | |
+<dd><p>Calculates the bulk porosity of the particle assemblage.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+containing all particles.</td> | |
</tr> | |
-<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
</tr> | |
</tbody> | |
</table> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.cellSize"> | |
+<code class="descname">cellSize</code><span class="sig-paren">(</span><span cl… | |
+<dd><p>Calculate the particle sorting (and fluid) cell dimensions. | |
+These values are stored in <cite>self.dx</cite> and are NOT returned.</p> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.checkerboardColors"> | |
-<tt class="descname">checkerboardColors</tt><big>(</big><em>nx=6</em>, <em>ny=… | |
+<code class="descname">checkerboardColors</code><span class="sig-paren">(</spa… | |
<dd><p>Assign checkerboard color values to the particles in an orthogonal grid… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -468,14 +506,14 @@ The plot is saved in the current folder as | |
<dl class="method"> | |
<dt id="sphere.sim.cleanup"> | |
-<tt class="descname">cleanup</tt><big>(</big><big>)</big><a class="headerlink"… | |
+<code class="descname">cleanup</code><span class="sig-paren">(</span><span cla… | |
<dd><p>Removes the input/output files and images belonging to the object | |
-simulation ID from the <tt class="docutils literal"><span class="pre">input/</… | |
+simulation ID from the <code class="docutils literal"><span class="pre">input/… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.consolidate"> | |
-<tt class="descname">consolidate</tt><big>(</big><em>normal_stress=10000.0</em… | |
+<code class="descname">consolidate</code><span class="sig-paren">(</span><em>n… | |
<dd><p>Setup consolidation experiment. Specify the upper wall normal stress in | |
Pascal, default value is 10 kPa.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -490,7 +528,7 @@ Pascal, default value is 10 kPa.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.contactModel"> | |
-<tt class="descname">contactModel</tt><big>(</big><em>contactmodel</em><big>)<… | |
+<code class="descname">contactModel</code><span class="sig-paren">(</span><em>… | |
<dd><p>Define which contact model to use for the tangential component of | |
particle-particle interactions. The elastic-viscous-frictional contact | |
model (2) is considered to be the most realistic contact model, while | |
t@@ -507,8 +545,67 @@ the viscous-frictional contact model is significantly fas… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.contactParticleArea"> | |
+<code class="descname">contactParticleArea</code><span class="sig-paren">(</sp… | |
+<dd><p>Finds the average area of an two particles in an inter-particle contact… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>i</strong> (<em>int or array of ints</em>) – Index of first … | |
+<li><strong>j</strong> (<em>int or array of ints</em>) – Index of second… | |
+<li><strong>d</strong> (<em>float or array of floats</em>) – Overlap dis… | |
+</ul> | |
+</td> | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</td> | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.contactSurfaceArea"> | |
+<code class="descname">contactSurfaceArea</code><span class="sig-paren">(</spa… | |
+<dd><p>Finds the contact surface area of an inter-particle contact.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>i</strong> (<em>int or array of ints</em>) – Index of first … | |
+<li><strong>j</strong> (<em>int or array of ints</em>) – Index of second… | |
+<li><strong>d</strong> (<em>float or array of floats</em>) – Overlap dis… | |
+</ul> | |
+</td> | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</td> | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.convergence"> | |
+<code class="descname">convergence</code><span class="sig-paren">(</span><span… | |
+<dd><p>Read the convergence evolution in the CFD solver. The values are stored | |
+in <cite>self.conv</cite> with iteration number in the first column and iterat… | |
+count in the second column.</p> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.plotConvergence" … | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.createBondPair"> | |
-<tt class="descname">createBondPair</tt><big>(</big><em>i</em>, <em>j</em>, <e… | |
+<code class="descname">createBondPair</code><span class="sig-paren">(</span><e… | |
<dd><p>Bond particles i and j. Particle j is moved adjacent to particle i, | |
and oriented randomly.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -530,15 +627,38 @@ overlap. The value is relative to the sum of the two rad… | |
<dl class="method"> | |
<dt id="sphere.sim.currentNormalStress"> | |
-<tt class="descname">currentNormalStress</tt><big>(</big><big>)</big><a class=… | |
-<dd><p>Calculates the current magnitude of the top wall normal stress.</p> | |
+<code class="descname">currentNormalStress</code><span class="sig-paren">(</sp… | |
+<dd><p>Calculates the current magnitude of the defined or effective top wall | |
+normal stress.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
</tr> | |
-<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.currentTime"> | |
+<code class="descname">currentTime</code><span class="sig-paren">(</span><em>v… | |
+<dd><p>Get or set the current time. If called without arguments the current | |
+time is returned. If a new time is passed in the ‘value’ argument,… | |
+time is written to the object.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
</tr> | |
</tbody> | |
</table> | |
t@@ -546,7 +666,7 @@ overlap. The value is relative to the sum of the two radii… | |
<dl class="method"> | |
<dt id="sphere.sim.defaultParams"> | |
-<tt class="descname">defaultParams</tt><big>(</big><em>mu_s=0.4</em>, <em>mu_d… | |
+<code class="descname">defaultParams</code><span class="sig-paren">(</span><em… | |
<dd><p>Initialize particle parameters to default values.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -562,7 +682,7 @@ overlap. The value is relative to the sum of the two radii… | |
not used</em></li> | |
<li><strong>gamma_n</strong> (<em>float</em>) – Particle-particle contac… | |
<li><strong>gamma_t</strong> (<em>float</em>) – Particle-particle contac… | |
-<li><strong>gamma_r</strong> (<em>float</em>) – Particle-particle contac… | |
+<li><strong>gamma_r</strong> (<em>float</em>) – Particle-particle contac… | |
not used</em></li> | |
<li><strong>gamma_wn</strong> (<em>float</em>) – Wall-particle contact n… | |
<li><strong>gamma_wt</strong> (<em>float</em>) – Wall-particle contact t… | |
t@@ -577,7 +697,7 @@ interaction model (0 = no (default), 1 = yes)</li> | |
<dl class="method"> | |
<dt id="sphere.sim.defineWorldBoundaries"> | |
-<tt class="descname">defineWorldBoundaries</tt><big>(</big><em>L, origo=[0.0, … | |
+<code class="descname">defineWorldBoundaries</code><span class="sig-paren">(</… | |
<dd><p>Set the boundaries of the world. Particles will only be able to interact | |
within this domain. With dynamic walls, allow space for expansions. | |
<em>Important</em>: The particle radii have to be set beforehand. The world | |
t@@ -601,19 +721,19 @@ won’t work. Default = [0.0, 0.0, 0.0].</li> | |
<dl class="method"> | |
<dt id="sphere.sim.deleteAllParticles"> | |
-<tt class="descname">deleteAllParticles</tt><big>(</big><big>)</big><a class="… | |
+<code class="descname">deleteAllParticles</code><span class="sig-paren">(</spa… | |
<dd><p>Deletes all particles in the simulation object.</p> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.deleteParticle"> | |
-<tt class="descname">deleteParticle</tt><big>(</big><em>i</em><big>)</big><a c… | |
-<dd><p>Delete particle with index <tt class="docutils literal"><span class="pr… | |
+<code class="descname">deleteParticle</code><span class="sig-paren">(</span><e… | |
+<dd><p>Delete particle(s) with index <code class="docutils literal"><span clas… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
</tr> | |
</tbody> | |
</table> | |
t@@ -621,15 +741,30 @@ won’t work. Default = [0.0, 0.0, 0.0].</li> | |
<dl class="method"> | |
<dt id="sphere.sim.disableFluidPressureModulation"> | |
-<tt class="descname">disableFluidPressureModulation</tt><big>(</big><big>)</bi… | |
+<code class="descname">disableFluidPressureModulation</code><span class="sig-p… | |
<dd><p>Set the parameters for the sine wave modulating the fluid pressures | |
at the top boundary to zero.</p> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.setFluidPressureM… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.setFluidPressureM… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.disableTopWallNormalStressModulation"> | |
+<code class="descname">disableTopWallNormalStressModulation</code><span class=… | |
+<dd><p>Set the parameters for the sine wave modulating the normal stress | |
+at the top dynamic wall to zero.</p> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.setTopWallNormalS… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.dry"> | |
+<code class="descname">dry</code><span class="sig-paren">(</span><span class="… | |
+<dd><p>Set the simulation to be dry (no fluids).</p> | |
+<p>See also <a class="reference internal" href="#sphere.sim.wet" title="sphere… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.energy"> | |
-<tt class="descname">energy</tt><big>(</big><em>method</em><big>)</big><a clas… | |
+<code class="descname">energy</code><span class="sig-paren">(</span><em>method… | |
<dd><p>Calculates the sum of the energy components of all particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -652,8 +787,150 @@ for the potential energy stored in bonds [J]</td> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.findAllAverageParticlePairAreas"> | |
+<code class="descname">findAllAverageParticlePairAreas</code><span class="sig-… | |
+<dd><p>Finds the average area of an inter-particle contact. This | |
+function requires a prior call to <a class="reference internal" href="#sphere.… | |
+from the <code class="docutils literal"><span class="pre">self.pairs</span></c… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findAllContactSurfaceAreas"> | |
+<code class="descname">findAllContactSurfaceAreas</code><span class="sig-paren… | |
+<dd><p>Finds the contact surface area of an inter-particle contact. This | |
+function requires a prior call to <a class="reference internal" href="#sphere.… | |
+from the <code class="docutils literal"><span class="pre">self.pairs</span></c… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findContactStresses"> | |
+<code class="descname">findContactStresses</code><span class="sig-paren">(</sp… | |
+<dd><p>Finds all particle-particle uniaxial normal stresses (by first calling | |
+<a class="reference internal" href="#sphere.sim.findNormalForces" title="spher… | |
+dividing the normal force magnitude with the average particle area | |
+(‘average’) or by the contact surface area (‘contact’)… | |
+<p>The result is saved in <code class="docutils literal"><span class="pre">sel… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.findNormalForces"… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findCoordinationNumber"> | |
+<code class="descname">findCoordinationNumber</code><span class="sig-paren">(<… | |
+<dd><p>Finds the coordination number (the average number of contacts per | |
+particle). Requires a previous call to <a class="reference internal" href="#sp… | |
+are stored in <code class="docutils literal"><span class="pre">self.coordinati… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findHydraulicConductivities"> | |
+<code class="descname">findHydraulicConductivities</code><span class="sig-pare… | |
+<dd><p>Calculates the hydrological conductivities from the Kozeny-Carman | |
+relationship. These values are only relevant when the Darcy solver is | |
+used (<cite>self.cfd_solver = 1</cite>). The permeability pre-factor <cite>sel… | |
+and the assemblage porosities must be set beforehand. The former values | |
+are set if a file from the <cite>output/</cite> folder is read using | |
+<cite>self.readbin</cite>.</p> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findLoadedContacts"> | |
+<code class="descname">findLoadedContacts</code><span class="sig-paren">(</spa… | |
+<dd><p>Finds the indices of contact pairs where the contact stress magnitude | |
+exceeds or is equal to a specified threshold value. This function calls | |
+<a class="reference internal" href="#sphere.sim.findContactStresses" title="sp… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findMeanCoordinationNumber"> | |
+<code class="descname">findMeanCoordinationNumber</code><span class="sig-paren… | |
+<dd><p>Returns the coordination number (the average number of contacts per | |
+particle). Requires a previous call to <a class="reference internal" href="#sp… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findNormalForces"> | |
+<code class="descname">findNormalForces</code><span class="sig-paren">(</span>… | |
+<dd><p>Finds all particle-particle overlaps (by first calling | |
+<a class="reference internal" href="#sphere.sim.findOverlaps" title="sphere.si… | |
+multiplying the overlaps with the elastic stiffness <code class="docutils lite… | |
+<p>The result is saved in <code class="docutils literal"><span class="pre">sel… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.findOverlaps" tit… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findOverlaps"> | |
+<code class="descname">findOverlaps</code><span class="sig-paren">(</span><spa… | |
+<dd><p>Find all particle-particle overlaps by a n^2 contact search, which is | |
+done in C++. The particle pair indexes and the distance of the overlaps | |
+is saved in the object itself as the <code class="docutils literal"><span clas… | |
+members.</p> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.findNormalForces"… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.findPermeabilities"> | |
+<code class="descname">findPermeabilities</code><span class="sig-paren">(</spa… | |
+<dd><p>Calculates the hydrological permeabilities from the Kozeny-Carman | |
+relationship. These values are only relevant when the Darcy solver is | |
+used (<cite>self.cfd_solver = 1</cite>). The permeability pre-factor <cite>sel… | |
+and the assemblage porosities must be set beforehand. The former values | |
+are set if a file from the <cite>output/</cite> folder is read using | |
+<cite>self.readbin</cite>.</p> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.forcechains"> | |
-<tt class="descname">forcechains</tt><big>(</big><em>lc=200.0</em>, <em>uc=650… | |
+<code class="descname">forcechains</code><span class="sig-paren">(</span><em>l… | |
<dd><p>Visualizes the force chains in the system from the magnitude of the | |
normal contact forces, and produces an image of them. Warning: Will | |
segfault if no contacts are found.</p> | |
t@@ -678,7 +955,7 @@ visualized with this value</li> | |
<dl class="method"> | |
<dt id="sphere.sim.forcechainsRose"> | |
-<tt class="descname">forcechainsRose</tt><big>(</big><em>lower_limit=0.25</em>… | |
+<code class="descname">forcechainsRose</code><span class="sig-paren">(</span><… | |
<dd><p>Visualize trend and plunge angles of the strongest force chains in a | |
rose plot. The plots are saved in the current folder with the name | |
‘fc-<simulation id>-rose.pdf’.</p> | |
t@@ -699,7 +976,7 @@ contact force magnitude, in ]0;1[</li> | |
<dl class="method"> | |
<dt id="sphere.sim.frictionalEnergy"> | |
-<tt class="descname">frictionalEnergy</tt><big>(</big><em>idx</em><big>)</big>… | |
+<code class="descname">frictionalEnergy</code><span class="sig-paren">(</span>… | |
<dd><p>Returns the frictional dissipated energy for a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -717,7 +994,7 @@ contact force magnitude, in ]0;1[</li> | |
<dl class="method"> | |
<dt id="sphere.sim.generateBimodalRadii"> | |
-<tt class="descname">generateBimodalRadii</tt><big>(</big><em>r_small=0.005</e… | |
+<code class="descname">generateBimodalRadii</code><span class="sig-paren">(</s… | |
<dd><p>Draw random radii from two distinct sizes.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -733,12 +1010,12 @@ populations (large/small).</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.generateRadii" ti… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.generateRadii" ti… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.generateRadii"> | |
-<tt class="descname">generateRadii</tt><big>(</big><em>psd='logn'</em>, <em>ra… | |
+<code class="descname">generateRadii</code><span class="sig-paren">(</span><em… | |
<dd><p>Draw random particle radii from a selected probability distribution. | |
The larger the variance of radii is, the slower the computations will | |
run. The reason is two-fold: The smallest particle dictates the time | |
t@@ -752,24 +1029,98 @@ more particles, causing more contact checks.</p> | |
<tbody valign="top"> | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
<li><strong>psd</strong> (<em>str</em>) – The particle side distribution… | |
-<tt class="docutils literal"><span class="pre">logn</span></tt>, which is a lo… | |
+<code class="docutils literal"><span class="pre">logn</span></code>, which is … | |
for approximating well-sorted, coarse sediments. The other possible | |
-value is <tt class="docutils literal"><span class="pre">uni</span></tt>, which… | |
-<tt class="docutils literal"><span class="pre">radius_mean-radius_variance</sp… | |
-<li><strong>radius_mean</strong> (<em>float</em>) – The mean radius [m] … | |
-<li><strong>radius_variance</strong> (<em>float</em>) – The variance in … | |
+value is <code class="docutils literal"><span class="pre">uni</span></code>, w… | |
+<code class="docutils literal"><span class="pre">mean</span> <span class="pre"… | |
+<li><strong>mean</strong> (<em>float</em>) – The mean radius [m] (defaul… | |
+<li><strong>variance</strong> (<em>float</em>) – The variance in the pro… | |
[m].</li> | |
</ul> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.generateBimodalRa… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.generateBimodalRa… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.hydraulicConductivity"> | |
+<code class="descname">hydraulicConductivity</code><span class="sig-paren">(</… | |
+<dd><p>Determine the hydraulic conductivity (K) [m/s] from the permeability | |
+prefactor and a chosen porosity. This value is stored in <cite>self.K_c</cite… | |
+This function only works for the Darcy solver (<cite>self.cfd_solver == 1</cit… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.hydraulicDiffusivity"> | |
+<code class="descname">hydraulicDiffusivity</code><span class="sig-paren">(</s… | |
+<dd><p>Determine the hydraulic diffusivity (D) [m*m/s]. The result is stored in | |
+<cite>self.D</cite>. This function only works for the Darcy solver | |
+(<cite>self.cfd_solver[0] == 1</cite>)</p> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.hydraulicPermeability"> | |
+<code class="descname">hydraulicPermeability</code><span class="sig-paren">(</… | |
+<dd><p>Determine the hydraulic permeability (k) [m*m] from the Kozeny-Carman | |
+relationship, using the permeability prefactor (<cite>self.k_c</cite>), and the | |
+range of valid porosities set in <cite>src/darcy.cuh</cite>, by default in the | |
+range 0.1 to 0.9.</p> | |
+<p>This function is only valid for the Darcy solver (<cite>self.cfd_solver == | |
+1</cite>).</p> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.id"> | |
+<code class="descname">id</code><span class="sig-paren">(</span><em>sid=''</em… | |
+<dd><p>Returns or sets the simulation id/name, which is used to identify | |
+simulation files in the output folders.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+simulation id will be returned.</td> | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.idAppend"> | |
+<code class="descname">idAppend</code><span class="sig-paren">(</span><em>stri… | |
+<dd><p>Append a string to the simulation id/name, which is used to identify | |
+simulation files in the output folders.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.inertiaParameterPlanarShear"> | |
-<tt class="descname">inertiaParameterPlanarShear</tt><big>(</big><big>)</big><… | |
+<code class="descname">inertiaParameterPlanarShear</code><span class="sig-pare… | |
<dd><p>Returns the value of the inertia parameter $I$ during planar shear | |
proposed by GDR-MiDi 2004.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -782,14 +1133,14 @@ proposed by GDR-MiDi 2004.</p> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
+<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.initFluid"> | |
-<tt class="descname">initFluid</tt><big>(</big><em>mu=0.00089</em>, <em>rho=10… | |
+<code class="descname">initFluid</code><span class="sig-paren">(</span><em>mu=… | |
<dd><p>Initialize the fluid arrays and the fluid viscosity. The default value | |
-of <tt class="docutils literal"><span class="pre">mu</span></tt> equals the dy… | |
+of <code class="docutils literal"><span class="pre">mu</span></code> equals th… | |
The value for water at 0 degrees Celcius is 17.87e-4 kg/(m*s).</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -803,8 +1154,10 @@ parameter <cite>hydrostatic</cite> is set to <cite>True<… | |
the fluid cells at the top</li> | |
<li><strong>hydrostatic</strong> (<em>bool</em>) – Initialize the fluid … | |
pressure distribution. A pressure gradient with depth is only | |
-created if a gravitational acceleration along <img class="math" src="_images/m… | |
+created if a gravitational acceleration along <img class="math" src="_images/m… | |
has been specified</li> | |
+<li><strong>cfd_solver</strong> (<em>int</em>) – Solver to use for the c… | |
+Accepted values: 0 (Navier Stokes, default) and 1 (Darcy).</li> | |
</ul> | |
</td> | |
</tr> | |
t@@ -814,7 +1167,7 @@ has been specified</li> | |
<dl class="method"> | |
<dt id="sphere.sim.initGrid"> | |
-<tt class="descname">initGrid</tt><big>(</big><em>dx=-1</em><big>)</big><a cla… | |
+<code class="descname">initGrid</code><span class="sig-paren">(</span><em>dx=-… | |
<dd><p>Initialize grid suitable for the particle positions set previously. | |
The margin parameter adjusts the distance (in no. of max. radii) | |
from the particle boundaries. | |
t@@ -833,7 +1186,7 @@ width isn’t specified by <cite>dx</cite>.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.initGridAndWorldsize"> | |
-<tt class="descname">initGridAndWorldsize</tt><big>(</big><em>margin=2.0</em><… | |
+<code class="descname">initGridAndWorldsize</code><span class="sig-paren">(</s… | |
<dd><p>Initialize grid suitable for the particle positions set previously. | |
The margin parameter adjusts the distance (in no. of max. radii) | |
from the particle boundaries. If the upper wall is dynamic, it is placed | |
t@@ -850,9 +1203,9 @@ at the top boundary of the world.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.initGridPos"> | |
-<tt class="descname">initGridPos</tt><big>(</big><em>gridnum=array([12</em>, <… | |
+<code class="descname">initGridPos</code><span class="sig-paren">(</span><em>g… | |
<dd><p>Initialize particle positions in loose, cubic configuration. | |
-<tt class="docutils literal"><span class="pre">gridnum</span></tt> is the numb… | |
+<code class="docutils literal"><span class="pre">gridnum</span></code> is the … | |
<em>Important</em>: The particle radii and the boundary conditions (periodic or | |
not) for the x and y boundaries have to be set beforehand.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -867,9 +1220,9 @@ not) for the x and y boundaries have to be set beforehand… | |
<dl class="method"> | |
<dt id="sphere.sim.initRandomGridPos"> | |
-<tt class="descname">initRandomGridPos</tt><big>(</big><em>gridnum=array([12</… | |
+<code class="descname">initRandomGridPos</code><span class="sig-paren">(</span… | |
<dd><p>Initialize particle positions in loose, cubic configuration with some | |
-variance. <tt class="docutils literal"><span class="pre">gridnum</span></tt> i… | |
+variance. <code class="docutils literal"><span class="pre">gridnum</span></cod… | |
directions. <em>Important</em>: The particle radii and the boundary conditions | |
(periodic or not) for the x and y boundaries have to be set beforehand. | |
The world size and grid height (in the z direction) is readjusted to fit | |
t@@ -878,7 +1231,13 @@ the particle positions.</p> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>gridnum</strong> (<em>numpy.array</em>) – The number of part… | |
+<li><strong>padding</strong> (<em>float</em>) – Increase distance betwee… | |
+directions with this multiplier. Large values create more random | |
+packings.</li> | |
+</ul> | |
+</td> | |
</tr> | |
</tbody> | |
</table> | |
t@@ -886,7 +1245,7 @@ the particle positions.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.initRandomPos"> | |
-<tt class="descname">initRandomPos</tt><big>(</big><em>gridnum=array([12</em>,… | |
+<code class="descname">initRandomPos</code><span class="sig-paren">(</span><em… | |
<dd><p>Initialize particle positions in completely random configuration. Radii | |
<em>must</em> be set beforehand. If the x and y boundaries are set as periodic, | |
the particle centers will be placed all the way to the edge. On regular, | |
t@@ -910,7 +1269,7 @@ make space for their radii within the bounding box.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.initTemporal"> | |
-<tt class="descname">initTemporal</tt><big>(</big><em>total</em>, <em>current=… | |
+<code class="descname">initTemporal</code><span class="sig-paren">(</span><em>… | |
<dd><p>Set temporal parameters for the simulation. <em>Important</em>: Particl… | |
physical parameters, and the optional fluid grid need to be set prior to | |
these if the computational time step (dt) isn’t set explicitly. If the | |
t@@ -931,7 +1290,7 @@ included.</p> | |
</ul> | |
</td> | |
</tr> | |
-<tr class="field-even field"><th class="field-name">Step_count :</th><td class… | |
+<tr class="field-even field"><th class="field-name">Step_count:</th><td class=… | |
</td> | |
</tr> | |
</tbody> | |
t@@ -940,7 +1299,7 @@ included.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.kineticEnergy"> | |
-<tt class="descname">kineticEnergy</tt><big>(</big><em>idx</em><big>)</big><a … | |
+<code class="descname">kineticEnergy</code><span class="sig-paren">(</span><em… | |
<dd><p>Returns the (linear) kinetic energy for a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -957,8 +1316,39 @@ included.</p> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.largestFluidTimeStep"> | |
+<code class="descname">largestFluidTimeStep</code><span class="sig-paren">(</s… | |
+<dd><p>Finds and returns the largest time step in the fluid phase by von | |
+Neumann and Courant-Friedrichs-Lewy analysis given the current | |
+velocities. This ensures stability in the diffusive and advective parts | |
+of the momentum equation.</p> | |
+<p>The value of the time step decreases with increasing fluid viscosity | |
+(<cite>self.mu</cite>), and increases with fluid cell size (<cite>self.L/self.… | |
+<p>and fluid velocities (<cite>self.v_f</cite>)</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>safety</strong> (<em>float</em>) – Safety factor which is mu… | |
+step.</li> | |
+<li><strong>v_max</strong> (<em>float</em>) – The largest anticipated ab… | |
+</ul> | |
+</td> | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</td> | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.largestMass"> | |
-<tt class="descname">largestMass</tt><big>(</big><big>)</big><a class="headerl… | |
+<code class="descname">largestMass</code><span class="sig-paren">(</span><span… | |
<dd><p>Returns the mass of the heaviest particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -976,7 +1366,7 @@ included.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.mass"> | |
-<tt class="descname">mass</tt><big>(</big><em>idx</em><big>)</big><a class="he… | |
+<code class="descname">mass</code><span class="sig-paren">(</span><em>idx</em>… | |
<dd><p>Returns the mass of a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -994,7 +1384,7 @@ included.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.momentOfInertia"> | |
-<tt class="descname">momentOfInertia</tt><big>(</big><em>idx</em><big>)</big><… | |
+<code class="descname">momentOfInertia</code><span class="sig-paren">(</span><… | |
<dd><p>Returns the moment of inertia of a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1012,7 +1402,7 @@ included.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.momentum"> | |
-<tt class="descname">momentum</tt><big>(</big><em>idx</em><big>)</big><a class… | |
+<code class="descname">momentum</code><span class="sig-paren">(</span><em>idx<… | |
<dd><p>Returns the momentum (m*v) of a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1030,32 +1420,53 @@ included.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.normalBoundariesXY"> | |
-<tt class="descname">normalBoundariesXY</tt><big>(</big><big>)</big><a class="… | |
+<code class="descname">normalBoundariesXY</code><span class="sig-paren">(</spa… | |
<dd><p>Set the x and y boundary conditions to be static walls.</p> | |
-<p>See also <a class="reference internal" href="#sphere.sim.periodicBoundaries… | |
-<a class="reference internal" href="#sphere.sim.periodicBoundariesX" title="sp… | |
+<p>See also <a class="reference internal" href="#sphere.sim.periodicBoundaries… | |
+<a class="reference internal" href="#sphere.sim.periodicBoundariesX" title="sp… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.periodicBoundariesX"> | |
-<tt class="descname">periodicBoundariesX</tt><big>(</big><big>)</big><a class=… | |
+<code class="descname">periodicBoundariesX</code><span class="sig-paren">(</sp… | |
<dd><p>Set the x boundary conditions to be periodic.</p> | |
-<p>See also <a class="reference internal" href="#sphere.sim.normalBoundariesXY… | |
-<a class="reference internal" href="#sphere.sim.periodicBoundariesXY" title="s… | |
+<p>See also <a class="reference internal" href="#sphere.sim.normalBoundariesXY… | |
+<a class="reference internal" href="#sphere.sim.periodicBoundariesXY" title="s… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.periodicBoundariesXY"> | |
-<tt class="descname">periodicBoundariesXY</tt><big>(</big><big>)</big><a class… | |
+<code class="descname">periodicBoundariesXY</code><span class="sig-paren">(</s… | |
<dd><p>Set the x and y boundary conditions to be periodic.</p> | |
-<p>See also <a class="reference internal" href="#sphere.sim.normalBoundariesXY… | |
-<a class="reference internal" href="#sphere.sim.periodicBoundariesX" title="sp… | |
+<p>See also <a class="reference internal" href="#sphere.sim.normalBoundariesXY… | |
+<a class="reference internal" href="#sphere.sim.periodicBoundariesX" title="sp… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.plotContacts"> | |
+<code class="descname">plotContacts</code><span class="sig-paren">(</span><em>… | |
+<dd><p>Plot current contact orientations on polar plot</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>lower_limit</strong> (<em>float</em>) – Do not visualize for… | |
+contact force magnitude, in ]0;1[</li> | |
+<li><strong>upper_limit</strong> (<em>float</em>) – Visualize force chai… | |
+contact force magnitude but cap color bar range, in ]0;1[</li> | |
+<li><strong>graphics_format</strong> (<em>str</em>) – Save the plot in t… | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotConvergence"> | |
-<tt class="descname">plotConvergence</tt><big>(</big><em>graphics_format='png'… | |
-<dd><p>Plot the convergence evolution in the CFD solver. The plot is saved | |
+<code class="descname">plotConvergence</code><span class="sig-paren">(</span><… | |
+<dd><p>Plot the convergence evolution in the CFD solver. The plot is saved | |
in the output folder with the file name | |
‘<simulation id>-conv.<graphics_format>’.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -1066,11 +1477,12 @@ in the output folder with the file name | |
</tr> | |
</tbody> | |
</table> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.convergence" titl… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotFluidDiffAdvPresZ"> | |
-<tt class="descname">plotFluidDiffAdvPresZ</tt><big>(</big><em>graphics_format… | |
+<code class="descname">plotFluidDiffAdvPresZ</code><span class="sig-paren">(</… | |
<dd><p>Compare contributions to the velocity from diffusion and advection, | |
assuming the flow is 1D along the z-axis, phi = 1, and dphi = 0. This | |
solution is analog to the predicted velocity and not constrained by the | |
t@@ -1089,7 +1501,7 @@ viscosity>Pa-s.<graphics_format>’.</p> | |
<dl class="method"> | |
<dt id="sphere.sim.plotFluidPressuresY"> | |
-<tt class="descname">plotFluidPressuresY</tt><big>(</big><em>y=-1</em>, <em>gr… | |
+<code class="descname">plotFluidPressuresY</code><span class="sig-paren">(</sp… | |
<dd><p>Plot fluid pressures in a plane normal to the second axis. | |
The plot is saved in the current folder with the format | |
‘p_f-<simulation id>-y<y value>.<graphics_format>̵… | |
t@@ -1106,12 +1518,12 @@ this value is -1, the center y position is used.</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotFluidPressuresZ"> | |
-<tt class="descname">plotFluidPressuresZ</tt><big>(</big><em>z=-1</em>, <em>gr… | |
+<code class="descname">plotFluidPressuresZ</code><span class="sig-paren">(</sp… | |
<dd><p>Plot fluid pressures in a plane normal to the third axis. | |
The plot is saved in the current folder with the format | |
‘p_f-<simulation id>-z<z value>.<graphics_format>̵… | |
t@@ -1128,12 +1540,12 @@ this value is -1, the center z position is used.</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotFluidVelocitiesY"> | |
-<tt class="descname">plotFluidVelocitiesY</tt><big>(</big><em>y=-1</em>, <em>g… | |
+<code class="descname">plotFluidVelocitiesY</code><span class="sig-paren">(</s… | |
<dd><p>Plot fluid velocities in a plane normal to the second axis. | |
The plot is saved in the current folder with the format | |
‘v_f-<simulation id>-z<z value>.<graphics_format>̵… | |
t@@ -1150,12 +1562,12 @@ this value is -1, the center y position is used.</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotFluidVelocitiesZ"> | |
-<tt class="descname">plotFluidVelocitiesZ</tt><big>(</big><em>z=-1</em>, <em>g… | |
+<code class="descname">plotFluidVelocitiesZ</code><span class="sig-paren">(</s… | |
<dd><p>Plot fluid velocities in a plane normal to the third axis. | |
The plot is saved in the current folder with the format | |
‘v_f-<simulation id>-z<z value>.<graphics_format>̵… | |
t@@ -1172,12 +1584,12 @@ this value is -1, the center z position is used.</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.writeFluidVTK" ti… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.plotLoadCurve"> | |
-<tt class="descname">plotLoadCurve</tt><big>(</big><em>graphics_format='png'</… | |
+<code class="descname">plotLoadCurve</code><span class="sig-paren">(</span><em… | |
<dd><p>Plot the load curve (log time vs. upper wall movement). The plot is | |
saved in the current folder with the file name | |
‘<simulation id>-loadcurve.<graphics_format>’. | |
t@@ -1197,7 +1609,7 @@ simulation (i.e. flat curve).</p> | |
<dl class="method"> | |
<dt id="sphere.sim.plotPrescribedFluidPressures"> | |
-<tt class="descname">plotPrescribedFluidPressures</tt><big>(</big><em>graphics… | |
+<code class="descname">plotPrescribedFluidPressures</code><span class="sig-par… | |
<dd><p>Plot the prescribed fluid pressures through time that may be | |
modulated through the class parameters p_mod_A, p_mod_f, and p_mod_phi. | |
The plot is saved in the output folder with the file name | |
t@@ -1205,8 +1617,35 @@ The plot is saved in the output folder with the file na… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.plotSinFunction"> | |
+<code class="descname">plotSinFunction</code><span class="sig-paren">(</span><… | |
+<dd><p>Plot the values of a sinusoidal modulated base value. Saves the output | |
+as a plot in the current folder. | |
+The time values will range from <cite>self.time_current</cite> to | |
+<cite>self.time_total</cite>.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>baseval</strong> (<em>float</em>) – The center value which t… | |
+modulating</li> | |
+<li><strong>A</strong> (<em>float</em>) – The fluctuation amplitude</li> | |
+<li><strong>phi</strong> (<em>float</em>) – The phase shift [s]</li> | |
+<li><strong>xlabel</strong> (<em>str</em>) – The label for the x axis</l… | |
+<li><strong>ylabel</strong> (<em>str</em>) – The label for the y axis</l… | |
+<li><strong>plotstyle</strong> (<em>str</em>) – Matplotlib-string for sp… | |
+<li><strong>outformat</strong> (<em>str</em>) – File format of the outpu… | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.porosities"> | |
-<tt class="descname">porosities</tt><big>(</big><em>graphics_format='pdf'</em>… | |
+<code class="descname">porosities</code><span class="sig-paren">(</span><em>gr… | |
<dd><p>Plot the averaged porosities with depth. The plot is saved in the format | |
‘<simulation id>-porosity.<graphics_format>’.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -1226,10 +1665,10 @@ the porosity in</li> | |
<dl class="method"> | |
<dt id="sphere.sim.porosity"> | |
-<tt class="descname">porosity</tt><big>(</big><em>slices=10</em>, <em>verbose=… | |
+<code class="descname">porosity</code><span class="sig-paren">(</span><em>slic… | |
<dd><p>Calculates the porosity as a function of depth, by averaging values in | |
horizontal slabs. Returns porosity values and their corresponding depth. | |
-The values are calculated using the external <tt class="docutils literal"><spa… | |
+The values are calculated using the external <code class="docutils literal"><s… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1253,7 +1692,7 @@ disk</li> | |
<dl class="method"> | |
<dt id="sphere.sim.randomBondPairs"> | |
-<tt class="descname">randomBondPairs</tt><big>(</big><em>ratio=0.3</em>, <em>s… | |
+<code class="descname">randomBondPairs</code><span class="sig-paren">(</span><… | |
<dd><p>Bond an amount of particles in two-particle clusters. The particles | |
should be initialized beforehand. Note: The actual number of bonds is | |
likely to be somewhat smaller than specified, due to the random | |
t@@ -1274,23 +1713,40 @@ particles, neg. values denote an overlap. Values in ]0… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.readTime"> | |
+<code class="descname">readTime</code><span class="sig-paren">(</span><em>time… | |
+<dd><p>Read the output file most closely corresponding to the time given as an | |
+argument.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+<a class="reference internal" href="#sphere.sim.readstep" title="sphere.sim.re… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.readbin"> | |
-<tt class="descname">readbin</tt><big>(</big><em>targetbin</em>, <em>verbose=T… | |
-<dd><p>Reads a target <tt class="docutils literal"><span class="pre">sphere</s… | |
-<p>See also <a class="reference internal" href="#sphere.sim.writebin" title="s… | |
-<a class="reference internal" href="#sphere.sim.readsecond" title="sphere.sim.… | |
+<code class="descname">readbin</code><span class="sig-paren">(</span><em>targe… | |
+<dd><p>Reads a target <code class="docutils literal"><span class="pre">sphere<… | |
+<p>See also <a class="reference internal" href="#sphere.sim.writebin" title="s… | |
+<a class="reference internal" href="#sphere.sim.readsecond" title="sphere.sim.… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
-<li><strong>targetbin</strong> (<em>str</em>) – The path to the binary <… | |
+<li><strong>targetbin</strong> (<em>str</em>) – The path to the binary <… | |
<li><strong>verbose</strong> (<em>bool</em>) – Show diagnostic informati… | |
<li><strong>bonds</strong> (<em>bool</em>) – The input file contains bon… | |
-This parameter should be true for all recent <tt class="docutils literal"><spa… | |
-<li><strong>devsmod</strong> (<em>bool</em>) – The input file contains i… | |
+This parameter should be true for all recent <code class="docutils literal"><s… | |
+<li><strong>sigma0mod</strong> (<em>bool</em>) – The input file contains… | |
stresses at the top wall (default = True). This parameter should be | |
-true for all recent <tt class="docutils literal"><span class="pre">sphere</spa… | |
+true for all recent <code class="docutils literal"><span class="pre">sphere</s… | |
<li><strong>esysparticle</strong> (<em>bool</em>) – Stop reading the fil… | |
which is useful for reading output files from other DEM programs. | |
(default = False)</li> | |
t@@ -1303,9 +1759,9 @@ which is useful for reading output files from other DEM … | |
<dl class="method"> | |
<dt id="sphere.sim.readfirst"> | |
-<tt class="descname">readfirst</tt><big>(</big><em>verbose=True</em><big>)</bi… | |
-<dd><p>Read the first output file from the <tt class="docutils literal"><span … | |
-to the object simulation id (<tt class="docutils literal"><span class="pre">se… | |
+<code class="descname">readfirst</code><span class="sig-paren">(</span><em>ver… | |
+<dd><p>Read the first output file from the <code class="docutils literal"><spa… | |
+to the object simulation id (<code class="docutils literal"><span class="pre">… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1314,15 +1770,15 @@ to the object simulation id (<tt class="docutils liter… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
-<a class="reference internal" href="#sphere.sim.readstep" title="sphere.sim.re… | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+<a class="reference internal" href="#sphere.sim.readstep" title="sphere.sim.re… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.readlast"> | |
-<tt class="descname">readlast</tt><big>(</big><em>verbose=True</em><big>)</big… | |
-<dd><p>Read the last output file from the <tt class="docutils literal"><span c… | |
-to the object simulation id (<tt class="docutils literal"><span class="pre">se… | |
+<code class="descname">readlast</code><span class="sig-paren">(</span><em>verb… | |
+<dd><p>Read the last output file from the <code class="docutils literal"><span… | |
+to the object simulation id (<code class="docutils literal"><span class="pre">… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1331,15 +1787,15 @@ to the object simulation id (<tt class="docutils liter… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
-<a class="reference internal" href="#sphere.sim.readstep" title="sphere.sim.re… | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+<a class="reference internal" href="#sphere.sim.readstep" title="sphere.sim.re… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.readsecond"> | |
-<tt class="descname">readsecond</tt><big>(</big><em>verbose=True</em><big>)</b… | |
-<dd><p>Read the second output file from the <tt class="docutils literal"><span… | |
-corresponding to the object simulation id (<tt class="docutils literal"><span … | |
+<code class="descname">readsecond</code><span class="sig-paren">(</span><em>ve… | |
+<dd><p>Read the second output file from the <code class="docutils literal"><sp… | |
+corresponding to the object simulation id (<code class="docutils literal"><spa… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1348,15 +1804,15 @@ corresponding to the object simulation id (<tt class="… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
-and <a class="reference internal" href="#sphere.sim.readstep" title="sphere.si… | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+and <a class="reference internal" href="#sphere.sim.readstep" title="sphere.si… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.readstep"> | |
-<tt class="descname">readstep</tt><big>(</big><em>step</em>, <em>verbose=True<… | |
-<dd><p>Read a output file from the <tt class="docutils literal"><span class="p… | |
-to the object simulation id (<tt class="docutils literal"><span class="pre">se… | |
+<code class="descname">readstep</code><span class="sig-paren">(</span><em>step… | |
+<dd><p>Read a output file from the <code class="docutils literal"><span class=… | |
+to the object simulation id (<code class="docutils literal"><span class="pre">… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1369,15 +1825,15 @@ to the object simulation id (<tt class="docutils liter… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
-and <a class="reference internal" href="#sphere.sim.readsecond" title="sphere.… | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+and <a class="reference internal" href="#sphere.sim.readsecond" title="sphere.… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.render"> | |
-<tt class="descname">render</tt><big>(</big><em>method='pres'</em>, <em>max_va… | |
+<code class="descname">render</code><span class="sig-paren">(</span><em>method… | |
<dd><p>Using the built-in ray tracer, render all output files that belong to | |
-the simulation, determined by the simulation id (<tt class="docutils literal">… | |
+the simulation, determined by the simulation id (<code class="docutils literal… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1391,7 +1847,7 @@ total displacement along the x-axis, ‘angpos’… | |
position.</li> | |
<li><strong>max_val</strong> (<em>float</em>) – The maximum value of the… | |
<li><strong>lower_cutoff</strong> (<em>float</em>) – Do not render parti… | |
-value, of the field selected by <tt class="docutils literal"><span class="pre"… | |
+value, of the field selected by <code class="docutils literal"><span class="pr… | |
<li><strong>graphics_format</strong> (<em>str</em>) – Convert the PPM im… | |
tracer to this image format using Imagemagick</li> | |
<li><strong>verbose</strong> (<em>bool</em>) – Show verbose information … | |
t@@ -1404,7 +1860,7 @@ tracer to this image format using Imagemagick</li> | |
<dl class="method"> | |
<dt id="sphere.sim.rotationalEnergy"> | |
-<tt class="descname">rotationalEnergy</tt><big>(</big><em>idx</em><big>)</big>… | |
+<code class="descname">rotationalEnergy</code><span class="sig-paren">(</span>… | |
<dd><p>Returns the rotational energy for a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1422,26 +1878,26 @@ tracer to this image format using Imagemagick</li> | |
<dl class="method"> | |
<dt id="sphere.sim.run"> | |
-<tt class="descname">run</tt><big>(</big><em>verbose=True</em>, <em>hideinputf… | |
-<dd><p>Start <tt class="docutils literal"><span class="pre">sphere</span></tt>… | |
+<code class="descname">run</code><span class="sig-paren">(</span><em>verbose=T… | |
+<dd><p>Start <code class="docutils literal"><span class="pre">sphere</span></c… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
-<li><strong>verbose</strong> (<em>bool</em>) – Show <tt class="docutils … | |
-<li><strong>hideinputfile</strong> (<em>bool</em>) – Hide the file name … | |
+<li><strong>verbose</strong> (<em>bool</em>) – Show <code class="docutil… | |
+<li><strong>hideinputfile</strong> (<em>bool</em>) – Hide the file name … | |
<li><strong>dry</strong> (<em>bool</em>) – Perform a dry run. Important … | |
-the <tt class="docutils literal"><span class="pre">sphere</span></tt> program,… | |
-<li><strong>valgrind</strong> (<em>bool</em>) – Run the program with <tt… | |
+the <code class="docutils literal"><span class="pre">sphere</span></code> prog… | |
+<li><strong>valgrind</strong> (<em>bool</em>) – Run the program with <co… | |
memory leaks in the host code. This causes a significant increase in | |
computational time.</li> | |
-<li><strong>cudamemcheck</strong> (<em>bool</em>) – Run the program with… | |
+<li><strong>cudamemcheck</strong> (<em>bool</em>) – Run the program with… | |
check for device memory leaks and errors. This causes a significant | |
increase in computational time.</li> | |
<li><strong>device</strong> (<em>int</em>) – Specify the GPU device to e… | |
If not specified, sphere will use the device with the most CUDA cores. | |
-To see a list of devices, run <tt class="docutils literal"><span class="pre">n… | |
+To see a list of devices, run <code class="docutils literal"><span class="pre"… | |
</ul> | |
</td> | |
</tr> | |
t@@ -1450,25 +1906,40 @@ To see a list of devices, run <tt class="docutils lite… | |
</dd></dl> | |
<dl class="method"> | |
-<dt id="sphere.sim.setBeta"> | |
-<tt class="descname">setBeta</tt><big>(</big><em>beta</em><big>)</big><a class… | |
-<dd><p>Beta is a fluid solver parameter, used in velocity prediction and | |
-pressure iteration 1.0: Use old pressures for fluid velocity prediction | |
+<dt id="sphere.sim.scaleSize"> | |
+<code class="descname">scaleSize</code><span class="sig-paren">(</span><em>fac… | |
+<dd><p>Scale the positions, linear velocities, forces, torques and radii of all | |
+particles and mobile walls.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setBeta"> | |
+<code class="descname">setBeta</code><span class="sig-paren">(</span><em>beta<… | |
+<dd><p>Beta is a fluid solver parameter, used in velocity prediction and | |
+pressure iteration 1.0: Use old pressures for fluid velocity prediction | |
(see Langtangen et al. 2002) 0.0: Do not use old pressures for fluid | |
velocity prediction (Chorin’s original projection method, see Chorin | |
(1968) and “Projection method (fluid dynamics)” page on Wikipedia.… | |
best results precision and performance-wise are obtained by using a beta | |
of 0 and a low tolerance criteria value.</p> | |
<p>The default and recommended value is 0.0.</p> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
-<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
-<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
+<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
+<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setDEMstepsPerCFDstep"> | |
-<tt class="descname">setDEMstepsPerCFDstep</tt><big>(</big><em>ndem</em><big>)… | |
+<code class="descname">setDEMstepsPerCFDstep</code><span class="sig-paren">(</… | |
<dd><p>A fluid solver parameter, the value of the maxiter parameter denotes the | |
number of DEM time steps to be performed per CFD time step.</p> | |
<p>The default value is 1.</p> | |
t@@ -1480,14 +1951,14 @@ number of DEM time steps to be performed per CFD time … | |
</tr> | |
</tbody> | |
</table> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
-<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
+<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setDampingNormal"> | |
-<tt class="descname">setDampingNormal</tt><big>(</big><em>gamma</em><big>)</bi… | |
+<code class="descname">setDampingNormal</code><span class="sig-paren">(</span>… | |
<dd><p>Set the dampening coefficient (gamma) in the normal direction of the | |
particle-particle contact model. The function will print the fraction | |
between the chosen damping and the critical damping value.</p> | |
t@@ -1495,16 +1966,20 @@ between the chosen damping and the critical damping va… | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>gamma</strong> (<em>float</em>) – The viscous damping consta… | |
+<li><strong>over_damping</strong> (<em>boolean</em>) – Accept overdampen… | |
+</ul> | |
+</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <tt class="xref py py-func docutils literal"><span class="pre">se… | |
+<p>See also: <code class="xref py py-func docutils literal"><span class="pre">… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setDampingTangential"> | |
-<tt class="descname">setDampingTangential</tt><big>(</big><em>gamma</em><big>)… | |
+<code class="descname">setDampingTangential</code><span class="sig-paren">(</s… | |
<dd><p>Set the dampening coefficient (gamma) in the tangential direction of the | |
particle-particle contact model. The function will print the fraction | |
between the chosen damping and the critical damping value.</p> | |
t@@ -1512,43 +1987,122 @@ between the chosen damping and the critical damping v… | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>gamma</strong> (<em>float</em>) – The viscous damping consta… | |
+<li><strong>over_damping</strong> (<em>boolean</em>) – Accept overdampen… | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <code class="xref py py-func docutils literal"><span class="pre">… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setDynamicFriction"> | |
+<code class="descname">setDynamicFriction</code><span class="sig-paren">(</spa… | |
+<dd><p>Set the dynamic friction coefficient for particle-particle interactions | |
+(<cite>self.mu_d</cite>). This value describes the resistance to a shearing mo… | |
+while it is happening (contact tangential velocity larger than 0). | |
+Strain softening can be introduced by having a smaller dynamic | |
+frictional coefficient than the static fricion coefficient. Usually this | |
+value is identical to the static friction coefficient.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+Usually between 0 and 1.</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <code class="xref py py-func docutils literal"><span class="pre">… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidBottomFixedFlux"> | |
+<code class="descname">setFluidBottomFixedFlux</code><span class="sig-paren">(… | |
+<dd><p>Define a constant fluid flux normal to the boundary.</p> | |
+<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
+<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+values upwards), [m/s]</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <tt class="xref py py-func docutils literal"><span class="pre">se… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidBottomFixedPressure"> | |
-<tt class="descname">setFluidBottomFixedPressure</tt><big>(</big><big>)</big><… | |
+<code class="descname">setFluidBottomFixedPressure</code><span class="sig-pare… | |
<dd><p>Set the lower boundary of the fluid domain to follow the fixed pressure | |
value (Dirichlet) boundary condition.</p> | |
<p>This is the default behavior for the boundary. See also | |
-<a class="reference internal" href="#sphere.sim.setFluidBottomNoFlow" title="s… | |
+<a class="reference internal" href="#sphere.sim.setFluidBottomNoFlow" title="s… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidBottomNoFlow"> | |
-<tt class="descname">setFluidBottomNoFlow</tt><big>(</big><big>)</big><a class… | |
+<code class="descname">setFluidBottomNoFlow</code><span class="sig-paren">(</s… | |
<dd><p>Set the lower boundary of the fluid domain to follow the no-flow | |
(Neumann) boundary condition with free slip parallel to the boundary.</p> | |
<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
-<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
+<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidBottomNoFlowNoSlip"> | |
-<tt class="descname">setFluidBottomNoFlowNoSlip</tt><big>(</big><big>)</big><a… | |
+<code class="descname">setFluidBottomNoFlowNoSlip</code><span class="sig-paren… | |
<dd><p>Set the lower boundary of the fluid domain to follow the no-flow | |
(Neumann) boundary condition with no slip parallel to the boundary.</p> | |
<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
-<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
+<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidCompressibility"> | |
+<code class="descname">setFluidCompressibility</code><span class="sig-paren">(… | |
+<dd><p>Set the fluid adiabatic compressibility [1/Pa]. This value is equal to | |
+<cite>1/K</cite> where <cite>K</cite> is the bulk modulus [Pa]. The value for … | |
+for water at 0 degrees Celcius. This parameter is used for the Darcy | |
+solver exclusively.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.setFluidDensity" … | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidDensity"> | |
+<code class="descname">setFluidDensity</code><span class="sig-paren">(</span><… | |
+<dd><p>Set the fluid density [kg/(m*m*m)]. The value for water is 1000. This | |
+parameter is used for the Navier-Stokes fluid solver exclusively.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+<dl class="docutils"> | |
+<dt>See also: <a class="reference internal" href="#sphere.sim.setFluidViscosit… | |
+<dd><a class="reference internal" href="#sphere.sim.setFluidCompressibility" t… | |
+</dl> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidPressureModulation"> | |
-<tt class="descname">setFluidPressureModulation</tt><big>(</big><em>A</em>, <e… | |
+<code class="descname">setFluidPressureModulation</code><span class="sig-paren… | |
<dd><p>Set the parameters for the sine wave modulating the fluid pressures | |
at the top boundary. Note that a cos-wave is obtained with phi=pi/2.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -1558,45 +2112,146 @@ at the top boundary. Note that a cos-wave is obtained… | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
<li><strong>A</strong> (<em>float</em>) – Fluctuation amplitude [Pa]</li> | |
<li><strong>f</strong> (<em>float</em>) – Fluctuation frequency [Hz]</li> | |
-<li><strong>phi</strong> (<em>float</em>) – Fluctuation phase shift (def… | |
+<li><strong>phi</strong> (<em>float</em>) – Fluctuation phase shift (def… | |
+<li><strong>plot</strong> (<em>bool</em>) – Show a plot of the resulting… | |
</ul> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.disableFluidPress… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.setTopWallNormalS… | |
+<a class="reference internal" href="#sphere.sim.disableFluidPressureModulation… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidTopFixedFlux"> | |
+<code class="descname">setFluidTopFixedFlux</code><span class="sig-paren">(</s… | |
+<dd><p>Define a constant fluid flux normal to the boundary.</p> | |
+<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
+<a class="reference internal" href="#sphere.sim.setFluidBottomFixedPressure" t… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+values upwards), [m/s]</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidTopFixedPressure"> | |
-<tt class="descname">setFluidTopFixedPressure</tt><big>(</big><big>)</big><a c… | |
+<code class="descname">setFluidTopFixedPressure</code><span class="sig-paren">… | |
<dd><p>Set the upper boundary of the fluid domain to follow the fixed pressure | |
value (Dirichlet) boundary condition.</p> | |
<p>This is the default behavior for the boundary. See also | |
-<a class="reference internal" href="#sphere.sim.setFluidTopNoFlow" title="sphe… | |
+<a class="reference internal" href="#sphere.sim.setFluidTopNoFlow" title="sphe… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidTopNoFlow"> | |
-<tt class="descname">setFluidTopNoFlow</tt><big>(</big><big>)</big><a class="h… | |
+<code class="descname">setFluidTopNoFlow</code><span class="sig-paren">(</span… | |
<dd><p>Set the upper boundary of the fluid domain to follow the no-flow | |
(Neumann) boundary condition with free slip parallel to the boundary.</p> | |
<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
-<a class="reference internal" href="#sphere.sim.setFluidTopFixedPressure" titl… | |
+<a class="reference internal" href="#sphere.sim.setFluidTopFixedPressure" titl… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setFluidTopNoFlowNoSlip"> | |
-<tt class="descname">setFluidTopNoFlowNoSlip</tt><big>(</big><big>)</big><a cl… | |
+<code class="descname">setFluidTopNoFlowNoSlip</code><span class="sig-paren">(… | |
<dd><p>Set the upper boundary of the fluid domain to follow the no-flow | |
(Neumann) boundary condition with no slip parallel to the boundary.</p> | |
<p>The default behavior for the boundary is fixed value (Dirichlet), see | |
-<a class="reference internal" href="#sphere.sim.setFluidTopFixedPressure" titl… | |
+<a class="reference internal" href="#sphere.sim.setFluidTopFixedPressure" titl… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidViscosity"> | |
+<code class="descname">setFluidViscosity</code><span class="sig-paren">(</span… | |
+<dd><p>Set the fluid dynamic viscosity [Pa*s]. The value for water is | |
+1.797e-3 at 0 degrees Celcius. This parameter is used for both the Darcy | |
+and Navier-Stokes fluid solver.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+<dl class="docutils"> | |
+<dt>See also: <a class="reference internal" href="#sphere.sim.setFluidDensity"… | |
+<dd><a class="reference internal" href="#sphere.sim.setFluidCompressibility" t… | |
+</dl> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidXFixedPressure"> | |
+<code class="descname">setFluidXFixedPressure</code><span class="sig-paren">(<… | |
+<dd><p>Set the X boundaries of the fluid domain to follow the fixed pressure | |
+value (Dirichlet) boundary condition.</p> | |
+<p>This is not the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidXFixedPressure" title=… | |
+<a class="reference internal" href="#sphere.sim.setFluidXNoFlow" title="sphere… | |
+<a class="reference internal" href="#sphere.sim.setFluidXPeriodic" title="sphe… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidXNoFlow"> | |
+<code class="descname">setFluidXNoFlow</code><span class="sig-paren">(</span><… | |
+<dd><p>Set the X boundaries of the fluid domain to follow the no-flow | |
+(Neumann) boundary condition.</p> | |
+<p>This is not the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidXFixedPressure" title=… | |
+<a class="reference internal" href="#sphere.sim.setFluidXNoFlow" title="sphere… | |
+<a class="reference internal" href="#sphere.sim.setFluidXPeriodic" title="sphe… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidXPeriodic"> | |
+<code class="descname">setFluidXPeriodic</code><span class="sig-paren">(</span… | |
+<dd><p>Set the X boundaries of the fluid domain to follow the periodic | |
+(cyclic) boundary condition.</p> | |
+<p>This is the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidXFixedPressure" title=… | |
+<a class="reference internal" href="#sphere.sim.setFluidXNoFlow" title="sphere… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidYFixedPressure"> | |
+<code class="descname">setFluidYFixedPressure</code><span class="sig-paren">(<… | |
+<dd><p>Set the Y boundaries of the fluid domain to follow the fixed pressure | |
+value (Dirichlet) boundary condition.</p> | |
+<p>This is not the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidYNoFlow" title="sphere… | |
+<a class="reference internal" href="#sphere.sim.setFluidYPeriodic" title="sphe… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidYNoFlow"> | |
+<code class="descname">setFluidYNoFlow</code><span class="sig-paren">(</span><… | |
+<dd><p>Set the Y boundaries of the fluid domain to follow the no-flow | |
+(Neumann) boundary condition.</p> | |
+<p>This is not the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidYFixedPressure" title=… | |
+<a class="reference internal" href="#sphere.sim.setFluidYPeriodic" title="sphe… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setFluidYPeriodic"> | |
+<code class="descname">setFluidYPeriodic</code><span class="sig-paren">(</span… | |
+<dd><p>Set the Y boundaries of the fluid domain to follow the periodic | |
+(cyclic) boundary condition.</p> | |
+<p>This is the default behavior for the boundary. See also | |
+<a class="reference internal" href="#sphere.sim.setFluidYFixedPressure" title=… | |
+<a class="reference internal" href="#sphere.sim.setFluidYNoFlow" title="sphere… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setGamma"> | |
-<tt class="descname">setGamma</tt><big>(</big><em>gamma</em><big>)</big><a cla… | |
+<code class="descname">setGamma</code><span class="sig-paren">(</span><em>gamm… | |
<dd><p>Gamma is a fluid solver parameter, used for smoothing the pressure | |
values. The epsilon (pressure) values are smoothed by including the | |
average epsilon value of the six closest (face) neighbor cells. This | |
t@@ -1611,14 +2266,14 @@ more averaging is introduced. A value of 0.0 disables … | |
</tr> | |
</tbody> | |
</table> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setBeta" title="sphere.sim.set… | |
-<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setBeta" title="sphere.sim.set… | |
+<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setMaxIterations"> | |
-<tt class="descname">setMaxIterations</tt><big>(</big><em>maxiter</em><big>)</… | |
+<code class="descname">setMaxIterations</code><span class="sig-paren">(</span>… | |
<dd><p>A fluid solver parameter, the value of the maxiter parameter denotes the | |
maximal allowed number of fluid solver iterations before ending the | |
fluid solver loop prematurely. The residual values are at that point not | |
t@@ -1634,14 +2289,101 @@ solver</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
-and <a class="reference internal" href="#sphere.sim.setTolerance" title="spher… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
+and <a class="reference internal" href="#sphere.sim.setTolerance" title="spher… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setPermeabilityGrainSize"> | |
+<code class="descname">setPermeabilityGrainSize</code><span class="sig-paren">… | |
+<dd><p>Set the permeability prefactor based on the mean grain size (Damsgaard | |
+et al., 2015, eq. 10).</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+hydraulic conductivities to expect with the chosen permeability | |
+prefactor.</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setPermeabilityPrefactor"> | |
+<code class="descname">setPermeabilityPrefactor</code><span class="sig-paren">… | |
+<dd><p>Set the permeability prefactor from Goren et al 2011, eq. 24. The | |
+function will print the limits of permeabilities to be simulated. This | |
+parameter is only used in the Darcy solver.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>k_c</strong> (<em>float</em>) – Permeability prefactor value… | |
+<li><strong>verbose</strong> (<em>bool</em>) – Print information about t… | |
+hydraulic conductivities to expect with the chosen permeability | |
+prefactor.</li> | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setStaticFriction"> | |
+<code class="descname">setStaticFriction</code><span class="sig-paren">(</span… | |
+<dd><p>Set the static friction coefficient for particle-particle interactions | |
+(<cite>self.mu_s</cite>). This value describes the resistance to a shearing mo… | |
+while it is not happenind (contact tangential velocity zero).</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+Usually between 0 and 1.</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <code class="xref py py-func docutils literal"><span class="pre">… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setStiffnessNormal"> | |
+<code class="descname">setStiffnessNormal</code><span class="sig-paren">(</spa… | |
+<dd><p>Set the elastic stiffness (<cite>k_n</cite>) in the normal direction of… | |
+contact.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setStiffnessTangential"> | |
+<code class="descname">setStiffnessTangential</code><span class="sig-paren">(<… | |
+<dd><p>Set the elastic stiffness (<cite>k_t</cite>) in the tangential directio… | |
+contact.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setTheta"> | |
-<tt class="descname">setTheta</tt><big>(</big><em>theta</em><big>)</big><a cla… | |
+<code class="descname">setTheta</code><span class="sig-paren">(</span><em>thet… | |
<dd><p>Theta is a fluid solver under-relaxation parameter, used in solution of | |
Poisson equation. The value should be within the range ]0.0;1.0]. At a | |
value of 1.0, the new estimate of epsilon values is used exclusively. At | |
t@@ -1657,18 +2399,18 @@ instabilities may be avoided with lower values.</p> | |
</tr> | |
</tbody> | |
</table> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setBeta" title="sphere.sim.set… | |
-<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setBeta" title="sphere.sim.set… | |
+<a class="reference internal" href="#sphere.sim.setDEMstepsPerCFDstep" title="… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.setTolerance"> | |
-<tt class="descname">setTolerance</tt><big>(</big><em>tolerance</em><big>)</bi… | |
+<code class="descname">setTolerance</code><span class="sig-paren">(</span><em>… | |
<dd><p>A fluid solver parameter, the value of the tolerance parameter denotes | |
the required value of the maximum normalized residual for the fluid | |
solver.</p> | |
-<p>The default and recommended value is 1.0e-8.</p> | |
+<p>The default and recommended value is 1.0e-3.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1678,31 +2420,97 @@ residual</td> | |
</tr> | |
</tbody> | |
</table> | |
-<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
-<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
-<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
+<p>Other solver parameter setting functions: <a class="reference internal" hre… | |
+<a class="reference internal" href="#sphere.sim.setTheta" title="sphere.sim.se… | |
+<a class="reference internal" href="#sphere.sim.setMaxIterations" title="spher… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setTopWallNormalStressModulation"> | |
+<code class="descname">setTopWallNormalStressModulation</code><span class="sig… | |
+<dd><p>Set the parameters for the sine wave modulating the normal stress | |
+at the top wall. Note that a cos-wave is obtained with phi=pi/2.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>A</strong> (<em>float</em>) – Fluctuation amplitude [Pa]</li> | |
+<li><strong>f</strong> (<em>float</em>) – Fluctuation frequency [Hz]</li> | |
+<li><strong>plot</strong> (<em>bool</em>) – Show a plot of the resulting… | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.setFluidPressureM… | |
+<a class="reference internal" href="#sphere.sim.disableTopWallNormalStressModu… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.setYoungsModulus"> | |
+<code class="descname">setYoungsModulus</code><span class="sig-paren">(</span>… | |
+<dd><p>Set the elastic Young’s modulus (<cite>E</cite>) for the contact … | |
+parameter is used over normal stiffness (<cite>k_n</cite>) and tangential | |
+stiffness (<cite>k_t</cite>) when its value is greater than zero. Using this | |
+parameter produces size-invariant behavior.</p> | |
+<p>Example values are ~70e9 Pa for quartz, | |
+<a class="reference external" href="http://www.engineeringtoolbox.com/young-mo… | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.shear"> | |
-<tt class="descname">shear</tt><big>(</big><em>shear_strain_rate=1.0</em><big>… | |
-<dd><p>Setup shear experiment. The shear strain rate is the shear velocity | |
-divided by the initial height per second. The shear movement is along | |
-the positive x axis. The function zeroes the tangential wall viscosity | |
-(gamma_wt) and the wall friction coefficients (mu_ws, mu_wn).</p> | |
+<code class="descname">shear</code><span class="sig-paren">(</span><em>shear_s… | |
+<dd><p>Setup shear experiment either by a constant shear rate or a constant | |
+shear stress. The shear strain rate is the shear velocity divided by | |
+the initial height per second. The shear movement is along the positive | |
+x axis. The function zeroes the tangential wall viscosity (gamma_wt) and | |
+the wall friction coefficients (mu_ws, mu_wn).</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>shear_strain_rate</strong> (<em>float</em>) – The shear stra… | |
+shear_stress isn’t False.</li> | |
+<li><strong>shear_stress</strong> (<em>float or bool</em>) – The shear s… | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.shearDisplacement"> | |
+<code class="descname">shearDisplacement</code><span class="sig-paren">(</span… | |
+<dd><p>Calculates and returns the current shear displacement. The displacement | |
+is found by determining the total x-axis displacement of the upper, | |
+fixed particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
</tr> | |
</tbody> | |
</table> | |
+<p>See also: <a class="reference internal" href="#sphere.sim.shearStrain" titl… | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.shearStrain"> | |
-<tt class="descname">shearStrain</tt><big>(</big><big>)</big><a class="headerl… | |
+<code class="descname">shearStrain</code><span class="sig-paren">(</span><span… | |
<dd><p>Calculates and returns the current shear strain (gamma) value of the | |
experiment. The shear strain is found by determining the total x-axis | |
displacement of the upper, fixed particles.</p> | |
t@@ -1716,48 +2524,73 @@ displacement of the upper, fixed particles.</p> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
+<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.shearStrainRate"> | |
-<tt class="descname">shearStrainRate</tt><big>(</big><big>)</big><a class="hea… | |
+<code class="descname">shearStrainRate</code><span class="sig-paren">(</span><… | |
<dd><p>Calculates the shear strain rate (dot(gamma)) value of the experiment.<… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
</tr> | |
<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.shearStrain" titl… | |
+<p>See also: <a class="reference internal" href="#sphere.sim.shearStrain" titl… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.shearStress"> | |
+<code class="descname">shearStress</code><span class="sig-paren">(</span><em>t… | |
+<dd><p>Calculates the sum of shear stress values measured on any moving | |
+particles with a finite and fixed velocity.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.shearVel"> | |
-<tt class="descname">shearVel</tt><big>(</big><big>)</big><a class="headerlink… | |
-<dd><p>Calculates and returns the shear velocity (gamma_dot) of the | |
-experiment. The shear velocity is the x-axis velocity value of the | |
-upper particles.</p> | |
+<code class="descname">shearVel</code><span class="sig-paren">(</span><span cl… | |
+<dd><p>Alias of <a class="reference internal" href="#sphere.sim.shearVelocity"… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.shearVelocity"> | |
+<code class="descname">shearVelocity</code><span class="sig-paren">(</span><sp… | |
+<dd><p>Calculates and returns the current shear velocity. The displacement | |
+is found by determining the total x-axis velocity of the upper, | |
+fixed particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
</tr> | |
<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
+<p>See also: <a class="reference internal" href="#sphere.sim.shearStrainRate" … | |
</dd></dl> | |
<dl class="method"> | |
<dt id="sphere.sim.sheardisp"> | |
-<tt class="descname">sheardisp</tt><big>(</big><em>graphics_format='pdf'</em>,… | |
+<code class="descname">sheardisp</code><span class="sig-paren">(</span><em>gra… | |
<dd><p>Plot the particle x-axis displacement against the original vertical | |
particle position. The plot is saved in the current directory with the | |
file name ‘<simulation id>-sheardisp.<graphics_format>’… | |
t@@ -1772,8 +2605,28 @@ file name ‘<simulation id>-sheardisp.<gr… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.show"> | |
+<code class="descname">show</code><span class="sig-paren">(</span><em>coloring… | |
+<dd><p>Show a rendering of all particles in a window.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>coloring</strong> (<em>numpy.array</em>) – Color the particl… | |
+to the values in this array.</li> | |
+<li><strong>resolution</strong> (<em>int</em>) – The resolution of the r… | |
+increase the performance requirements.</li> | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.smallestMass"> | |
-<tt class="descname">smallestMass</tt><big>(</big><big>)</big><a class="header… | |
+<code class="descname">smallestMass</code><span class="sig-paren">(</span><spa… | |
<dd><p>Returns the mass of the leightest particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1790,10 +2643,17 @@ file name ‘<simulation id>-sheardisp.<g… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.staticGrid"> | |
+<code class="descname">staticGrid</code><span class="sig-paren">(</span><span … | |
+<dd><p>Set the height of the fluid grid to be constant as set in <cite>self.L[… | |
+<p>See also <a class="reference internal" href="#sphere.sim.adaptiveGrid" titl… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.status"> | |
-<tt class="descname">status</tt><big>(</big><big>)</big><a class="headerlink" … | |
+<code class="descname">status</code><span class="sig-paren">(</span><span clas… | |
<dd><p>Returns the current simulation status by using the simulation id | |
-(<tt class="docutils literal"><span class="pre">sid</span></tt>) as an identif… | |
+(<code class="docutils literal"><span class="pre">sid</span></code>) as an ide… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -1807,8 +2667,26 @@ file name ‘<simulation id>-sheardisp.<gr… | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.surfaceArea"> | |
+<code class="descname">surfaceArea</code><span class="sig-paren">(</span><em>i… | |
+<dd><p>Returns the surface area of a particle.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="fi… | |
+</tr> | |
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class=… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.thinsection_x1x3"> | |
-<tt class="descname">thinsection_x1x3</tt><big>(</big><em>x2='center'</em>, <e… | |
+<code class="descname">thinsection_x1x3</code><span class="sig-paren">(</span>… | |
<dd><p>Produce a 2D image of particles on a x1,x3 plane, intersecting the | |
second axis at x2. Output is saved as ‘<sid>-ts-x1x3.txt’ in… | |
current folder.</p> | |
t@@ -1842,7 +2720,7 @@ gnuplot> plot ‘<sid>-ts-x1x3.txt’ w… | |
<dl class="method"> | |
<dt id="sphere.sim.torqueScript"> | |
-<tt class="descname">torqueScript</tt><big>(</big><em>email='adc@geo.au.dk… | |
+<code class="descname">torqueScript</code><span class="sig-paren">(</span><em>… | |
<dd><p>Creates a job script for the Torque queue manager for the simulation | |
object.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -1876,8 +2754,37 @@ folder</li> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.torqueScriptPenguin"> | |
+<code class="descname">torqueScriptPenguin</code><span class="sig-paren">(</sp… | |
+<dd><p>Creates a job script for the Torque queue manager for the simulation | |
+object.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>email</strong> (<em>str</em>) – The e-mail address that Torq… | |
+<li><strong>email_alerts</strong> (<em>str</em>) – The type of Torque me… | |
+address. The character ‘b’ causes a mail to be sent when the | |
+execution begins. The character ‘e’ causes a mail to be sent when | |
+the execution ends normally. The character ‘a’ causes a mail to be | |
+sent if the execution ends abnormally. The characters can be written | |
+in any order.</li> | |
+<li><strong>walltime</strong> (<em>str</em>) – The maximal allowed time … | |
+‘HH:MM:SS’.</li> | |
+<li><strong>queue</strong> (<em>str</em>) – The Torque queue to schedule… | |
+<li><strong>spheredir</strong> (<em>str</em>) – The path to the root dir… | |
+cluster</li> | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.totalFrictionalEnergy"> | |
-<tt class="descname">totalFrictionalEnergy</tt><big>(</big><big>)</big><a clas… | |
+<code class="descname">totalFrictionalEnergy</code><span class="sig-paren">(</… | |
<dd><p>Returns the total frictional dissipated energy for all particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1893,7 +2800,7 @@ folder</li> | |
<dl class="method"> | |
<dt id="sphere.sim.totalKineticEnergy"> | |
-<tt class="descname">totalKineticEnergy</tt><big>(</big><big>)</big><a class="… | |
+<code class="descname">totalKineticEnergy</code><span class="sig-paren">(</spa… | |
<dd><p>Returns the total linear kinetic energy for all particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1906,8 +2813,22 @@ folder</li> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.totalMass"> | |
+<code class="descname">totalMass</code><span class="sig-paren">(</span><span c… | |
+<dd><p>Returns the total mass of all particles.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.totalMomentum"> | |
-<tt class="descname">totalMomentum</tt><big>(</big><big>)</big><a class="heade… | |
+<code class="descname">totalMomentum</code><span class="sig-paren">(</span><sp… | |
<dd><p>Returns the sum of particle momentums.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1923,7 +2844,7 @@ folder</li> | |
<dl class="method"> | |
<dt id="sphere.sim.totalRotationalEnergy"> | |
-<tt class="descname">totalRotationalEnergy</tt><big>(</big><big>)</big><a clas… | |
+<code class="descname">totalRotationalEnergy</code><span class="sig-paren">(</… | |
<dd><p>Returns the total rotational kinetic energy for all particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1937,7 +2858,7 @@ folder</li> | |
<dl class="method"> | |
<dt id="sphere.sim.totalViscousEnergy"> | |
-<tt class="descname">totalViscousEnergy</tt><big>(</big><big>)</big><a class="… | |
+<code class="descname">totalViscousEnergy</code><span class="sig-paren">(</spa… | |
<dd><p>Returns the total viscous dissipated energy for all particles.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -1953,7 +2874,7 @@ folder</li> | |
<dl class="method"> | |
<dt id="sphere.sim.triaxial"> | |
-<tt class="descname">triaxial</tt><big>(</big><em>wvel=-0.001</em>, <em>normal… | |
+<code class="descname">triaxial</code><span class="sig-paren">(</span><em>wvel… | |
<dd><p>Setup triaxial experiment. The upper wall is moved at a fixed velocity | |
in m/s, default values is -0.001 m/s (i.e. downwards). The side walls | |
are exerting a defined normal stress.</p> | |
t@@ -1974,7 +2895,7 @@ moves downwards.</li> | |
<dl class="method"> | |
<dt id="sphere.sim.uniaxialStrainRate"> | |
-<tt class="descname">uniaxialStrainRate</tt><big>(</big><em>wvel=-0.001</em><b… | |
+<code class="descname">uniaxialStrainRate</code><span class="sig-paren">(</spa… | |
<dd><p>Setup consolidation experiment. Specify the upper wall velocity in m/s, | |
default value is -0.001 m/s (i.e. downwards).</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -1990,9 +2911,9 @@ moves downwards.</td> | |
<dl class="method"> | |
<dt id="sphere.sim.video"> | |
-<tt class="descname">video</tt><big>(</big><em>out_folder='./'</em>, <em>video… | |
+<code class="descname">video</code><span class="sig-paren">(</span><em>out_fol… | |
<dd><p>Uses ffmpeg to combine images to animation. All images should be | |
-rendered beforehand using <a class="reference internal" href="#sphere.render" … | |
+rendered beforehand using <a class="reference internal" href="#sphere.render" … | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -2015,7 +2936,7 @@ rendered beforehand using <a class="reference internal" … | |
<dl class="method"> | |
<dt id="sphere.sim.viscousEnergy"> | |
-<tt class="descname">viscousEnergy</tt><big>(</big><em>idx</em><big>)</big><a … | |
+<code class="descname">viscousEnergy</code><span class="sig-paren">(</span><em… | |
<dd><p>Returns the viscous dissipated energy for a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -2033,7 +2954,7 @@ rendered beforehand using <a class="reference internal" … | |
<dl class="method"> | |
<dt id="sphere.sim.visualize"> | |
-<tt class="descname">visualize</tt><big>(</big><em>method='energy'</em>, <em>s… | |
+<code class="descname">visualize</code><span class="sig-paren">(</span><em>met… | |
<dd><p>Visualize output from the simulation, where the temporal progress is | |
of interest. The output will be saved in the current folder with a name | |
combining the simulation id of the simulation, and the visualization | |
t@@ -2044,10 +2965,20 @@ method.</p> | |
<tbody valign="top"> | |
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
<li><strong>method</strong> (<em>str</em>) – The type of plot to render.… | |
-‘walls’, ‘triaxial’ and ‘shear’</li> | |
+‘walls’, ‘triaxial’, ‘inertia’, ‘mea… | |
+‘fluid-pressure’, ‘shear’, ‘shear-displacement&#… | |
+‘rate-dependence’, ‘contacts’</li> | |
<li><strong>savefig</strong> (<em>bool</em>) – Save the image instead of… | |
<li><strong>outformat</strong> – The output format of the plot data. Thi… | |
image format, or in text (‘txt’).</li> | |
+<li><strong>figsize</strong> (<em>array</em>) – Specify output figure si… | |
+<li><strong>pickle</strong> (<em>bool</em>) – Save all figure content as… | |
+be opened later using <cite>fig = pickle.load(open(‘file.pickle’,&… | |
+<li><strong>xlim</strong> (<em>array</em>) – Set custom limits to the x … | |
+range will correspond to the entire data interval.</li> | |
+<li><strong>firststep</strong> (<em>int</em>) – The first output file st… | |
+<li><strong>cmap</strong> (<em>matplotlib.colors.LinearSegmentedColormap</em>)… | |
+<cite>cmap=matplotlib.cm.get_cmap(‘afmhot’)</cite></li> | |
</ul> | |
</td> | |
</tr> | |
t@@ -2057,7 +2988,7 @@ image format, or in text (‘txt’).</li> | |
<dl class="method"> | |
<dt id="sphere.sim.voidRatio"> | |
-<tt class="descname">voidRatio</tt><big>(</big><big>)</big><a class="headerlin… | |
+<code class="descname">voidRatio</code><span class="sig-paren">(</span><span c… | |
<dd><p>Calculates the current void ratio</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -2073,7 +3004,7 @@ image format, or in text (‘txt’).</li> | |
<dl class="method"> | |
<dt id="sphere.sim.volume"> | |
-<tt class="descname">volume</tt><big>(</big><em>idx</em><big>)</big><a class="… | |
+<code class="descname">volume</code><span class="sig-paren">(</span><em>idx</e… | |
<dd><p>Returns the volume of a particle.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -2090,10 +3021,33 @@ image format, or in text (‘txt’).</li> | |
</dd></dl> | |
<dl class="method"> | |
+<dt id="sphere.sim.wall0iz"> | |
+<code class="descname">wall0iz</code><span class="sig-paren">(</span><span cla… | |
+<dd><p>Returns the cell index of wall 0 along z.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="fie… | |
+</tr> | |
+<tr class="field-even field"><th class="field-name">Return type:</th><td class… | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.wet"> | |
+<code class="descname">wet</code><span class="sig-paren">(</span><span class="… | |
+<dd><p>Set the simulation to be wet (total fluid saturation).</p> | |
+<p>See also <a class="reference internal" href="#sphere.sim.dry" title="sphere… | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
<dt id="sphere.sim.writeFluidVTK"> | |
-<tt class="descname">writeFluidVTK</tt><big>(</big><em>folder='../output/'</em… | |
-<dd><p>Writes a VTK file for the fluid grid to the <tt class="docutils literal… | |
-default. The file name will be in the format <tt class="docutils literal"><spa… | |
+<code class="descname">writeFluidVTK</code><span class="sig-paren">(</span><em… | |
+<dd><p>Writes a VTK file for the fluid grid to the <code class="docutils liter… | |
+default. The file name will be in the format <code class="docutils literal"><s… | |
The vti files can be used for visualizing the fluid in ParaView.</p> | |
<p>The scalars (pressure, porosity, porosity change) and the velocity | |
vectors are either placed in a grid where the grid corners correspond to | |
t@@ -2125,7 +3079,7 @@ order to visualize fluid vector fields, the cell-centere… | |
selected in the “Pipeline Browser”, and is filtered using “F… | |
“Alphabetical” -> “Cell Data to Point Data”.</p> | |
<p>If several data files are generated for the same simulation (e.g. using | |
-the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
+the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
visualization through time by using the ParaView controls.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -2146,9 +3100,9 @@ cell corners (False), (default = True)</li> | |
<dl class="method"> | |
<dt id="sphere.sim.writeVTK"> | |
-<tt class="descname">writeVTK</tt><big>(</big><em>folder='../output/'</em>, <e… | |
-<dd><p>Writes a VTK file with particle information to the <tt class="docutils … | |
-by default. The file name will be in the format <tt class="docutils literal"><… | |
+<code class="descname">writeVTK</code><span class="sig-paren">(</span><em>fold… | |
+<dd><p>Writes a VTK file with particle information to the <code class="docutil… | |
+by default. The file name will be in the format <code class="docutils literal"… | |
The vtu files can be used to visualize the particles in ParaView.</p> | |
<p>After opening the vtu files, the particle fields will show up in the | |
“Properties” list. Press “Apply” to import all fields … | |
t@@ -2165,7 +3119,7 @@ resolution”) to increase the quality and the compu… | |
of the rendering. All adjustments by default require the “Apply” b… | |
to be pressed before regenerating the view.</p> | |
<p>If several vtu files are generated for the same simulation (e.g. using | |
-the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
+the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
visualization through time by using the ParaView controls.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
t@@ -2184,11 +3138,11 @@ visualization through time by using the ParaView contr… | |
<dl class="method"> | |
<dt id="sphere.sim.writeVTKall"> | |
-<tt class="descname">writeVTKall</tt><big>(</big><em>cell_centered=True</em>, … | |
+<code class="descname">writeVTKall</code><span class="sig-paren">(</span><em>c… | |
<dd><p>Writes a VTK file for each simulation output file with particle | |
-information and the fluid grid to the <tt class="docutils literal"><span class… | |
-The file name will be in the format <tt class="docutils literal"><span class="… | |
-<tt class="docutils literal"><span class="pre">fluid-<self.sid>.vti</spa… | |
+information and the fluid grid to the <code class="docutils literal"><span cla… | |
+The file name will be in the format <code class="docutils literal"><span class… | |
+<code class="docutils literal"><span class="pre">fluid-<self.sid>.vti</s… | |
particles, and the vti files for visualizing the fluid in ParaView.</p> | |
<p>After opening the vtu files, the particle fields will show up in the | |
“Properties” list. Press “Apply” to import all fields … | |
t@@ -2222,13 +3176,43 @@ that “Arrow” is selected as the “Gly… | |
big as the number of fluid cells in the grid. Press “Apply” to vis… | |
the arrows.</p> | |
<p>If several data files are generated for the same simulation (e.g. using | |
-the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
+the <a class="reference internal" href="#sphere.sim.writeVTKall" title="sphere… | |
visualization through time by using the ParaView controls.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
<tbody valign="top"> | |
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>verbose</strong> (<em>bool</em>) – Show diagnostic informati… | |
+<li><strong>cell_centered</strong> (<em>bool</em>) – Write fluid values … | |
+(default = true)</li> | |
+<li><strong>forces</strong> (<em>bool</em>) – Write contact force files … | |
+</ul> | |
+</td> | |
+</tr> | |
+</tbody> | |
+</table> | |
+</dd></dl> | |
+ | |
+<dl class="method"> | |
+<dt id="sphere.sim.writeVTKforces"> | |
+<code class="descname">writeVTKforces</code><span class="sig-paren">(</span><e… | |
+<dd><p>Writes a VTK file with particle-interaction information to the | |
+<code class="docutils literal"><span class="pre">../output/</span></code> fold… | |
+<code class="docutils literal"><span class="pre"><self.sid>.vtp</span></… | |
+particle interactions in ParaView. First use the “Cell Data to Point | |
+Data” filter, and afterwards show the contact network with the “Tu… | |
+filter.</p> | |
+<table class="docutils field-list" frame="void" rules="none"> | |
+<col class="field-name" /> | |
+<col class="field-body" /> | |
+<tbody valign="top"> | |
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="… | |
+<li><strong>folder</strong> (<em>str</em>) – The folder where to place t… | |
+(default = ‘../output/’)</li> | |
+<li><strong>verbose</strong> (<em>bool</em>) – Show diagnostic informati… | |
+</ul> | |
+</td> | |
</tr> | |
</tbody> | |
</table> | |
t@@ -2236,10 +3220,10 @@ visualization through time by using the ParaView contr… | |
<dl class="method"> | |
<dt id="sphere.sim.writebin"> | |
-<tt class="descname">writebin</tt><big>(</big><em>folder='../input/'</em>, <em… | |
-<dd><p>Writes a <tt class="docutils literal"><span class="pre">sphere</span></… | |
-The file name will be in the format <tt class="docutils literal"><span class="… | |
-<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
+<code class="descname">writebin</code><span class="sig-paren">(</span><em>fold… | |
+<dd><p>Writes a <code class="docutils literal"><span class="pre">sphere</span>… | |
+The file name will be in the format <code class="docutils literal"><span class… | |
+<p>See also <a class="reference internal" href="#sphere.sim.readbin" title="sp… | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -2256,7 +3240,7 @@ The file name will be in the format <tt class="docutils … | |
<dl class="method"> | |
<dt id="sphere.sim.zeroKinematics"> | |
-<tt class="descname">zeroKinematics</tt><big>(</big><big>)</big><a class="head… | |
+<code class="descname">zeroKinematics</code><span class="sig-paren">(</span><s… | |
<dd><p>Zero all kinematic parameters of the particles. This function is useful | |
when output from one simulation is reused in another simulation.</p> | |
</dd></dl> | |
t@@ -2265,7 +3249,7 @@ when output from one simulation is reused in another sim… | |
<dl class="function"> | |
<dt id="sphere.status"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">status</tt><big>(</… | |
+<code class="descclassname">sphere.</code><code class="descname">status</code>… | |
<dd><p>Check the status.dat file for the target project, and return the last o… | |
file number.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -2284,7 +3268,7 @@ file number.</p> | |
<dl class="function"> | |
<dt id="sphere.thinsectionVideo"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">thinsectionVideo</t… | |
+<code class="descclassname">sphere.</code><code class="descname">thinsectionVi… | |
<dd><p>Uses ffmpeg to combine thin section images to an animation. This functi… | |
will implicity render the thin section images beforehand.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -2308,7 +3292,7 @@ will implicity render the thin section images beforehand… | |
<dl class="function"> | |
<dt id="sphere.torqueScriptParallel3"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">torqueScriptParalle… | |
+<code class="descclassname">sphere.</code><code class="descname">torqueScriptP… | |
<dd><p>Create job script for the Torque queue manager for three binaries, | |
executed in parallel, ideally on three GPUs.</p> | |
<table class="docutils field-list" frame="void" rules="none"> | |
t@@ -2342,14 +3326,14 @@ in any order.</li> | |
</tr> | |
</tbody> | |
</table> | |
-<p>See also <tt class="xref py py-func docutils literal"><span class="pre">tor… | |
+<p>See also <code class="xref py py-func docutils literal"><span class="pre">t… | |
</dd></dl> | |
<dl class="function"> | |
<dt id="sphere.video"> | |
-<tt class="descclassname">sphere.</tt><tt class="descname">video</tt><big>(</b… | |
+<code class="descclassname">sphere.</code><code class="descname">video</code><… | |
<dd><p>Uses ffmpeg to combine images to animation. All images should be | |
-rendered beforehand using <a class="reference internal" href="#sphere.render" … | |
+rendered beforehand using <a class="reference internal" href="#sphere.render" … | |
<table class="docutils field-list" frame="void" rules="none"> | |
<col class="field-name" /> | |
<col class="field-body" /> | |
t@@ -2378,13 +3362,13 @@ rendered beforehand using <a class="reference internal… | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="index.html">Table Of Contents</a></h3> | |
<ul> | |
<li><a class="reference internal" href="#">Python API</a><ul> | |
<li><a class="reference internal" href="#sample-usage">Sample usage</a></li> | |
-<li><a class="reference internal" href="#module-sphere">The <tt class="docutil… | |
+<li><a class="reference internal" href="#module-sphere">The <code class="docut… | |
</ul> | |
</li> | |
</ul> | |
t@@ -2392,29 +3376,28 @@ rendered beforehand using <a class="reference internal… | |
<h4>Previous topic</h4> | |
<p class="topless"><a href="cfd.html" | |
title="previous chapter">Fluid simulation and particle… | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/python_api.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/python_api.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -2426,12 +3409,12 @@ rendered beforehand using <a class="reference internal… | |
<li class="right" > | |
<a href="cfd.html" title="Fluid simulation and particle-fluid intera… | |
>previous</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/search.html b/doc/html/search.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>Search — sphere 1.00-alpha documentation</title> | |
+ <title>Search — sphere 1.00-alpha documentation</title> | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -27,6 +24,8 @@ | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
<script type="text/javascript" src="_static/searchtools.js"></script> | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="#" /> | |
<link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
<script type="text/javascript"> | |
jQuery(function() { Search.loadIndex("searchindex.js"); }); | |
t@@ -36,8 +35,8 @@ | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -46,14 +45,14 @@ | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<h1 id="search-documentation">Search</h1> | |
<div id="fallback" class="admonition warning"> | |
t@@ -82,13 +81,13 @@ | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -97,12 +96,12 @@ | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/html/searchindex.js b/doc/html/searchindex.js | |
t@@ -1 +1 @@ | |
-Search.setIndex({objects:{"":{sphere:[5,0,1,""]},sphere:{status:[5,1,1,""],con… | |
-\ No newline at end of file | |
+Search.setIndex({envversion:49,filenames:["cfd","dem","index","introduction","… | |
+\ No newline at end of file | |
diff --git a/doc/html/sphere_internals.html b/doc/html/sphere_internals.html | |
t@@ -1,5 +1,3 @@ | |
- | |
- | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
t@@ -8,15 +6,14 @@ | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
- <title>sphere internals — sphere 1.00-alpha documentation</title> | |
+ <title>sphere internals — sphere 1.00-alpha documentation</title> | |
- <link rel="stylesheet" href="_static/default.css" type="text/css" /> | |
+ <link rel="stylesheet" href="_static/classic.css" type="text/css" /> | |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> | |
- <link rel="stylesheet" href="_static/breathe.css" type="text/css" /> | |
<script type="text/javascript"> | |
var DOCUMENTATION_OPTIONS = { | |
- URL_ROOT: '', | |
+ URL_ROOT: './', | |
VERSION: '1.00-alpha', | |
COLLAPSE_INDEX: false, | |
FILE_SUFFIX: '.html', | |
t@@ -26,10 +23,13 @@ | |
<script type="text/javascript" src="_static/jquery.js"></script> | |
<script type="text/javascript" src="_static/underscore.js"></script> | |
<script type="text/javascript" src="_static/doctools.js"></script> | |
- <link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
+ <link rel="index" title="Index" href="genindex.html" /> | |
+ <link rel="search" title="Search" href="search.html" /> | |
+ <link rel="top" title="sphere 1.00-alpha documentation" href="index.html" … | |
+ <link rel="prev" title="Python API" href="python_api.html" /> | |
</head> | |
- <body> | |
- <div class="related"> | |
+ <body role="document"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -38,27 +38,33 @@ | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="right" > | |
+ <a href="python_api.html" title="Python API" | |
+ accesskey="P">previous</a> |</li> | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
<div class="document"> | |
<div class="documentwrapper"> | |
<div class="bodywrapper"> | |
- <div class="body"> | |
+ <div class="body" role="main"> | |
<div class="section" id="sphere-internals"> | |
<h1>sphere internals<a class="headerlink" href="#sphere-internals" title="Perm… | |
<p>The <em>sphere</em> executable has the following options:</p> | |
-<div class="highlight-text"><div class="highlight"><pre>$ ../../sphere --help | |
+<div class="highlight-text"><div class="highlight"><pre><span></span>$ ../../s… | |
../../sphere: particle dynamics simulator | |
Usage: ../../sphere [OPTION[S]]... [FILE1 ...] | |
Options: | |
-h, --help print help | |
-V, --version print version information and exit | |
-q, --quiet suppress status messages to stdout | |
+-d <device> execute on device with specified id | |
-n, --dry show key experiment parameters and quit | |
--r, --render render input files instead of simulating temporal … | |
+-f, --fluid simulate fluid between particles | |
+-r, --render render input files to images instead of | |
+ simulating the temporal evolution | |
-dc, --dont-check don't check values before running | |
Raytracer (-r) specific options: | |
t@@ -68,9 +74,10 @@ Raytracer (-r) specific options: | |
normal, pres, vel, angvel, xdisp, angpos | |
'normal' is the default mode | |
if -l is appended, don't render particles with value below | |
+-c, --contacts Print a list of particle-particle contacts | |
</pre></div> | |
</div> | |
-<p>The most common way to invoke <em>sphere</em> is however via the Python API… | |
+<p>The most common way to invoke <em>sphere</em> is however via the Python API… | |
<p>subsection{The <em>sphere</em> algorithm} | |
label{subsec:spherealgo} | |
The <em>sphere</em>-binary is launched from the system terminal by passing the… | |
t@@ -210,9 +217,9 @@ item Update of verb”<simulation_ID>.status#..b… | |
</ol> | |
<p>The length of the computational time steps (texttt{time.dt}) is calculated … | |
<div class="math"> | |
-<p><img src="_images/math/a32f407296c4d7fd42fe568d2ad7e8fa81f2df27.png" alt="\… | |
-</div><p>where <img class="math" src="_images/math/f5047d1e0cbb50ec208923a22cd… | |
-The time step is set by this relationship in <tt class="xref py py-func docuti… | |
+<p><img src="_images/math/6af8f3510a4e3f1aea74c1b180c9d93ef248128c.png" alt="\… | |
+</div><p>where <img class="math" src="_images/math/c4bb40dd65eae6c11b325989b14… | |
+The time step is set by this relationship in <code class="xref py py-func docu… | |
This equation ensures that the elastic wave (traveling at the speed of sound) … | |
<p>subsubsection{Host and device memory types} | |
label{subsubsec:memorytypes} | |
t@@ -220,9 +227,9 @@ A full, listed description of the <em>sphere</em> source c… | |
<p>The floating point precision operating internally in <em>sphere</em> is def… | |
<p>Three-dimensional variables (e.g. spatial vectors in <cite>E^3</cite>) are … | |
<p>paragraph{Host memory} is the main random-access computer memory (RAM), i.e… | |
-<p>paragraph{Device memory} is the main, global device memory. It resides off-… | |
+<p>paragraph{Device memory} is the main, global device memory. It resides off-… | |
<p>marginpar{Todo: Expand section on device memory types}</p> | |
-<p>paragraph{Constant memory} values cannot be changed after they are set, and… | |
+<p>paragraph{Constant memory} values cannot be changed after they are set, and… | |
<p>%subsection{The main loop} | |
%label{subsec:mainloop} | |
%The <em>sphere</em> software calculates particle movement and rotation based … | |
t@@ -232,187 +239,15 @@ subsubsection{Particles and computational time}</p> | |
<p>subsection{Compilation} | |
label{subsec:compilation} | |
An important note is that the texttt{C} examples of the NVIDIA CUDA SDK should… | |
-<p><em>sphere</em> is supplied with several Makefiles, which automate the comp… | |
+<p><em>sphere</em> is supplied with several Makefiles, which automate the comp… | |
</div> | |
<div class="section" id="c-reference"> | |
<h2>C++ reference<a class="headerlink" href="#c-reference" title="Permalink to… | |
-<div class="line-block"> | |
-<div class="line" id=""><span id="project0classDEM"></span><em>class</em> <str… | |
-</div> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-<em>Public Functions</em><blockquote> | |
-<div><p id=""><span id="project0classDEM_1a991dd9d5ffe9935e1105d3c024a06a8c"><… | |
-<div class="line"> <strong>DEM</strong>(std::string inputbin, const int verbos… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1aa3066aa501f982c2df51f58fb5a91148"></span… | |
-<div class="line"> <strong>~DEM</strong>(void)</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ac32ef9094b25ee9c35e30f4488491fe2"></span… | |
-<div class="line">void <strong>readbin</strong>(const char * target)</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a242634f10a9bc1f19e4eb46b7168f288"></span… | |
-<div class="line">void <strong>writebin</strong>(const char * target)</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a2fabfdb491bd95fc41b78b14d7098b76"></span… | |
-<div class="line">void <strong>diagnostics</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ac8ee9469bd6efd769a87e9537be1ad9c"></span… | |
-<div class="line">void <strong>checkValues</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a3f6f5bdff5193be0deeff3599559e33a"></span… | |
-<div class="line">void <strong>reportValues</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a4d8d968838244cd44b0961bdc621f874"></span… | |
-<div class="line">void <strong>startTime</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ab28a7813c5848d3b27e6f1ed5196d649"></span… | |
-<div class="line">void <strong>render</strong>(const int method = 1, const flo… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a5abc32b3691e7336e80cfab162d0a237"></span… | |
-<div class="line">void <strong>writePPM</strong>(const char * target)</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ad4e191a3aa8491ae04f1897ff1f24bde"></span… | |
-<div class="line">void <strong>porosity</strong>(const int z_slices = 10)</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a5e3a8e75216d4014819019b365b718cb"></span… | |
-<div class="line">Float3 <strong>minPos</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a55e5de749a916600bb4e0680ecafcd0f"></span… | |
-<div class="line">Float3 <strong>maxPos</strong>()</div> | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a9fa9b39cf7f038cc961337f9d4e162e5"></span… | |
-<div class="line">void <strong>findOverlaps</strong>(std::vector< std::vect… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ad94250277dec22f68e096bbf149ff0a8"></span… | |
-<div class="line">void <strong>forcechains</strong>(const std::string format =… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a4f398ac462ce442eff0b649286c03bcb"></span… | |
-<div class="line">void <strong>printNSarray</strong>(FILE * stream, Float * ar… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a5495c54f09b7a9d157352daf7de77500"></span… | |
-<div class="line">void <strong>printNSarray</strong>(FILE * stream, Float * ar… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1ae7b0770eb976dbc262e76f414444f78d"></span… | |
-<div class="line">void <strong>printNSarray</strong>(FILE * stream, Float3 * a… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1add65316e75fc181c73ab636dff42187a"></span… | |
-<div class="line">void <strong>printNSarray</strong>(FILE * stream, Float3 * a… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a777844d118f6d317b17466ec0760bbff"></span… | |
-<div class="line">void <strong>writeNSarray</strong>(Float * array, const char… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-<p id=""><span id="project0classDEM_1a9eb88295a2de9273d24605e960e1b6f0"></span… | |
-<div class="line">void <strong>writeNSarray</strong>(Float3 * array, const cha… | |
-</div> | |
-</p> | |
-<blockquote> | |
-<div><p></p> | |
-<p></p> | |
-</div></blockquote> | |
-</div></blockquote> | |
-</div></blockquote> | |
+<dl class="class"> | |
+<dt id="_CPPv23DEM"> | |
+<span id="DEM"></span><span class="target" id="classDEM"></span><em class="pro… | |
+<dd></dd></dl> | |
+ | |
</div> | |
</div> | |
t@@ -420,7 +255,7 @@ An important note is that the texttt{C} examples of the NV… | |
</div> | |
</div> | |
</div> | |
- <div class="sphinxsidebar"> | |
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation… | |
<div class="sphinxsidebarwrapper"> | |
<h3><a href="index.html">Table Of Contents</a></h3> | |
<ul> | |
t@@ -431,29 +266,31 @@ An important note is that the texttt{C} examples of the … | |
</li> | |
</ul> | |
- <h3>This Page</h3> | |
- <ul class="this-page-menu"> | |
- <li><a href="_sources/sphere_internals.txt" | |
- rel="nofollow">Show Source</a></li> | |
- </ul> | |
-<div id="searchbox" style="display: none"> | |
+ <h4>Previous topic</h4> | |
+ <p class="topless"><a href="python_api.html" | |
+ title="previous chapter">Python API</a></p> | |
+ <div role="note" aria-label="source link"> | |
+ <h3>This Page</h3> | |
+ <ul class="this-page-menu"> | |
+ <li><a href="_sources/sphere_internals.txt" | |
+ rel="nofollow">Show Source</a></li> | |
+ </ul> | |
+ </div> | |
+<div id="searchbox" style="display: none" role="search"> | |
<h3>Quick search</h3> | |
<form class="search" action="search.html" method="get"> | |
- <input type="text" name="q" /> | |
- <input type="submit" value="Go" /> | |
+ <div><input type="text" name="q" /></div> | |
+ <div><input type="submit" value="Go" /></div> | |
<input type="hidden" name="check_keywords" value="yes" /> | |
<input type="hidden" name="area" value="default" /> | |
</form> | |
- <p class="searchtip" style="font-size: 90%"> | |
- Enter search terms or a module, class or function name. | |
- </p> | |
</div> | |
<script type="text/javascript">$('#searchbox').show(0);</script> | |
</div> | |
</div> | |
<div class="clearer"></div> | |
</div> | |
- <div class="related"> | |
+ <div class="related" role="navigation" aria-label="related navigation"> | |
<h3>Navigation</h3> | |
<ul> | |
<li class="right" style="margin-right: 10px"> | |
t@@ -462,12 +299,15 @@ An important note is that the texttt{C} examples of the … | |
<li class="right" > | |
<a href="py-modindex.html" title="Python Module Index" | |
>modules</a> |</li> | |
- <li><a href="index.html">sphere 1.00-alpha documentation</a> »</… | |
+ <li class="right" > | |
+ <a href="python_api.html" title="Python API" | |
+ >previous</a> |</li> | |
+ <li class="nav-item nav-item-0"><a href="index.html">sphere 1.00-alpha… | |
</ul> | |
</div> | |
- <div class="footer"> | |
- © Copyright 2014, Anders Damsgaard. | |
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | |
+ <div class="footer" role="contentinfo"> | |
+ © Copyright 2014, Anders Damsgaard. | |
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. | |
</div> | |
</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/doc/pdf/sphere.pdf b/doc/pdf/sphere.pdf | |
Binary files differ. | |
diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst | |
t@@ -14,7 +14,7 @@ supervision of David Lundbek Egholm and Jan A. Piotrowski, a… | |
of Geoscience, Aarhus University, Denmark. The author welcomes interested third | |
party developers. This document is a work in progress. | |
-Contact: Anders Damsgaard, `<http://cs.au.dk/~adc>`_, | |
+Contact: Anders Damsgaard, `<https://adamsgaard.dk>`_, | |
`<[email protected]>`_ | |
t@@ -27,7 +27,7 @@ Contents | |
dem | |
cfd | |
python_api | |
- .. sphere_internals | |
+ sphere_internals | |
diff --git a/doc/sphinx/introduction.rst b/doc/sphinx/introduction.rst | |
t@@ -1,5 +1,5 @@ | |
-Introduction | |
-============ | |
+Introduction and Installation | |
+============================= | |
The ``sphere``-software is used for three-dimensional discrete element method | |
(DEM) particle simulations. The source code is written in C++, CUDA C and | |
t@@ -37,11 +37,11 @@ The build requirements are: | |
* `CMake <http://www.cmake.org>`_, version 2.8 or newer | |
* The `GNU Compiler Collection <http://gcc.gnu.org/>`_ (GCC) | |
* The `Nvidia CUDA toolkit <https://developer.nvidia.com/cuda-downloads>`_, | |
- version 5.0 or newer | |
+ version 8.0 or newer | |
In Debian GNU/Linux, these dependencies can be installed by running:: | |
- $ sudo apt-get install build-essential cmake nvidia-cuda-toolkit | |
+ $ sudo apt-get install build-essential cmake nvidia-cuda-toolkit clang-3.8 | |
Unfortunately, the Nvidia Toolkit is shipped under a non-free license. In order | |
to install it in Debian GNU/Linux, add ``non-free`` archives to your | |
t@@ -50,7 +50,7 @@ to install it in Debian GNU/Linux, add ``non-free`` archives… | |
The runtime requirements are: | |
* A `CUDA-enabled GPU <http://www.nvidia.com/object/cuda_gpus.html>`_ with | |
- compute capability 1.1 or greater. | |
+ compute capability 2.0 or greater. | |
* A Nvidia CUDA-enabled GPU and device driver | |
Optional tools, required for simulation setup and data processing: | |
t@@ -113,11 +113,6 @@ Building ``sphere`` | |
``sphere`` is built using ``cmake``, the platform-specific C/C++ compilers, | |
and ``nvcc`` from the Nvidia CUDA toolkit. | |
-If you plan to run ``sphere`` on a Kepler GPU, execute the following commands | |
-from the root directory:: | |
- | |
- $ cmake . && make | |
- | |
If you instead plan to execute it on a Fermi GPU, change ``set(GPU_GENERATION | |
1)`` to ``set(GPU_GENERATION 0`` in ``CMakeLists.txt``. | |
t@@ -132,19 +127,27 @@ sample subdirectory ``common/inc/helper_math.h`` into th… | |
directory, and run ``cmake`` and ``make`` again. Due to license restrictions, | |
sphere cannot be distributed with this file. | |
+If you plan to run ``sphere`` on a Kepler GPU, execute the following commands | |
+from the root directory:: | |
+ | |
+ $ cmake . && make | |
+ | |
+NOTE: If your system does not have a GCC compiler (e.g. GCC-5 for CUDA 8) | |
+compatible with the installed CUDA version, try using ``clang-3.8`` instead:: | |
+ | |
+ $ export CC=$(which clang-3.8) && export CXX=$(which clang++-3.8) && cmake . … | |
+ | |
After a successfull installation, the ``sphere`` executable will be located | |
in the root folder. To make sure that all components are working correctly, | |
execute:: | |
$ make test | |
-All instructions required for building ``sphere`` are provided in a number of | |
-``Makefile``'s. To generate the main ``sphere`` command-line executable, go to | |
-the root directory, and invoke CMake and GNU Make:: | |
- | |
- $ cmake . && make | |
+Disclaimer: On some systems the Navier-Stokes related tests will fail. If you | |
+do encounter these problems, but do not plan on using the Navier Stokes solver | |
+for fluid dynamics, carry on. | |
-If successfull, the Makefiles will create the required data folders, object | |
+If successful the Makefiles will create the required data folders, object | |
files, as well as the ``sphere`` executable in the root folder. Issue the | |
following commands to check the executable:: | |